Compare commits
	
		
			155 Commits
		
	
	
		
			7b583f761b
			...
			develop
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 5f383f661f | |||
| ee38db98fb | |||
| d334518da7 | |||
| 8f41d5907a | |||
| 9866588986 | |||
| 5ab4a3b925 | |||
| 2604512f47 | |||
| 0bb1e5bd54 | |||
| 5d6679d919 | |||
| 41c132e506 | |||
| 09f760b10a | |||
| b0619e1b31 | |||
| 43a4fca804 | |||
| 53e692f6ca | |||
| dd1855002f | |||
| d1dd920fd2 | |||
| a69034a18e | |||
| 7fc4f14756 | |||
| feff8c3a76 | |||
| 58b8c6a897 | |||
| 349c91f8df | |||
| 92ef4a68fd | |||
| 623a220cbf | |||
| e8258d96d0 | |||
| d0a682f233 | |||
| 65441ddff4 | |||
| 7f3b04eb08 | |||
| 9289d08f24 | |||
| f9a3ffb359 | |||
| f5d915bd58 | |||
| 91cc200917 | |||
| 0c4c956868 | |||
| 838f39ba40 | |||
| 077170f2d4 | |||
| a1e33d907d | |||
| 57a9ccacbd | |||
| 0eef08ce45 | |||
| 0f9ad0a0f0 | |||
| c6f3138e25 | |||
| 819166bae0 | |||
| 159ade36f0 | |||
| f8443b7f62 | |||
| 7feab0786a | |||
| 5ceaa3b649 | |||
| 9f216b7257 | |||
| 4247327bfa | |||
| 1856bc85e3 | |||
| dff3739a0f | |||
| 53d2f06918 | |||
| cb2741862a | |||
| ce065fb845 | |||
| f37f95d646 | |||
| 6117e74a44 | |||
| ec41c867d4 | |||
| a7a743a394 | |||
| fb2681fdbe | |||
| 427b38a6c3 | |||
| b5e21fec3c | |||
| 1a1aa9f6a5 | |||
| 1229226e8f | |||
| 979a285295 | |||
| 18cec0d742 | |||
| 1ea59d0f8a | |||
| 2d1bc61cca | |||
| 5f6211a01d | |||
| 97c0d13a88 | |||
| 8618508d3f | |||
| dd213e8337 | |||
| a293246c07 | |||
| 9d1c25e8ef | |||
| c08dfb0f85 | |||
| 15460702f9 | |||
| 2c27391058 | |||
| 80869050e1 | |||
| 8025a298a2 | |||
| 0f518ef6cb | |||
| 1af43bb6a9 | |||
| ea80fe325c | |||
| e8e1e320b3 | |||
| 4f0c0ca76d | |||
| 2aade7eef9 | |||
| 71988d8833 | |||
| dd1c7acde1 | |||
| b2d307b308 | |||
| 4f57ac3d9e | |||
| 3d0493e0dd | |||
| 4d35b29526 | |||
| e342fa1d80 | |||
| 8eb1bd98cc | |||
| 644c0d2e28 | |||
| e51357efa7 | |||
| 379a560fbc | |||
| a4cd365c83 | |||
| 3358221da9 | |||
| f1e0ac166e | |||
| 3fab8ea031 | |||
| de4aead219 | |||
| ef2c158727 | |||
| 9ecb3c7269 | |||
| 1936a142b1 | |||
| a9594ccec2 | |||
| 23420762ca | |||
| 04ccdc73ca | |||
| 2e301cd0fc | |||
| d1bcba6a13 | |||
| 6729b60806 | |||
| 7be9a6a41d | |||
| 25a7c967bb | |||
| 713f03284b | |||
| 08bdd515a9 | |||
| eec0ca44c0 | |||
| 9f35d752c2 | |||
| 22f9693957 | |||
| e022aa5ef1 | |||
| 4411c9d17d | |||
| b4f7e7ad8f | |||
| d7ecd6d865 | |||
| a6fb1af6f9 | |||
| d17b038388 | |||
| fff8041faa | |||
| 20ae03cc5e | |||
| ebaa10a79b | |||
| b7e0249757 | |||
| 67540c1808 | |||
| a888969c5d | |||
| 6bd3778ad9 | |||
| 0007343353 | |||
| e6da82c76c | |||
| d8962ff3cc | |||
| 7958e40494 | |||
| 00f1a40e2a | |||
| e38dd4d029 | |||
| 656a21a6dd | |||
| bdc7e58263 | |||
| d47ab3715d | |||
| 20a9388579 | |||
| ef3a682724 | |||
| 4954b51176 | |||
| 01e2422444 | |||
| 7a00e78145 | |||
| e2657ce0a8 | |||
| 76f4b707a6 | |||
| 01d82c16c9 | |||
| 8afd3138f4 | |||
| 3bbc71065a | |||
| 53ba8cb014 | |||
| 829d1a59f7 | |||
| 8ca3576c3e | |||
| a79c09b45d | |||
| f2a198ddaf | |||
| 72fc510167 | |||
| 552c086d3a | |||
| 603421ea87 | |||
| 9e0a43a75f | |||
| 60378db79d | 
| @ -1,5 +1,5 @@ | ||||
| class BaseDialog { | ||||
|   constructor(container, options = {}) { | ||||
|   constructor(container, options = {}, only = true) { | ||||
|     this.container = container | ||||
|     this.options = { ...options } | ||||
|     this.options.ismove = true | ||||
| @ -9,10 +9,13 @@ class BaseDialog { | ||||
|     this.closeCallBack = options.closeCallBack | ||||
|     this._element = {} | ||||
|     this._element_style = undefined | ||||
|     this.only = only | ||||
|   } | ||||
|  | ||||
|   async init() { | ||||
|     this.closeAll() | ||||
|     if (this.only) { | ||||
|       this.closeAll() | ||||
|     } | ||||
|     DialogAll.push(this) | ||||
|     this.isDestroy = false | ||||
|     // body | ||||
| @ -48,6 +51,15 @@ class BaseDialog { | ||||
|     <button class="close">关闭</button> | ||||
|     ` | ||||
|     this._element.body.appendChild(this._element.foot) | ||||
|     let curtain = await document.createElement('div') | ||||
|     curtain.style.position = 'absolute' | ||||
|     curtain.style.top = '0' | ||||
|     curtain.style.left = '0' | ||||
|     curtain.style.width = '100%' | ||||
|     curtain.style.height = '100%' | ||||
|     curtain.style.backdropFilter = 'blur(2px)' | ||||
|     curtain.style.zIndex = '-999999' | ||||
|     this._element.body.appendChild(curtain) | ||||
|  | ||||
|     // 关闭 | ||||
|     let closeBtnsBox = this._element.body.getElementsByClassName('close-box')[0]; | ||||
|  | ||||
| @ -59,12 +59,17 @@ export default class DrawAttackArrow extends Draw { | ||||
|           return | ||||
|         } | ||||
|         into = '3D' | ||||
|         let pos84 = this.cartesian3Towgs84(cartesian, this.viewer) | ||||
|         let lastPos84 = cache_positions[cache_positions.length - 1] | ||||
|         if(lastPos84 && (lastPos84.lng === pos84.lng && lastPos84.lat === pos84.lat)) { | ||||
|           return | ||||
|         } | ||||
|         if (!this.entityHasCreated) { | ||||
|           let polyline_id = DrawAttackArrow.create_arrow_polygon(this) | ||||
|           this.points_ids.push(polyline_id) | ||||
|         } | ||||
|         this.points_ids.push(this.create_point(cartesian)) | ||||
|         cache_positions.push(this.cartesian3Towgs84(cartesian, this.viewer)) | ||||
|         cache_positions.push(pos84) | ||||
|         isMove = false | ||||
|       }) | ||||
|       this.event.mouse_right((movement, cartesian) => { | ||||
|  | ||||
| @ -13,6 +13,7 @@ class DrawPolygon extends Draw { | ||||
|    * */ | ||||
|   constructor(sdk, options = {}) { | ||||
|     super(sdk, options) | ||||
|     this.color = options.color || 'rgba(255,0,0,0.5)' | ||||
|     this.polygonHasCreated = false | ||||
|   } | ||||
|  | ||||
| @ -34,8 +35,8 @@ class DrawPolygon extends Draw { | ||||
|           positions: new Cesium.CallbackProperty((e) => { | ||||
|             return that.positions.concat(that.positions[0]) | ||||
|           }), | ||||
|           width: 2, | ||||
|           material: Cesium.Color.fromCssColorString('#c1c505').withAlpha(0.5), | ||||
|           width: 3, | ||||
|           material: Cesium.Color.fromCssColorString(that.color).withAlpha(1), | ||||
|           clampToGround: true, | ||||
|           zIndex: 99999999 | ||||
|         }, | ||||
|  | ||||
							
								
								
									
										317
									
								
								src/Draw/drawThreeRect.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										317
									
								
								src/Draw/drawThreeRect.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,317 @@ | ||||
| import MouseTip from '../MouseTip' | ||||
| import MouseEvent from '../Event' | ||||
| import Draw from './draw' | ||||
|  | ||||
| /** | ||||
|  * @extends Draw*/ | ||||
| class DrawThreeRect extends Draw { | ||||
|   /** | ||||
|    * @constructor | ||||
|    * @param [options] {object} 三点矩形属性 | ||||
|    * @param [options.color=rgba(185,14,14,0.58)] {object} 线属性 | ||||
|  | ||||
|    * */ | ||||
|   constructor(sdk, options = {}) { | ||||
|     super(sdk, options) | ||||
|     this.polygonHasCreated = false | ||||
|     this.rectObject = [] | ||||
|   } | ||||
|  | ||||
|   static create_polygon(that, viewer = that.viewer) { | ||||
|     that.polygonHasCreated = true | ||||
|     let id = that.randomString() | ||||
|     viewer.entities.add( | ||||
|       new Cesium.Entity({ | ||||
|         id: id, | ||||
|         polygon: { | ||||
|           classificationType: Cesium.ClassificationType.BOTH, | ||||
|           hierarchy: new Cesium.CallbackProperty((e) => { | ||||
|             return new Cesium.PolygonHierarchy(that.positions) | ||||
|           }), | ||||
|           material: Cesium.Color.fromCssColorString(that.color), | ||||
|           zIndex: 99999999 | ||||
|         }, | ||||
|         polyline: { | ||||
|           positions: new Cesium.CallbackProperty((e) => { | ||||
|             return that.positions.concat(that.positions[0]) | ||||
|           }), | ||||
|           width: 2, | ||||
|           material: Cesium.Color.fromCssColorString('#c1c505').withAlpha(0.5), | ||||
|           clampToGround: true, | ||||
|           zIndex: 99999999 | ||||
|         }, | ||||
|       }) | ||||
|     ) | ||||
|     return id | ||||
|   } | ||||
|   computedLastPoint(arr) { | ||||
|     const start = arr[0]; | ||||
|     const end = arr[1]; | ||||
|     // 计算点到线的距离 | ||||
|     const directionVector = Cesium.Cartesian3.subtract(end, start, new Cesium.Cartesian3()); | ||||
|     const pointToStart = Cesium.Cartesian3.subtract(arr[2], start, new Cesium.Cartesian3()); | ||||
|     const projectionLength = Cesium.Cartesian3.dot(pointToStart, directionVector) / Cesium.Cartesian3.magnitudeSquared(directionVector); | ||||
|     const projectionVector = Cesium.Cartesian3.multiplyByScalar(directionVector, projectionLength, new Cesium.Cartesian3()); | ||||
|     const projectionPoint = Cesium.Cartesian3.add(start, projectionVector, new Cesium.Cartesian3()); | ||||
|     const distance = Cesium.Cartesian3.distance(arr[2], projectionPoint) | ||||
|  | ||||
|     const perp = Cesium.Cartesian3.subtract(arr[2], projectionPoint, new Cesium.Cartesian3()); | ||||
|     Cesium.Cartesian3.normalize(perp, perp); | ||||
|     // 生成偏移向量 | ||||
|     const offset = Cesium.Cartesian3.multiplyByScalar(perp, distance, new Cesium.Cartesian3()); | ||||
|     let threePoint = Cesium.Cartesian3.add(end, offset, new Cesium.Cartesian3()) | ||||
|     let lastPoint = Cesium.Cartesian3.add(start, offset, new Cesium.Cartesian3()) | ||||
|     return [{ ...threePoint }, { ...lastPoint }] | ||||
|   } | ||||
|   /** | ||||
|    * @desc 开始动态绘制面 | ||||
|    * @method start | ||||
|    * @param cb {function} 回调函数 | ||||
|    * @memberOf DrawPolygon | ||||
|    * @example draw.start((err,positions)=>{ | ||||
|    * | ||||
|    * }) | ||||
|    * */ | ||||
|   start(cb) { | ||||
|     if (YJ.Measure.GetMeasureStatus()) { | ||||
|       cb('上一次测量未结束') | ||||
|     } else { | ||||
|       this.polygonHasCreated = false | ||||
|       super.start() | ||||
|       YJ.Measure.SetMeasureStatus(true) | ||||
|       let into | ||||
|       this.tip = new MouseTip('左键确定,右键结束;CTRL+右键撤销', this.sdk) | ||||
|       this.event = new MouseEvent(this.sdk) | ||||
|       let cnt = 0 | ||||
|       this.positions = [] | ||||
|       this.positionsLine = [] | ||||
|       this.points_ids = [] //存放左键点击时临时添加的point的id | ||||
|       let cache_positions = [] | ||||
|       let cache_84_position = [] | ||||
|       this.event.mouse_left((movement, cartesian) => { | ||||
|         if (into === '2D') { | ||||
|           return | ||||
|         } | ||||
|         into = '3D' | ||||
|         cnt++ | ||||
|         this.positions = cache_positions.concat({ ...cartesian }) | ||||
|         this.tip.setPosition( | ||||
|           cartesian, | ||||
|           movement.position.x, | ||||
|           movement.position.y | ||||
|         ) | ||||
|         if (!this.polygonHasCreated) { | ||||
|           let polyline_id = DrawThreeRect.create_polygon(this) | ||||
|           this.points_ids.push(polyline_id) | ||||
|         } | ||||
|         cache_positions.push(cartesian) | ||||
|         cache_84_position.push(this.cartesian3Towgs84(cartesian, this.viewer)) | ||||
|         this.points_ids.push(this.create_point(cartesian)) | ||||
|         if (cnt == 3) { | ||||
|           this.end() | ||||
|           cb(null, this.rectObject) | ||||
|         } | ||||
|       }) | ||||
|       this.event.mouse_right((movement, cartesian) => { | ||||
|         if (into === '2D') { | ||||
|           return | ||||
|         } | ||||
|         // let positions = [] | ||||
|         // console.log(cache_positions) | ||||
|         // cache_positions.forEach((item) => { | ||||
|         //   let p = this.cartesian3Towgs84(item) | ||||
|         //   console.log(item) | ||||
|         //   positions.push(p) | ||||
|         // }) | ||||
|         this.end() | ||||
|         cb('取消', '') | ||||
|       }) | ||||
|       this.event.mouse_move((movement, cartesian) => { | ||||
|         if (into === '2D') { | ||||
|           return | ||||
|         } | ||||
|  | ||||
|         // this.positions = cache_positions.concat({ ...cartesian }) | ||||
|         this.tip.setPosition( | ||||
|           cartesian, | ||||
|           movement.endPosition.x, | ||||
|           movement.endPosition.y | ||||
|         ) | ||||
|  | ||||
|         if (cnt == 2) { | ||||
|           let arr = JSON.parse(JSON.stringify(cache_positions)) | ||||
|           let arr1 = arr.concat({ ...cartesian }) | ||||
|           let pointArr = this.computedLastPoint(arr1) | ||||
|           arr = arr.concat(pointArr) | ||||
|           this.positions = arr | ||||
|           let arr_84 = arr.map(item => { | ||||
|             return this.cartesian3Towgs84(item, this.viewer) | ||||
|           }) | ||||
|           this.rectObject = arr_84 | ||||
|         } | ||||
|       }) | ||||
|       this.event.mouse_right_keyboard_ctrl((movement, cartesian) => { | ||||
|         if (into === '2D') { | ||||
|           return | ||||
|         } | ||||
|         if (this.points_ids.length > 1) { | ||||
|           this.remove_entity(this.points_ids.pop()) //移除point | ||||
|           cache_positions.pop() | ||||
|           cache_84_position.pop() | ||||
|         } | ||||
|       }) | ||||
|  | ||||
|       this.event.gesture_pinck_start_keyboard_ctrl(() => { | ||||
|         if (into === '2D') { | ||||
|           return | ||||
|         } | ||||
|         if (this.points_ids.length > 1) { | ||||
|           this.remove_entity(this.points_ids.pop()) //移除point | ||||
|           cache_positions.pop() | ||||
|           cache_84_position.pop() | ||||
|           this.positions = cache_positions.concat(cartesian) | ||||
|         } | ||||
|       }) | ||||
|  | ||||
|       this.event.gesture_pinck_start((movement, cartesian) => { | ||||
|         if (into === '2D') { | ||||
|           return | ||||
|         } | ||||
|         let startTime = new Date() | ||||
|         this.event.gesture_pinck_end(() => { | ||||
|           let endTime = new Date() | ||||
|           if (endTime - startTime >= 500) { | ||||
|             cb(null, cache_84_position) | ||||
|             this.end() | ||||
|           } | ||||
|           else { | ||||
|             this.tip.setPosition( | ||||
|               cartesian, | ||||
|               (movement.position1.x + movement.position2.x) / 2, | ||||
|               (movement.position1.y + movement.position2.y) / 2 | ||||
|             ) | ||||
|             if (!this.polygonHasCreated) { | ||||
|               let polyline_id = DrawThreeRect.create_polygon(this) | ||||
|               this.points_ids.push(polyline_id) | ||||
|             } | ||||
|             cache_positions.push(cartesian) | ||||
|             cache_84_position.push(this.cartesian3Towgs84(cartesian, this.viewer)) | ||||
|             this.points_ids.push(this.create_point(cartesian)) | ||||
|             this.positions = cache_positions.concat(cartesian) | ||||
|           } | ||||
|         }) | ||||
|       }) | ||||
|  | ||||
|       if (!this._is2D && this._sdk2D) { | ||||
|         this.event2D = new MouseEvent(this._sdk2D) | ||||
|         this.event2D.mouse_left((movement, cartesian) => { | ||||
|           if (into === '3D') { | ||||
|             return | ||||
|           } | ||||
|           into = '2D' | ||||
|           cnt++ | ||||
|           this.positions = cache_positions.concat({ ...cartesian }) | ||||
|           this.tip.setPosition( | ||||
|             cartesian, | ||||
|             movement.position.x + this.viewer.canvas.width, | ||||
|             movement.position.y | ||||
|           ) | ||||
|           if (!this.polygonHasCreated) { | ||||
|             let polyline_id = DrawThreeRect.create_polygon(this, this._sdk2D.viewer) | ||||
|             this.points_ids.push(polyline_id) | ||||
|           } | ||||
|           cache_positions.push(cartesian) | ||||
|           cache_84_position.push(this.cartesian3Towgs84(cartesian, this.viewer)) | ||||
|           this.points_ids.push(this.create_point(cartesian, this._sdk2D.viewer)) | ||||
|           if (cnt == 3) { | ||||
|             this.end() | ||||
|             cb(null, this.rectObject) | ||||
|           } | ||||
|         }) | ||||
|         this.event2D.mouse_right((movement, cartesian) => { | ||||
|           if (into === '3D') { | ||||
|             return | ||||
|           } | ||||
|           this.end() | ||||
|           cb('取消', '') | ||||
|         }) | ||||
|         this.event2D.mouse_move((movement, cartesian) => { | ||||
|           if (into === '3D') { | ||||
|             return | ||||
|           } | ||||
|           // this.positions = cache_positions.concat({ ...cartesian }) | ||||
|           this.tip.setPosition( | ||||
|             cartesian, | ||||
|             movement.endPosition.x + this.viewer.canvas.width, | ||||
|             movement.endPosition.y | ||||
|           ) | ||||
|  | ||||
|           if (cnt == 2) { | ||||
|             let arr = JSON.parse(JSON.stringify(cache_positions)) | ||||
|             let arr1 = arr.concat({ ...cartesian }) | ||||
|             let pointArr = this.computedLastPoint(arr1) | ||||
|             arr = arr.concat(pointArr) | ||||
|             this.positions = arr | ||||
|             let arr_84 = arr.map(item => { | ||||
|               return this.cartesian3Towgs84(item, this.viewer) | ||||
|             }) | ||||
|             this.rectObject = arr_84 | ||||
|           } | ||||
|         }) | ||||
|         this.event2D.mouse_right_keyboard_ctrl((movement, cartesian) => { | ||||
|           if (into === '3D') { | ||||
|             return | ||||
|           } | ||||
|           if (this.points_ids.length > 1) { | ||||
|             this.remove_entity(this.points_ids.pop()) //移除point | ||||
|             cache_positions.pop() | ||||
|             cache_84_position.pop() | ||||
|           } | ||||
|         }) | ||||
|  | ||||
|         this.event2D.gesture_pinck_start_keyboard_ctrl(() => { | ||||
|           if (into === '3D') { | ||||
|             return | ||||
|           } | ||||
|           if (this.points_ids.length > 1) { | ||||
|             this.remove_entity(this.points_ids.pop()) //移除point | ||||
|             cache_positions.pop() | ||||
|             cache_84_position.pop() | ||||
|             this.positions = cache_positions.concat(cartesian) | ||||
|           } | ||||
|         }) | ||||
|  | ||||
|         this.event2D.gesture_pinck_start((movement, cartesian) => { | ||||
|           if (into === '3D') { | ||||
|             return | ||||
|           } | ||||
|           let startTime = new Date() | ||||
|           this.event2D.gesture_pinck_end(() => { | ||||
|             let endTime = new Date() | ||||
|             if (endTime - startTime >= 500) { | ||||
|               cb(null, cache_84_position) | ||||
|               this.end() | ||||
|             } | ||||
|             else { | ||||
|               this.tip.setPosition( | ||||
|                 cartesian, | ||||
|                 ((movement.position1.x + movement.position2.x) / 2) + this.viewer.canvas.width, | ||||
|                 (movement.position1.y + movement.position2.y) / 2 | ||||
|               ) | ||||
|               if (!this.polygonHasCreated) { | ||||
|                 let polyline_id = DrawThreeRect.create_polygon(this, this._sdk2D.viewer) | ||||
|                 this.points_ids.push(polyline_id) | ||||
|               } | ||||
|               cache_positions.push(cartesian) | ||||
|               cache_84_position.push(this.cartesian3Towgs84(cartesian, this.viewer)) | ||||
|               this.points_ids.push(this.create_point(cartesian, this._sdk2D.viewer)) | ||||
|               this.positions = cache_positions.concat(cartesian) | ||||
|             } | ||||
|           }) | ||||
|         }) | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
| export default DrawThreeRect | ||||
| @ -72,13 +72,267 @@ function openLeftClick(sdk, cb) { | ||||
|         click = true | ||||
|       }, 600); | ||||
|       if (!YJ.Measure.GetMeasureStatus() && cartesian) { | ||||
|         let flag = false | ||||
|         const pick = sdk.viewer.scene.pick(movement.position) | ||||
|         if (pick) { | ||||
|           if (pick.id) { | ||||
|             let entityId | ||||
|             // 矢量 | ||||
|             if (pick.id.type && pick.id.type === 'vector' && pick.id.parentId) { | ||||
|               let obj = leftClickCallbackMap.get(pick.id.parentId) | ||||
|               if (obj.that.picking && obj.that.geojson) { | ||||
|                 for (let i = 0; i < obj.that.geojson.features.length; i++) { | ||||
|                   if (obj.that.geojson.features[i].id === pick.id._id) { | ||||
|                     obj.callback( | ||||
|                       movement, | ||||
|                       obj.that.geojson.features[i].id, | ||||
|                       cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                     return | ||||
|                   } | ||||
|                 } | ||||
|               } | ||||
|             } | ||||
|             else if (typeof pick.id.id == 'string') { | ||||
|               let array = pick.id.id.split('-') | ||||
|               array.splice(array.length - 1, 1) | ||||
|               entityId = array.join('-') | ||||
|             } | ||||
|  | ||||
|             if (pick.id.properties && pick.id.properties.id && leftClickCallbackMap.has(pick.id.properties.id._value)) { | ||||
|               let obj = leftClickCallbackMap.get(pick.id.properties.id._value) | ||||
|               if (obj.that.picking) { | ||||
|                 obj.callback( | ||||
|                   movement, | ||||
|                   pick.id.properties.id._value, | ||||
|                   cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                 return | ||||
|               } | ||||
|             } | ||||
|             else if (leftClickCallbackMap.has(pick.id.id)) { | ||||
|               let obj = leftClickCallbackMap.get(pick.id.id) | ||||
|               if (obj.that.type === 'PolygonObject') { | ||||
|                 // 是否可点击y | ||||
|                 if (obj.that.picking) { | ||||
|                   if (obj.that.options.positions && obj.that.options.positions.length >= 3) { | ||||
|                     let pt = turf.point([pos84.lng, pos84.lat]); | ||||
|                     let polyPos = [] | ||||
|                     for (let i = 0; i < obj.that.options.positions.length; i++) { | ||||
|                       polyPos.push([ | ||||
|                         obj.that.options.positions[i].lng, | ||||
|                         obj.that.options.positions[i].lat | ||||
|                       ]) | ||||
|                     } | ||||
|                     polyPos.push([ | ||||
|                       obj.that.options.positions[0].lng, | ||||
|                       obj.that.options.positions[0].lat | ||||
|                     ]) | ||||
|                     let poly = turf.polygon([polyPos]); | ||||
|                     let contain = turf.booleanPointInPolygon(pt, poly); | ||||
|                     if (contain) { | ||||
|                       obj.callback( | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       return | ||||
|                     } | ||||
|                   } | ||||
|                 } | ||||
|               } | ||||
|               // 聚集地 | ||||
|               else if (obj.that.type === 'AssembleObject') { | ||||
|                 if (obj.that.picking) { | ||||
|                   if (obj.that.options.positions && obj.that.options.positions.length >= 3) { | ||||
|                     let positions = obj.that.computeAssemble(obj.that.options.positions, true) | ||||
|                     let pt = turf.point([pos84.lng, pos84.lat]); | ||||
|                     let polyPos = [] | ||||
|                     for (let i = 0; i < positions.length; i += 2) { | ||||
|                       polyPos.push([ | ||||
|                         positions[i], | ||||
|                         positions[i + 1] | ||||
|                       ]) | ||||
|                     } | ||||
|                     let poly = turf.polygon([polyPos]); | ||||
|                     let contain = turf.booleanPointInPolygon(pt, poly); | ||||
|                     if (contain) { | ||||
|                       obj.callback( | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       return | ||||
|                     } | ||||
|                   } | ||||
|                 } | ||||
|               } | ||||
|               // 单箭头 | ||||
|               else if (obj.that.type === 'AttackArrowObject') { | ||||
|                 if (obj.that.picking) { | ||||
|                   if (obj.that.options.positions && obj.that.options.positions.length >= 3) { | ||||
|                     let pt = turf.point([pos84.lng, pos84.lat]); | ||||
|                     let positions = obj.that.computeAttackArrow(obj.that.options.positions) | ||||
|                     let polyPos = [] | ||||
|                     for (let m = 0; m < positions.length; m++) { | ||||
|                       let pos84 = cartesian3Towgs84(positions[m], sdk.viewer) | ||||
|                       polyPos.push([pos84.lng, pos84.lat]) | ||||
|                     } | ||||
|                     let poly = turf.polygon([polyPos]); | ||||
|                     let contain = turf.booleanPointInPolygon(pt, poly); | ||||
|                     if (contain) { | ||||
|                       obj.callback( | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       return | ||||
|                     } | ||||
|                   } | ||||
|                 } | ||||
|               } | ||||
|               // 双箭头 | ||||
|               else if (obj.that.type === 'PincerArrowObject') { | ||||
|                 if (obj.that.picking) { | ||||
|                   if (obj.that.options.positions && obj.that.options.positions.length >= 5) { | ||||
|                     let pt = turf.point([pos84.lng, pos84.lat]); | ||||
|                     let positions = obj.that.computePincerArrow(obj.that.options.positions) | ||||
|                     let polyPos = [] | ||||
|                     for (let m = 0; m < positions.length; m++) { | ||||
|                       let pos84 = cartesian3Towgs84(positions[m], sdk.viewer) | ||||
|                       polyPos.push([pos84.lng, pos84.lat]) | ||||
|                     } | ||||
|                     let pos84_0 = cartesian3Towgs84(positions[0], sdk.viewer) | ||||
|                     polyPos.push([pos84_0.lng, pos84_0.lat]) | ||||
|                     let poly = turf.polygon([polyPos]); | ||||
|                     let contain = turf.booleanPointInPolygon(pt, poly); | ||||
|                     if (contain) { | ||||
|                       obj.callback( | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       return | ||||
|                     } | ||||
|                   } | ||||
|                 } | ||||
|               } | ||||
|               // 圆 | ||||
|               else if (obj.that.type === 'CircleObject') { | ||||
|                 if (obj.that.picking) { | ||||
|                   let pt = turf.point([pos84.lng, pos84.lat]); | ||||
|                   if (obj.that.options.center && obj.that.options.radius) { | ||||
|                     let center = [obj.that.options.center.lng, obj.that.options.center.lat]; | ||||
|                     let radius = obj.that.options.radius / 1000; | ||||
|                     let options = { steps: 360, units: 'kilometers' }; | ||||
|                     let circle = turf.circle(center, radius, options); | ||||
|                     let contain = turf.booleanPointInPolygon(pt, circle); | ||||
|                     if (contain) { | ||||
|                       obj.callback( | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       return | ||||
|                     } | ||||
|                   } | ||||
|  | ||||
|                 } | ||||
|               } | ||||
|               // 扇形 | ||||
|               else if (obj.that.type === 'SectorObject') { | ||||
|                 if (obj.that.picking) { | ||||
|                   let pt = turf.point([pos84.lng, pos84.lat]); | ||||
|                   if (obj.that.options.center && obj.that.options.radius && obj.that.options.startAngle && obj.that.options.endAngle) { | ||||
|                     let positions = obj.that.calSector(obj.that.options.center, obj.that.options.radius, obj.that.options.startAngle, obj.that.options.endAngle, undefined, true) | ||||
|                     let polyPos = [] | ||||
|                     for (let m = 0; m < positions.length; m++) { | ||||
|                       polyPos.push([positions[m].lng, positions[m].lat]) | ||||
|                     } | ||||
|                     let poly = turf.polygon([polyPos]); | ||||
|                     let contain = turf.booleanPointInPolygon(pt, poly); | ||||
|                     if (contain) { | ||||
|                       obj.callback( | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       return | ||||
|                     } | ||||
|                   } | ||||
|  | ||||
|                 } | ||||
|               } | ||||
|               if (obj.that.picking) { | ||||
|                 obj.callback( | ||||
|                   movement, | ||||
|                   pick.id.id, | ||||
|                   cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                 return | ||||
|               } | ||||
|             } | ||||
|             else if (entityId && leftClickCallbackMap.has(entityId)) { | ||||
|               let obj = leftClickCallbackMap.get(entityId) | ||||
|               if (obj.that.picking) { | ||||
|                 obj.callback( | ||||
|                   movement, | ||||
|                   entityId, | ||||
|                   cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                 return | ||||
|               } | ||||
|             } | ||||
|             else if (pick.primitive) { | ||||
|               if (typeof pick.id == 'string' && leftClickCallbackMap.has(pick.id)) { | ||||
|                 let obj = leftClickCallbackMap.get(pick.id) | ||||
|                 obj.callback( | ||||
|                   movement, | ||||
|                   pick.id, | ||||
|                   cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                 return | ||||
|               } | ||||
|             } | ||||
|           } | ||||
|           else { | ||||
|             if (pick.primitive && pick.primitive.id) { | ||||
|               if (leftClickCallbackMap.has(pick.primitive.id)) { | ||||
|                 let obj = leftClickCallbackMap.get(pick.primitive.id) | ||||
|                 if (obj.that.picking) { | ||||
|                   if (obj.that.type === 'bim') { | ||||
|                     if (YJ.Global.getBimPickStatus(sdk)) { | ||||
|                       obj.callback( | ||||
|                         movement, | ||||
|                         pick.primitive, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                     } | ||||
|                   } | ||||
|                   else { | ||||
|                     obj.callback( | ||||
|                       movement, | ||||
|                       pick.primitive.id, | ||||
|                       cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                   } | ||||
|                 } | ||||
|               } | ||||
|             } | ||||
|           } | ||||
|           if (pick.content && (!pick.primitive || !pick.primitive.id)) { | ||||
|             if (leftClickCallbackMap.has(pick.content.tileset.id)) { | ||||
|               let obj = leftClickCallbackMap.get(pick.content.tileset.id) | ||||
|               if (obj.that.picking) { | ||||
|                 if (obj.that.type === 'bim') { | ||||
|                   if (YJ.Global.getBimPickStatus(sdk)) { | ||||
|                     obj.callback( | ||||
|                       movement, | ||||
|                       pick.content.tileset, | ||||
|                       cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                   } | ||||
|                 } | ||||
|                 else { | ||||
|                   obj.callback( | ||||
|                     movement, | ||||
|                     pick.content.tileset.id, | ||||
|                     cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                 } | ||||
|               } | ||||
|             } | ||||
|           } | ||||
|         } | ||||
|         for (let i = leftClickCallbackMap.size - 1; i >= 0; i--) { | ||||
|           let key = Array.from(leftClickCallbackMap.keys())[i] | ||||
|           let obj = leftClickCallbackMap.get(key) | ||||
|           if (obj) { | ||||
|  | ||||
|             if (obj.that) { | ||||
|             if (obj.that && obj.that.show && (obj.that.entity && obj.that.entity.show)) { | ||||
|               // 是否为多边形 | ||||
|               if (obj.that.type === 'PolygonObject') { | ||||
|                 // 是否可点击y | ||||
| @ -103,7 +357,6 @@ function openLeftClick(sdk, cb) { | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       flag = true | ||||
|                       break | ||||
|                     } | ||||
|                   } | ||||
| @ -129,7 +382,6 @@ function openLeftClick(sdk, cb) { | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       flag = true | ||||
|                       break | ||||
|                     } | ||||
|                   } | ||||
| @ -153,7 +405,6 @@ function openLeftClick(sdk, cb) { | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       flag = true | ||||
|                       break | ||||
|                     } | ||||
|                   } | ||||
| @ -179,7 +430,6 @@ function openLeftClick(sdk, cb) { | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       flag = true | ||||
|                       break | ||||
|                     } | ||||
|                   } | ||||
| @ -200,7 +450,6 @@ function openLeftClick(sdk, cb) { | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       flag = true | ||||
|                       break | ||||
|                     } | ||||
|                   } | ||||
| @ -224,7 +473,6 @@ function openLeftClick(sdk, cb) { | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       flag = true | ||||
|                       break | ||||
|                     } | ||||
|                   } | ||||
| @ -234,114 +482,6 @@ function openLeftClick(sdk, cb) { | ||||
|             } | ||||
|           } | ||||
|         } | ||||
|         if (!flag) { | ||||
|           const pick = sdk.viewer.scene.pick(movement.position) | ||||
|           if (pick) { | ||||
|             if (pick.id) { | ||||
|               let entityId | ||||
|               // 矢量 | ||||
|               if (pick.id.type && pick.id.type === 'vector' && pick.id.parentId) { | ||||
|                 let obj = leftClickCallbackMap.get(pick.id.parentId) | ||||
|                 if (obj.that.picking && obj.that.geojson) { | ||||
|                   for (let i = 0; i < obj.that.geojson.features.length; i++) { | ||||
|                     if (obj.that.geojson.features[i].id === pick.id._id) { | ||||
|                       obj.callback( | ||||
|                         movement, | ||||
|                         obj.that.geojson.features[i].id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                     } | ||||
|                   } | ||||
|                 } | ||||
|               } | ||||
|               else if (typeof pick.id.id == 'string') { | ||||
|                 let array = pick.id.id.split('-') | ||||
|                 array.splice(array.length - 1, 1) | ||||
|                 entityId = array.join('-') | ||||
|               } | ||||
|  | ||||
|               if (pick.id.properties && pick.id.properties.id && leftClickCallbackMap.has(pick.id.properties.id._value)) { | ||||
|                 let obj = leftClickCallbackMap.get(pick.id.properties.id._value) | ||||
|                 if (obj.that.picking) { | ||||
|                   obj.callback( | ||||
|                     movement, | ||||
|                     pick.id.properties.id._value, | ||||
|                     cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                 } | ||||
|               } | ||||
|               else if (leftClickCallbackMap.has(pick.id.id)) { | ||||
|                 let obj = leftClickCallbackMap.get(pick.id.id) | ||||
|                 if (obj.that.picking) { | ||||
|                   obj.callback( | ||||
|                     movement, | ||||
|                     pick.id.id, | ||||
|                     cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                 } | ||||
|               } | ||||
|               else if (entityId && leftClickCallbackMap.has(entityId)) { | ||||
|                 let obj = leftClickCallbackMap.get(entityId) | ||||
|                 if (obj.that.picking) { | ||||
|                   obj.callback( | ||||
|                     movement, | ||||
|                     entityId, | ||||
|                     cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                 } | ||||
|               } | ||||
|               else if (pick.primitive) { | ||||
|                 if (typeof pick.id == 'string' && leftClickCallbackMap.has(pick.id)) { | ||||
|                   let obj = leftClickCallbackMap.get(pick.id) | ||||
|                   obj.callback( | ||||
|                     movement, | ||||
|                     pick.id, | ||||
|                     cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                 } | ||||
|               } | ||||
|             } | ||||
|             else { | ||||
|               if (pick.primitive && pick.primitive.id) { | ||||
|                 if (leftClickCallbackMap.has(pick.primitive.id)) { | ||||
|                   let obj = leftClickCallbackMap.get(pick.primitive.id) | ||||
|                   if (obj.that.picking) { | ||||
|                     if (obj.that.type === 'bim') { | ||||
|                       if (YJ.Global.getBimPickStatus(sdk)) { | ||||
|                         obj.callback( | ||||
|                           movement, | ||||
|                           pick.primitive, | ||||
|                           cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       } | ||||
|                     } | ||||
|                     else { | ||||
|                       obj.callback( | ||||
|                         movement, | ||||
|                         pick.primitive.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                     } | ||||
|                   } | ||||
|                 } | ||||
|               } | ||||
|             } | ||||
|             if (pick.content && (!pick.primitive || !pick.primitive.id)) { | ||||
|               if (leftClickCallbackMap.has(pick.content.tileset.id)) { | ||||
|                 let obj = leftClickCallbackMap.get(pick.content.tileset.id) | ||||
|                 if (obj.that.picking) { | ||||
|                   if (obj.that.type === 'bim') { | ||||
|                     if (YJ.Global.getBimPickStatus(sdk)) { | ||||
|                       obj.callback( | ||||
|                         movement, | ||||
|                         pick.content.tileset, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                     } | ||||
|                   } | ||||
|                   else { | ||||
|                     obj.callback( | ||||
|                       movement, | ||||
|                       pick.content.tileset.id, | ||||
|                       cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                   } | ||||
|                 } | ||||
|               } | ||||
|             } | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|  | ||||
|  | ||||
| @ -135,6 +135,7 @@ const open = async (sdk, options = {}, _Dialog = {}) => { | ||||
|       pitch: viewer.camera.pitch, | ||||
|       roll: viewer.camera.roll | ||||
|     } | ||||
|     tools.message({text: '操作成功'}) | ||||
|   }) | ||||
|  | ||||
|   let totalTimeElm = contentElm.querySelector("input[name='totalTime']") | ||||
|  | ||||
| @ -101,6 +101,7 @@ function getFlagFromKeyboard(key) { | ||||
|  */ | ||||
| function keyDown(event) { | ||||
|   let _viewer = this | ||||
|  | ||||
|   // 判断是否有输入框聚焦 | ||||
|   function isInputFocused() { | ||||
|     const activeElement = document.activeElement; | ||||
| @ -164,32 +165,51 @@ function keyUp(event) { | ||||
|  * @return {*} | ||||
|  */ | ||||
| function keyboardMapRoamingRender(_viewer) { | ||||
|   if(!_viewer.scene.screenSpaceCameraController.enableTilt) { | ||||
|   if(!_viewer || !_viewer.scene || !_viewer.scene.screenSpaceCameraController.enableTilt) { | ||||
|     return | ||||
|   } | ||||
|   let camera = _viewer.camera; | ||||
|   let ellipsoid = _viewer.scene.globe.ellipsoid; | ||||
|   let cameraHeight = ellipsoid.cartesianToCartographic(camera.position).height; | ||||
|   let cameraHeight2 = camera.positionCartographic.height; | ||||
|  | ||||
|  | ||||
|   // 根据相机高度设置移动距离,比默认距离移动效果更好 | ||||
|   let moveRate = cameraHeight / 20.0; | ||||
|   let rotationRate = moveRate / 500000 / Cesium.Math.toDegrees(camera.pitch); | ||||
|   let moveRate2 = cameraHeight2 / 100.0; | ||||
|  | ||||
|   if (flags.moveForward) { | ||||
|     // camera.moveForward(moveRate); | ||||
|     camera.rotate(camera.right, -rotationRate); | ||||
|     if(_viewer.scene.mode == 2) { | ||||
|       camera.moveUp(moveRate2); | ||||
|     } | ||||
|     else { | ||||
|       camera.rotate(camera.right, -rotationRate); | ||||
|     } | ||||
|   } | ||||
|   if (flags.moveBackward) { | ||||
|     // camera.moveBackward(moveRate); | ||||
|     camera.rotate(camera.right, rotationRate); | ||||
|     if(_viewer.scene.mode == 2) { | ||||
|       camera.moveDown(moveRate2); | ||||
|     } | ||||
|     else { | ||||
|       camera.rotate(camera.right, rotationRate); | ||||
|     } | ||||
|   } | ||||
|   if (flags.moveLeft) { | ||||
|     // camera.moveLeft(moveRate); | ||||
|     camera.rotate(camera.up, -rotationRate); | ||||
|     if(_viewer.scene.mode == 2) { | ||||
|       camera.moveLeft(moveRate2); | ||||
|     } | ||||
|     else { | ||||
|       camera.rotate(camera.up, -rotationRate); | ||||
|     } | ||||
|   } | ||||
|   if (flags.moveRight) { | ||||
|     // camera.moveRight(moveRate); | ||||
|     camera.rotate(camera.up, rotationRate); | ||||
|     if(_viewer.scene.mode == 2) { | ||||
|       camera.moveRight(moveRate2); | ||||
|     } | ||||
|     else { | ||||
|       camera.rotate(camera.up, rotationRate); | ||||
|     } | ||||
|   } | ||||
|   if (flags.moveUp) { | ||||
|     camera.moveUp(moveRate); | ||||
|  | ||||
| @ -1420,11 +1420,11 @@ async function MapPrint(sdk, thumbnailImg, rectangle, originalImg) { | ||||
|         const url = URL.createObjectURL(blob); | ||||
|         let downloadElement = document.createElement('a'); | ||||
|         downloadElement.href = url; | ||||
|         downloadElement.download = `高清出图-${getDateTimeString()}.jpg`; | ||||
|         downloadElement.download = `高清出图-${getDateTimeString()}.png`; | ||||
|         document.body.appendChild(downloadElement); | ||||
|         downloadElement.click(); | ||||
|         document.body.removeChild(downloadElement); | ||||
|       }, 'image/jpeg', 0.95); | ||||
|       }, 'image/png', 0.95); | ||||
|       exporting = false; | ||||
|       exportBtn.innerHTML = '打印'; | ||||
|       // canvas2.toBlob(function (blob) { | ||||
|  | ||||
| @ -124,7 +124,7 @@ function syncViewer() { | ||||
|   if (height > 9000000) { | ||||
|     height = 9000000 | ||||
|   } | ||||
|   if (height < 100000) { | ||||
|   if (height < 400000) { | ||||
|     this.entity.billboard.show = true | ||||
|     this.entity.rectangle.show = false | ||||
|   } | ||||
|  | ||||
| @ -4,18 +4,38 @@ | ||||
| import Tools from "../../Tools"; | ||||
| import { getCoordinateSystem } from "../../Global/global"; | ||||
| import MouseEvent from '../../Event/index' | ||||
| import { getSdk as get2DSdk } from '../../Global/MultiViewportMode' | ||||
| import { getSdk as getSplitScreenSdk } from "../../Global/SplitScreen"; | ||||
|  | ||||
| let event | ||||
| let event2 | ||||
| let MouseCoordinateElm | ||||
| let requestAnimationFrameEventId | ||||
| let tmovement | ||||
| let targetSdk | ||||
| let sdkD | ||||
|  | ||||
| const MouseCoordinate = (sdk, status) => { | ||||
|   if (!sdk || !sdk.viewer) { | ||||
|     return | ||||
|   } | ||||
|   targetSdk = sdk | ||||
|   sdkD = get2DSdk().sdkD | ||||
|   if(!sdkD) { | ||||
|     sdkD = getSplitScreenSdk().sdkD | ||||
|   } | ||||
|  | ||||
|   let tools = new Tools(sdk) | ||||
|   if (status) { | ||||
|     if (event) { | ||||
|       event.destroy() | ||||
|     } | ||||
|     if (event2) { | ||||
|       event2.destroy() | ||||
|       event2 = undefined | ||||
|     } | ||||
|     event = new MouseEvent(sdk) | ||||
|     tmovement = null | ||||
|     let position = { | ||||
|       x: '', | ||||
|       y: '', | ||||
| @ -40,22 +60,60 @@ const MouseCoordinate = (sdk, status) => { | ||||
|       contentElm.style['background-size'] = `200% 200%`; | ||||
|       MouseCoordinateElm = contentElm | ||||
|     } | ||||
|     sdk.viewer._element.appendChild(contentElm) | ||||
|     let tmovement | ||||
|     sdk.viewer.container.appendChild(contentElm) | ||||
|  | ||||
|     event.mouse_move((movement, cartesian) => { | ||||
|       tmovement = { ...movement } | ||||
|       targetSdk = sdk | ||||
|       tmovement = { ...movement.endPosition } | ||||
|     }) | ||||
|  | ||||
|     const getPosition = () => { | ||||
|       if(!tmovement) { | ||||
|       if (!targetSdk) { | ||||
|         return | ||||
|       } | ||||
|       let canvas = sdk.viewer._element.getElementsByTagName('canvas')[0] | ||||
|       let left = tmovement.endPosition.x; | ||||
|       let top = tmovement.endPosition.y; | ||||
|       let cartesian = event.getcartesian(tmovement) | ||||
|       contentElm.style['background-position-x'] = `${-canvas.width + left + 4}px`; | ||||
|       contentElm.style['background-position-y'] = `${-canvas.height + top - 2}px`; | ||||
|       sdkD = get2DSdk().sdkD | ||||
|       if(!sdkD) { | ||||
|         sdkD = getSplitScreenSdk().sdkD | ||||
|       } | ||||
|       if (!event2 && sdkD) { | ||||
|         event2 = new MouseEvent(sdkD) | ||||
|         event2.mouse_move((movement, cartesian) => { | ||||
|           targetSdk = sdkD | ||||
|           tmovement = { x: movement.endPosition.x, y: movement.endPosition.y } | ||||
|         }) | ||||
|       } | ||||
|       if (!tmovement) { | ||||
|         return | ||||
|       } | ||||
|       let left = tmovement.x; | ||||
|       let top = tmovement.y; | ||||
|       let cartesian | ||||
|       if (targetSdk.viewer.scene.mode === 2) { | ||||
|         left = left + canvas.width | ||||
|         cartesian = targetSdk.viewer.camera.pickEllipsoid(tmovement, targetSdk.viewer.scene.globe.ellipsoid) | ||||
|       } | ||||
|       else { | ||||
|         cartesian = targetSdk.viewer.scene.pickPosition(tmovement) | ||||
|         if (!cartesian) { | ||||
|           const ray = targetSdk.viewer.camera.getPickRay(position); //相交的射线 | ||||
|           let pickedObjects = targetSdk.viewer.scene.drillPickFromRay(ray, 10); | ||||
|           let result = {} | ||||
|           for (let i = 0; i < pickedObjects.length; i++) { | ||||
|             if (pickedObjects[i].position) { | ||||
|               result = pickedObjects[i] | ||||
|               break | ||||
|             } | ||||
|           } | ||||
|           cartesian = result.position | ||||
|           if (!cartesian) { | ||||
|             cartesian = targetSdk.viewer.scene.globe.pick(ray, targetSdk.viewer.scene); | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|       contentElm.style['background-position-x'] = `${-sdk.viewer.container.clientWidth + left + 4}px`; | ||||
|  | ||||
|       contentElm.style['background-position-y'] = `${-sdk.viewer.container.clientHeight + top - 2}px`; | ||||
|       // this.entity.position = cartesian | ||||
|       if (cartesian) { | ||||
|         let degrees = tools.cartesian3Towgs84(cartesian, sdk.viewer) | ||||
| @ -97,10 +155,13 @@ const MouseCoordinate = (sdk, status) => { | ||||
|   else { | ||||
|     if (event) { | ||||
|       event.destroy() | ||||
|       event = undefined | ||||
|     } | ||||
|     if (event2) { | ||||
|       event2.destroy() | ||||
|       event2 = undefined | ||||
|     } | ||||
|     if (MouseCoordinateElm) { | ||||
|       sdk.viewer._element.removeChild(MouseCoordinateElm) | ||||
|       sdk.viewer.container.removeChild(MouseCoordinateElm) | ||||
|       MouseCoordinateElm = undefined | ||||
|     } | ||||
|     if (requestAnimationFrameEventId) { | ||||
|  | ||||
							
								
								
									
										718
									
								
								src/Global/MultiViewportMode/ClickCallback/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										718
									
								
								src/Global/MultiViewportMode/ClickCallback/index.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,718 @@ | ||||
| /** | ||||
|  * @name: click | ||||
|  * @author: Administrator | ||||
|  * @date: 2023-05-28 11:05 | ||||
|  * @description:click | ||||
|  * @update: 2023-05-28 11:05 | ||||
|  */ | ||||
| let leftClickHandler = null | ||||
| let rightClickHandler = null | ||||
| let MoveHandler = null | ||||
| let leftClickCallbackMap = new Map() | ||||
| let rightClickCallbackMap = new Map() | ||||
| let MoveCallbackMap = new Map() | ||||
| let selectedFeature; | ||||
|  | ||||
|  | ||||
| function cartesian3Towgs84(cartesian, viewer) { | ||||
|   var ellipsoid = viewer.scene.globe.ellipsoid | ||||
|   var cartesian3 = new Cesium.Cartesian3( | ||||
|     cartesian.x, | ||||
|     cartesian.y, | ||||
|     cartesian.z | ||||
|   ) | ||||
|   var cartographic = ellipsoid.cartesianToCartographic(cartesian3) | ||||
|   var lat = Cesium.Math.toDegrees(cartographic.latitude) | ||||
|   var lng = Cesium.Math.toDegrees(cartographic.longitude) | ||||
|   var alt = cartographic.height < 0 ? 0 : cartographic.height | ||||
|   return { | ||||
|     lng: lng, | ||||
|     lat: lat, | ||||
|     alt: alt, | ||||
|   } | ||||
| } | ||||
|  | ||||
| function getcartesian(sdk, movement) { | ||||
|   if (movement.endPosition) { | ||||
|     movement.endPosition.y -= 2 | ||||
|   } | ||||
|   let position = movement.position || movement.endPosition | ||||
|   // 获取世界坐标系地表坐标,考虑地形,不包括模型,倾斜摄影模型表面; | ||||
|   let cartesian = sdk.viewer.scene.pickPosition(position) | ||||
|   if (!cartesian) { | ||||
|     const ray = sdk.viewer.camera.getPickRay(position); //相交的射线 | ||||
|     cartesian = sdk.viewer.scene.globe.pick(ray, sdk.viewer.scene); | ||||
|   } | ||||
|   return cartesian | ||||
| } | ||||
|  | ||||
| function openLeftClick(sdk, cb) { | ||||
|   if (!sdk || !sdk.viewer) { | ||||
|     return | ||||
|   } | ||||
|   let click = true | ||||
|   leftClickHandler = new Cesium.ScreenSpaceEventHandler(sdk.viewer.canvas) | ||||
|   leftClickHandler.setInputAction((movement) => { | ||||
|     let cartesian = sdk.viewer.scene.pickPosition(movement.position) | ||||
|     if (!cartesian) { | ||||
|       const ray = sdk.viewer.camera.getPickRay(movement.position); //相交的射线 | ||||
|       cartesian = sdk.viewer.scene.globe.pick(ray, sdk.viewer.scene); | ||||
|     } | ||||
|     if (!cartesian) { | ||||
|       return | ||||
|     } | ||||
|  | ||||
|     let pos84 = cartesian3Towgs84(cartesian, sdk.viewer) | ||||
|  | ||||
|     cb && cb(pos84) | ||||
|  | ||||
|     if (click) { | ||||
|       click = false | ||||
|       setTimeout(() => { | ||||
|         click = true | ||||
|       }, 600); | ||||
|       if (!YJ.Measure.GetMeasureStatus() && cartesian) { | ||||
|         const pick = sdk.viewer.scene.pick(movement.position) | ||||
|         if (pick) { | ||||
|           if (pick.id) { | ||||
|             let entityId | ||||
|             // 矢量 | ||||
|             if (pick.id.type && pick.id.type === 'vector' && pick.id.parentId) { | ||||
|               let obj = leftClickCallbackMap.get(pick.id.parentId) | ||||
|               if (obj.that.picking && obj.that.geojson) { | ||||
|                 for (let i = 0; i < obj.that.geojson.features.length; i++) { | ||||
|                   if (obj.that.geojson.features[i].id === pick.id._id) { | ||||
|                     obj.callback( | ||||
|                       movement, | ||||
|                       obj.that.geojson.features[i].id, | ||||
|                       cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                     return | ||||
|                   } | ||||
|                 } | ||||
|               } | ||||
|             } | ||||
|             else if (typeof pick.id.id == 'string') { | ||||
|               let array = pick.id.id.split('-') | ||||
|               array.splice(array.length - 1, 1) | ||||
|               entityId = array.join('-') | ||||
|             } | ||||
|  | ||||
|             if (pick.id.properties && pick.id.properties.id && leftClickCallbackMap.has(pick.id.properties.id._value)) { | ||||
|               let obj = leftClickCallbackMap.get(pick.id.properties.id._value) | ||||
|               if (obj.that.picking) { | ||||
|                 obj.callback( | ||||
|                   movement, | ||||
|                   pick.id.properties.id._value, | ||||
|                   cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                 return | ||||
|               } | ||||
|             } | ||||
|             else if (leftClickCallbackMap.has(pick.id.id)) { | ||||
|               let obj = leftClickCallbackMap.get(pick.id.id) | ||||
|               if (obj.that.type === 'PolygonObject') { | ||||
|                 // 是否可点击y | ||||
|                 if (obj.that.picking) { | ||||
|                   if (obj.that.options.positions && obj.that.options.positions.length >= 3) { | ||||
|                     let pt = turf.point([pos84.lng, pos84.lat]); | ||||
|                     let polyPos = [] | ||||
|                     for (let i = 0; i < obj.that.options.positions.length; i++) { | ||||
|                       polyPos.push([ | ||||
|                         obj.that.options.positions[i].lng, | ||||
|                         obj.that.options.positions[i].lat | ||||
|                       ]) | ||||
|                     } | ||||
|                     polyPos.push([ | ||||
|                       obj.that.options.positions[0].lng, | ||||
|                       obj.that.options.positions[0].lat | ||||
|                     ]) | ||||
|                     let poly = turf.polygon([polyPos]); | ||||
|                     let contain = turf.booleanPointInPolygon(pt, poly); | ||||
|                     if (contain) { | ||||
|                       obj.callback( | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       return | ||||
|                     } | ||||
|                   } | ||||
|                 } | ||||
|               } | ||||
|               // 聚集地 | ||||
|               else if (obj.that.type === 'AssembleObject') { | ||||
|                 if (obj.that.picking) { | ||||
|                   if (obj.that.options.positions && obj.that.options.positions.length >= 3) { | ||||
|                     let positions = obj.that.computeAssemble(obj.that.options.positions, true) | ||||
|                     let pt = turf.point([pos84.lng, pos84.lat]); | ||||
|                     let polyPos = [] | ||||
|                     for (let i = 0; i < positions.length; i += 2) { | ||||
|                       polyPos.push([ | ||||
|                         positions[i], | ||||
|                         positions[i + 1] | ||||
|                       ]) | ||||
|                     } | ||||
|                     let poly = turf.polygon([polyPos]); | ||||
|                     let contain = turf.booleanPointInPolygon(pt, poly); | ||||
|                     if (contain) { | ||||
|                       obj.callback( | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       return | ||||
|                     } | ||||
|                   } | ||||
|                 } | ||||
|               } | ||||
|               // 单箭头 | ||||
|               else if (obj.that.type === 'AttackArrowObject') { | ||||
|                 if (obj.that.picking) { | ||||
|                   if (obj.that.options.positions && obj.that.options.positions.length >= 3) { | ||||
|                     let pt = turf.point([pos84.lng, pos84.lat]); | ||||
|                     let positions = obj.that.computeAttackArrow(obj.that.options.positions) | ||||
|                     let polyPos = [] | ||||
|                     for (let m = 0; m < positions.length; m++) { | ||||
|                       let pos84 = cartesian3Towgs84(positions[m], sdk.viewer) | ||||
|                       polyPos.push([pos84.lng, pos84.lat]) | ||||
|                     } | ||||
|                     let poly = turf.polygon([polyPos]); | ||||
|                     let contain = turf.booleanPointInPolygon(pt, poly); | ||||
|                     if (contain) { | ||||
|                       obj.callback( | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       return | ||||
|                     } | ||||
|                   } | ||||
|                 } | ||||
|               } | ||||
|               // 双箭头 | ||||
|               else if (obj.that.type === 'PincerArrowObject') { | ||||
|                 if (obj.that.picking) { | ||||
|                   if (obj.that.options.positions && obj.that.options.positions.length >= 5) { | ||||
|                     let pt = turf.point([pos84.lng, pos84.lat]); | ||||
|                     let positions = obj.that.computePincerArrow(obj.that.options.positions) | ||||
|                     let polyPos = [] | ||||
|                     for (let m = 0; m < positions.length; m++) { | ||||
|                       let pos84 = cartesian3Towgs84(positions[m], sdk.viewer) | ||||
|                       polyPos.push([pos84.lng, pos84.lat]) | ||||
|                     } | ||||
|                     let pos84_0 = cartesian3Towgs84(positions[0], sdk.viewer) | ||||
|                     polyPos.push([pos84_0.lng, pos84_0.lat]) | ||||
|                     let poly = turf.polygon([polyPos]); | ||||
|                     let contain = turf.booleanPointInPolygon(pt, poly); | ||||
|                     if (contain) { | ||||
|                       obj.callback( | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       return | ||||
|                     } | ||||
|                   } | ||||
|                 } | ||||
|               } | ||||
|               // 圆 | ||||
|               else if (obj.that.type === 'CircleObject') { | ||||
|                 if (obj.that.picking) { | ||||
|                   let pt = turf.point([pos84.lng, pos84.lat]); | ||||
|                   if (obj.that.options.center && obj.that.options.radius) { | ||||
|                     let center = [obj.that.options.center.lng, obj.that.options.center.lat]; | ||||
|                     let radius = obj.that.options.radius / 1000; | ||||
|                     let options = { steps: 360, units: 'kilometers' }; | ||||
|                     let circle = turf.circle(center, radius, options); | ||||
|                     let contain = turf.booleanPointInPolygon(pt, circle); | ||||
|                     if (contain) { | ||||
|                       obj.callback( | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       return | ||||
|                     } | ||||
|                   } | ||||
|  | ||||
|                 } | ||||
|               } | ||||
|               // 扇形 | ||||
|               else if (obj.that.type === 'SectorObject') { | ||||
|                 if (obj.that.picking) { | ||||
|                   let pt = turf.point([pos84.lng, pos84.lat]); | ||||
|                   if (obj.that.options.center && obj.that.options.radius && obj.that.options.startAngle && obj.that.options.endAngle) { | ||||
|                     let positions = obj.that.calSector(obj.that.options.center, obj.that.options.radius, obj.that.options.startAngle, obj.that.options.endAngle, undefined, true) | ||||
|                     let polyPos = [] | ||||
|                     for (let m = 0; m < positions.length; m++) { | ||||
|                       polyPos.push([positions[m].lng, positions[m].lat]) | ||||
|                     } | ||||
|                     let poly = turf.polygon([polyPos]); | ||||
|                     let contain = turf.booleanPointInPolygon(pt, poly); | ||||
|                     if (contain) { | ||||
|                       obj.callback( | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       return | ||||
|                     } | ||||
|                   } | ||||
|  | ||||
|                 } | ||||
|               } | ||||
|               if (obj.that.picking) { | ||||
|                 obj.callback( | ||||
|                   movement, | ||||
|                   pick.id.id, | ||||
|                   cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                 return | ||||
|               } | ||||
|             } | ||||
|             else if (entityId && leftClickCallbackMap.has(entityId)) { | ||||
|               let obj = leftClickCallbackMap.get(entityId) | ||||
|               if (obj.that.picking) { | ||||
|                 obj.callback( | ||||
|                   movement, | ||||
|                   entityId, | ||||
|                   cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                 return | ||||
|               } | ||||
|             } | ||||
|             else if (pick.primitive) { | ||||
|               if (typeof pick.id == 'string' && leftClickCallbackMap.has(pick.id)) { | ||||
|                 let obj = leftClickCallbackMap.get(pick.id) | ||||
|                 obj.callback( | ||||
|                   movement, | ||||
|                   pick.id, | ||||
|                   cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                 return | ||||
|               } | ||||
|             } | ||||
|           } | ||||
|           else { | ||||
|             if (pick.primitive && pick.primitive.id) { | ||||
|               if (leftClickCallbackMap.has(pick.primitive.id)) { | ||||
|                 let obj = leftClickCallbackMap.get(pick.primitive.id) | ||||
|                 if (obj.that.picking) { | ||||
|                   if (obj.that.type === 'bim') { | ||||
|                     if (YJ.Global.getBimPickStatus(sdk)) { | ||||
|                       obj.callback( | ||||
|                         movement, | ||||
|                         pick.primitive, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                     } | ||||
|                   } | ||||
|                   else { | ||||
|                     obj.callback( | ||||
|                       movement, | ||||
|                       pick.primitive.id, | ||||
|                       cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                   } | ||||
|                 } | ||||
|               } | ||||
|             } | ||||
|           } | ||||
|           if (pick.content && (!pick.primitive || !pick.primitive.id)) { | ||||
|             if (leftClickCallbackMap.has(pick.content.tileset.id)) { | ||||
|               let obj = leftClickCallbackMap.get(pick.content.tileset.id) | ||||
|               if (obj.that.picking) { | ||||
|                 if (obj.that.type === 'bim') { | ||||
|                   if (YJ.Global.getBimPickStatus(sdk)) { | ||||
|                     obj.callback( | ||||
|                       movement, | ||||
|                       pick.content.tileset, | ||||
|                       cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                   } | ||||
|                 } | ||||
|                 else { | ||||
|                   obj.callback( | ||||
|                     movement, | ||||
|                     pick.content.tileset.id, | ||||
|                     cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                 } | ||||
|               } | ||||
|             } | ||||
|           } | ||||
|         } | ||||
|         for (let i = leftClickCallbackMap.size - 1; i >= 0; i--) { | ||||
|           let key = Array.from(leftClickCallbackMap.keys())[i] | ||||
|           let obj = leftClickCallbackMap.get(key) | ||||
|           if (obj) { | ||||
|             if (obj.that && obj.that.show && (obj.that.entity && obj.that.entity.show)) { | ||||
|               // 是否为多边形 | ||||
|               if (obj.that.type === 'PolygonObject') { | ||||
|                 // 是否可点击y | ||||
|                 if (obj.that.picking) { | ||||
|                   if (obj.that.options.positions && obj.that.options.positions.length >= 3) { | ||||
|                     let pt = turf.point([pos84.lng, pos84.lat]); | ||||
|                     let polyPos = [] | ||||
|                     for (let i = 0; i < obj.that.options.positions.length; i++) { | ||||
|                       polyPos.push([ | ||||
|                         obj.that.options.positions[i].lng, | ||||
|                         obj.that.options.positions[i].lat | ||||
|                       ]) | ||||
|                     } | ||||
|                     polyPos.push([ | ||||
|                       obj.that.options.positions[0].lng, | ||||
|                       obj.that.options.positions[0].lat | ||||
|                     ]) | ||||
|                     let poly = turf.polygon([polyPos]); | ||||
|                     let contain = turf.booleanPointInPolygon(pt, poly); | ||||
|                     if (contain) { | ||||
|                       obj.callback( | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       break | ||||
|                     } | ||||
|                   } | ||||
|                 } | ||||
|               } | ||||
|               // 聚集地 | ||||
|               else if (obj.that.type === 'AssembleObject') { | ||||
|                 if (obj.that.picking) { | ||||
|                   if (obj.that.options.positions && obj.that.options.positions.length >= 3) { | ||||
|                     let positions = obj.that.computeAssemble(obj.that.options.positions, true) | ||||
|                     let pt = turf.point([pos84.lng, pos84.lat]); | ||||
|                     let polyPos = [] | ||||
|                     for (let i = 0; i < positions.length; i += 2) { | ||||
|                       polyPos.push([ | ||||
|                         positions[i], | ||||
|                         positions[i + 1] | ||||
|                       ]) | ||||
|                     } | ||||
|                     let poly = turf.polygon([polyPos]); | ||||
|                     let contain = turf.booleanPointInPolygon(pt, poly); | ||||
|                     if (contain) { | ||||
|                       obj.callback( | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       break | ||||
|                     } | ||||
|                   } | ||||
|                 } | ||||
|               } | ||||
|               // 单箭头 | ||||
|               else if (obj.that.type === 'AttackArrowObject') { | ||||
|                 if (obj.that.picking) { | ||||
|                   if (obj.that.options.positions && obj.that.options.positions.length >= 3) { | ||||
|                     let pt = turf.point([pos84.lng, pos84.lat]); | ||||
|                     let positions = obj.that.computeAttackArrow(obj.that.options.positions) | ||||
|                     let polyPos = [] | ||||
|                     for (let m = 0; m < positions.length; m++) { | ||||
|                       let pos84 = cartesian3Towgs84(positions[m], sdk.viewer) | ||||
|                       polyPos.push([pos84.lng, pos84.lat]) | ||||
|                     } | ||||
|                     let poly = turf.polygon([polyPos]); | ||||
|                     let contain = turf.booleanPointInPolygon(pt, poly); | ||||
|                     if (contain) { | ||||
|                       obj.callback( | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       break | ||||
|                     } | ||||
|                   } | ||||
|                 } | ||||
|               } | ||||
|               // 双箭头 | ||||
|               else if (obj.that.type === 'PincerArrowObject') { | ||||
|                 if (obj.that.picking) { | ||||
|                   if (obj.that.options.positions && obj.that.options.positions.length >= 5) { | ||||
|                     let pt = turf.point([pos84.lng, pos84.lat]); | ||||
|                     let positions = obj.that.computePincerArrow(obj.that.options.positions) | ||||
|                     let polyPos = [] | ||||
|                     for (let m = 0; m < positions.length; m++) { | ||||
|                       let pos84 = cartesian3Towgs84(positions[m], sdk.viewer) | ||||
|                       polyPos.push([pos84.lng, pos84.lat]) | ||||
|                     } | ||||
|                     let pos84_0 = cartesian3Towgs84(positions[0], sdk.viewer) | ||||
|                     polyPos.push([pos84_0.lng, pos84_0.lat]) | ||||
|                     let poly = turf.polygon([polyPos]); | ||||
|                     let contain = turf.booleanPointInPolygon(pt, poly); | ||||
|                     if (contain) { | ||||
|                       obj.callback( | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       break | ||||
|                     } | ||||
|                   } | ||||
|                 } | ||||
|               } | ||||
|               // 圆 | ||||
|               else if (obj.that.type === 'CircleObject') { | ||||
|                 if (obj.that.picking) { | ||||
|                   let pt = turf.point([pos84.lng, pos84.lat]); | ||||
|                   if (obj.that.options.center && obj.that.options.radius) { | ||||
|                     let center = [obj.that.options.center.lng, obj.that.options.center.lat]; | ||||
|                     let radius = obj.that.options.radius / 1000; | ||||
|                     let options = { steps: 360, units: 'kilometers' }; | ||||
|                     let circle = turf.circle(center, radius, options); | ||||
|                     let contain = turf.booleanPointInPolygon(pt, circle); | ||||
|                     if (contain) { | ||||
|                       obj.callback( | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       break | ||||
|                     } | ||||
|                   } | ||||
|  | ||||
|                 } | ||||
|               } | ||||
|               // 扇形 | ||||
|               else if (obj.that.type === 'SectorObject') { | ||||
|                 if (obj.that.picking) { | ||||
|                   let pt = turf.point([pos84.lng, pos84.lat]); | ||||
|                   if (obj.that.options.center && obj.that.options.radius && obj.that.options.startAngle && obj.that.options.endAngle) { | ||||
|                     let positions = obj.that.calSector(obj.that.options.center, obj.that.options.radius, obj.that.options.startAngle, obj.that.options.endAngle, undefined, true) | ||||
|                     let polyPos = [] | ||||
|                     for (let m = 0; m < positions.length; m++) { | ||||
|                       polyPos.push([positions[m].lng, positions[m].lat]) | ||||
|                     } | ||||
|                     let poly = turf.polygon([polyPos]); | ||||
|                     let contain = turf.booleanPointInPolygon(pt, poly); | ||||
|                     if (contain) { | ||||
|                       obj.callback( | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       break | ||||
|                     } | ||||
|                   } | ||||
|  | ||||
|                 } | ||||
|               } | ||||
|             } | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|  | ||||
|  | ||||
|     // if (click) { | ||||
|     //   click = false | ||||
|     //   setTimeout(() => { | ||||
|     //     click = true | ||||
|     //   }, 300); | ||||
|     //   if (!YJ.Measure.GetMeasureStatus()) { | ||||
|  | ||||
|     //   } | ||||
|     // } | ||||
|   }, Cesium.ScreenSpaceEventType.LEFT_CLICK) | ||||
|  | ||||
|   // leftClickHandler.setInputAction(function (movement) { | ||||
|   //   const feature = sdk.viewer.scene.pick(movement.endPosition); | ||||
|   //   // unselectFeature(selectedFeature); | ||||
|   //   if (selectedFeature) { | ||||
|   //     selectedFeature.color = Cesium.Color.WHITE; | ||||
|   //   } | ||||
|   //   selectedFeature = feature | ||||
|   //   if (feature) { | ||||
|   //     feature.color = Cesium.Color.YELLOW; | ||||
|   //   } | ||||
|   // }, Cesium.ScreenSpaceEventType.MOUSE_MOVE); | ||||
|   // } | ||||
|  | ||||
| } | ||||
|  | ||||
| function closeLeftClick(sdk) { | ||||
|   leftClickHandler.destroy() //关闭事件句柄 | ||||
|   leftClickHandler = null | ||||
|   // } | ||||
| } | ||||
|  | ||||
| function openRightClick(sdk) { | ||||
|   if (!sdk || !sdk.viewer) { | ||||
|     return | ||||
|   } | ||||
|   rightClickHandler = new Cesium.ScreenSpaceEventHandler(sdk.viewer.canvas) | ||||
|   rightClickHandler.setInputAction((movement) => { | ||||
|     if (!YJ.Measure.GetMeasureStatus()) { | ||||
|       const pick = sdk.viewer.scene.pick(movement.position) | ||||
|       if (pick && pick.id) { | ||||
|         let id | ||||
|         if (pick.id.type && pick.id.type === 'vector' && pick.id.parentId) { | ||||
|           let obj = rightClickCallbackMap.get(pick.id.parentId) | ||||
|           if (obj.that.picking && obj.that.geojson) { | ||||
|             for (let i = 0; i < obj.that.geojson.features.length; i++) { | ||||
|               if (obj.that.geojson.features[i].id === pick.id._id) { | ||||
|                 obj.callback( | ||||
|                   movement, | ||||
|                   obj.that.geojson.features[i].id, | ||||
|                   cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|               } | ||||
|             } | ||||
|           } | ||||
|         } | ||||
|         else { | ||||
|           if (typeof pick.id === 'string') { | ||||
|             id = pick.id | ||||
|           } | ||||
|           else { | ||||
|             id = pick.id.id | ||||
|           } | ||||
|           if (rightClickCallbackMap.has(id)) { | ||||
|             let obj = rightClickCallbackMap.get(id) | ||||
|             if (obj.that.picking) { | ||||
|               let cartesian = getcartesian(sdk, movement) | ||||
|               if (!cartesian) { | ||||
|                 return | ||||
|               } | ||||
|               obj.callback( | ||||
|                 movement, | ||||
|                 id, | ||||
|                 cartesian3Towgs84(cartesian, sdk.viewer), obj.that) | ||||
|             } | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|       if (pick && pick.content) { | ||||
|         if (rightClickCallbackMap.has(pick.content.tileset.id)) { | ||||
|           let obj = rightClickCallbackMap.get(pick.content.tileset.id) | ||||
|           if (obj.that.picking) { | ||||
|             if (obj.that.type === 'bim') { | ||||
|               if (YJ.Global.getBimPickStatus(sdk)) { | ||||
|                 let cartesian = getcartesian(sdk, movement) | ||||
|                 if (!cartesian) { | ||||
|                   return | ||||
|                 } | ||||
|                 obj.callback( | ||||
|                   movement, | ||||
|                   pick.getProperty('id'), | ||||
|                   cartesian3Towgs84(cartesian, sdk.viewer), obj.that) | ||||
|               } | ||||
|             } | ||||
|             else { | ||||
|               let cartesian = getcartesian(sdk, movement) | ||||
|               if (!cartesian) { | ||||
|                 return | ||||
|               } | ||||
|               obj.callback( | ||||
|                 movement, | ||||
|                 pick.content.tileset.id, | ||||
|                 cartesian3Towgs84(cartesian, sdk.viewer), obj.that) | ||||
|             } | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|   }, Cesium.ScreenSpaceEventType.RIGHT_CLICK) | ||||
| } | ||||
|  | ||||
| function closeRightClick() { | ||||
|   if (rightClickHandler) { | ||||
|     rightClickHandler.destroy() //关闭事件句柄 | ||||
|     rightClickHandler = null | ||||
|   } | ||||
| } | ||||
|  | ||||
| function openMove(sdk) { | ||||
|   MoveHandler = new Cesium.ScreenSpaceEventHandler(sdk.viewer.canvas) | ||||
|   MoveHandler.setInputAction(function (movement) { | ||||
|     const pick = sdk.viewer.scene.pick(movement.endPosition); | ||||
|     // unselectFeature(selectedFeature); | ||||
|     // if (selectedFeature) { | ||||
|     //   let color = '#fff' | ||||
|     //   let state = selectedFeature.getProperty('state') | ||||
|     //   switch (state) { | ||||
|     //     case '0': | ||||
|     //       color = '#fff' | ||||
|     //       break; | ||||
|     //     case '1': | ||||
|     //       color = '#f00' | ||||
|     //       break; | ||||
|     //     case '2': | ||||
|     //       color = '#0f0' | ||||
|     //       break; | ||||
|     //     case '3': | ||||
|     //       color = '#00f' | ||||
|     //       break; | ||||
|     //     default: | ||||
|     //   } | ||||
|     //   selectedFeature.color = Cesium.Color.fromCssColorString(color).withAlpha(selectedFeature.tileset.transparency) | ||||
|     // } | ||||
|     // if (pick && pick.id) { } | ||||
|     // if (pick && pick.content) { | ||||
|     //   if (MoveCallbackMap.has(pick.content.tileset.id)) { | ||||
|     //     let obj = MoveCallbackMap.get(pick.content.tileset.id) | ||||
|     //     if (obj.that.picking) { | ||||
|     //       if (obj.that.type === 'bim') { | ||||
|     //         if (YJ.Global.getBimPickStatus(sdk)) { | ||||
|     //           selectedFeature = pick | ||||
|     //           pick.color = Cesium.Color.YELLOW; | ||||
|     //         } | ||||
|     //         else { | ||||
|     //           selectedFeature = null | ||||
|     //         } | ||||
|     //       } | ||||
|     //       else { | ||||
|     //         selectedFeature = pick | ||||
|     //         pick.color = Cesium.Color.YELLOW; | ||||
|     //       } | ||||
|     //     } | ||||
|     //     else { | ||||
|     //       selectedFeature = null | ||||
|     //     } | ||||
|     //   } | ||||
|     // } | ||||
|   }, Cesium.ScreenSpaceEventType.MOUSE_MOVE); | ||||
| } | ||||
|  | ||||
| function closeMove() { | ||||
|   if (MoveHandler) { | ||||
|     MoveHandler.destroy() //关闭事件句柄 | ||||
|     MoveHandler = null | ||||
|   } | ||||
| } | ||||
|  | ||||
| /*注册左键回调*/ | ||||
| function regLeftClickCallback(id, callback, that) { | ||||
|  | ||||
|   leftClickCallbackMap.set(id, { callback, that }) | ||||
| }/*取消左键回调*/ | ||||
| function unRegLeftClickCallback(id,) { | ||||
|   leftClickCallbackMap.delete(id,) | ||||
| } | ||||
|  | ||||
| /*注册右键回调*/ | ||||
| function regRightClickCallback(id, callback, that) { | ||||
|   rightClickCallbackMap.set(id, { callback, that }) | ||||
| }/*取消右键回调*/ | ||||
| function unRegRightClickCallback(id,) { | ||||
|   rightClickCallbackMap.delete(id,) | ||||
| } | ||||
|  | ||||
| /*注册左键回调*/ | ||||
| function regMoveCallback(id, callback, that) { | ||||
|   MoveCallbackMap.set(id, { callback, that }) | ||||
| }/*取消左键回调*/ | ||||
| function unregMoveCallback(id,) { | ||||
|   MoveCallbackMap.delete(id,) | ||||
| } | ||||
|  | ||||
| function getLeftClickState() { | ||||
|   if (leftClickHandler) { | ||||
|     return true | ||||
|   } | ||||
|   else { | ||||
|     false | ||||
|   } | ||||
| } | ||||
|  | ||||
| function getRightClickState() { | ||||
|   if (rightClickHandler) { | ||||
|     return true | ||||
|   } | ||||
|   else { | ||||
|     false | ||||
|   } | ||||
| } | ||||
|  | ||||
| function getMoveState() { | ||||
|   if (MoveHandler) { | ||||
|     return true | ||||
|   } | ||||
|   else { | ||||
|     false | ||||
|   } | ||||
| } | ||||
|  | ||||
|  | ||||
| export { openLeftClick, closeLeftClick, regLeftClickCallback, unRegLeftClickCallback, openRightClick, closeRightClick, regRightClickCallback, unRegRightClickCallback, openMove, closeMove, regMoveCallback, unregMoveCallback, getLeftClickState, getRightClickState, getMoveState } | ||||
| @ -7,6 +7,9 @@ import { CesiumContainer } from '../global' | ||||
| import { off as offSplitScreen } from "../SplitScreen"; | ||||
| import { FlwStatusSwitch, JwwStatusSwitch, getFlwStatus, getJwwStatus } from "../global" | ||||
| import { SheetIndexStatusSwitch, getStatus } from '../SheetIndex' | ||||
| import { getLeftClickState, getRightClickState, getMoveState } from "../../Global/ClickCallback" | ||||
| import { openLeftClick, openRightClick, openMove } from "./ClickCallback" | ||||
|  | ||||
|  | ||||
| let sdk2D | ||||
| let sdk3D | ||||
| @ -32,6 +35,16 @@ async function init(sdk) { | ||||
|   }) | ||||
|   sdk2.viewer.scene.mode = Cesium.SceneMode.SCENE2D | ||||
|   sdk2D = await sdk2 | ||||
|   if(getLeftClickState()) { | ||||
|     openLeftClick(sdk2D) | ||||
|   } | ||||
|   if(getRightClickState()) { | ||||
|     openRightClick(sdk2D) | ||||
|   } | ||||
|   if(getMoveState()) { | ||||
|     openMove(sdk2D) | ||||
|   } | ||||
|  | ||||
|   // window.sdk2D = sdk2D | ||||
|   solveBug() | ||||
|   syncObject = { sdks: [sdk, sdk2], tools } | ||||
| @ -49,7 +62,16 @@ async function init(sdk) { | ||||
|   sdk2D.viewer.imageryLayers.removeAll() | ||||
|   for (let i = 0; i < imageryLayers.length; i++) { | ||||
|     let entity = sdk2D.viewer.imageryLayers.addImageryProvider(imageryLayers[i].imageryProvider, imageryLayers[i]._layerIndex) | ||||
|     if(imageryLayers[i]._id) { | ||||
|       entity._id = imageryLayers[i]._id | ||||
|     } | ||||
|     entity.show = imageryLayers[i].show | ||||
|     entity.alpha = imageryLayers[i].alpha | ||||
|     if (imageryLayers[i]._objectState) { | ||||
|       if (imageryLayers[i]._showView == 3) { | ||||
|         entity.show = false | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|   // sdk.viewer.entities.collectionChanged.addEventListener(syncEntities) | ||||
|   // sdk.viewer.dataSources.dataSourceAdded.addEventListener(syncDataSources) | ||||
| @ -61,6 +83,12 @@ async function init(sdk) { | ||||
|     JwwStatusSwitch(sdk2, true) | ||||
|   } | ||||
|  | ||||
|   sdk.entityMap.forEach((item, key) => { | ||||
|     if (item.showView == 2) { | ||||
|       item.showView = 2 | ||||
|     } | ||||
|   }) | ||||
|  | ||||
| } | ||||
| async function on(sdk) { | ||||
|   if (sdk2D) { | ||||
| @ -94,6 +122,11 @@ function off(sdk) { | ||||
|     activeViewer = null | ||||
|     syncObject = {} | ||||
|   } | ||||
|   sdk.entityMap.forEach((item, key) => { | ||||
|     if (item.showView) { | ||||
|       item.show = item.show | ||||
|     } | ||||
|   }) | ||||
| } | ||||
|  | ||||
| async function syncData2(sdk, id, entityId) { | ||||
| @ -119,8 +152,17 @@ async function syncData2(sdk, id, entityId) { | ||||
|         options.heightMode = 0 | ||||
|         options.height = 0 | ||||
|       } | ||||
|       if (!that.type || (that.type !== 'tileset' && that.type !== 'bim' && that.type !== 'glb' && that.type !== 'layer')) { | ||||
|         let newObject = await new that.constructor(sdk2D, options) | ||||
|  | ||||
|       if (!that.type || (that.type !== 'tileset' && that.type !== 'bim' && that.type !== 'glb' && that.type !== 'layer' && that.type !== 'wallStereoscopic')) { | ||||
|         if (that.showView == 3) { | ||||
|           options.show = false | ||||
|         } | ||||
|         let callback | ||||
|         if(that.type === 'TextBox') { | ||||
|           callback = that.callback | ||||
|         } | ||||
|  | ||||
|         let newObject = await new that.constructor(sdk2D, options, callback) | ||||
|         newObject.onClick = that.onClick | ||||
|         newObject.onRightClick = that.onRightClick | ||||
|         newObject.onMouseMove = that.onMouseMove | ||||
| @ -207,8 +249,19 @@ async function syncData2(sdk, id, entityId) { | ||||
|         obj.options.heightReference = 1 | ||||
|       } | ||||
|       let options = syncObject.tools.deepCopyObj(obj.options) | ||||
|       if (!obj.type || (obj.type !== 'tileset' && obj.type !== 'bim' && obj.type !== 'glb' && obj.type !== 'layer')) { | ||||
|         let target = await new obj.constructor(sdk2D, options) | ||||
|       if (!obj.type || (obj.type !== 'tileset' && obj.type !== 'bim' && obj.type !== 'glb' && obj.type !== 'layer' && obj.type !== 'wallStereoscopic')) { | ||||
|         if (obj.showView == 3) { | ||||
|           options.show = false | ||||
|         } | ||||
|         let target = await sdk2D.entityMap.get(options.id) | ||||
|         if(target) { | ||||
|           await target.remove() | ||||
|         } | ||||
|         let callback | ||||
|         if(obj.type === 'TextBox') { | ||||
|           callback = obj.callback | ||||
|         } | ||||
|         target = await new obj.constructor(sdk2D, options, callback) | ||||
|         target.onClick = obj.onClick | ||||
|         target.onRightClick = obj.onRightClick | ||||
|         target.onMouseMove = obj.onMouseMove | ||||
| @ -401,11 +454,25 @@ function syncImageryLayerRemoved(layer, index) { | ||||
|   sdk2D.viewer.imageryLayers.remove(layer2d) | ||||
| } | ||||
| function syncImageryLayerShownOrHidden(layer, index, state) { | ||||
|   return | ||||
|   let layer2d = sdk2D.viewer.imageryLayers._layers[index] | ||||
|   let layer3d = sdk3D.viewer.imageryLayers._layers[index] | ||||
|   console.log('layer2d', layer2d, sdk2D, layer3d) | ||||
|  | ||||
|   if (!layer2d) { | ||||
|     return | ||||
|   } | ||||
|   layer2d.show = state | ||||
|   if (layer3d._objectState) { | ||||
|     if (!layer3d._showView || layer3d._showView == 2) { | ||||
|       layer2d.show = true | ||||
|     } | ||||
|     if (layer3d._showView == 3) { | ||||
|       layer2d.show = false | ||||
|     } | ||||
|   } | ||||
|   else { | ||||
|     layer2d.show = state | ||||
|   } | ||||
| } | ||||
|  | ||||
| async function syncPrimitives(primitive) { | ||||
| @ -535,6 +602,7 @@ function syncViewer() { | ||||
|  | ||||
| } | ||||
|  | ||||
|  | ||||
| function get2DView() { | ||||
|   return sdk2D | ||||
| } | ||||
|  | ||||
| @ -72,13 +72,267 @@ function openLeftClick(sdk, cb) { | ||||
|         click = true | ||||
|       }, 600); | ||||
|       if (!YJ.Measure.GetMeasureStatus() && cartesian) { | ||||
|         let flag = false | ||||
|         const pick = sdk.viewer.scene.pick(movement.position) | ||||
|         if (pick) { | ||||
|           if (pick.id) { | ||||
|             let entityId | ||||
|             // 矢量 | ||||
|             if (pick.id.type && pick.id.type === 'vector' && pick.id.parentId) { | ||||
|               let obj = leftClickCallbackMap.get(pick.id.parentId) | ||||
|               if (obj.that.picking && obj.that.geojson) { | ||||
|                 for (let i = 0; i < obj.that.geojson.features.length; i++) { | ||||
|                   if (obj.that.geojson.features[i].id === pick.id._id) { | ||||
|                     obj.callback( | ||||
|                       movement, | ||||
|                       obj.that.geojson.features[i].id, | ||||
|                       cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                     return | ||||
|                   } | ||||
|                 } | ||||
|               } | ||||
|             } | ||||
|             else if (typeof pick.id.id == 'string') { | ||||
|               let array = pick.id.id.split('-') | ||||
|               array.splice(array.length - 1, 1) | ||||
|               entityId = array.join('-') | ||||
|             } | ||||
|  | ||||
|             if (pick.id.properties && pick.id.properties.id && leftClickCallbackMap.has(pick.id.properties.id._value)) { | ||||
|               let obj = leftClickCallbackMap.get(pick.id.properties.id._value) | ||||
|               if (obj.that.picking) { | ||||
|                 obj.callback( | ||||
|                   movement, | ||||
|                   pick.id.properties.id._value, | ||||
|                   cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                 return | ||||
|               } | ||||
|             } | ||||
|             else if (leftClickCallbackMap.has(pick.id.id)) { | ||||
|               let obj = leftClickCallbackMap.get(pick.id.id) | ||||
|               if (obj.that.type === 'PolygonObject') { | ||||
|                 // 是否可点击y | ||||
|                 if (obj.that.picking) { | ||||
|                   if (obj.that.options.positions && obj.that.options.positions.length >= 3) { | ||||
|                     let pt = turf.point([pos84.lng, pos84.lat]); | ||||
|                     let polyPos = [] | ||||
|                     for (let i = 0; i < obj.that.options.positions.length; i++) { | ||||
|                       polyPos.push([ | ||||
|                         obj.that.options.positions[i].lng, | ||||
|                         obj.that.options.positions[i].lat | ||||
|                       ]) | ||||
|                     } | ||||
|                     polyPos.push([ | ||||
|                       obj.that.options.positions[0].lng, | ||||
|                       obj.that.options.positions[0].lat | ||||
|                     ]) | ||||
|                     let poly = turf.polygon([polyPos]); | ||||
|                     let contain = turf.booleanPointInPolygon(pt, poly); | ||||
|                     if (contain) { | ||||
|                       obj.callback( | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       return | ||||
|                     } | ||||
|                   } | ||||
|                 } | ||||
|               } | ||||
|               // 聚集地 | ||||
|               else if (obj.that.type === 'AssembleObject') { | ||||
|                 if (obj.that.picking) { | ||||
|                   if (obj.that.options.positions && obj.that.options.positions.length >= 3) { | ||||
|                     let positions = obj.that.computeAssemble(obj.that.options.positions, true) | ||||
|                     let pt = turf.point([pos84.lng, pos84.lat]); | ||||
|                     let polyPos = [] | ||||
|                     for (let i = 0; i < positions.length; i += 2) { | ||||
|                       polyPos.push([ | ||||
|                         positions[i], | ||||
|                         positions[i + 1] | ||||
|                       ]) | ||||
|                     } | ||||
|                     let poly = turf.polygon([polyPos]); | ||||
|                     let contain = turf.booleanPointInPolygon(pt, poly); | ||||
|                     if (contain) { | ||||
|                       obj.callback( | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       return | ||||
|                     } | ||||
|                   } | ||||
|                 } | ||||
|               } | ||||
|               // 单箭头 | ||||
|               else if (obj.that.type === 'AttackArrowObject') { | ||||
|                 if (obj.that.picking) { | ||||
|                   if (obj.that.options.positions && obj.that.options.positions.length >= 3) { | ||||
|                     let pt = turf.point([pos84.lng, pos84.lat]); | ||||
|                     let positions = obj.that.computeAttackArrow(obj.that.options.positions) | ||||
|                     let polyPos = [] | ||||
|                     for (let m = 0; m < positions.length; m++) { | ||||
|                       let pos84 = cartesian3Towgs84(positions[m], sdk.viewer) | ||||
|                       polyPos.push([pos84.lng, pos84.lat]) | ||||
|                     } | ||||
|                     let poly = turf.polygon([polyPos]); | ||||
|                     let contain = turf.booleanPointInPolygon(pt, poly); | ||||
|                     if (contain) { | ||||
|                       obj.callback( | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       return | ||||
|                     } | ||||
|                   } | ||||
|                 } | ||||
|               } | ||||
|               // 双箭头 | ||||
|               else if (obj.that.type === 'PincerArrowObject') { | ||||
|                 if (obj.that.picking) { | ||||
|                   if (obj.that.options.positions && obj.that.options.positions.length >= 5) { | ||||
|                     let pt = turf.point([pos84.lng, pos84.lat]); | ||||
|                     let positions = obj.that.computePincerArrow(obj.that.options.positions) | ||||
|                     let polyPos = [] | ||||
|                     for (let m = 0; m < positions.length; m++) { | ||||
|                       let pos84 = cartesian3Towgs84(positions[m], sdk.viewer) | ||||
|                       polyPos.push([pos84.lng, pos84.lat]) | ||||
|                     } | ||||
|                     let pos84_0 = cartesian3Towgs84(positions[0], sdk.viewer) | ||||
|                     polyPos.push([pos84_0.lng, pos84_0.lat]) | ||||
|                     let poly = turf.polygon([polyPos]); | ||||
|                     let contain = turf.booleanPointInPolygon(pt, poly); | ||||
|                     if (contain) { | ||||
|                       obj.callback( | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       return | ||||
|                     } | ||||
|                   } | ||||
|                 } | ||||
|               } | ||||
|               // 圆 | ||||
|               else if (obj.that.type === 'CircleObject') { | ||||
|                 if (obj.that.picking) { | ||||
|                   let pt = turf.point([pos84.lng, pos84.lat]); | ||||
|                   if (obj.that.options.center && obj.that.options.radius) { | ||||
|                     let center = [obj.that.options.center.lng, obj.that.options.center.lat]; | ||||
|                     let radius = obj.that.options.radius / 1000; | ||||
|                     let options = { steps: 360, units: 'kilometers' }; | ||||
|                     let circle = turf.circle(center, radius, options); | ||||
|                     let contain = turf.booleanPointInPolygon(pt, circle); | ||||
|                     if (contain) { | ||||
|                       obj.callback( | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       return | ||||
|                     } | ||||
|                   } | ||||
|  | ||||
|                 } | ||||
|               } | ||||
|               // 扇形 | ||||
|               else if (obj.that.type === 'SectorObject') { | ||||
|                 if (obj.that.picking) { | ||||
|                   let pt = turf.point([pos84.lng, pos84.lat]); | ||||
|                   if (obj.that.options.center && obj.that.options.radius && obj.that.options.startAngle && obj.that.options.endAngle) { | ||||
|                     let positions = obj.that.calSector(obj.that.options.center, obj.that.options.radius, obj.that.options.startAngle, obj.that.options.endAngle, undefined, true) | ||||
|                     let polyPos = [] | ||||
|                     for (let m = 0; m < positions.length; m++) { | ||||
|                       polyPos.push([positions[m].lng, positions[m].lat]) | ||||
|                     } | ||||
|                     let poly = turf.polygon([polyPos]); | ||||
|                     let contain = turf.booleanPointInPolygon(pt, poly); | ||||
|                     if (contain) { | ||||
|                       obj.callback( | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       return | ||||
|                     } | ||||
|                   } | ||||
|  | ||||
|                 } | ||||
|               } | ||||
|               if (obj.that.picking) { | ||||
|                 obj.callback( | ||||
|                   movement, | ||||
|                   pick.id.id, | ||||
|                   cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                 return | ||||
|               } | ||||
|             } | ||||
|             else if (entityId && leftClickCallbackMap.has(entityId)) { | ||||
|               let obj = leftClickCallbackMap.get(entityId) | ||||
|               if (obj.that.picking) { | ||||
|                 obj.callback( | ||||
|                   movement, | ||||
|                   entityId, | ||||
|                   cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                 return | ||||
|               } | ||||
|             } | ||||
|             else if (pick.primitive) { | ||||
|               if (typeof pick.id == 'string' && leftClickCallbackMap.has(pick.id)) { | ||||
|                 let obj = leftClickCallbackMap.get(pick.id) | ||||
|                 obj.callback( | ||||
|                   movement, | ||||
|                   pick.id, | ||||
|                   cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                 return | ||||
|               } | ||||
|             } | ||||
|           } | ||||
|           else { | ||||
|             if (pick.primitive && pick.primitive.id) { | ||||
|               if (leftClickCallbackMap.has(pick.primitive.id)) { | ||||
|                 let obj = leftClickCallbackMap.get(pick.primitive.id) | ||||
|                 if (obj.that.picking) { | ||||
|                   if (obj.that.type === 'bim') { | ||||
|                     if (YJ.Global.getBimPickStatus(sdk)) { | ||||
|                       obj.callback( | ||||
|                         movement, | ||||
|                         pick.primitive, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                     } | ||||
|                   } | ||||
|                   else { | ||||
|                     obj.callback( | ||||
|                       movement, | ||||
|                       pick.primitive.id, | ||||
|                       cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                   } | ||||
|                 } | ||||
|               } | ||||
|             } | ||||
|           } | ||||
|           if (pick.content && (!pick.primitive || !pick.primitive.id)) { | ||||
|             if (leftClickCallbackMap.has(pick.content.tileset.id)) { | ||||
|               let obj = leftClickCallbackMap.get(pick.content.tileset.id) | ||||
|               if (obj.that.picking) { | ||||
|                 if (obj.that.type === 'bim') { | ||||
|                   if (YJ.Global.getBimPickStatus(sdk)) { | ||||
|                     obj.callback( | ||||
|                       movement, | ||||
|                       pick.content.tileset, | ||||
|                       cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                   } | ||||
|                 } | ||||
|                 else { | ||||
|                   obj.callback( | ||||
|                     movement, | ||||
|                     pick.content.tileset.id, | ||||
|                     cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                 } | ||||
|               } | ||||
|             } | ||||
|           } | ||||
|         } | ||||
|         for (let i = leftClickCallbackMap.size - 1; i >= 0; i--) { | ||||
|           let key = Array.from(leftClickCallbackMap.keys())[i] | ||||
|           let obj = leftClickCallbackMap.get(key) | ||||
|           if (obj) { | ||||
|  | ||||
|             if (obj.that) { | ||||
|             if (obj.that && obj.that.show && (obj.that.entity && obj.that.entity.show)) { | ||||
|               // 是否为多边形 | ||||
|               if (obj.that.type === 'PolygonObject') { | ||||
|                 // 是否可点击y | ||||
| @ -103,7 +357,6 @@ function openLeftClick(sdk, cb) { | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       flag = true | ||||
|                       break | ||||
|                     } | ||||
|                   } | ||||
| @ -129,7 +382,6 @@ function openLeftClick(sdk, cb) { | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       flag = true | ||||
|                       break | ||||
|                     } | ||||
|                   } | ||||
| @ -153,7 +405,6 @@ function openLeftClick(sdk, cb) { | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       flag = true | ||||
|                       break | ||||
|                     } | ||||
|                   } | ||||
| @ -179,7 +430,6 @@ function openLeftClick(sdk, cb) { | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       flag = true | ||||
|                       break | ||||
|                     } | ||||
|                   } | ||||
| @ -200,7 +450,6 @@ function openLeftClick(sdk, cb) { | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       flag = true | ||||
|                       break | ||||
|                     } | ||||
|                   } | ||||
| @ -224,7 +473,6 @@ function openLeftClick(sdk, cb) { | ||||
|                         movement, | ||||
|                         obj.that.options.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       flag = true | ||||
|                       break | ||||
|                     } | ||||
|                   } | ||||
| @ -234,114 +482,6 @@ function openLeftClick(sdk, cb) { | ||||
|             } | ||||
|           } | ||||
|         } | ||||
|         if (!flag) { | ||||
|           const pick = sdk.viewer.scene.pick(movement.position) | ||||
|           if (pick) { | ||||
|             if (pick.id) { | ||||
|               let entityId | ||||
|               // 矢量 | ||||
|               if (pick.id.type && pick.id.type === 'vector' && pick.id.parentId) { | ||||
|                 let obj = leftClickCallbackMap.get(pick.id.parentId) | ||||
|                 if (obj.that.picking && obj.that.geojson) { | ||||
|                   for (let i = 0; i < obj.that.geojson.features.length; i++) { | ||||
|                     if (obj.that.geojson.features[i].id === pick.id._id) { | ||||
|                       obj.callback( | ||||
|                         movement, | ||||
|                         obj.that.geojson.features[i].id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                     } | ||||
|                   } | ||||
|                 } | ||||
|               } | ||||
|               else if (typeof pick.id.id == 'string') { | ||||
|                 let array = pick.id.id.split('-') | ||||
|                 array.splice(array.length - 1, 1) | ||||
|                 entityId = array.join('-') | ||||
|               } | ||||
|  | ||||
|               if (pick.id.properties && pick.id.properties.id && leftClickCallbackMap.has(pick.id.properties.id._value)) { | ||||
|                 let obj = leftClickCallbackMap.get(pick.id.properties.id._value) | ||||
|                 if (obj.that.picking) { | ||||
|                   obj.callback( | ||||
|                     movement, | ||||
|                     pick.id.properties.id._value, | ||||
|                     cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                 } | ||||
|               } | ||||
|               else if (leftClickCallbackMap.has(pick.id.id)) { | ||||
|                 let obj = leftClickCallbackMap.get(pick.id.id) | ||||
|                 if (obj.that.picking) { | ||||
|                   obj.callback( | ||||
|                     movement, | ||||
|                     pick.id.id, | ||||
|                     cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                 } | ||||
|               } | ||||
|               else if (entityId && leftClickCallbackMap.has(entityId)) { | ||||
|                 let obj = leftClickCallbackMap.get(entityId) | ||||
|                 if (obj.that.picking) { | ||||
|                   obj.callback( | ||||
|                     movement, | ||||
|                     entityId, | ||||
|                     cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                 } | ||||
|               } | ||||
|               else if (pick.primitive) { | ||||
|                 if (typeof pick.id == 'string' && leftClickCallbackMap.has(pick.id)) { | ||||
|                   let obj = leftClickCallbackMap.get(pick.id) | ||||
|                   obj.callback( | ||||
|                     movement, | ||||
|                     pick.id, | ||||
|                     cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                 } | ||||
|               } | ||||
|             } | ||||
|             else { | ||||
|               if (pick.primitive && pick.primitive.id) { | ||||
|                 if (leftClickCallbackMap.has(pick.primitive.id)) { | ||||
|                   let obj = leftClickCallbackMap.get(pick.primitive.id) | ||||
|                   if (obj.that.picking) { | ||||
|                     if (obj.that.type === 'bim') { | ||||
|                       if (YJ.Global.getBimPickStatus(sdk)) { | ||||
|                         obj.callback( | ||||
|                           movement, | ||||
|                           pick.primitive, | ||||
|                           cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                       } | ||||
|                     } | ||||
|                     else { | ||||
|                       obj.callback( | ||||
|                         movement, | ||||
|                         pick.primitive.id, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                     } | ||||
|                   } | ||||
|                 } | ||||
|               } | ||||
|             } | ||||
|             if (pick.content && (!pick.primitive || !pick.primitive.id)) { | ||||
|               if (leftClickCallbackMap.has(pick.content.tileset.id)) { | ||||
|                 let obj = leftClickCallbackMap.get(pick.content.tileset.id) | ||||
|                 if (obj.that.picking) { | ||||
|                   if (obj.that.type === 'bim') { | ||||
|                     if (YJ.Global.getBimPickStatus(sdk)) { | ||||
|                       obj.callback( | ||||
|                         movement, | ||||
|                         pick.content.tileset, | ||||
|                         cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                     } | ||||
|                   } | ||||
|                   else { | ||||
|                     obj.callback( | ||||
|                       movement, | ||||
|                       pick.content.tileset.id, | ||||
|                       cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that) | ||||
|                   } | ||||
|                 } | ||||
|               } | ||||
|             } | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|  | ||||
|  | ||||
| @ -102,11 +102,20 @@ function off() { | ||||
|   let leftCanvas = leftBox.getElementsByTagName('canvas')[0] | ||||
|   leftBox.style.width = '100%' | ||||
|   leftCanvas.style.width = '100%' | ||||
|   let billboardAttributeBoxs = sdkP.viewer._element.getElementsByClassName('billboard-attribute-box') | ||||
|   for (let i = 0; i < billboardAttributeBoxs.length; i++) { | ||||
|     billboardAttributeBoxs[i].style.display = 'block' | ||||
|   } | ||||
|   sdkP = null | ||||
| } | ||||
|  | ||||
|  | ||||
| async function init(sdk) { | ||||
|   let billboardAttributeBoxs = sdk.viewer._element.getElementsByClassName('billboard-attribute-box') | ||||
|   for (let i = 0; i < billboardAttributeBoxs.length; i++) { | ||||
|     billboardAttributeBoxs[i].style.display = 'none' | ||||
|   } | ||||
|  | ||||
|   sdk.entityMap.forEach((item, key) => { | ||||
|     if (item.type && item.type == 'TrajectoryMotion' && item.viewFollow) { | ||||
|       item.viewFollow = false | ||||
| @ -137,10 +146,8 @@ async function init(sdk) { | ||||
|   rightElm.style.position = 'absolute' | ||||
|   rightElm.style.right = 'calc(50% - 50px)' | ||||
|  | ||||
|   if (!activeIds || activeIds.length == 0) { | ||||
|     leftElm.style.display = 'none' | ||||
|     rightElm.style.display = 'none' | ||||
|   } | ||||
|   leftElm.style.display = 'none' | ||||
|   rightElm.style.display = 'none' | ||||
|  | ||||
|   sdk.viewer._element.appendChild(leftElm) | ||||
|   sdk.viewer._element.appendChild(rightElm) | ||||
| @ -149,6 +156,12 @@ async function init(sdk) { | ||||
|   let right = 0 | ||||
|   if (activeIds) { | ||||
|     for (let i = 0; i < activeIds.length; i++) { | ||||
|       let thatP = sdk.entityMap.get(activeIds[i]) | ||||
|       if (!thatP || (thatP.type === 'terrain' || !thatP.show) || thatP.type === 'TextBox') { | ||||
|         continue | ||||
|       } | ||||
|       leftElm.style.display = 'unset' | ||||
|       rightElm.style.display = 'unset' | ||||
|       let status = statusMap.get(activeIds[i]) | ||||
|       if (status) { | ||||
|         if (status.P) { | ||||
| @ -517,7 +530,7 @@ async function setSplitDirection(v, id, isoff = false, entityId) { | ||||
|             thatD.textShow = thatP.textShow | ||||
|           } | ||||
|           if (thatP.label && thatP.labelShow) { | ||||
|             thatP.label.entity.show = true | ||||
|             thatP.labelShow = true | ||||
|           } | ||||
|           if (thatD.label) { | ||||
|             thatD.label.options.ground = false | ||||
| @ -911,7 +924,7 @@ async function setSplitDirection(v, id, isoff = false, entityId) { | ||||
|           } | ||||
|           if (thatP.type === 'GroundSvg' && thatP.text) { | ||||
|             thatP.text.show = thatP.textShow | ||||
|             target.textShow = false | ||||
|             target && (target.textShow = false) | ||||
|           } | ||||
|           if (thatP.label && thatP.labelShow) { | ||||
|             thatP.label.entity.show = true | ||||
| @ -1281,6 +1294,8 @@ function setActiveId(ids = []) { | ||||
|   } | ||||
|   else { | ||||
|     if (leftElm && rightElm) { | ||||
|       leftElm.style.display = 'none' | ||||
|       rightElm.style.display = 'none' | ||||
|       let left = 0 | ||||
|       let right = 0 | ||||
|       for (let i = 0; i < activeIds.length; i++) { | ||||
| @ -1298,10 +1313,8 @@ function setActiveId(ids = []) { | ||||
|  | ||||
|  | ||||
|         let thatP = sdkP.entityMap.get(activeIds[i]) | ||||
|         let thatD = sdkD.entityMap.get(activeIds[i]) | ||||
|         if (!thatP || (thatP.type === 'terrain' || !thatP.show)) { | ||||
|           leftElm.style.display = 'none' | ||||
|           rightElm.style.display = 'none' | ||||
|         // let thatD = sdkD.entityMap.get(activeIds[i]) | ||||
|         if (!thatP || (thatP.type === 'terrain' || !thatP.show) || thatP.type === 'TextBox') { | ||||
|           continue | ||||
|         } | ||||
|         leftElm.style.display = 'unset' | ||||
|  | ||||
| @ -1,45 +1,89 @@ | ||||
| class eventBinding { | ||||
| class EventBinding { | ||||
|   constructor() { | ||||
|     this.element = {} | ||||
|   } | ||||
|   static event = {} | ||||
|  | ||||
|   getEvent(name) { | ||||
|     return eventBinding.event[name] | ||||
|     return EventBinding.event[name] | ||||
|   } | ||||
|  | ||||
|   getEventAll() { | ||||
|     return eventBinding.event | ||||
|     return EventBinding.event | ||||
|   } | ||||
|  | ||||
|   setEvent(name, event) { | ||||
|     eventBinding.event[name] = event | ||||
|     EventBinding.event[name] = event | ||||
|   } | ||||
|  | ||||
|   on(that, elements) { | ||||
|     this.element = {} | ||||
|     for (let i = 0; i < elements.length; i++) { | ||||
|       let Event = [] | ||||
|       let isEvent = false | ||||
|       let removeName = [] | ||||
|       if (!elements[i] || !elements[i].attributes) { | ||||
|         continue; | ||||
|       } | ||||
|       let Event = { | ||||
|         'input': [], | ||||
|         'change': [], | ||||
|         'blur': [], | ||||
|         'click': [] | ||||
|       } | ||||
|       let isEvent = false | ||||
|       let removeName = [] | ||||
|       for (let m of elements[i].attributes) { | ||||
|         switch (m.name) { | ||||
|           case '@model': { | ||||
|             isEvent = true | ||||
|             if (elements[i].type == 'checkbox') { | ||||
|               Event.push((e) => { that[m.value] = e.target.checked }) | ||||
|               Event.change.push((e) => { that[m.value] = e.target.checked }) | ||||
|               elements[i].checked = that[m.value] | ||||
|             } | ||||
|             else { | ||||
|               Event.push((e) => { | ||||
|                 let value = e.target.value | ||||
|                 if (e.target.type == 'number') { | ||||
|                   value = Number(value) | ||||
|                 } | ||||
|                 that[m.value] = value | ||||
|               }) | ||||
|               if (elements[i].type == 'number') { | ||||
|                 Event.input.push((e) => { | ||||
|                   if (e.target.value || e.target.value === 0) { | ||||
|                     let value = e.target.value | ||||
|                     value = Number(value) | ||||
|                     if (e.data != '.' && (e.data != '-' || e.target.value)) { | ||||
|                       if (((!e.target.max) && (!e.target.min)) || ((value <= Number(e.target.max)) && value >= Number(e.target.min))) { | ||||
|                         // that[m.value] = value | ||||
|                         value = value | ||||
|                       } | ||||
|                       if ((e.target.max) && value > Number(e.target.max)) { | ||||
|                         value = Number(e.target.max) | ||||
|                       } | ||||
|                       if ((e.target.min) && value < Number(e.target.min)) { | ||||
|                         value = Number(e.target.min) | ||||
|                       } | ||||
|                       // if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) { | ||||
|                       //   value = Number(e.target.dataset.min) | ||||
|                       // } | ||||
|                       that[m.value] = value | ||||
|                     } | ||||
|                   } | ||||
|                 }) | ||||
|                 Event.blur.push((e) => { | ||||
|                   let value = e.target.value | ||||
|                   if (e.target.value || (e.target.dataset.null !== 'undefined' && e.target.dataset.null !== '' && !Boolean(e.target.dataset.null))) { | ||||
|                     value = Number(value) | ||||
|                     if ((e.target.max) && value > Number(e.target.max)) { | ||||
|                       value = Number(e.target.max) | ||||
|                     } | ||||
|                     if ((e.target.min) && value < Number(e.target.min)) { | ||||
|                       value = Number(e.target.min) | ||||
|                     } | ||||
|                     if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) { | ||||
|                       value = Number(e.target.dataset.min) | ||||
|                     } | ||||
|                   } | ||||
|                   that[m.value] = value | ||||
|                 }) | ||||
|               } | ||||
|               else { | ||||
|                 Event.input.push((e) => { | ||||
|                   that[m.value] = e.target.value | ||||
|                 }) | ||||
|               } | ||||
|               if (elements[i].nodeName == 'IMG') { | ||||
|                 elements[i].src = that[m.value] | ||||
|               } | ||||
| @ -57,13 +101,13 @@ class eventBinding { | ||||
|             break; | ||||
|           } | ||||
|           case '@click': { | ||||
|             elements[i].addEventListener('click', (e) => { | ||||
|               if (typeof (that.Dialog[m.value]) === 'function') { | ||||
|                 that.Dialog[m.value](e) | ||||
|             isEvent = true | ||||
|             Event.click.push((e) => { | ||||
|               if (typeof (that[m.value]) === 'function') { | ||||
|                 that[m.value](e) | ||||
|               } | ||||
|             }); | ||||
|             }) | ||||
|             removeName.push(m.name) | ||||
|             // elements[i].attributes.removeNamedItem(m.name) | ||||
|             break; | ||||
|           } | ||||
|         } | ||||
| @ -74,19 +118,18 @@ class eventBinding { | ||||
|       } | ||||
|  | ||||
|       if (isEvent) { | ||||
|         let ventType = 'input' | ||||
|         if (elements[i].tagName != 'INPUT' || elements[i].type == 'checkbox') { | ||||
|           ventType = 'change' | ||||
|         } | ||||
|         elements[i].addEventListener(ventType, (e) => { | ||||
|           for (let t = 0; t < Event.length; t++) { | ||||
|             Event[t](e) | ||||
|         for (let key in Event) { | ||||
|           if (Event[key].length > 0) { | ||||
|             elements[i].addEventListener(key, (e) => { | ||||
|               for (let t = 0; t < Event[key].length; t++) { | ||||
|                 Event[key][t](e) | ||||
|               } | ||||
|             }); | ||||
|           } | ||||
|         }); | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
| const EventBinding = new eventBinding(); | ||||
| export default EventBinding; | ||||
|  | ||||
| @ -3,7 +3,7 @@ | ||||
|  */ | ||||
| import Dialog from '../../../Obj/Element/Dialog'; | ||||
| import { html } from "./_element"; | ||||
| import EventBinding from '../../../Obj/Element/Dialog/eventBinding'; | ||||
| import EventBinding from './eventBinding'; | ||||
| import { syncData } from '../../MultiViewportMode' | ||||
| import Tools from '../../../Tools' | ||||
| import TimeLine from './TimeLine' | ||||
| @ -52,6 +52,14 @@ export default class Sunshine { | ||||
|     that.viewer.clock.currentTime = Cesium.JulianDate.fromDate(now); | ||||
|     that.viewer.clock.multiplier = that.options.speed; | ||||
|     that.viewer.shadowMap.softShadows = that.options.softShadow; | ||||
|     that.viewer.shadowMap.cascadesEnabled = true | ||||
|     that.viewer.shadowMap.size = 2048; | ||||
|     that.viewer.shadowMap.numberOfCascades = 4;   // 增加级联层数(默认3层) | ||||
|     that.viewer.shadowMap.maximumDistance = 5000; // 扩大阴影渲染距离 | ||||
|     const lightCamera = that.viewer.shadowMap._lightCamera; | ||||
|     lightCamera.frustum.near = 0.1;    // 缩小近平面距离 | ||||
|     lightCamera.frustum.far = 10000;   // 扩大远平面距离 | ||||
|     that.viewer.shadowMap.normalOffset = true; // 避免深度冲突导致的阴影闪烁 | ||||
|  | ||||
|     that.edit(true) | ||||
|   } | ||||
| @ -72,6 +80,10 @@ export default class Sunshine { | ||||
|   } | ||||
|   set speed(v) { | ||||
|     this.options.speed = v | ||||
|     this._elms.speed && | ||||
|       this._elms.speed.forEach(item => { | ||||
|         item.value = v | ||||
|       }) | ||||
|     this.viewer.clock.multiplier = this.options.speed; | ||||
|     this.timeLine.setSpeed(v) | ||||
|   } | ||||
| @ -218,6 +230,12 @@ export default class Sunshine { | ||||
|     this.entity = null | ||||
|     this.timeLine.clear() | ||||
|  | ||||
|     this.viewer.shadowMap.cascadesEnabled = false | ||||
|     this.viewer.shadowMap.size = 1024; | ||||
|     this.viewer.shadowMap.numberOfCascades = 3;   // 增加级联层数(默认3层) | ||||
|     const lightCamera = this.viewer.shadowMap._lightCamera; | ||||
|     this.viewer.shadowMap.normalOffset = false; // 避免深度冲突导致的阴影闪烁 | ||||
|  | ||||
|     if (this._DialogObject && !this._DialogObject.isDestroy) { | ||||
|       this._DialogObject.close() | ||||
|       this._DialogObject = null | ||||
|  | ||||
| @ -9,7 +9,7 @@ export default class TimeLine { | ||||
|     this.timelineCon = document.getElementsByClassName('timeline-container')[0]; | ||||
|     this.speed = speed; | ||||
|     this.animationId; | ||||
|     this.startTime = Date.now(); | ||||
|     this.startTime = performance.now(); | ||||
|     this.manualPosition = null; | ||||
|     this.isDragging = false; | ||||
|     this.pauseed = false; | ||||
| @ -28,12 +28,12 @@ export default class TimeLine { | ||||
|         document.getElementsByClassName('time-marks')[0].appendChild(label) | ||||
|       } | ||||
|     } | ||||
|  | ||||
|  | ||||
|     that.startTime = Date.now() - ((that.manualPosition || 0) * 86400 * 1000 / that.speed); | ||||
|     that.startTime = performance.now() - ((that.manualPosition || 0) * 86400 * 1000 / that.speed); | ||||
|  | ||||
|     that.timeline.addEventListener('mousedown', (e) => { | ||||
|       that.isDragging = true; | ||||
|       if (e.srcElement.className === 'handle') { | ||||
|         that.isDragging = true; | ||||
|       } | ||||
|       e.preventDefault(); | ||||
|     }); | ||||
|  | ||||
| @ -55,21 +55,22 @@ export default class TimeLine { | ||||
|     document.getElementById('timePause').addEventListener('click', function () { | ||||
|       that.pauseed = !that.pauseed; | ||||
|       if (that.pauseed) {//暂停 | ||||
|         that.pausedTime = performance.now(); // 记录暂停时刻 | ||||
|         document.getElementById('timePause').textContent = '播放'; | ||||
|         that.animationId && cancelAnimationFrame(that.animationId); | ||||
|         that.pausedTime = Date.now(); // 记录暂停时刻 | ||||
|         that.sdk.viewer.clock.shouldAnimate = false | ||||
|       } else {//播放 | ||||
|         let now = performance.now() | ||||
|         const pausedDuration = now - that.pausedTime; | ||||
|         document.getElementById('timePause').textContent = '暂停'; | ||||
|         that.manualPosition = null | ||||
|         const pausedDuration = Date.now() - that.pausedTime; | ||||
|         that.startTime += pausedDuration; // 补偿暂停期间的时间差 | ||||
|  | ||||
|         if (that.changeDate) {//切换日期后让时间从0开始 | ||||
|           if (that.changeDateGrag) { | ||||
|             that.changeDateGrag = undefined | ||||
|           } else { | ||||
|             that.startTime = Date.now() | ||||
|             that.startTime = now | ||||
|           } | ||||
|           that.changeDate = undefined | ||||
|         } | ||||
| @ -80,21 +81,24 @@ export default class TimeLine { | ||||
|   } | ||||
|   moveComplay(func) { | ||||
|     let that = this | ||||
|     that.timeline.addEventListener('mouseup', () => { | ||||
|       that.isDragging = false; | ||||
|       if (that.manualPosition !== null) { | ||||
|         // that.sdk.viewer.clock.shouldAnimate = true | ||||
|         that.startTime = Date.now() - (that.manualPosition * 86400 * 1000 / that.speed); | ||||
|         that.manualPosition = null; | ||||
|         that.changeDate && (that.changeDateGrag = true) | ||||
|         if (!that.pauseed) { | ||||
|           that.update() | ||||
|           func(that.time) | ||||
|         } else { | ||||
|           that.pausedTime = Date.now(); // 记录暂停时刻 | ||||
|           func(that.currentTime.textContent) | ||||
|         } | ||||
|     // that.timeline.addEventListener('mouseup', () => { | ||||
|     document.addEventListener('mouseup', () => { | ||||
|       if (that.isDragging) { | ||||
|         that.isDragging = false; | ||||
|         if (that.manualPosition !== null) { | ||||
|           // that.sdk.viewer.clock.shouldAnimate = true | ||||
|           that.startTime = performance.now() - (that.manualPosition * 86400 * 1000 / that.speed); | ||||
|           that.manualPosition = null; | ||||
|           that.changeDate && (that.changeDateGrag = true) | ||||
|           if (!that.pauseed) { | ||||
|             that.update() | ||||
|             func(that.time) | ||||
|           } else { | ||||
|             that.pausedTime = performance.now(); // 记录暂停时刻 | ||||
|             func(that.currentTime.textContent) | ||||
|           } | ||||
|  | ||||
|         } | ||||
|       } | ||||
|     }); | ||||
|   } | ||||
| @ -108,9 +112,9 @@ export default class TimeLine { | ||||
|   update() { | ||||
|     if (this.manualPosition !== null) return; | ||||
|     if (this.changeDate) {//切换日期后让时间从0开始 | ||||
|       this.startTime = Date.now() | ||||
|       this.startTime = performance.now() | ||||
|     } | ||||
|     let elapsed = (Date.now() - this.startTime) * this.speed; | ||||
|     let elapsed = (performance.now() - this.startTime) * this.speed; | ||||
|     // if (this.elapsed) { | ||||
|     //   elapsed = elapsed + this.elapsed | ||||
|     //   this.elapsed = undefined | ||||
| @ -128,23 +132,23 @@ export default class TimeLine { | ||||
|     } | ||||
|   } | ||||
|   setSpeed(v) { | ||||
|     let now = performance.now() | ||||
|     if (!this.pauseed) { | ||||
|       const currentProgress = this.manualPosition ?? | ||||
|         (Date.now() - this.startTime) * this.speed / (86400 * 1000); | ||||
|         (performance.now() - this.startTime) * this.speed / (86400 * 1000); | ||||
|       this.speed = v; | ||||
|       this.startTime = Date.now() - (currentProgress * 86400 * 1000 / this.speed); | ||||
|       this.startTime = performance.now() - (currentProgress * 86400 * 1000 / this.speed); | ||||
|  | ||||
|     } else { | ||||
|       let pausedDuration = Date.now() - this.pausedTime; | ||||
|       let pausedDuration = now - this.pausedTime; | ||||
|       this.startTime += pausedDuration; // 补偿暂停期间的时间差 | ||||
|  | ||||
|       const currentProgress = this.manualPosition ?? | ||||
|         (Date.now() - this.startTime) * this.speed / (86400 * 1000); | ||||
|         (now - this.startTime) * this.speed / (86400 * 1000); | ||||
|       this.speed = v; | ||||
|       this.startTime = Date.now() - (currentProgress * 86400 * 1000 / this.speed); | ||||
|       this.startTime = now - (currentProgress * 86400 * 1000 / this.speed); | ||||
|  | ||||
|       this.pausedTime = Date.now(); // 记录切换speed暂停时刻 | ||||
|       this.speed = v; | ||||
|       this.pausedTime = now; // 记录切换speed暂停时刻 | ||||
|       // this.speed = v; | ||||
|     } | ||||
|     this.manualPosition = null; | ||||
|  | ||||
| @ -153,7 +157,7 @@ export default class TimeLine { | ||||
|   } | ||||
|   updateTime() { | ||||
|     this.manualPosition = null; | ||||
|     this.startTime = Date.now() - ((this.manualPosition || 0) * 86400 * 1000 / this.speed); | ||||
|     this.startTime = performance.now() - ((this.manualPosition || 0) * 86400 * 1000 / this.speed); | ||||
|     this.pauseed && (this.changeDate = true) | ||||
|     this.changeDateGrag = undefined | ||||
|     this.update(); | ||||
|  | ||||
| @ -29,7 +29,7 @@ function getCurrentView(sdk) { | ||||
|     // heading: viewer.camera.heading, | ||||
|     // pitch: viewer.camera.pitch, | ||||
|     // roll: viewer.camera.roll, | ||||
|     position: tools.cartesian3Towgs84(viewer.camera.position, viewer), | ||||
|     position: tools.cartesian3Towgs84(viewer.camera._positionWC, viewer), | ||||
|     orientation: { | ||||
|       heading: Cesium.Math.toDegrees(viewer.camera.heading), | ||||
|       pitch: Cesium.Math.toDegrees(viewer.camera.pitch), | ||||
|  | ||||
| @ -25,15 +25,15 @@ function MouseRightMenu(sdk, status, callBack) { | ||||
|   if (eventListener[sdk.div_id].click) { | ||||
|     document.removeEventListener('click', eventListener[sdk.div_id].click) | ||||
|   } | ||||
|   if(!eventListener[sdk.div_id].callBack) { | ||||
|   if (!eventListener[sdk.div_id].callBack) { | ||||
|     eventListener[sdk.div_id].callBack = callBack | ||||
|   } | ||||
|    | ||||
|   if(sdk !== sdkD) { | ||||
|  | ||||
|   if (sdk !== sdkD) { | ||||
|     eventListener[sdk.div_id].mouseRightMenuEvent && | ||||
|     eventListener[sdk.div_id].mouseRightMenuEvent.destroy() | ||||
|       eventListener[sdk.div_id].mouseRightMenuEvent.destroy() | ||||
|   } | ||||
|    | ||||
|  | ||||
|   let menuElm = document.getElementById('custom-menu') | ||||
|   if (menuElm) { | ||||
|     _element.removeChild(menuElm) | ||||
| @ -87,17 +87,17 @@ function MouseRightMenu(sdk, status, callBack) { | ||||
|         } | ||||
|         let entityId = getEntityId(movement) | ||||
|         let targetId | ||||
|         if(Object.prototype.toString.call(entityId) === '[object Object]') { | ||||
|         if (Object.prototype.toString.call(entityId) === '[object Object]') { | ||||
|           targetId = entityId.id | ||||
|           entityId = entityId.parentId | ||||
|         } | ||||
|         let addedMenu = '' | ||||
|         let that = sdk.entityMap.get(entityId) | ||||
|         let that = sdk.entityMap.get(entityId+'') | ||||
|         if (!that && entityId) { | ||||
|           let array = entityId.split('-') | ||||
|           let array = (entityId+'').split('-') | ||||
|           array.splice(array.length - 1, 1) | ||||
|           entityId = array.join('-') | ||||
|           that = sdk.entityMap.get(entityId) | ||||
|           that = sdk.entityMap.get(entityId+'') | ||||
|         } | ||||
|  | ||||
|         if (that && that.picking) { | ||||
| @ -121,9 +121,12 @@ function MouseRightMenu(sdk, status, callBack) { | ||||
|         <ul class="base" style="list-style: none;padding: 0;margin: 0;font-size: 12px;"> | ||||
|           <li style="padding: 3px 10px;cursor: pointer;">绕鼠标点旋转</li> | ||||
|         </ul> | ||||
|         <ul class="base" style="list-style: none;padding: 0;margin: 0;font-size: 12px;"> | ||||
|           <li style="padding: 3px 10px;cursor: pointer;">文本框</li> | ||||
|         </ul> | ||||
|         ${addedMenu} | ||||
|       ` | ||||
|       _element.appendChild(menuElm) | ||||
|         _element.appendChild(menuElm) | ||||
|         let left = movement.position.x | ||||
|         let top = movement.position.y | ||||
|         if ( | ||||
| @ -141,7 +144,7 @@ function MouseRightMenu(sdk, status, callBack) { | ||||
|         menuElm.style.left = left + 'px' | ||||
|         menuElm.style.top = top + 'px' | ||||
|  | ||||
|         menuElm.addEventListener('contextmenu', function(event) { | ||||
|         menuElm.addEventListener('contextmenu', function (event) { | ||||
|           event.preventDefault() | ||||
|         }) | ||||
|         let liElms = menuElm.getElementsByTagName('li') | ||||
| @ -162,7 +165,7 @@ function MouseRightMenu(sdk, status, callBack) { | ||||
|                 // this.rotateAround(position) | ||||
|                 break | ||||
|               case '属性': | ||||
|                 if(targetId) { | ||||
|                 if (targetId) { | ||||
|                   object.id = targetId | ||||
|                   object.parentId = that.options.id | ||||
|                 } | ||||
| @ -173,6 +176,10 @@ function MouseRightMenu(sdk, status, callBack) { | ||||
|                 // that.edit(true) | ||||
|                 // this.attribute(entityId) | ||||
|                 break | ||||
|               case '文本框': | ||||
|                 object.position = position | ||||
|                 key = 'textBox' | ||||
|                 break | ||||
|             } | ||||
|             eventListener[sdk.div_id].callBack(key, object) | ||||
|             _element.removeChild(menuElm) | ||||
|  | ||||
| @ -100,6 +100,7 @@ import MeasureAngle from '../Measure/MeasureAngle' | ||||
| import MeasureAzimuth from '../Measure/MeasureAzimuth' | ||||
| import DrawPolyline from '../Draw/drawPolyline' | ||||
| import DrawPolygon from '../Draw/drawPolygon' | ||||
| import DrawThreeRect from '../Draw/drawThreeRect' | ||||
| import DrawPoint from '../Draw/drawPoint' | ||||
| import DrawCircle from '../Draw/drawCircle' | ||||
| import DrawElliptic from '../Draw/drawElliptic' | ||||
| @ -185,6 +186,9 @@ import Frustum from '../Obj/AirLine/frustum' | ||||
| import DrawTakeOff from '../Obj/AirLine/DrawTakeOff' | ||||
| import FlowLine from '../Obj/Base/FlowLine' | ||||
| import Sunshine from '../Global/efflect/Sunshine' | ||||
| import Road2 from '../Obj/Base/RoadObject' | ||||
| import TextBox from '../Obj/Base/TextBox' | ||||
| import BatchModel from '../Obj/Base/BatchModel' | ||||
|  | ||||
| const YJEarthismeasuring = Symbol('测量状态') | ||||
| const screenRecord = Symbol('录屏对象') | ||||
| @ -256,7 +260,10 @@ if (!window.YJ) { | ||||
|       FRUSTUN: Frustum, | ||||
|       // GenerateRoute | ||||
|       Dialog, | ||||
|       FlowLine | ||||
|       FlowLine, | ||||
|       Road2, | ||||
|       TextBox, | ||||
|       BatchModel | ||||
|     }, | ||||
|     YJEarth, | ||||
|     Tools, | ||||
| @ -374,6 +381,7 @@ if (!window.YJ) { | ||||
|       DrawAssemble, | ||||
|       DrawSector, | ||||
|       DrawTakeOff, | ||||
|       DrawThreeRect | ||||
|     }, | ||||
|     // 分析 | ||||
|     Analysis: { | ||||
|  | ||||
| @ -91,7 +91,7 @@ class MeasureDistance extends Measure { | ||||
|  | ||||
|  | ||||
|     //暂时固定取20个点 | ||||
|     if (d > 20) {//大于20m时,固定取20个点 | ||||
|     if (d > 2) {//大于20m时,固定取20个点 | ||||
|       meters = d / 20 | ||||
|       await start(meters) | ||||
|     } else if (d < 1) { | ||||
| @ -106,8 +106,8 @@ class MeasureDistance extends Measure { | ||||
|  | ||||
|  | ||||
|   async sampleHeight(p1, index) { | ||||
|     let p2 = await this.sampleHeightMostDetailed([p1]) | ||||
|     p1.alt = p2[0].height | ||||
|     let height = await this.getClampToHeight(p1, [...this.sdk.viewer.entities.values]) | ||||
|     p1.alt = height | ||||
|     return {position: p1, index} | ||||
|   } | ||||
|  | ||||
|  | ||||
| @ -47,6 +47,11 @@ class ContourAnalysis { | ||||
|     YJ.Analysis.AnalysesResults.push(this) | ||||
|     this.createNewLine(); | ||||
|   } | ||||
|  | ||||
|   get type() { | ||||
|     return 'ContourAnalysis' | ||||
|   } | ||||
|  | ||||
|   createNewLine() { | ||||
|     ContourAnalysis.interpolatePoint(this); | ||||
|   } | ||||
|  | ||||
| @ -63,11 +63,15 @@ class VisibilityAnalysis extends Tools { | ||||
|         that.tip.set_text("左键创建视角终点,右键结束通视分析") | ||||
|         if (!that.resultObject.viewPoint) { | ||||
|           let pos84 = that.cartesian3Towgs84(cartesian, that.viewer) | ||||
|           let positions = await Cesium.sampleTerrainMostDetailed( | ||||
|             that.sdk.viewer.terrainProvider, | ||||
|             [Cesium.Cartographic.fromDegrees(pos84.lng, pos84.lat)] | ||||
|           ); | ||||
|           if (positions[0].height > pos84.alt) { | ||||
|           let positions | ||||
|           if(that.sdk.viewer.terrainProvider.availability) | ||||
|           { | ||||
|             positions = await Cesium.sampleTerrainMostDetailed( | ||||
|               that.sdk.viewer.terrainProvider, | ||||
|               [Cesium.Cartographic.fromDegrees(pos84.lng, pos84.lat)] | ||||
|             ); | ||||
|           } | ||||
|           if (positions && positions[0].height > pos84.alt) { | ||||
|             pos84.alt = positions[0].height | ||||
|           } | ||||
|           pos84.alt = pos84.alt + that.viewPointHeight | ||||
|  | ||||
| @ -292,7 +292,7 @@ class PolygonObject extends Base { | ||||
|   } | ||||
|   set labelShow(v) { | ||||
|     this.options.label.show = v | ||||
|     if (this.show) { | ||||
|     if (this.show && !this.showView || this.showView == 3) { | ||||
|       this.label.show = v | ||||
|     } | ||||
|     else { | ||||
|  | ||||
| @ -40,7 +40,7 @@ class AssembleObject extends Base { | ||||
|     this.options.positions = options.positions || [] | ||||
|     this.options.line = options.line || {} | ||||
|     this.options.line.width = ((this.options.line.width || this.options.line.width === 0) ? this.options.line.width : 3) | ||||
|     this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 0.5)' | ||||
|     this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 1)' | ||||
|     this.options['area-unit'] = options['area-unit'] || '平方米' | ||||
|     this.entity | ||||
|     this.event = new MouseEvent(this.sdk) | ||||
| @ -319,7 +319,7 @@ class AssembleObject extends Base { | ||||
|   } | ||||
|   set labelShow(v) { | ||||
|     this.options.label.show = v | ||||
|     if (this.show) { | ||||
|     if (this.show && !this.showView || this.showView == 3) { | ||||
|       this.label.show = v | ||||
|     } | ||||
|     else { | ||||
|  | ||||
| @ -40,7 +40,7 @@ class AttackArrowObject extends Base { | ||||
|     this.options.heightMode = (options.heightMode || options.heightMode == 0) ? options.heightMode : 2 | ||||
|     this.options.line = options.line || {} | ||||
|     this.options.line.width = ((this.options.line.width || this.options.line.width === 0) ? this.options.line.width : 3) | ||||
|     this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 0.5)' | ||||
|     this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 1)' | ||||
|     this.options['area-unit'] = options['area-unit'] || '平方米' | ||||
|     this.entity | ||||
|     this.event = new MouseEvent(this.sdk) | ||||
| @ -324,7 +324,7 @@ class AttackArrowObject extends Base { | ||||
|   } | ||||
|   set labelShow(v) { | ||||
|     this.options.label.show = v | ||||
|     if (this.show) { | ||||
|     if (this.show && !this.showView || this.showView == 3) { | ||||
|       this.label.show = v | ||||
|     } | ||||
|     else { | ||||
|  | ||||
| @ -9,7 +9,7 @@ | ||||
| import Dialog from '../../../Element/Dialog'; | ||||
| import CoordTransform from "../../../../transform/CoordTransform"; | ||||
| import BaseSource from "../index"; | ||||
| import { syncData } from '../../../../Global/MultiViewportMode' | ||||
| import { syncData, get2DView } from '../../../../Global/MultiViewportMode' | ||||
| import { setSplitDirection, syncSplitData } from '../../../../Global/SplitScreen' | ||||
| import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../../Global/global' | ||||
|  | ||||
| @ -244,8 +244,19 @@ class BaseLayer extends BaseSource { | ||||
|         this.originalOptions = this.deepCopyObj(this.options) | ||||
|         this._DialogObject.close() | ||||
|         this.Dialog.confirmCallBack && this.Dialog.confirmCallBack(this.originalOptions) | ||||
|         syncData(this.sdk, this.options.id) | ||||
|         // syncData(this.sdk, this.options.id) | ||||
|         syncSplitData(this.sdk, this.options.id) | ||||
|         let sdk2D = get2DView() | ||||
|         if (sdk2D && sdk2D != this.sdk) { | ||||
|           for(let i=0;i<sdk2D.viewer.imageryLayers._layers.length;i++) { | ||||
|             let layer = sdk2D.viewer.imageryLayers._layers[i] | ||||
|             if(layer._id && layer._id == this.options.id) { | ||||
|               layer.alpha = this.options.alpha | ||||
|               break | ||||
|             } | ||||
|           } | ||||
|  | ||||
|         } | ||||
|       }, | ||||
|       closeCallBack: () => { | ||||
|         this.reset() | ||||
|  | ||||
| @ -56,7 +56,7 @@ function html(that) { | ||||
|         </div> | ||||
|       </div> | ||||
|       <div class="col"> | ||||
|         <span class="label">固定大小</span> | ||||
|         <span class="label" style="flex: 0 0 60px;">固定大小</span> | ||||
|         <input class="btn-switch" type="checkbox" @model="scaleByDistance"> | ||||
|       </div> | ||||
|     </div> | ||||
|  | ||||
| @ -637,7 +637,7 @@ class Model extends BaseModel { | ||||
|  | ||||
|   set labelShow(v) { | ||||
|     this.options.label.show = v | ||||
|     if (this.show) { | ||||
|     if (this.show && !this.showView || this.showView == 3) { | ||||
|       this.label && (this.label.show = v) | ||||
|     } | ||||
|     else { | ||||
|  | ||||
| @ -8,7 +8,7 @@ | ||||
| import Dialog from '../../../Element/Dialog'; | ||||
| import { getHost } from "../../../../on"; | ||||
| import BaseSource from "../index"; | ||||
| import { setActiveViewer, closeRotateAround, closeViewFollow} from '../../../../Global/global' | ||||
| import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../../Global/global' | ||||
| import { setSplitDirection, syncSplitData } from '../../../../Global/SplitScreen' | ||||
|  | ||||
| class BaseTerrain extends BaseSource { | ||||
| @ -78,6 +78,11 @@ class BaseTerrain extends BaseSource { | ||||
|   close() { | ||||
|     this.sdk.viewer.scene.terrainProvider = | ||||
|       new Cesium.EllipsoidTerrainProvider({}) | ||||
|     for (let i = 0; i < YJ.Analysis.AnalysesResults.length; i++) { | ||||
|       if (YJ.Analysis.AnalysesResults[i].type === 'ContourAnalysis') { | ||||
|         YJ.Analysis.AnalysesResults[i].destroy() | ||||
|       } | ||||
|     } | ||||
|     syncSplitData(this.sdk, this.options.id) | ||||
|  | ||||
|     clearTimeout(this.#updateModelTimeout) | ||||
| @ -156,7 +161,7 @@ class BaseTerrain extends BaseSource { | ||||
|     } | ||||
|     setActiveViewer(0) | ||||
|     closeRotateAround(this.sdk) | ||||
|   closeViewFollow(this.sdk) | ||||
|     closeViewFollow(this.sdk) | ||||
|  | ||||
|     if (this.options.customView && this.options.customView.relativePosition && this.options.customView.orientation) { | ||||
|       let orientation = { | ||||
|  | ||||
							
								
								
									
										24
									
								
								src/Obj/Base/BatchModel/_element.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								src/Obj/Base/BatchModel/_element.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,24 @@ | ||||
| function html() { | ||||
|   return ` | ||||
|     <span class="custom-divider"></span> | ||||
|     <div class="div-item"> | ||||
|         <div class="row"> | ||||
|             <div class="col add-type-box"> | ||||
|                 <span class="label" style="flex: 0 0 56px;">添加方式</span> | ||||
|                 <div class="add-type"></div> | ||||
|             </div> | ||||
|             <div class="col"> | ||||
|                 <span class="label">间距</span> | ||||
|                 <div class="input-number input-number-unit-1"> | ||||
|                     <input class="input" type="number" title="" min="1" max="99999" @model="spacing"> | ||||
|                     <span class="unit">米</span> | ||||
|                     <span class="arrow"></span> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
|     <span class="custom-divider"></span> | ||||
|     ` | ||||
| } | ||||
|  | ||||
| export { html } | ||||
							
								
								
									
										229
									
								
								src/Obj/Base/BatchModel/_element_拓展.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										229
									
								
								src/Obj/Base/BatchModel/_element_拓展.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,229 @@ | ||||
| import { attributeElm } from '../../Element/elm_html' | ||||
|  | ||||
| function html(that) { | ||||
|   return ` | ||||
|     <span class="custom-divider"></span> | ||||
|     <div class="div-item"> | ||||
|         <div class="row"> | ||||
|             <div class="col"> | ||||
|                 <span class="label">颜色</span> | ||||
|                 <div class="color"></div> | ||||
|             </div> | ||||
|             <div class="col"> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
|     <span class="custom-divider"></span> | ||||
|     <div class="div-item"> | ||||
|         <div class="row"> | ||||
|             <div style="width: 46%;"> | ||||
|                 <div class="row add-type-box"> | ||||
|                     <div class="lable-left-line">添加方式 | ||||
|                         <div class="input input-select add-type" style="margin-left: 20px;"></div> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </div> | ||||
|             <div style="width: 50%;"> | ||||
|                 <div class="row" style="margin-bottom: 5px;"> | ||||
|                     <div class="col"> | ||||
|                         <span class="label">朝向偏移</span> | ||||
|                         <div class="input-number input-number-unit-1"> | ||||
|                             <input class="input" type="number" title="" min="0" max="360" @model="deviation"> | ||||
|                             <span class="unit">°</span> | ||||
|                             <span class="arrow"></span> | ||||
|                         </div> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|         <h4>模型间隔</h4> | ||||
|         <div class="row"> | ||||
|             <div class="col"> | ||||
|                 <div class="YJ-custom-checkbox-box" style="display: flex;align-items: center;cursor: pointer;"> | ||||
|                     <input type="checkbox" class="YJ-custom-checkbox"> | ||||
|                     <span style="margin-left: 10px; margin-bottom: 1px;user-select: none;">自定义距离</span> | ||||
|                 </div> | ||||
|             </div> | ||||
|             <div class="col"> | ||||
|                 <div class="YJ-custom-checkbox-box" style="display: flex;align-items: center;cursor: pointer;"> | ||||
|                     <input type="checkbox" class="YJ-custom-checkbox"> | ||||
|                     <span style="margin-left: 10px; margin-bottom: 1px;user-select: none;">固定距离</span> | ||||
|                 </div> | ||||
|             </div> | ||||
|             <div class="col"> | ||||
|                 <span class="label">模型间隔</span> | ||||
|                 <div class="input-number input-number-unit-1"> | ||||
|                     <input class="input" type="number" title="" min="0" max="360" @model="spacing"> | ||||
|                     <span class="unit">米</span> | ||||
|                     <span class="arrow"></span> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|         <h4>线型选择</h4> | ||||
|         <div class="row"> | ||||
|             <div class="col"> | ||||
|                 <div class="YJ-custom-checkbox-box" style="display: flex;align-items: center;cursor: pointer;"> | ||||
|                     <input type="checkbox" class="YJ-custom-checkbox"> | ||||
|                     <span style="margin-left: 10px; margin-bottom: 1px;user-select: none;">折线</span> | ||||
|                 </div> | ||||
|             </div> | ||||
|             <div class="col"> | ||||
|                 <div class="YJ-custom-checkbox-box" style="display: flex;align-items: center;cursor: pointer;"> | ||||
|                     <input type="checkbox" class="YJ-custom-checkbox"> | ||||
|                     <span style="margin-left: 10px; margin-bottom: 1px;user-select: none;">曲线</span> | ||||
|                 </div> | ||||
|             </div> | ||||
|             <div class="col"> | ||||
|                 <span class="label">线条数量</span> | ||||
|                 <div class="input-number input-number-unit-1"> | ||||
|                     <input class="input" type="number" title="" min="0" max="360" @model="lineNum"> | ||||
|                     <span class="unit">条</span> | ||||
|                     <span class="arrow"></span> | ||||
|                 </div> | ||||
|             </div> | ||||
|             <div class="col"> | ||||
|                 <span class="label">线条间隔</span> | ||||
|                 <div class="input-number input-number-unit-1"> | ||||
|                     <input class="input" type="number" title="" min="0" max="360" @model="lineSpacing"> | ||||
|                     <span class="unit">米</span> | ||||
|                     <span class="arrow"></span> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|         <div class="row"> | ||||
|             <div class="col"> | ||||
|                 <div class="YJ-custom-checkbox-box" style="display: flex;align-items: center;cursor: pointer;"> | ||||
|                     <input type="checkbox" class="YJ-custom-checkbox"> | ||||
|                     <span style="margin-left: 10px; margin-bottom: 1px;user-select: none;">随机采样</span> | ||||
|                 </div> | ||||
|             </div> | ||||
|             <div class="col"> | ||||
|                 <span class="label">随机数量</span> | ||||
|                 <div class="input-number input-number-unit-1"> | ||||
|                     <input class="input" type="number" title="" min="0" max="360" @model="lineNum"> | ||||
|                     <span class="unit">个</span> | ||||
|                     <span class="arrow"></span> | ||||
|                 </div> | ||||
|             </div> | ||||
|             <div class="col"></div> | ||||
|         </div> | ||||
|         <div class="row"> | ||||
|             <div class="col"> | ||||
|                 <div class="YJ-custom-checkbox-box" style="display: flex;align-items: center;cursor: pointer;"> | ||||
|                     <input type="checkbox" class="YJ-custom-checkbox"> | ||||
|                     <span style="margin-left: 10px; margin-bottom: 1px;user-select: none;">网格采样</span> | ||||
|                 </div> | ||||
|             </div> | ||||
|             <div class="col"> | ||||
|                 <span class="label">首边间隔</span> | ||||
|                 <div class="input-number input-number-unit-1"> | ||||
|                     <input class="input" type="number" title="" min="0" max="360" @model="fistLineSpacing"> | ||||
|                     <span class="unit">米</span> | ||||
|                     <span class="arrow"></span> | ||||
|                 </div> | ||||
|             </div> | ||||
|             <div class="col"> | ||||
|                 <span class="label">次边间隔</span> | ||||
|                 <div class="input-number input-number-unit-1"> | ||||
|                     <input class="input" type="number" title="" min="0" max="360" @model="secondLineSpacing"> | ||||
|                     <span class="unit">米</span> | ||||
|                     <span class="arrow"></span> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
|     <span class="custom-divider"></span> | ||||
|     <div class="row"> | ||||
|         <DIV-cy-tabs id="point-object-edit-tabs"> | ||||
|             <DIV-cy-tab-pane label="空间信息"> | ||||
|                 <div class="row"> | ||||
|                     <div class="col height-mode-box"> | ||||
|                         <span class="label" style="flex: 0 0 56px;">高度模式</span> | ||||
|                         <div class="height-mode"></div> | ||||
|                     </div> | ||||
|                 </div> | ||||
|                 <div class="row"> | ||||
|                     <div style="width: 46%;"> | ||||
|                         <div class="row add-type-box"> | ||||
|                             <div class="lable-left-line">缩放 | ||||
|                                 <div class="YJ-custom-checkbox-box" style="display: flex;align-items: center;cursor: pointer;"> | ||||
|                                     <input type="checkbox" class="YJ-custom-checkbox"> | ||||
|                                     <span style="margin-left: 10px; margin-bottom: 1px;user-select: none;">是否等比例缩放</span> | ||||
|                                 </div> | ||||
|                             </div> | ||||
|                         </div> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </DIV-cy-tab-pane> | ||||
|             <DIV-cy-tab-pane label="标注风格"> | ||||
|                 <div> | ||||
|                     <div class="row" style="margin-bottom: 10px;"> | ||||
|                       <div class="col"> | ||||
|                           <span class="label">新增模型风格设置</span> | ||||
|                           <button @click="openRichTextEditor">初始风格</button> | ||||
|                       </div> | ||||
|                       <div class="col"> | ||||
|                           <button @click="openRichTextEditor">当前风格</button> | ||||
|                       </div> | ||||
|                     </div> | ||||
|  | ||||
|                     <div class="row" style="margin-bottom: 10px;"> | ||||
|                         <div class="col" style="flex: 0 0 80px;"> | ||||
|                             <span class="label" style="flex: none;">显隐</span> | ||||
|                             <input class="btn-switch" type="checkbox" @model="billboardShow"> | ||||
|                         </div> | ||||
|                         <div class="col" style="flex: 0 0 90px;"> | ||||
|                             <span class="label" style="flex: none;">图标</span> | ||||
|                             <div class="image-box" @click="clickChangeImage"> | ||||
|                                 <img class="image" src="" alt="" @model="billboardImage"> | ||||
|                             </div> | ||||
|                         </div> | ||||
|                         <div class="col" style="flex: 0 0 90px;"> | ||||
|                             <span class="label" style="flex: none;">默认图标</span> | ||||
|                             <div class="image-box" @click="clickChangeDefaultImage"> | ||||
|                                 <img class="image" src="" alt="" @model="billboardDefaultImage"> | ||||
|                             </div> | ||||
|                         </div> | ||||
|                         <div class="col"> | ||||
|                             <span class="label">图标倍数</span> | ||||
|                             <div class="input-number input-number-unit-2"> | ||||
|                                 <input class="input" type="number" title="" min="0.1" max="99" @model="billboardScale"> | ||||
|                                 <span class="unit">倍</span> | ||||
|                                 <span class="arrow"></span> | ||||
|                             </div> | ||||
|                         </div> | ||||
|                     </div> | ||||
|                 </div> | ||||
|                 <div> | ||||
|                     <h4>文字设置</h4> | ||||
|                     <div class="row"> | ||||
|                         <div class="col" style="flex: 0 0 80px;"> | ||||
|                             <span class="label" style="flex: none;">显隐</span> | ||||
|                             <input class="btn-switch" type="checkbox" @model="labelShow"> | ||||
|                         </div> | ||||
|                         <div class="col font-select-box"> | ||||
|                             <span class="label" style="flex: none;">字体选择</span> | ||||
|                             <div class="input input-select font-select"></div> | ||||
|                         </div> | ||||
|                         <div class="col"> | ||||
|                             <span class="label">文字大小</span> | ||||
|                             <div class="input-number input-number-unit-2"> | ||||
|                                 <input class="input" type="number" title="" min="1" max="99" @model="labelFontSize" style="width: 70px;"> | ||||
|                                 <span class="unit">px</span> | ||||
|                                 <span class="arrow"></span> | ||||
|                             </div> | ||||
|                         </div> | ||||
|                         <div class="col"> | ||||
|                             <span class="label">文字颜色</span> | ||||
|                             <div class="labelColor"></div> | ||||
|                         </div> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </DIV-cy-tab-pane> | ||||
|         </DIV-cy-tabs> | ||||
|     </div> | ||||
|     <span class="custom-divider"></span> | ||||
|     ` | ||||
| } | ||||
|  | ||||
| export { html } | ||||
							
								
								
									
										92
									
								
								src/Obj/Base/BatchModel/eventBinding.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										92
									
								
								src/Obj/Base/BatchModel/eventBinding.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,92 @@ | ||||
| class eventBinding { | ||||
|   constructor() { | ||||
|     this.element = {} | ||||
|   } | ||||
|   static event = {} | ||||
|  | ||||
|   getEvent(name) { | ||||
|     return eventBinding.event[name] | ||||
|   } | ||||
|  | ||||
|   getEventAll() { | ||||
|     return eventBinding.event | ||||
|   } | ||||
|  | ||||
|   setEvent(name, event) { | ||||
|     eventBinding.event[name] = event | ||||
|   } | ||||
|  | ||||
|   on(that, elements) { | ||||
|     for (let i = 0; i < elements.length; i++) { | ||||
|       let Event = [] | ||||
|       let isEvent = false | ||||
|       let removeName = [] | ||||
|       if (!elements[i] || !elements[i].attributes) { | ||||
|         continue; | ||||
|       } | ||||
|       for (let m of elements[i].attributes) { | ||||
|         switch (m.name) { | ||||
|           case '@model': { | ||||
|             isEvent = true | ||||
|             if (elements[i].type == 'checkbox') { | ||||
|               Event.push((e) => { that[m.value] = e.target.checked }) | ||||
|               elements[i].checked = that[m.value] | ||||
|             } | ||||
|             else { | ||||
|               Event.push((e) => { | ||||
|                 let value = e.target.value | ||||
|                 if (e.target.type == 'number') { | ||||
|                   value = Number(value) | ||||
|                 } | ||||
|                 that[m.value] = value | ||||
|               }) | ||||
|               if (elements[i].nodeName == 'IMG') { | ||||
|                 elements[i].src = that[m.value] | ||||
|               } | ||||
|               else { | ||||
|                 elements[i].value = that[m.value] | ||||
|               } | ||||
|             } | ||||
|             if (this.element[m.value]) { | ||||
|               this.element[m.value].push(elements[i]) | ||||
|             } | ||||
|             else { | ||||
|               this.element[m.value] = [elements[i]] | ||||
|             } | ||||
|             removeName.push(m.name) | ||||
|             break; | ||||
|           } | ||||
|           case '@click': { | ||||
|             elements[i].addEventListener('click', (e) => { | ||||
|               if (typeof (that.Dialog[m.value]) === 'function') { | ||||
|                 that.Dialog[m.value](e) | ||||
|               } | ||||
|             }); | ||||
|             removeName.push(m.name) | ||||
|             // elements[i].attributes.removeNamedItem(m.name) | ||||
|             break; | ||||
|           } | ||||
|         } | ||||
|         // elements[i].attributes[m] = undefined | ||||
|       } | ||||
|       for (let n = 0; n < removeName.length; n++) { | ||||
|         elements[i].attributes.removeNamedItem(removeName[n]) | ||||
|       } | ||||
|  | ||||
|       if (isEvent) { | ||||
|         let ventType = 'input' | ||||
|         if (elements[i].tagName != 'INPUT' || elements[i].type == 'checkbox') { | ||||
|           ventType = 'change' | ||||
|         } | ||||
|         elements[i].addEventListener(ventType, (e) => { | ||||
|           for (let t = 0; t < Event.length; t++) { | ||||
|             Event[t](e) | ||||
|           } | ||||
|         }); | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
| const EventBinding = new eventBinding(); | ||||
| export default EventBinding; | ||||
							
								
								
									
										725
									
								
								src/Obj/Base/BatchModel/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										725
									
								
								src/Obj/Base/BatchModel/index.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,725 @@ | ||||
| /** | ||||
|  * @description 批量模型 | ||||
|  */ | ||||
| import Dialog from '../../Element/Dialog'; | ||||
| import { html } from "./_element"; | ||||
| import EventBinding from '../../Element/Dialog/eventBinding'; | ||||
| import Base from "../index"; | ||||
| import Tools from "../../../Tools"; | ||||
| import { syncData } from '../../../Global/MultiViewportMode' | ||||
| import Model from '../BaseSource/BaseModel/Model' | ||||
| import { legp } from '../../Element/datalist' | ||||
|  | ||||
| import DrawPolyline from '../../../Draw/drawPolyline' | ||||
| import DrawPolygon from '../../../Draw/drawPolygon' | ||||
| import DrawThreeRect from '../../../Draw/drawThreeRect' | ||||
| import DrawPoint from '../../../Draw/drawPoint' | ||||
| import { setActiveViewer, closeRotateAround, closeViewFollow, CesiumContainer } from '../../../Global/global' | ||||
|  | ||||
| import { setSplitDirection, syncSplitData, setActiveId } from '../../../Global/SplitScreen' | ||||
|  | ||||
| class BatchModel extends Base { | ||||
|   /** | ||||
|    * @constructor | ||||
|    * @param sdk | ||||
|    * @description 批量模型 | ||||
|    * @param options {object} 批量模型属性 | ||||
|    * @param options.name=未命名对象 {string} 名称 | ||||
|    * @param options.type=polygon {string} 线类型(line,polygon) | ||||
|    * @param options.url=polygon {string} 线类型(line,polygon,point) | ||||
|    * @param options.spacing= {number} 间距 | ||||
|    * @param options.show=true {boolean} | ||||
|    * @param Dialog {object} 弹框对象 | ||||
|    * @param Dialog.confirmCallBack {function} 弹框确认时的回调 | ||||
|    * */ | ||||
|   constructor(sdk, options = {}, callback = null, _Dialog = {}) { | ||||
|     super(sdk, options); | ||||
|     this.viewer = this.sdk.viewer | ||||
|     this.options.name = options.name || '批量模型' | ||||
|     this.options.type = options.type || '面' | ||||
|     this.options.url = options.url || '' | ||||
|     this.options.spacing = options.spacing * 1 || 50 | ||||
|     this.options.positions = options.positions || [] | ||||
|     this.options.show = (options.show || options.show === false) ? options.show : true | ||||
|     this.callback = callback | ||||
|     this.Dialog = _Dialog | ||||
|     this._EventBinding = new EventBinding() | ||||
|     this._elms = {}; | ||||
|     this.pointArr = [] | ||||
|     // this.sdk.addIncetance(this.options.id, this) | ||||
|     let tools = new Tools(sdk) | ||||
|     // BatchModel.computeDis(this) | ||||
|     // if (this.options.positions.length > 0 || this.options.positions.lng) { | ||||
|     if (this.options.spacing < 0 || options.spacing * 1 === 0) { | ||||
|       tools.message({ type: 'warning', text: '请输入正确的间距!' }) | ||||
|       return; | ||||
|     } | ||||
|     if ((options.type && options.spacing != undefined) || options.type == '点') { | ||||
|       // BatchModel.computeDis(this) | ||||
|  | ||||
|       let Draw | ||||
|       console.log('kkkkk') | ||||
|       switch (options.type) { | ||||
|         case '点': | ||||
|           Draw = new DrawPoint(this.sdk) | ||||
|           break; | ||||
|         case '线': | ||||
|           Draw = new DrawPolyline(this.sdk) | ||||
|           break; | ||||
|         case '面': | ||||
|           Draw = new DrawThreeRect(this.sdk) | ||||
|           break; | ||||
|         default: | ||||
|           break; | ||||
|       } | ||||
|       Draw && Draw.start((a, positions) => { | ||||
|         this.options.positions = positions; | ||||
|         console.log('uuuuuu') | ||||
|         //判断范围是否过大 | ||||
|         if (positions.length != 0 || positions.lng) { | ||||
|           if (options.type == '面') { | ||||
|             let posi = positions.map(v => { | ||||
|               return Cesium.Cartesian3.fromDegrees(v.lng, v.lat) | ||||
|             }) | ||||
|             let dis1 = Cesium.Cartesian3.distance(posi[0], posi[1]) | ||||
|             let dis2 = Cesium.Cartesian3.distance(posi[1], posi[2]) | ||||
|             let num1 = dis1 / this.options.spacing | ||||
|             let num2 = dis2 / this.options.spacing | ||||
|             if (num1 * num2 > 100) { | ||||
|               tools.message({ type: 'warning', text: '数量大于100,请重新绘制' }) | ||||
|               return; | ||||
|             } | ||||
|           } else if (options.type == '线') { | ||||
|             let posi = positions.map(v => { | ||||
|               return Cesium.Cartesian3.fromDegrees(v.lng, v.lat) | ||||
|             }) | ||||
|             let dis = 0 | ||||
|             for (let i = 0; i < posi.length - 2; i++) { | ||||
|               dis += Cesium.Cartesian3.distance(posi[i], posi[i + 1]) | ||||
|             } | ||||
|             if (dis / this.options.spacing > 100) { | ||||
|               tools.message({ type: 'warning', text: '数量大于100,请重新绘制' }) | ||||
|               return; | ||||
|             } | ||||
|           } | ||||
|           // this.callback(this.options); | ||||
|           (this.options.positions.length || this.options.positions.lng) && BatchModel.computeDis(this) | ||||
|         } | ||||
|       }) | ||||
|  | ||||
|     } else { | ||||
|       this.edit(true) | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   // 计算距离 | ||||
|   static async computeDis(that) { | ||||
|     let fromDegreesArray = [] | ||||
|     let arr | ||||
|     let posiArr = [] | ||||
|     let array = [] | ||||
|     if (that.options.type == '面') { | ||||
|       if (that.options.positions.length != 0) { | ||||
|         that.options.positions.forEach(item => { | ||||
|           fromDegreesArray.push(item.lng, item.lat) | ||||
|         }) | ||||
|         // arr = that.generateInterpolatedPoints(Cesium.Cartesian3.fromDegreesArray(fromDegreesArray), that.options.spacing) | ||||
|         arr = await that.computedArea(Cesium.Cartesian3.fromDegreesArray(fromDegreesArray), that.options.spacing) | ||||
|         array[0] = arr | ||||
|         array[1] = that.calculateRoadAngle(Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)[0], Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)[3]) | ||||
|         arr.forEach((item, index) => { | ||||
|           const cartographic = Cesium.Cartographic.fromCartesian( | ||||
|             item // Cartesian3对象 {x, y, z} | ||||
|           ); | ||||
|           const longitude = Cesium.Math.toDegrees(cartographic.longitude); | ||||
|           const latitude = Cesium.Math.toDegrees(cartographic.latitude); | ||||
|           const height = cartographic.height; | ||||
|           posiArr.push({ | ||||
|             lng: longitude, | ||||
|             lat: latitude, | ||||
|             alt: height | ||||
|           }) | ||||
|         }) | ||||
|       } | ||||
|     } else if (that.options.type == '线') { | ||||
|       if (that.options.positions.length != 0) { | ||||
|         that.options.positions.forEach(item => { | ||||
|           fromDegreesArray.push(item.lng, item.lat) | ||||
|         }) | ||||
|         array = await that.linePoint(Cesium.Cartesian3.fromDegreesArray(fromDegreesArray), that.options.spacing) | ||||
|         arr = array[0] | ||||
|         that.pointArr = arr | ||||
|         arr.forEach((item, index) => { | ||||
|           const cartographic = Cesium.Cartographic.fromCartesian( | ||||
|             item // Cartesian3对象 {x, y, z} | ||||
|           ); | ||||
|           const longitude = Cesium.Math.toDegrees(cartographic.longitude); | ||||
|           const latitude = Cesium.Math.toDegrees(cartographic.latitude); | ||||
|           const height = cartographic.height; | ||||
|           posiArr.push({ | ||||
|             lng: longitude, | ||||
|             lat: latitude, | ||||
|             alt: height | ||||
|           }) | ||||
|         }) | ||||
|       } | ||||
|  | ||||
|     } else if (that.options.type == '点') { | ||||
|       if (that.options.positions.lng) { | ||||
|         let height = await that.getClampToHeight({ lng: that.options.positions.lng, lat: that.options.positions.lat }) | ||||
|         posiArr = [{ lng: that.options.positions.lng, lat: that.options.positions.lat, alt: height }] | ||||
|         // posiArr = [that.options.positions] | ||||
|         that.pointArr = posiArr | ||||
|       } | ||||
|  | ||||
|     } | ||||
|     let params = { | ||||
|       type: that.options.type, | ||||
|       positions: posiArr, | ||||
|       rotate: that.options.type == '点' ? undefined : array[1] | ||||
|     } | ||||
|     that.callback(params) | ||||
|     // posiArr.forEach((item, index) => { | ||||
|     //   let model = new Model(that.sdk, { | ||||
|     //     id: 'model' + index, | ||||
|     //     show: that.options.show, | ||||
|     //     url: that.options.url, | ||||
|     //     position: item, | ||||
|     //     rotate: that.options.type == '点' ? undefined : { x: 0, y: 0, z: array[1] && (array[1][index] || array[1]) } | ||||
|     //   }) | ||||
|     //   that.pointArr.push(model) | ||||
|     // }) | ||||
|   } | ||||
|   async linePoint(polygonPositions, spacing) { | ||||
|     let boundaryPoints = []; | ||||
|     let boundaryAngle = []; | ||||
|     for (let i = 0; i < polygonPositions.length - 1; i++) { | ||||
|  | ||||
|       const start = polygonPositions[i]; | ||||
|       const end = polygonPositions[(i + 1) % polygonPositions.length]; | ||||
|       const segmentLength = Cesium.Cartesian3.distance(start, end); | ||||
|       const segments = Math.ceil(segmentLength / spacing); | ||||
|  | ||||
|       for (let j = 0; j <= segments; j++) { | ||||
|         const ratio = j / segments; | ||||
|         let point = Cesium.Cartesian3.lerp( | ||||
|           start, end, ratio, new Cesium.Cartesian3() | ||||
|         ); | ||||
|  | ||||
|         const cartographic = Cesium.Cartographic.fromCartesian( | ||||
|           point // Cartesian3对象 {x, y, z} | ||||
|         ); | ||||
|         const longitude = Cesium.Math.toDegrees(cartographic.longitude); | ||||
|         const latitude = Cesium.Math.toDegrees(cartographic.latitude); | ||||
|  | ||||
|  | ||||
|         let height = await this.getClampToHeight({ lng: longitude, lat: latitude }) | ||||
|         point = Cesium.Cartesian3.fromDegrees(longitude, latitude, height); | ||||
|  | ||||
|         boundaryPoints.push(point); | ||||
|         if (j != segments || i == polygonPositions.length - 2) { | ||||
|           boundaryAngle.push(this.calculateRoadAngle(start, end)) | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|     return [[...new Set(boundaryPoints | ||||
|       .map(p => `${p.x},${p.y},${p.z}`))] | ||||
|       .map(str => { | ||||
|         const [x, y, z] = str.split(',').map(Number); | ||||
|         return new Cesium.Cartesian3(x, y, z); | ||||
|       }), boundaryAngle]; | ||||
|   } | ||||
|   calculateRoadAngle(startPoint, endPoint) { | ||||
|     const normal = Cesium.Ellipsoid.WGS84.geodeticSurfaceNormal(startPoint); | ||||
|     const enuMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(startPoint, undefined, normal); | ||||
|     const inverseMatrix = Cesium.Matrix4.inverse(enuMatrix, new Cesium.Matrix4()); | ||||
|  | ||||
|     const localEnd = Cesium.Matrix4.multiplyByPoint(inverseMatrix, endPoint, new Cesium.Cartesian3()); | ||||
|     const horizontalVec = new Cesium.Cartesian2(localEnd.x, localEnd.y); | ||||
|     Cesium.Cartesian2.normalize(horizontalVec, horizontalVec); | ||||
|  | ||||
|     const north = new Cesium.Cartesian2(1, 0); | ||||
|  | ||||
|     let angle = Cesium.Cartesian2.angleBetween(north, horizontalVec); | ||||
|     angle = Cesium.Math.toDegrees(angle) | ||||
|     const cross = Cesium.Cartesian2.cross(north, horizontalVec, new Cesium.Cartesian2()); | ||||
|     // return cross < 0 ? angle : - angle; | ||||
|     return cross < 0 ? -angle : angle; | ||||
|   } | ||||
|   generateInterpolatedPoints(polygonPositions, spacing) { | ||||
|     // 1. 边界点插值 | ||||
|     const boundaryPoints = []; | ||||
|  | ||||
|     for (let i = 0; i < polygonPositions.length; i++) { | ||||
|  | ||||
|       const start = polygonPositions[i]; | ||||
|       const end = polygonPositions[(i + 1) % polygonPositions.length]; | ||||
|       const segmentLength = Cesium.Cartesian3.distance(start, end); | ||||
|       const segments = Math.ceil(segmentLength / spacing); | ||||
|  | ||||
|       for (let j = 0; j <= segments; j++) { | ||||
|         const ratio = j / segments; | ||||
|         const point = Cesium.Cartesian3.lerp( | ||||
|           start, end, ratio, new Cesium.Cartesian3() | ||||
|         ); | ||||
|         boundaryPoints.push(point); | ||||
|       } | ||||
|     } | ||||
|  | ||||
|     // 2. 内部网格生成 | ||||
|     const extent = this.computePolygonExtent(polygonPositions); | ||||
|     let result = this.createGridFromBBox(extent, this.options.spacing) | ||||
|     // const extent = Cesium.Rectangle.fromCartesianArray(polygonPositions); | ||||
|  | ||||
|     const gridPoints = []; | ||||
|     // const polygon = new Cesium.PolygonHierarchy(polygonPositions); | ||||
|     var polygon = [] | ||||
|     this.options.positions.forEach(item => { | ||||
|       polygon.push([item.lng, item.lat]) | ||||
|     }) | ||||
|     polygon.push(polygon[0]) | ||||
|     for (let x = extent.west; x <= extent.east; x += result.lonStep) { | ||||
|       for (let y = extent.south; y <= extent.north; y += result.latStep) { | ||||
|         const position = Cesium.Cartesian3.fromDegrees(x, y); | ||||
|         const point = turf.point([x, y]); | ||||
|         const polygonTurf = turf.polygon([polygon]); | ||||
|         const isInside = turf.booleanPointInPolygon(point, polygonTurf); | ||||
|         isInside && gridPoints.push(position) | ||||
|       } | ||||
|     } | ||||
|  | ||||
|     // 3. 合并结果并去重 | ||||
|     // return [...new Set([...boundaryPoints, ...gridPoints] | ||||
|     return [...new Set([...gridPoints] | ||||
|       .map(p => `${p.x},${p.y},${p.z}`))] | ||||
|       .map(str => { | ||||
|         const [x, y, z] = str.split(',').map(Number); | ||||
|         return new Cesium.Cartesian3(x, y, z); | ||||
|       }); | ||||
|   } | ||||
|  | ||||
|   createGridFromBBox(bbox, spacing) { | ||||
|     const earthRadius = 6378137; // WGS84椭球体长半轴 | ||||
|     // 计算经度方向网格数 | ||||
|     const lonDistance = Cesium.Cartesian3.distance( | ||||
|       Cesium.Cartesian3.fromDegrees(bbox.west, (bbox.south + bbox.north) / 2, 0), | ||||
|       Cesium.Cartesian3.fromDegrees(bbox.east, (bbox.south + bbox.north) / 2, 0) | ||||
|     ); | ||||
|     const lonCount = Math.ceil(lonDistance / spacing); | ||||
|  | ||||
|     // 计算纬度方向网格数 | ||||
|     const latDistance = Cesium.Cartesian3.distance( | ||||
|       Cesium.Cartesian3.fromDegrees((bbox.west + bbox.east) / 2, bbox.south, 0), | ||||
|       Cesium.Cartesian3.fromDegrees((bbox.west + bbox.east) / 2, bbox.north, 0) | ||||
|     ); | ||||
|     const latCount = Math.ceil(latDistance / spacing); | ||||
|     // 生成网格线 | ||||
|     const lonStep = (bbox.east - bbox.west) / lonCount; | ||||
|     const latStep = (bbox.north - bbox.south) / latCount; | ||||
|     return { lonStep, latStep } | ||||
|   } | ||||
|  | ||||
|   computePolygonExtent(positions) { | ||||
|     // 计算多边形经纬度范围 | ||||
|     const cartographics = positions.map(p => | ||||
|       Cesium.Cartographic.fromCartesian(p)); | ||||
|     const lons = cartographics.map(c => Cesium.Math.toDegrees(c.longitude)); | ||||
|     const lats = cartographics.map(c => Cesium.Math.toDegrees(c.latitude)); | ||||
|     return { | ||||
|       west: Math.min(...lons), | ||||
|       east: Math.max(...lons), | ||||
|       south: Math.min(...lats), | ||||
|       north: Math.max(...lats) | ||||
|     }; | ||||
|   } | ||||
|   async computedArea(polygonPositions, spacing) { | ||||
|     let dis12 = Cesium.Cartesian3.distance(polygonPositions[0], polygonPositions[1]); | ||||
|     let dis23 = Cesium.Cartesian3.distance(polygonPositions[1], polygonPositions[2]); | ||||
|     let vec12 = Cesium.Cartesian3.subtract(polygonPositions[1], polygonPositions[0], new Cesium.Cartesian3()); | ||||
|     let vec23 = Cesium.Cartesian3.subtract(polygonPositions[2], polygonPositions[1], new Cesium.Cartesian3()); | ||||
|  | ||||
|     let num12 = Math.ceil(dis12 / spacing); | ||||
|     let num23 = Math.ceil(dis23 / spacing); | ||||
|  | ||||
|     let line1 = [] | ||||
|     for (let i = 0; i < num12; i++) { | ||||
|       line1.push(await this.calculatePointB(polygonPositions[0], polygonPositions[1], i * spacing)) | ||||
|     } | ||||
|     let line2 = [] | ||||
|     for (let i = 0; i < num12; i++) { | ||||
|       line2.push(await this.calculatePointB(polygonPositions[3], polygonPositions[2], i * spacing)) | ||||
|     } | ||||
|  | ||||
|     let allPoints = [] | ||||
|     for (let i = 0; i < line1.length; i++) { | ||||
|       for (let j = 0; j < num23; j++) { | ||||
|         allPoints.push(await this.calculatePointB(line1[i], line2[i], j * spacing)) | ||||
|       } | ||||
|     } | ||||
|     return allPoints | ||||
|   } | ||||
|   async calculatePointB(pointA, pointC, distance) { | ||||
|     // 将输入坐标转换为Cartesian3类型 | ||||
|     // const pointA = Cesium.Cartesian3.fromDegrees(a.longitude, a.latitude, a.height); | ||||
|     // const pointC = Cesium.Cartesian3.fromDegrees(c.longitude, c.latitude, c.height); | ||||
|  | ||||
|     // 计算向量AC | ||||
|     const vectorAC = Cesium.Cartesian3.subtract(pointC, pointA, new Cesium.Cartesian3()); | ||||
|  | ||||
|     // 计算向量AC的长度 | ||||
|     const lengthAC = Cesium.Cartesian3.magnitude(vectorAC); | ||||
|  | ||||
|     // 归一化向量AC | ||||
|     const unitVector = Cesium.Cartesian3.normalize(vectorAC, new Cesium.Cartesian3()); | ||||
|  | ||||
|     // 计算点B坐标 | ||||
|     const scaledVector = Cesium.Cartesian3.multiplyByScalar(unitVector, distance, new Cesium.Cartesian3()); | ||||
|     const pointB = Cesium.Cartesian3.add(pointA, scaledVector, new Cesium.Cartesian3()); | ||||
|  | ||||
|  | ||||
|     const cartographic = Cesium.Cartographic.fromCartesian( | ||||
|       pointB // Cartesian3对象 {x, y, z} | ||||
|     ); | ||||
|     const longitude = Cesium.Math.toDegrees(cartographic.longitude); | ||||
|     const latitude = Cesium.Math.toDegrees(cartographic.latitude); | ||||
|  | ||||
|  | ||||
|     let height = await this.getClampToHeight({ lng: longitude, lat: latitude }) | ||||
|     let point = Cesium.Cartesian3.fromDegrees(longitude, latitude, height); | ||||
|     // 转换回经纬度 | ||||
|     // const cartographic = Cesium.Cartographic.fromCartesian(pointB); | ||||
|     // return { | ||||
|     //   longitude: Cesium.Math.toDegrees(cartographic.longitude), | ||||
|     //   latitude: Cesium.Math.toDegrees(cartographic.latitude), | ||||
|     //   height: cartographic.height | ||||
|     // }; | ||||
|     // return pointB | ||||
|     return point | ||||
|   } | ||||
|   get show() { | ||||
|     return this.options.show | ||||
|   } | ||||
|  | ||||
|   set show(v) { | ||||
|     this.options.show = v | ||||
|     for (let i = 0; i < this.pointArr.length; i++) { | ||||
|       this.pointArr[i].show = v | ||||
|     } | ||||
|   } | ||||
|   get type() { | ||||
|     return this.options.type | ||||
|   } | ||||
|  | ||||
|   set type(v) { | ||||
|     this.options.type = v | ||||
|     this._elms.type && | ||||
|       this._elms.type.forEach(item => { | ||||
|         item.value = v | ||||
|       }) | ||||
|   } | ||||
|   get spacing() { | ||||
|     return this.options.spacing | ||||
|   } | ||||
|  | ||||
|   set spacing(v) { | ||||
|     this.options.spacing = v | ||||
|     this._elms.spacing && | ||||
|       this._elms.spacing.forEach(item => { | ||||
|         item.value = v | ||||
|       }) | ||||
|   } | ||||
|   /** | ||||
|    * @description 编辑框 | ||||
|    * @param state=false {boolean} 状态: true打开, false关闭 | ||||
|    */ | ||||
|   async edit(state = false) { | ||||
|     let _this = this | ||||
|     this.originalOptions = this.deepCopyObj(this.options) | ||||
|  | ||||
|     // let elms = this.sdk.viewer._container.getElementsByClassName('YJ-custom-base-dialog') | ||||
|     // for (let i = elms.length - 1; i >= 0; i--) { | ||||
|     //   this.sdk.viewer._container.removeChild(elms[i]) | ||||
|     // } | ||||
|  | ||||
|     if (this._DialogObject && this._DialogObject.close) { | ||||
|       this._DialogObject.close() | ||||
|       this._DialogObject = null | ||||
|     } | ||||
|  | ||||
|     if (state) { | ||||
|       this._DialogObject = await new Dialog(this.sdk, this.originalOptions, { | ||||
|         title: '默认模型参数设置', left: '180px', top: '100px', | ||||
|         confirmCallBack: (options) => { | ||||
|           this.name = this.name.trim() | ||||
|           if (!this.name) { | ||||
|             // this.name = '未命名对象' | ||||
|             this.name = '飞线' | ||||
|           } | ||||
|  | ||||
|           let Draw | ||||
|           switch (this.options.type) { | ||||
|             case '点': | ||||
|               Draw = new DrawPoint(this.sdk) | ||||
|               break; | ||||
|             case '线': | ||||
|               Draw = new DrawPolyline(this.sdk) | ||||
|               break; | ||||
|             case '面': | ||||
|               Draw = new DrawThreeRect(this.sdk) | ||||
|               break; | ||||
|             default: | ||||
|               break; | ||||
|           } | ||||
|           Draw && Draw.start((a, positions) => { | ||||
|             this.options.positions = positions; | ||||
|             // this.callback(this.options); | ||||
|             (this.options.positions.length || this.options.positions.lng) && BatchModel.computeDis(this) | ||||
|           }) | ||||
|  | ||||
|           this.originalOptions = this.deepCopyObj(this.options) | ||||
|           this._DialogObject.close() | ||||
|           this.Dialog.confirmCallBack && this.Dialog.confirmCallBack(this.originalOptions) | ||||
|           syncData(this.sdk, this.options.id) | ||||
|           syncSplitData(this.sdk, this.options.id) | ||||
|         }, | ||||
|         // resetCallBack: () => { | ||||
|         //   this.reset() | ||||
|         //   console.log('22222') | ||||
|         //   this.Dialog.resetCallBack && this.Dialog.resetCallBack() | ||||
|         // }, | ||||
|         // removeCallBack: () => { | ||||
|         //   console.log('33333') | ||||
|         //   this.Dialog.removeCallBack && this.Dialog.removeCallBack() | ||||
|         // }, | ||||
|         closeCallBack: () => { | ||||
|           this.reset() | ||||
|           // this.entity.style = new Cesium.Cesium3DTileStyle({ | ||||
|           //   color: "color('rgba(255,255,255," + this.newData.transparency + ")')", | ||||
|           //   show: true, | ||||
|           // }); | ||||
|           this.Dialog.closeCallBack && this.Dialog.closeCallBack() | ||||
|         }, | ||||
|         addFootElm: [ | ||||
|           { | ||||
|             tagName: 'button', | ||||
|             className: 'flipe-over-y', | ||||
|             innerHTML: '重置', | ||||
|             event: [ | ||||
|               'click', | ||||
|               () => { | ||||
|                 this.reset() | ||||
|               } | ||||
|             ] | ||||
|           } | ||||
|         ] | ||||
|         // showCallBack: (show) => { | ||||
|         //   this.show = show | ||||
|         //   this.Dialog.showCallBack && this.Dialog.showCallBack() | ||||
|         // } | ||||
|       }, true) | ||||
|       this._DialogObject._element.body.className = this._DialogObject._element.body.className + ' flow-line-surface' | ||||
|       let contentElm = document.createElement('div'); | ||||
|       contentElm.innerHTML = html() | ||||
|       this._DialogObject.contentAppChild(contentElm) | ||||
|       // 颜色组件 | ||||
|       // let waterColorPicker = new YJColorPicker({ | ||||
|       //   el: contentElm.getElementsByClassName("flowLine-color")[0], | ||||
|       //   size: 'mini',//颜色box类型 | ||||
|       //   alpha: true,//是否开启透明度 | ||||
|       //   defaultColor: this.color, | ||||
|       //   disabled: false,//是否禁止打开颜色选择器 | ||||
|       //   openPickerAni: 'opacity',//打开颜色选择器动画 | ||||
|       //   sure: (color) => { | ||||
|       //     this.color = color | ||||
|       //   },//点击确认按钮事件回调 | ||||
|       //   clear: () => { | ||||
|       //     this.color = 'rgba(255,255,255,1)' | ||||
|       //   },//点击清空按钮事件回调 | ||||
|       // }) | ||||
|  | ||||
|       let all_elm = contentElm.getElementsByTagName("*") | ||||
|       this._EventBinding.on(this, all_elm) | ||||
|       this._elms = this._EventBinding.element | ||||
|  | ||||
|       let nameData = [ | ||||
|         { | ||||
|           name: '点', | ||||
|           value: '点', | ||||
|         }, | ||||
|         { | ||||
|           name: '线', | ||||
|           value: '线', | ||||
|         }, | ||||
|         { | ||||
|           name: '面', | ||||
|           value: '面', | ||||
|         } | ||||
|       ] | ||||
|  | ||||
|       let nameDataLegpObject = legp( | ||||
|         this._DialogObject._element.content.getElementsByClassName( | ||||
|           'add-type-box' | ||||
|         )[0], | ||||
|         '.add-type' | ||||
|       ) | ||||
|       if (nameDataLegpObject) { | ||||
|         nameDataLegpObject.legp_search(nameData) | ||||
|         let nameDataLegpElm = this._DialogObject._element.content | ||||
|           .getElementsByClassName('add-type')[0] | ||||
|           .getElementsByTagName('input')[0] | ||||
|         this._elms.type = [nameDataLegpElm] | ||||
|         nameDataLegpElm.value = this.options.type | ||||
|         for (let i = 0; i < nameData.length; i++) { | ||||
|           if (nameData[i].value === nameDataLegpElm.value) { | ||||
|             nameDataLegpObject.legp_searchActive(nameData[i].value) | ||||
|             break | ||||
|           } | ||||
|         } | ||||
|         nameDataLegpElm.addEventListener('input', () => { | ||||
|           for (let i = 0; i < nameData.length; i++) { | ||||
|             if (nameData[i].value === nameDataLegpElm.value) { | ||||
|               this.type = nameData[i].value | ||||
|               break | ||||
|             } | ||||
|           } | ||||
|         }) | ||||
|       } | ||||
|       // this._elms.color = [waterColorPicker] | ||||
|     } else { | ||||
|       // if (this._element_style) { | ||||
|       //   document.getElementsByTagName('head')[0].removeChild(this._element_style) | ||||
|       //   this._element_style = null | ||||
|       // } | ||||
|       // if (this._DialogObject && this._DialogObject.remove) { | ||||
|       //   this._DialogObject.remove() | ||||
|       //   this._DialogObject = null | ||||
|       // } | ||||
|     } | ||||
|   } | ||||
|   drawArea() { | ||||
|  | ||||
|   } | ||||
|  | ||||
|   reset() { | ||||
|     this.name = this.originalOptions.name | ||||
|     this.type = this.originalOptions.type | ||||
|     this.spacing = this.originalOptions.spacing | ||||
|     this.show = this.originalOptions.show | ||||
|     this.options.spacing = this.originalOptions.spacing | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * 飞到对应实体 | ||||
|    */ | ||||
|   async flyTo(options = {}) { | ||||
|     setActiveViewer(0) | ||||
|     closeRotateAround(this.sdk) | ||||
|     closeViewFollow(this.sdk) | ||||
|  | ||||
|     if (this.options.customView && this.options.customView.relativePosition && this.options.customView.orientation) { | ||||
|       let orientation = { | ||||
|         heading: Cesium.Math.toRadians(this.options.customView.orientation.heading || 0.0), | ||||
|         pitch: Cesium.Math.toRadians(this.options.customView.orientation.pitch || -60.0), | ||||
|         roll: Cesium.Math.toRadians(this.options.customView.orientation.roll || 0.0) | ||||
|       } | ||||
|  | ||||
|       let lng = this.options.customView.relativePosition.lng | ||||
|       let lat = this.options.customView.relativePosition.lat | ||||
|       let alt = this.options.customView.relativePosition.alt | ||||
|       let destination = Cesium.Cartesian3.fromDegrees(lng, lat, alt) | ||||
|  | ||||
|       let position = { lng: 0, lat: 0 } | ||||
|       if (this.options.position) { | ||||
|         position = { ...this.options.position } | ||||
|       } | ||||
|       else if (this.options.positions) { | ||||
|         position = { ...this.options.positions[0] } | ||||
|       } | ||||
|       else if (this.options.center) { | ||||
|         position = { ...this.options.center } | ||||
|       } | ||||
|       else if (this.options.start) { | ||||
|         position = { ...this.options.start } | ||||
|       } | ||||
|       else { | ||||
|         if (this.options.hasOwnProperty('lng')) { | ||||
|           position.lng = this.options.lng | ||||
|         } | ||||
|         if (this.options.hasOwnProperty('lat')) { | ||||
|           position.lat = this.options.lat | ||||
|         } | ||||
|         if (this.options.hasOwnProperty('alt')) { | ||||
|           position.alt = this.options.alt | ||||
|         } | ||||
|       } | ||||
|       // 如果没有高度值,则获取紧贴高度计算 | ||||
|       // if (!position.hasOwnProperty('alt')) { | ||||
|       //   position.alt = await this.getClampToHeight(position) | ||||
|       // } | ||||
|       lng = this.options.customView.relativePosition.lng + position.lng | ||||
|       lat = this.options.customView.relativePosition.lat + position.lat | ||||
|       alt = this.options.customView.relativePosition.alt + position.alt | ||||
|       destination = Cesium.Cartesian3.fromDegrees(lng, lat, alt) | ||||
|       this.sdk.viewer.camera.flyTo({ | ||||
|         destination: destination, | ||||
|         orientation: orientation | ||||
|       }) | ||||
|     } | ||||
|     else { | ||||
|       let positionArray = [] | ||||
|       if (this.options.positions.length > 0) { | ||||
|         for (let i = 0; i < this.options.positions.length; i++) { | ||||
|           let a = Cesium.Cartesian3.fromDegrees( | ||||
|             this.options.positions[i].lng, | ||||
|             this.options.positions[i].lat, | ||||
|             this.options.positions[i].alt | ||||
|           ) | ||||
|           positionArray.push(a.x, a.y, a.z) | ||||
|         } | ||||
|         let BoundingSphere = Cesium.BoundingSphere.fromVertices(positionArray) | ||||
|         this.viewer.camera.flyToBoundingSphere(BoundingSphere, { | ||||
|           offset: { | ||||
|             heading: Cesium.Math.toRadians(0.0), | ||||
|             pitch: Cesium.Math.toRadians(-20.0), | ||||
|             roll: Cesium.Math.toRadians(0.0) | ||||
|           } | ||||
|         }) | ||||
|       } else if (this.options.positions.lng) { | ||||
|         let orientation = { | ||||
|           heading: Cesium.Math.toRadians(0.0), | ||||
|           pitch: Cesium.Math.toRadians(-60.0), | ||||
|           roll: Cesium.Math.toRadians(0.0) | ||||
|         } | ||||
|         this.sdk.viewer.camera.flyTo({ | ||||
|           destination: Cesium.Cartesian3.fromDegrees(this.options.positions.lng, this.options.positions.lat, this.options.positions.alt + 100), | ||||
|           // orientation: orientation | ||||
|         }) | ||||
|  | ||||
|       } | ||||
|  | ||||
|     } | ||||
|   } | ||||
|   /** | ||||
|    * 删除 | ||||
|    */ | ||||
|   async remove() { | ||||
|     for (let i = 0; i < this.pointArr.length; i++) { | ||||
|       this.pointArr[i].remove() | ||||
|     } | ||||
|  | ||||
|     this.pointArr = [] | ||||
|     this.positions = [] | ||||
|     this.entity = null | ||||
|  | ||||
|     if (this._DialogObject && !this._DialogObject.isDestroy) { | ||||
|       this._DialogObject.close() | ||||
|       this._DialogObject = null | ||||
|     } | ||||
|     await this.sdk.removeIncetance(this.options.id) | ||||
|     await syncData(this.sdk, this.options.id) | ||||
|   } | ||||
|  | ||||
|   flicker() { } | ||||
| } | ||||
|  | ||||
| export default BatchModel | ||||
| @ -29,7 +29,8 @@ import MouseTip from '../../../MouseTip' | ||||
| import { | ||||
|   setSplitDirection, | ||||
|   syncSplitData, | ||||
|   setActiveId | ||||
|   setActiveId, | ||||
|   getState | ||||
| } from '../../../Global/SplitScreen' | ||||
| import { | ||||
|   setActiveViewer, | ||||
| @ -40,6 +41,11 @@ import { | ||||
| import { getGoodsList } from '../../../Tools/getGoodsList' | ||||
|  | ||||
| class BillboardObject extends Base { | ||||
|   #_postRenderEvent = null | ||||
|   #_destroyMouseEvent = null | ||||
|   #_billboardHeight = 0 | ||||
|  | ||||
|  | ||||
|   /** | ||||
|    * @constructor | ||||
|    * @description 创建点标注 | ||||
| @ -118,6 +124,7 @@ class BillboardObject extends Base { | ||||
|     this.options.positions.alt = Number( | ||||
|       Number(options.positions.alt || 0).toFixed(2) | ||||
|     ) | ||||
|     this.#_billboardHeight = this.options.positions.alt | ||||
|     // this.options.diffuseShow = options.diffuseShow || false | ||||
|     // this.options.diffuseRadius = (options.diffuseRadius || options.diffuseRadius === 0) ? options.diffuseRadius : 10 | ||||
|     // this.options.diffuseDuration = (options.diffuseDuration || options.diffuseDuration === 0) ? options.diffuseDuration : 2000 | ||||
| @ -145,11 +152,18 @@ class BillboardObject extends Base { | ||||
|       this.options.attribute.goods.content || [] | ||||
|     this.options.attributeType = options.attributeType || 'richText' | ||||
|     this.options.coordinate = options.coordinate || '' | ||||
|     this.options.attributeBoxState = options.attributeBoxState || false | ||||
|     this.operate = {} | ||||
|     this._elms = {} | ||||
|     this.previous = { | ||||
|       positions: { ...this.options.positions } | ||||
|     } | ||||
|     this.options.attributePos = options.attributePos || { | ||||
|       x: 60, | ||||
|       y: 60, | ||||
|       width: 200, | ||||
|       height: 120 | ||||
|     } | ||||
|     this.entity | ||||
|     this._proj = this.sdk.proj | ||||
|  | ||||
| @ -182,7 +196,111 @@ class BillboardObject extends Base { | ||||
|  | ||||
|  | ||||
|  | ||||
|     this.#_destroyMouseEvent = () => { | ||||
|       this.attributeElm && (this.attributeElm.style.pointerEvents = 'unset') | ||||
|       if(this.sdk && this.sdk.viewer && this.sdk.viewer._element) { | ||||
|         this.sdk.viewer._element.onmousemove = null | ||||
|       } | ||||
|       document.removeEventListener('mouseup', this.#_destroyMouseEvent) | ||||
|       document.removeEventListener('mouseleave', this.#_destroyMouseEvent) | ||||
|     } | ||||
|  | ||||
|     this.#_postRenderEvent = () => { | ||||
|       let siteInfoPosition = Cesium.Cartesian3.fromDegrees( | ||||
|         this.options.positions.lng, | ||||
|         this.options.positions.lat, | ||||
|         this.#_billboardHeight | ||||
|       ) | ||||
|       if (this.attributeElm && this.entity) { | ||||
|         let winpos = this.sdk.viewer.scene.cartesianToCanvasCoordinates( | ||||
|           siteInfoPosition | ||||
|         ) | ||||
|         let pixelOffset = this.entity.label.pixelOffset.getValue() | ||||
|         if (winpos) { | ||||
|           let scale = getCurrentBillboardScale(this.entity, this.sdk.viewer.scene) | ||||
|           let height = ((this.entity.billboard.height.getValue() * (this.options.billboard.scale || 0)) + this.options.label.fontSize) * (1 - (scale * scale)) | ||||
|           let flag = false | ||||
|           let lineElm = this.attributeElm.getElementsByClassName('billboard-attribute-box-line')[0] | ||||
|           let leftTopElm = this.attributeElm.getElementsByClassName('left-top')[0] | ||||
|           let rightTopElm = this.attributeElm.getElementsByClassName('right-top')[0] | ||||
|           this.attributeElm.style.left = (winpos.x + this.options.attributePos.x).toFixed(0) + 'px' | ||||
|           this.attributeElm.style.top = (winpos.y + pixelOffset.y - (this.options.label.show ? (this.options.label.fontSize / 2) : -(this.options.label.fontSize / 2)) - this.attributeElm.offsetHeight - this.options.attributePos.y + height).toFixed(0) + 'px' | ||||
|           this.attributeElm.style.width = this.options.attributePos.width + 'px' | ||||
|           this.attributeElm.style.height = this.options.attributePos.height + 'px' | ||||
|           lineElm.style.zIndex = '-1' | ||||
|           if (this.options.attributePos.x < -this.options.attributePos.width / 2) { | ||||
|             flag = true | ||||
|             lineElm.style.left = 'unset' | ||||
|             lineElm.style.right = '0' | ||||
|             leftTopElm.style.display = 'block' | ||||
|             rightTopElm.style.display = 'none' | ||||
|           } | ||||
|           else { | ||||
|             lineElm.style.left = '0' | ||||
|             lineElm.style.right = 'unset' | ||||
|             leftTopElm.style.display = 'none' | ||||
|             rightTopElm.style.display = 'block' | ||||
|           } | ||||
|  | ||||
|           let lineLength | ||||
|           let lineAngleRad | ||||
|           let lineAngle | ||||
|           let x | ||||
|           let y | ||||
|           if (flag) { | ||||
|             x = this.attributeElm.offsetWidth + this.options.attributePos.x | ||||
|             y = this.options.attributePos.y ? this.options.attributePos.y : 0 | ||||
|           } | ||||
|           else { | ||||
|             x = this.options.attributePos.x | ||||
|             y = this.options.attributePos.y ? this.options.attributePos.y : 0 | ||||
|           } | ||||
|           lineLength = Math.sqrt((x * x) + (y * y)).toFixed(2); | ||||
|           lineAngleRad = Math.atan(x / y); | ||||
|           lineAngle = parseFloat((lineAngleRad * 180 / Math.PI).toFixed(2)); | ||||
|           if (this.options.attributePos.y < 0) { | ||||
|             lineAngle = lineAngle + 180 | ||||
|           } | ||||
|           // if(this.options.attributePos.y<-this.options.attributePos.height/2) { | ||||
|           //   lineElm.style.bottom = 'unset' | ||||
|           //   lineElm.style.top = '0' | ||||
|           // } | ||||
|           // else { | ||||
|           //   lineElm.style.bottom = -lineLength + 'px' | ||||
|           //   lineElm.style.top = 'unset' | ||||
|           // } | ||||
|           lineElm.style.height = lineLength + 'px' | ||||
|           lineElm.style.transform = 'rotate(' + lineAngle + 'deg)' | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|  | ||||
|     function getCurrentBillboardScale(entity, scene) { | ||||
|       // 获取相机到Billboard的距离 | ||||
|       const distance = Cesium.Cartesian3.distance( | ||||
|         scene.camera.positionWC, | ||||
|         entity.position.getValue() | ||||
|       ); | ||||
|       // 获取缩放距离配置 | ||||
|       const scaleByDistance = entity.billboard.scaleByDistance ? entity.billboard.scaleByDistance.getValue() : undefined; | ||||
|  | ||||
|       if (!scaleByDistance) { | ||||
|         // 如果没有设置距离缩放,则使用基础缩放值 | ||||
|         return 1.0; | ||||
|       } | ||||
|  | ||||
|       // 解析缩放距离参数 [near, nearScale, far, farScale] | ||||
|       const { near, nearValue, far, farValue } = scaleByDistance; | ||||
|       if (distance <= near) { | ||||
|         return nearValue; | ||||
|       } else if (distance >= far) { | ||||
|         return farValue; | ||||
|       } else { | ||||
|         // 计算中间距离的缩放值(线性插值) | ||||
|         const t = (distance - near) / (far - near); | ||||
|         return Cesium.Math.lerp(nearValue, farValue, t); | ||||
|       } | ||||
|     } | ||||
|  | ||||
|  | ||||
|     this.sdk.addIncetance(this.options.id, this) | ||||
| @ -243,6 +361,7 @@ class BillboardObject extends Base { | ||||
|             that.entity.billboard.imgHeight = 0 | ||||
|             that.entity.billboard.image = canvas | ||||
|             addCluster(that.sdk, that.entity) | ||||
|             that.attributeBoxState && (that.attributeBoxState = true) | ||||
|           } | ||||
|           return | ||||
|         } | ||||
| @ -267,13 +386,14 @@ class BillboardObject extends Base { | ||||
|             return img | ||||
|           }, false) | ||||
|           addCluster(that.sdk, that.entity) | ||||
|           that.attributeBoxState && (that.attributeBoxState = true) | ||||
|         } | ||||
|       }) | ||||
|     } | ||||
|     else { | ||||
|       let image = new Image() | ||||
|       image.src = | ||||
|       url || | ||||
|         url || | ||||
|         that.getSourceRootPath() + '/img/A-ablu-blank.png' | ||||
|       switch (that.options.heightMode) { | ||||
|         case 2: | ||||
| @ -298,6 +418,7 @@ class BillboardObject extends Base { | ||||
|           that.entity.billboard.imgHeight = height | ||||
|           that.entity.billboard.image = canvas | ||||
|           addCluster(that.sdk, that.entity) | ||||
|           that.attributeBoxState && (that.attributeBoxState = true) | ||||
|         } | ||||
|       } | ||||
|       image.onerror = function (err) { | ||||
| @ -309,6 +430,7 @@ class BillboardObject extends Base { | ||||
|           that.entity.billboard.imgHeight = 0 | ||||
|           that.entity.billboard.image = canvas | ||||
|           addCluster(that.sdk, that.entity) | ||||
|           that.attributeBoxState && (that.attributeBoxState = true) | ||||
|         } | ||||
|       }; | ||||
|     } | ||||
| @ -465,14 +587,45 @@ class BillboardObject extends Base { | ||||
|     return this.options.show | ||||
|   } | ||||
|   set show(v) { | ||||
|     this.options.show = v | ||||
|     this.originalOptions.show = v | ||||
|     this.entity && (this.entity.show = v) | ||||
|     if (!this.isShowView) { | ||||
|       this.options.show = v | ||||
|       this.originalOptions.show = v | ||||
|     } | ||||
|     if (!this.showView || this.showView == 3) { | ||||
|       this.entity && (this.entity.show = this.options.show) | ||||
|       if (this.attributeBoxState && this.options.show) { | ||||
|         this.attributeBoxState = this.options.show | ||||
|       } | ||||
|       else { | ||||
|         // 关闭属性框 | ||||
|         document.addEventListener('mouseup', this.#_destroyMouseEvent); | ||||
|         document.addEventListener('mouseleave', this.#_destroyMouseEvent); | ||||
|         if (this.attributeElm) { | ||||
|           this.sdk.viewer._element.removeChild(this.attributeElm) | ||||
|           this.attributeElm = null | ||||
|         } | ||||
|         this.sdk.viewer.scene.postRender.removeEventListener(this.#_postRenderEvent) | ||||
|       } | ||||
|     } | ||||
|     else { | ||||
|       this.entity && (this.entity.show = false) | ||||
|       // 关闭属性框 | ||||
|       document.addEventListener('mouseup', this.#_destroyMouseEvent); | ||||
|       document.addEventListener('mouseleave', this.#_destroyMouseEvent); | ||||
|       if (this.attributeElm) { | ||||
|         this.sdk.viewer._element.removeChild(this.attributeElm) | ||||
|         this.attributeElm = null | ||||
|       } | ||||
|       this.sdk.viewer.scene.postRender.removeEventListener(this.#_postRenderEvent) | ||||
|     } | ||||
|     syncData(this.sdk, this.options.id) | ||||
|     syncSplitData(this.sdk, this.options.id) | ||||
|  | ||||
|     if (this._DialogObject && this._DialogObject.showBtn) { | ||||
|       this._DialogObject.showBtn.checked = v | ||||
|       this._DialogObject.showBtn.checked = this.options.show | ||||
|     } | ||||
|  | ||||
|     this.isShowView = false | ||||
|     // if (v) { | ||||
|     //   if (this.diffuseShow) { | ||||
|     //     this.diffuseShow = true | ||||
| @ -552,6 +705,26 @@ class BillboardObject extends Base { | ||||
|     if (this.entity) { | ||||
|       this.entity.billboard.heightReference = heightMode | ||||
|       this.entity.label.heightReference = heightMode | ||||
|       if(heightMode == Cesium.HeightReference.CLAMP_TO_GROUND) { | ||||
|         if (this.sdk.viewer.scene.terrainProvider.availability) { | ||||
|           Cesium.sampleTerrainMostDetailed( | ||||
|             this.sdk.viewer.scene.terrainProvider, | ||||
|             [ | ||||
|               Cesium.Cartographic.fromDegrees( | ||||
|                 this.options.positions.lng, | ||||
|                 this.options.positions.lat | ||||
|               ) | ||||
|             ] | ||||
|           ).then(position => { | ||||
|             this.#_billboardHeight = position[0].height | ||||
|           }) | ||||
|         } else { | ||||
|           this.#_billboardHeight = 0 | ||||
|         } | ||||
|       } | ||||
|       else { | ||||
|         this.#_billboardHeight = this.options.positions.alt | ||||
|       } | ||||
|     } | ||||
|     this._elms.heightMode && (this._elms.heightMode.value = heightModeName) | ||||
|   } | ||||
| @ -606,6 +779,7 @@ class BillboardObject extends Base { | ||||
|   } | ||||
|   set alt(v) { | ||||
|     this.options.positions.alt = Number(Number(v).toFixed(2)) | ||||
|     this.#_billboardHeight = this.options.positions.alt | ||||
|     // this.scan && (this.scan.alt = v) | ||||
|     // this.diffuse && (this.diffuse.alt = v) | ||||
|     this.renewPoint() | ||||
| @ -766,6 +940,8 @@ class BillboardObject extends Base { | ||||
|       _this._frameImages = [] | ||||
|       superGif.load(function (status) { | ||||
|         if (status == 404) { | ||||
|           let width = 31 | ||||
|           let height = 36 | ||||
|           canvas = document.createElement('canvas') | ||||
|           canvas.width = 0 | ||||
|           canvas.height = 0 | ||||
| @ -855,6 +1031,8 @@ class BillboardObject extends Base { | ||||
|         billboardH = height * (31 / width) | ||||
|       } | ||||
|       image.onerror = function (err) { | ||||
|         let width = 31 | ||||
|         let height = 36 | ||||
|         canvas.width = 0 | ||||
|         canvas.height = 0 | ||||
|         billboardH = 0 | ||||
| @ -1702,6 +1880,22 @@ class BillboardObject extends Base { | ||||
|         this.cameraSelect && this.cameraSelect() | ||||
|         this.ISCSelect && this.ISCSelect() | ||||
|         this.goodsSelect && this.goodsSelect() | ||||
|  | ||||
|         let col = document.createElement('div') | ||||
|         col.className = 'col' | ||||
|         col.style.flex = '0 0 110px' | ||||
|         col.innerHTML = ` | ||||
|           <span class="label">属性框</span> | ||||
|           <input class="btn-switch" type="checkbox"> | ||||
|         ` | ||||
|  | ||||
|         let row = this._DialogObject._element.content.getElementsByClassName('attribute')[0].getElementsByClassName('row')[0] | ||||
|         row.appendChild(col) | ||||
|         let boxSwitch = col.getElementsByClassName('btn-switch')[0] | ||||
|         boxSwitch.checked = this.attributeBoxState | ||||
|         boxSwitch.addEventListener('change', (e) => { | ||||
|           this.attributeBoxState = boxSwitch.checked | ||||
|         }) | ||||
|         let tagData = this.attributeSelect | ||||
|         let attributeElm = this._DialogObject._element.content.getElementsByClassName( | ||||
|           'attribute-select-box' | ||||
| @ -2213,6 +2407,7 @@ class BillboardObject extends Base { | ||||
|     this.attributeCamera = this.options.attribute.camera.content | ||||
|     this.attributeGoods = this.options.attribute.goods.content | ||||
|     this.attributeISC = this.options.attribute.ISC.content | ||||
|     this.attributeBoxState = this.options.attributeBoxState | ||||
|     this.cameraSelect && this.cameraSelect() | ||||
|     this.goodsSelect && this.goodsSelect() | ||||
|   } | ||||
| @ -2220,6 +2415,7 @@ class BillboardObject extends Base { | ||||
|   async remove() { | ||||
|     await remove_entity_from_cluster(this.sdk.viewer, this.entity) | ||||
|     this.entity = null | ||||
|     this.attributeBoxState = false | ||||
|     if (!this.sdk.viewer || !this.sdk.viewer.entities) { | ||||
|       return | ||||
|     } | ||||
| @ -2344,6 +2540,9 @@ class BillboardObject extends Base { | ||||
|   } | ||||
|  | ||||
|   async updateHeight() { | ||||
|     if (!this.sdk || !this.sdk.viewer || !this.sdk.viewer.scene) { | ||||
|       return | ||||
|     } | ||||
|     let height | ||||
|     let height2 | ||||
|     let point1 = new Cesium.Cartesian3.fromDegrees( | ||||
| @ -2407,6 +2606,7 @@ class BillboardObject extends Base { | ||||
|     } | ||||
|     if (height !== undefined) { | ||||
|       this.options.positions.alt = Number(Number(height).toFixed(2)) | ||||
|       this.#_billboardHeight = this.options.positions.alt | ||||
|       this._elms.alt && | ||||
|         this._elms.alt.forEach(item => { | ||||
|           item.value = this.options.positions.alt | ||||
| @ -2422,6 +2622,7 @@ class BillboardObject extends Base { | ||||
|           switch (this._elms.heightMode.value) { | ||||
|             case '海拔高度': | ||||
|               heightElm.value = this.options.positions.alt | ||||
|               this.#_billboardHeight = this.options.positions.alt | ||||
|               break | ||||
|             case '相对地表': | ||||
|               if (this.sdk.viewer.scene.terrainProvider.availability) { | ||||
| @ -2437,15 +2638,18 @@ class BillboardObject extends Base { | ||||
|                   heightElm.value = Number( | ||||
|                     (this.options.positions.alt - position[0].height).toFixed(2) | ||||
|                   ) | ||||
|                   this.#_billboardHeight = this.options.positions.alt | ||||
|                 }) | ||||
|               } else { | ||||
|                 heightElm.value = this.options.positions.alt | ||||
|                 this.#_billboardHeight = this.options.positions.alt | ||||
|               } | ||||
|               break | ||||
|             case '依附地表': | ||||
|               break | ||||
|             case '依附模型': | ||||
|               heightElm.value = this.options.positions.alt | ||||
|               this.#_billboardHeight = this.options.positions.alt | ||||
|               break | ||||
|           } | ||||
|         } | ||||
| @ -2719,6 +2923,219 @@ class BillboardObject extends Base { | ||||
|         (this.originalOptions.customView = this.options.customView) | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   get attributeBoxState() { | ||||
|     return this.options.attributeBoxState | ||||
|   } | ||||
|  | ||||
|   set attributeBoxState(state) { | ||||
|     state = state ? true : false | ||||
|     this.options.attributeBoxState = state | ||||
|     document.addEventListener('mouseup', this.#_destroyMouseEvent); | ||||
|     document.addEventListener('mouseleave', this.#_destroyMouseEvent); | ||||
|     if (this.attributeElm) { | ||||
|       this.sdk.viewer._element.removeChild(this.attributeElm) | ||||
|       this.attributeElm = null | ||||
|     } | ||||
|     this.sdk.viewer.scene.postRender.removeEventListener(this.#_postRenderEvent) | ||||
|     if (state && this.sdk && this.sdk.viewer && this.sdk.viewer._element && this.show) { | ||||
|       let attributeElm = document.createElement('div') | ||||
|       this.attributeElm = attributeElm | ||||
|       attributeElm.className = 'billboard-attribute-box' | ||||
|       attributeElm.style.top = '0px' | ||||
|       attributeElm.style.left = '0px' | ||||
|       attributeElm.style.width = 0 | ||||
|       attributeElm.style.height = 0 | ||||
|       if(getState()) { | ||||
|         attributeElm.style.display = 'none' | ||||
|       } | ||||
|       // attributeElm.innerHTML = this.options.richTextContent | ||||
|       this.sdk.viewer._element.appendChild(attributeElm) | ||||
|       let linkHtml = '' | ||||
|       let goodsHtml = '' | ||||
|       let richTextHtml = '' | ||||
|       for (let i = 0; i < this.options.attribute.link.content.length; i++) { | ||||
|         linkHtml += `<DIV-cy-tab-pane label="${this.options.attribute.link.content[i].name}"><iframe width='100%' height='100%' src="${this.options.attribute.link.content[i].url}" ></iframe></DIV-cy-tab-pane>` | ||||
|       } | ||||
|       if (this.options.attribute.goods && this.options.attribute.goods.content && this.options.attribute.goods.content.length > 0) { | ||||
|         goodsHtml += `<DIV-cy-tab-pane label="物资"> | ||||
|         <div class="table"> | ||||
|           <div class="table-head"> | ||||
|             <div class="tr"> | ||||
|               <div class="th" style="width: 20%; flex: 0 20%;">序号</div> | ||||
|               <div class="th" style="width: 40%; flex: 0 40%;">名称</div> | ||||
|               <div class="th" style="width: 40%; flex: 0 40%;">数量</div> | ||||
|             </div> | ||||
|           </div> | ||||
|           <div class="table-body"> | ||||
|         ` | ||||
|         for (let i = 0; i < this.options.attribute.goods.content.length; i++) { | ||||
|           goodsHtml += `<div class="tr"> | ||||
|             <div class="td" style="width: 20%; flex: 0 20%;">${i + 1}</div> | ||||
|             <div class="td" style="width: 40%; flex: 0 40%;">${this.options.attribute.goods.content[i].name}</div> | ||||
|             <div class="td" style="width: 40%; flex: 0 40%;">${this.options.attribute.goods.content[i].cnt}</div> | ||||
|           </div>` | ||||
|         } | ||||
|         goodsHtml += `</div></div></DIV-cy-tab-pane>` | ||||
|       } | ||||
|       if (this.options.richTextContent) { | ||||
|         richTextHtml = `<DIV-cy-tab-pane label="富文本"> | ||||
|           ${this.options.richTextContent} | ||||
|         </DIV-cy-tab-pane>` | ||||
|       } | ||||
|  | ||||
|       let boxHtml = ` | ||||
|         <span class="drag-nook left-top"></span> | ||||
|         <span class="drag-nook right-top"></span> | ||||
|         ` | ||||
|  | ||||
|       if (!linkHtml && !goodsHtml && !richTextHtml) { | ||||
|         boxHtml = boxHtml + '<p style="margin: 0;width: 100%;height: 100%;display: flex;justify-content: center;align-items: center;backdrop-filter: blur(2px);">暂无属性信息</p><div class="billboard-attribute-box-line"></div>' | ||||
|       } | ||||
|       else { | ||||
|         boxHtml = boxHtml + ` | ||||
|         <DIV-cy-tabs class="tabs"> | ||||
|           ${richTextHtml} | ||||
|           ${goodsHtml} | ||||
|           ${linkHtml} | ||||
|         </DIV-cy-tabs> | ||||
|         <div class="billboard-attribute-box-line"></div>` | ||||
|       } | ||||
|  | ||||
|       attributeElm.innerHTML = boxHtml | ||||
|  | ||||
|       if (attributeElm.getElementsByClassName('tabs')[0]) { | ||||
|         let tabsElm = new cy_tabs(attributeElm.getElementsByClassName('tabs')[0], undefined, this.sdk) | ||||
|       } | ||||
|  | ||||
|       let imgElm = attributeElm.getElementsByTagName('img') | ||||
|       for (let i = 0; i < imgElm.length; i++) { | ||||
|         if (!imgElm[i].style.width) { | ||||
|           imgElm[i].style.width = '100%' | ||||
|         } | ||||
|       } | ||||
|  | ||||
|       this.sdk.viewer.scene.postRender.addEventListener(this.#_postRenderEvent) | ||||
|       let leftOnmousedown = (e) => { | ||||
|         if (this.options.attributePos.width < 200) { | ||||
|           this.options.attributePos.width = 200 | ||||
|         } | ||||
|         if (this.options.attributePos.height < 120) { | ||||
|           this.options.attributePos.height = 120 | ||||
|         } | ||||
|         let x = e.x | ||||
|         let y = e.y | ||||
|         let width = this.options.attributePos.width | ||||
|         let height = this.options.attributePos.height | ||||
|         let positionx = this.options.attributePos.x | ||||
|         this.sdk.viewer._element.onmousemove = (e2) => { | ||||
|           this.options.attributePos.width = width + (x - e2.x) | ||||
|           this.options.attributePos.height = height + (y - e2.y) | ||||
|           if (this.options.attributePos.width < 200) { | ||||
|             this.options.attributePos.width = 200 | ||||
|           } | ||||
|           else { | ||||
|             this.options.attributePos.x = positionx - (x - e2.x) | ||||
|           } | ||||
|           if (this.options.attributePos.height < 120) { | ||||
|             this.options.attributePos.height = 120 | ||||
|           } | ||||
|           // this.options.attributePos.y = positiony + (y - e2.y) | ||||
|         } | ||||
|         document.addEventListener('mouseup', this.#_destroyMouseEvent); | ||||
|         document.addEventListener('mouseleave', this.#_destroyMouseEvent); | ||||
|       } | ||||
|       let rightOnmousedown = (e) => { | ||||
|         let x = e.x | ||||
|         let y = e.y | ||||
|         if (this.options.attributePos.width < 200) { | ||||
|           this.options.attributePos.width = 200 | ||||
|         } | ||||
|         if (this.options.attributePos.height < 120) { | ||||
|           this.options.attributePos.height = 120 | ||||
|         } | ||||
|         let width = this.options.attributePos.width | ||||
|         let height = this.options.attributePos.height | ||||
|         this.sdk.viewer._element.onmousemove = (e2) => { | ||||
|           this.options.attributePos.width = width + (e2.x - x) | ||||
|           this.options.attributePos.height = height + (y - e2.y) | ||||
|         } | ||||
|         document.addEventListener('mouseup', this.#_destroyMouseEvent); | ||||
|         document.addEventListener('mouseleave', this.#_destroyMouseEvent); | ||||
|       } | ||||
|       // leftTopElm.onmousedown = (e) => { | ||||
|       //   console.log(1111111111) | ||||
|       //   if (this.options.attributePos.width < 200) { | ||||
|       //     this.options.attributePos.width = 200 | ||||
|       //   } | ||||
|       //   if (this.options.attributePos.height < 120) { | ||||
|       //     this.options.attributePos.height = 120 | ||||
|       //   } | ||||
|       //   let x = e.x | ||||
|       //   let y = e.y | ||||
|       //   let width = this.options.attributePos.width | ||||
|       //   let height = this.options.attributePos.height | ||||
|       //   let positionx = this.options.attributePos.x | ||||
|       //   this.sdk.viewer._element.onmousemove = (e2) => { | ||||
|       //     this.options.attributePos.width = width + (x - e2.x) | ||||
|       //     this.options.attributePos.height = height + (y - e2.y) | ||||
|       //     if (this.options.attributePos.width < 200) { | ||||
|       //       this.options.attributePos.width = 200 | ||||
|       //     } | ||||
|       //     else { | ||||
|       //       this.options.attributePos.x = positionx - (x - e2.x) | ||||
|       //     } | ||||
|       //     if (this.options.attributePos.height < 120) { | ||||
|       //       this.options.attributePos.height = 120 | ||||
|       //     } | ||||
|       //     // this.options.attributePos.y = positiony + (y - e2.y) | ||||
|       //   } | ||||
|       //   document.addEventListener('mouseup', this.#_destroyMouseEvent); | ||||
|       //   document.addEventListener('mouseleave', this.#_destroyMouseEvent); | ||||
|       // } | ||||
|       // rightTopElm.onmousedown = (e) => { | ||||
|       //   let x = e.x | ||||
|       //   let y = e.y | ||||
|       //   if (this.options.attributePos.width < 200) { | ||||
|       //     this.options.attributePos.width = 200 | ||||
|       //   } | ||||
|       //   if (this.options.attributePos.height < 120) { | ||||
|       //     this.options.attributePos.height = 120 | ||||
|       //   } | ||||
|       //   let width = this.options.attributePos.width | ||||
|       //   let height = this.options.attributePos.height | ||||
|       //   this.sdk.viewer._element.onmousemove = (e2) => { | ||||
|       //     this.options.attributePos.width = width + (e2.x - x) | ||||
|       //     this.options.attributePos.height = height + (y - e2.y) | ||||
|       //   } | ||||
|       //   document.addEventListener('mouseup', this.#_destroyMouseEvent); | ||||
|       //   document.addEventListener('mouseleave', this.#_destroyMouseEvent); | ||||
|       // } | ||||
|  | ||||
|       attributeElm.onmousedown = (e) => { | ||||
|         attributeElm.style.pointerEvents = 'none' | ||||
|         if (e.target.className.indexOf('left-top') != -1) { | ||||
|           leftOnmousedown(e) | ||||
|         } | ||||
|         else if (e.target.className.indexOf('right-top') != -1) { | ||||
|           rightOnmousedown(e) | ||||
|         } | ||||
|         else { | ||||
|           let x = e.x | ||||
|           let y = e.y | ||||
|           let oldX = this.options.attributePos.x | ||||
|           let oldXY = this.options.attributePos.y | ||||
|           let height = this.options.attributePos.height | ||||
|           this.sdk.viewer._element.onmousemove = (e2) => { | ||||
|             this.options.attributePos.x = oldX + (e2.x - x) | ||||
|             this.options.attributePos.y = oldXY - (e2.y - y) | ||||
|           } | ||||
|           document.addEventListener('mouseup', this.#_destroyMouseEvent); | ||||
|           document.addEventListener('mouseleave', this.#_destroyMouseEvent); | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
| export default BillboardObject | ||||
|  | ||||
| @ -6,7 +6,7 @@ import EventBinding from '../../Element/Dialog/eventBinding'; | ||||
| import richText from "../../Element/richText"; | ||||
| import MouseEvent from '../../../Event/index' | ||||
| import LabelObject from '../LabelObject' | ||||
| import { syncData } from '../../../Global/MultiViewportMode' | ||||
| import { syncData, getSdk as get2DSdk } from '../../../Global/MultiViewportMode' | ||||
| import { legp } from '../../Element/datalist'; | ||||
| import { getFontList, getFontFamilyName } from '../../Element/fontSelect' | ||||
| import MouseTip from '../../../MouseTip' | ||||
| @ -181,7 +181,7 @@ class CircleDiffuse extends Base { | ||||
|       } | ||||
|       that.sdk._entityZIndex++ | ||||
|       if (that.sdk.viewer._element.className === 'cesium-viewer 2d') { | ||||
|         that.entity.ellipse.height = 1000000 | ||||
|         that.entity.ellipse.height = 1 | ||||
|       } | ||||
|       CircleDiffuse.createLabel(that) | ||||
|       syncData(that.sdk, that.options.id) | ||||
| @ -223,16 +223,31 @@ class CircleDiffuse extends Base { | ||||
|  | ||||
|   set show(v) { | ||||
|     if (typeof v === "boolean") { | ||||
|       this.options.show = v | ||||
|       this.entity.show = v | ||||
|       let sdkD = get2DSdk().sdkD | ||||
|       if (!this.isShowView || !sdkD) { | ||||
|         this.options.show = v | ||||
|       } | ||||
|       if (!this.showView || this.showView == 3 || !sdkD) { | ||||
|         this.entity.show = this.options.show  | ||||
|         if (this.options.label.show) { | ||||
|           this.label.show = this.options.show  | ||||
|         } | ||||
|       } | ||||
|       else { | ||||
|         this.entity.show = false | ||||
|         if (this.options.label.show) { | ||||
|           this.label.show = false | ||||
|         } | ||||
|       } | ||||
|  | ||||
|       this.isShowView = false | ||||
|        | ||||
|       syncData(this.sdk, this.options.id) | ||||
|       syncSplitData(this.sdk, this.options.id) | ||||
|       if (this._DialogObject && this._DialogObject.showBtn) { | ||||
|         this._DialogObject.showBtn.checked = v | ||||
|       } | ||||
|       if (this.options.label.show) { | ||||
|         this.label.show = v | ||||
|       } | ||||
|        | ||||
|     } else { | ||||
|       console.error("参数必须为boolean") | ||||
|     } | ||||
| @ -362,6 +377,7 @@ class CircleDiffuse extends Base { | ||||
|     return this.options.circle | ||||
|   } | ||||
|   set circle(v) { | ||||
|     console.log(v) | ||||
|     this.options.circle = v || [{ radius: 10 }] | ||||
|     for (let i = 0; i < this.options.circle.length; i++) { | ||||
|       if(this.options.circle[i].radius>999999) { | ||||
| @ -427,8 +443,9 @@ class CircleDiffuse extends Base { | ||||
|     return this.options.label.show | ||||
|   } | ||||
|   set labelShow(v) { | ||||
|     let sdkD = get2DSdk().sdkD | ||||
|     this.options.label.show = v | ||||
|     if (this.show) { | ||||
|     if (this.show && (!this.showView || this.showView == 3 || !sdkD)) { | ||||
|       this.label.show = v | ||||
|     } | ||||
|     else { | ||||
| @ -1321,7 +1338,7 @@ class CircleDiffuse extends Base { | ||||
|   } | ||||
|  | ||||
|   async remove() { | ||||
|     this.label.remove() | ||||
|     this.label && this.label.remove() | ||||
|     this.entity && this.sdk.viewer.entities.remove(this.entity) | ||||
|     this.entity2 && this.sdk.viewer.entities.remove(this.entity2) | ||||
|     this.entity = null | ||||
| @ -1405,7 +1422,7 @@ class CircleDiffuse extends Base { | ||||
|                   } | ||||
|                 } | ||||
|                 this._radius = radius | ||||
|                 inputElm.value = value | ||||
|                 // inputElm.value = value | ||||
|                 CircleDiffuse.create(this) | ||||
|               } | ||||
|             } | ||||
|  | ||||
| @ -45,7 +45,7 @@ class CircleObject extends Base { | ||||
|     this.options.center = options.center || {} | ||||
|     this.options.line = options.line || {} | ||||
|     this.options.line.width = ((this.options.line.width || this.options.line.width === 0) ? this.options.line.width : 3) | ||||
|     this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 0.5)' | ||||
|     this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 1)' | ||||
|     this.options['area-unit'] = options['area-unit'] || '平方米' | ||||
|     options.label = options.label || {} | ||||
|     this._elms = {}; | ||||
| @ -333,7 +333,7 @@ class CircleObject extends Base { | ||||
|   } | ||||
|   set labelShow(v) { | ||||
|     this.options.label.show = v | ||||
|     if (this.show) { | ||||
|     if (this.show && (!this.showView || this.showView == 3)) { | ||||
|       this.label.show = v | ||||
|     } | ||||
|     else { | ||||
|  | ||||
| @ -1,7 +1,7 @@ | ||||
| import { attributeElm, labelStyleElm1, labelStyleElm2 } from '../../Element/elm_html' | ||||
|  | ||||
| function html(that) { | ||||
|     return ` | ||||
|   return ` | ||||
|     <span class="custom-divider"></span> | ||||
|     <div class="div-item"> | ||||
|         <div class="row" style="align-items: flex-start;"> | ||||
| @ -9,22 +9,15 @@ function html(that) { | ||||
|                 <span class="label">名称</span> | ||||
|                 <input class="input" maxlength="40" type="text" @model="name"> | ||||
|             </div> | ||||
|             <div class="col" style="flex: 0 0 54%;"> | ||||
|             <div class="col" style="flex: 0 0 56%;"> | ||||
|                 <div> | ||||
|                     <div class="row"> | ||||
|                         <div class="col input-select-unit-box"> | ||||
|                             <span class="label">原始长度:</span> | ||||
|                             <div class="input-select-unit"></div> | ||||
|                             <input class="input input-text" readonly="readonly" type="text" style="flex: 0 0 130px;" @model="length"> | ||||
|                             <div class="input-select-unit"></div> | ||||
|                         </div> | ||||
|                     </div> | ||||
|                     <div class="row"> | ||||
|                         <div class="col input-select-fit-unit-box"> | ||||
|                             <span class="label">拟合长度:</span> | ||||
|                             <input class="input input-text" readonly="readonly" type="text" style="flex: 0 0 130px;" @model="fitLength"> | ||||
|                             <div class="input-select-fit-unit"></div> | ||||
|                         </div> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
| @ -72,7 +65,7 @@ function html(that) { | ||||
|                             <span class="label">线条颜色</span> | ||||
|                             <div class="color"></div> | ||||
|                         </div> | ||||
|                         <div class="col"> | ||||
|                         <div class="col" style="flex: 0 0 33%;"> | ||||
|                             <span class="label">线条宽度</span> | ||||
|                             <div class="input-number input-number-unit-1" style="width: 80px;"> | ||||
|                                 <input class="input" type="number" title="" min="1" max="999" @model="lineWidth"> | ||||
| @ -80,7 +73,7 @@ function html(that) { | ||||
|                                 <span class="arrow"></span> | ||||
|                             </div> | ||||
|                         </div> | ||||
|                         <div class="col input-select-line-type-box"> | ||||
|                         <div class="col input-select-line-type-box" style="flex: 0 0 37%;"> | ||||
|                             <span class="label">线条形式</span> | ||||
|                             <div class="input-select-line-type"></div> | ||||
|                         </div> | ||||
| @ -90,7 +83,7 @@ function html(that) { | ||||
|                             <span class="label">线段缓冲</span> | ||||
|                             <input class="btn-switch" type="checkbox" @model="extend"> | ||||
|                         </div> | ||||
|                         <div class="col"> | ||||
|                         <div class="col" style="flex: 0 0 33%;"> | ||||
|                             <span class="label">缓冲宽度</span> | ||||
|                             <div class="input-number input-number-unit-1" style="width: 80px;"> | ||||
|                                 <input class="input" type="number" title="" min="0" data-min="0.01" max="999999" @model="extendWidth"> | ||||
| @ -98,21 +91,43 @@ function html(that) { | ||||
|                                 <span class="arrow"></span> | ||||
|                             </div> | ||||
|                         </div> | ||||
|                         <div class="col"> | ||||
|                         <div class="col" style="flex: 0 0 37%;"> | ||||
|                             <span class="label">缓冲颜色</span> | ||||
|                             <div class="extendColor"></div> | ||||
|                         </div> | ||||
|                     </div> | ||||
|                     <div class="row" id="dashTextureDom"> | ||||
|                         <div class="col"> | ||||
|                             <span class="label">动画顺向</span> | ||||
|                             <input class="btn-switch" type="checkbox" @model="rotate"> | ||||
|                         </div> | ||||
|                         <div class="col" style="flex: 0 0 33%;"> | ||||
|                             <span class="label">流动速率</span> | ||||
|                             <div class="input-number input-number-unit-1" style="width: 80px;"> | ||||
|                                 <input class="input" type="number" title="" min="0" max="999999" step="1" @model="speed"> | ||||
|                                 <span class="arrow"></span> | ||||
|                             </div> | ||||
|                         </div> | ||||
|                         <div class="col" style="flex: 0 0 37%;"> | ||||
|                               <span class="label lineSpace">间距</span> | ||||
|                               <div class="input-number input-number-unit-1 lineSpace" style="width: 80px;"> | ||||
|                                   <input class="input" type="number" title="" min="0" max="4.5" step="0.1" @model="space"> | ||||
|                                   <span class="unit">倍</span> | ||||
|                                   <span class="arrow"></span> | ||||
|                               </div> | ||||
|                         </div> | ||||
|                     </div> | ||||
|                     <div class="row"> | ||||
|                         <div class="col"> | ||||
|                             <span class="label">首尾相连</span> | ||||
|                             <input class="btn-switch" type="checkbox" @model="noseToTail"> | ||||
|                         </div> | ||||
|                         <div class="col"> | ||||
|                         <div class="col" style="flex: 0 0 33%;"> | ||||
|                         </div> | ||||
|                         <div class="col"> | ||||
|                         <div class="col" style="flex: 0 0 37%;"> | ||||
|                         </div> | ||||
|                     </div> | ||||
|  | ||||
|                 </DIV-cy-tab-pane> | ||||
|                 <DIV-cy-tab-pane label="标注风格"> | ||||
|                     ${labelStyleElm1()} | ||||
|  | ||||
| @ -11,7 +11,7 @@ import LabelObject from '../LabelObject' | ||||
| import MouseEvent from '../../../Event/index' | ||||
| import MouseTip from '../../../MouseTip' | ||||
| import Controller from '../../../Controller/index' | ||||
| import { syncData } from '../../../Global/MultiViewportMode' | ||||
| import { syncData, get3DView } from '../../../Global/MultiViewportMode' | ||||
| import { legp } from '../../Element/datalist' | ||||
| import { getFontList, getFontFamilyName } from '../../Element/fontSelect' | ||||
| import { setSplitDirection, syncSplitData, setActiveId } from '../../../Global/SplitScreen' | ||||
| @ -30,7 +30,7 @@ class CurvelineObject extends Base { | ||||
|    * @param options.heightMode{number} 高度模式(0:海拔高度;1:相对高度;2:依附模式) | ||||
|    * @param options['nose-to-tail']=false {boolean} 首尾相连 | ||||
|    * @param options.extend=false {boolean} 线缓冲 | ||||
|    * @param options['extend-width']=1 {number} 线缓冲宽度 | ||||
|    * @param options['extend-width']=10 {number} 线缓冲宽度 | ||||
|    * @param options['extend-color']=#ffde00 {number} 线缓冲颜色 | ||||
|    * @param options.show=true {boolean} 显隐 | ||||
|    * @param {Array.<object>} options.positions 坐标数组 [{lng,lat},...] | ||||
| @ -56,13 +56,18 @@ class CurvelineObject extends Base { | ||||
|     this.options.type = options.type ? Number(options.type) : 0 | ||||
|     this.options['nose-to-tail'] = options['nose-to-tail'] || false | ||||
|     this.options.extend = options.extend || false | ||||
|     this.options.rotate = options.rotate || true | ||||
|     this.options.space = options.space || 1 | ||||
|     this.options.speed = options.speed || 10 | ||||
|     this.options.dashSize = options.dashSize || 0.03 | ||||
|     this.options['length-unit'] = options['length-unit'] || '米' | ||||
|     this.options['fit-length-unit'] = options['fit-length-unit'] || '米' | ||||
|     this.options['words-name'] = options['words-name'] || '空间长度' | ||||
|     this.options['extend-width'] = | ||||
|       options['extend-width'] || options['extend-width'] === 0 | ||||
|         ? options['extend-width'] | ||||
|         : 1 | ||||
|     this.options['extend-color'] = options['extend-color'] || '#ffde00' | ||||
|         : 10 | ||||
|     this.options['extend-color'] = options['extend-color'] || 'rgba(255,255,80,0.3)' | ||||
|     this.options.show = | ||||
|       options.show || options.show === false ? options.show : true | ||||
|     this.options.heightMode = (options.heightMode || options.heightMode == 0) ? options.heightMode : 2 | ||||
| @ -116,6 +121,8 @@ class CurvelineObject extends Base { | ||||
|     this.options.attributeType = options.attributeType || 'richText' | ||||
|     this.operate = {} | ||||
|     this.nodePoints = [] | ||||
|     this.unitNum = 0 | ||||
|     this.inputSpeed = (options.speed && Math.pow(options.speed, -1) * 100) || 10 | ||||
|     this.Dialog = _Dialog | ||||
|     if (!this.options.positions || this.options.positions.length < 2) { | ||||
|       this._error = '线段最少需要两个坐标!' | ||||
| @ -144,7 +151,11 @@ class CurvelineObject extends Base { | ||||
|   } | ||||
|   set color(v) { | ||||
|     this.options.color = v || '#ff0000' | ||||
|     this.entity.polyline.material = this.getMaterial(v, this.options.type) | ||||
|     // this.entity.polyline.material = this.getMaterial(v, this.options.type) | ||||
|     let params = { ...this.options } | ||||
|     params.speed = this.inputSpeed | ||||
|     // this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, this.options) | ||||
|     this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, params) | ||||
|     if (this._elms.color) { | ||||
|       this._elms.color.forEach((item, i) => { | ||||
|         let colorPicker = new YJColorPicker({ | ||||
| @ -165,6 +176,58 @@ class CurvelineObject extends Base { | ||||
|       }) | ||||
|     } | ||||
|   } | ||||
|   get speed() { | ||||
|     return this.options.speed | ||||
|   } | ||||
|  | ||||
|   set speed(v) { | ||||
|     this.options.speed = v | ||||
|     // this.options.speed = v !== 0 ? Math.pow(v, -1) * 100 : 0 | ||||
|     this.inputSpeed = v !== 0 ? Math.pow(v, -1) * 100 : 0 | ||||
|     let params = { ...this.options } | ||||
|     params.speed = this.inputSpeed | ||||
|     // this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, this.options) | ||||
|     this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, params) | ||||
|   } | ||||
|   get dashSize() { | ||||
|     return this.options.dashSize | ||||
|   } | ||||
|  | ||||
|   set dashSize(v) { | ||||
|     this.options.dashSize = v | ||||
|     let params = { ...this.options } | ||||
|     params.speed = this.inputSpeed | ||||
|     // this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, this.options) | ||||
|     this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, params) | ||||
|   } | ||||
|  | ||||
|   get rotate() { | ||||
|     return this.options.rotate | ||||
|   } | ||||
|  | ||||
|   set rotate(v) { | ||||
|     this.options.rotate = v | ||||
|     CurvelineObject.closeNodeEdit(this) | ||||
|     this._elms.rotate && | ||||
|       this._elms.rotate.forEach(item => { | ||||
|         item.checked = v | ||||
|       }) | ||||
|  | ||||
|     this.options.rotate = v | ||||
|     this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, this.options) | ||||
|   } | ||||
|  | ||||
|   get space() { | ||||
|     return this.options.space | ||||
|   } | ||||
|  | ||||
|   set space(v) { | ||||
|     this.options.space = v | ||||
|     let params = { ...this.options } | ||||
|     params.speed = this.inputSpeed | ||||
|     // this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, this.options) | ||||
|     this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, params) | ||||
|   } | ||||
|  | ||||
|   get length() { | ||||
|     return this.options.length | ||||
| @ -172,6 +235,8 @@ class CurvelineObject extends Base { | ||||
|  | ||||
|   set length(v) { | ||||
|     this.options.length = v | ||||
|     //判断数值是否大于1000m | ||||
|  | ||||
|     this._elms.length && | ||||
|       this._elms.length.forEach(item => { | ||||
|         item.value = v | ||||
| @ -194,25 +259,60 @@ class CurvelineObject extends Base { | ||||
|     return this.options['length-unit'] | ||||
|   } | ||||
|   set lengthUnit(v) { | ||||
|     this.unitNum++ | ||||
|     this.options['length-unit'] = v | ||||
|     this._elms.lengthUnit && | ||||
|       this._elms.lengthUnit.forEach(item => { | ||||
|         item.value = v | ||||
|       }) | ||||
|     if (this.options.lengthByMeter) { | ||||
|       switch (v) { | ||||
|         case '米': | ||||
|           this.length = this.options.lengthByMeter | ||||
|           break | ||||
|         case '千米': | ||||
|           this.length = (this.options.lengthByMeter / 1000).toFixed(5) | ||||
|           break | ||||
|         default: | ||||
|           this.length = this.options.lengthByMeter | ||||
|       if (this.unitNum > 2) { | ||||
|         switch (v) { | ||||
|           case '米': | ||||
|             this.length = this.noseToTail ? this.options.fitLengthByMeter : this.options.lengthByMeter | ||||
|  | ||||
|             break | ||||
|           case '千米': | ||||
|             this.length = this.noseToTail ? (this.options.fitLengthByMeter / 1000).toFixed(5) : (this.options.lengthByMeter / 1000).toFixed(5) | ||||
|  | ||||
|             break | ||||
|           default: | ||||
|             this.length = this.noseToTail ? this.options.fitLengthByMeter : this.options.lengthByMeter | ||||
|  | ||||
|             break | ||||
|         } | ||||
|       } else { | ||||
|         let length = this.noseToTail ? this.options.fitLengthByMeter : this.options.lengthByMeter | ||||
|         this.lengthUnit = length > 1000 || length == 1000 ? '千米' : '米' | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   get wordsName() { | ||||
|     return this.options['words-name'] | ||||
|   } | ||||
|   set wordsName(v) { | ||||
|     this.options['words-name'] = v | ||||
|     this._elms.wordsName && | ||||
|       this._elms.wordsName.forEach(item => { | ||||
|         item.value = v | ||||
|       }) | ||||
|  | ||||
|     let _this = this | ||||
|     if (!this.noseToTail) { | ||||
|       this.computeDistance( | ||||
|         this.smoothHandle(this.options.positions), | ||||
|         2, | ||||
|         v | ||||
|       ).then(res => { | ||||
|         _this.options.lengthByMeter = res | ||||
|         _this.lengthUnit = this.options['length-unit'] | ||||
|       }) | ||||
|     } else { | ||||
|       let fromDegreesArray = this.renewPositions(this.options.positions) | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   get fitLengthUnit() { | ||||
|     return this.options['fit-length-unit'] | ||||
|   } | ||||
| @ -248,9 +348,10 @@ class CurvelineObject extends Base { | ||||
|       this._elms.lineWidth.forEach(item => { | ||||
|         item.value = this.options.width | ||||
|       }) | ||||
|     this.entity && | ||||
|       this.entity.polyline && | ||||
|       (this.entity.polyline.width = this.options.width) | ||||
|     if (this.entity && this.entity.polyline) { | ||||
|       this.entity.polyline.width = this.entity.polyline.width + v - this.entity.polyline.oriWidth | ||||
|       this.entity.polyline.oriWidth = this.options.width | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   get lineType() { | ||||
| @ -260,19 +361,82 @@ class CurvelineObject extends Base { | ||||
|   set lineType(v) { | ||||
|     let lineTypeData = [ | ||||
|       { | ||||
|         name: '实线', | ||||
|         name: '<i class="icon line"></i>实线', | ||||
|         value: '实线', | ||||
|         key: 0 | ||||
|         key: 0, | ||||
|         icon: 'line' | ||||
|       }, | ||||
|       { | ||||
|         name: '虚线', | ||||
|         name: '<i class="icon dash-line"></i>虚线', | ||||
|         value: '虚线', | ||||
|         key: 1 | ||||
|         key: 1, | ||||
|         icon: 'dash-line' | ||||
|       }, | ||||
|       { | ||||
|         name: '泛光', | ||||
|         name: '<i class="icon light-line"></i>泛光', | ||||
|         value: '泛光', | ||||
|         key: 2 | ||||
|         key: 2, | ||||
|         icon: 'light-line' | ||||
|       }, | ||||
|       { | ||||
|         name: '<i class="icon tail-line"></i>尾迹光线', | ||||
|         value: '尾迹光线', | ||||
|         key: 3, | ||||
|         icon: 'tail-line' | ||||
|       }, | ||||
|       { | ||||
|         name: '<i class="icon mult-tail-line"></i>多尾迹光线', | ||||
|         value: '多尾迹光线', | ||||
|         key: 4, | ||||
|         icon: 'mult-tail-line' | ||||
|       }, | ||||
|       { | ||||
|         name: '<i class="icon flow-dash-line1"></i>流动虚线1', | ||||
|         value: '流动虚线1', | ||||
|         key: 5, | ||||
|         icon: 'flow-dash-line1' | ||||
|       }, | ||||
|       { | ||||
|         name: '<i class="icon flow-dash-line2"></i>流动虚线2', | ||||
|         value: '流动虚线2', | ||||
|         key: 6, | ||||
|         icon: 'flow-dash-line2' | ||||
|       }, | ||||
|       { | ||||
|         name: '<i class="icon pic-line1"></i>流动箭头1', | ||||
|         value: '流动箭头1', | ||||
|         key: 7, | ||||
|         icon: 'pic-line1' | ||||
|       }, | ||||
|       { | ||||
|         name: '<i class="icon pic-line2"></i>流动箭头2', | ||||
|         value: '流动箭头2', | ||||
|         key: 8, | ||||
|         icon: 'pic-line2' | ||||
|       }, | ||||
|       { | ||||
|         name: '<i class="icon pic-line3"></i>流动箭头3', | ||||
|         value: '流动箭头3', | ||||
|         key: 9, | ||||
|         icon: 'pic-line3' | ||||
|       }, | ||||
|       { | ||||
|         name: '<i class="icon pic-line4"></i>流动箭头4', | ||||
|         value: '流动箭头4', | ||||
|         key: 10, | ||||
|         icon: 'pic-line4' | ||||
|       }, | ||||
|       { | ||||
|         name: '<i class="icon pic-line5"></i>流动箭头5', | ||||
|         value: '流动箭头5', | ||||
|         key: 11, | ||||
|         icon: 'pic-line5' | ||||
|       }, | ||||
|       { | ||||
|         name: '<i class="icon pic-line6"></i>流动箭头6', | ||||
|         value: '流动箭头6', | ||||
|         key: 12, | ||||
|         icon: 'pic-line6' | ||||
|       } | ||||
|     ] | ||||
|     this.options.type = Number(v) | ||||
| @ -281,15 +445,31 @@ class CurvelineObject extends Base { | ||||
|         this._elms.lineType && | ||||
|           this._elms.lineType.forEach(item => { | ||||
|             item.value = lineTypeData[i].value | ||||
|             if (2 < item.value && item.value < 13) {//贴图参数 | ||||
|               document.getElementById('dashTextureDom') && (document.getElementById('dashTextureDom').style.display = 'flex') | ||||
|             } else { | ||||
|               document.getElementById('dashTextureDom') && (document.getElementById('dashTextureDom').style.display = 'none') | ||||
|             } | ||||
|             if (2 < item.value && item.value < 5) {//尾迹参数 | ||||
|               document.getElementsByClassName('lineSpace')[0] && (document.getElementsByClassName('lineSpace')[0].style.display = 'none') | ||||
|               document.getElementsByClassName('lineSpace')[1] && (document.getElementsByClassName('lineSpace')[1].style.display = 'none') | ||||
|             } else { | ||||
|               document.getElementsByClassName('lineSpace')[0] && (document.getElementsByClassName('lineSpace')[0].style.display = 'flex') | ||||
|               document.getElementsByClassName('lineSpace')[1] && (document.getElementsByClassName('lineSpace')[1].style.display = 'flex') | ||||
|             } | ||||
|           }) | ||||
|         break | ||||
|       } | ||||
|     } | ||||
|     let params = { ...this.options } | ||||
|     params.speed = this.inputSpeed | ||||
|     this.entity && | ||||
|       this.entity.polyline && | ||||
|       (this.entity.polyline.material = this.getMaterial( | ||||
|         this.options.color, | ||||
|         this.options.type | ||||
|         this.options.type, | ||||
|         this.entity, | ||||
|         params | ||||
|       )) | ||||
|   } | ||||
|   get noseToTail() { | ||||
| @ -310,8 +490,28 @@ class CurvelineObject extends Base { | ||||
|       ) | ||||
|       this.renewPolygon(fromDegreesArray) | ||||
|     } | ||||
|     this.lengthUnit = this.options['length-unit'] | ||||
|     // if (v) { | ||||
|     //   if (this.options.fitLengthByMeter > 1000 || this.options.fitLengthByMeter == 1000) { | ||||
|     //     let dom = document.getElementsByClassName('input-select-unit')[1] | ||||
|     //     dom && dom.querySelectorAll('dd')[1] && dom.querySelectorAll('dd')[1].click() | ||||
|     //   } else { | ||||
|     //     let dom = document.getElementsByClassName('input-select-unit')[1] | ||||
|     //     dom && dom.querySelectorAll('dd')[0] && dom.querySelectorAll('dd')[0].click() | ||||
|     //   } | ||||
|  | ||||
|     // } else { | ||||
|     //   if (this.options.lengthByMeter > 1000 || this.options.lengthByMeter == 1000) { | ||||
|     //     let dom = document.getElementsByClassName('input-select-unit')[1] | ||||
|     //     dom && dom.querySelectorAll('dd')[1] && dom.querySelectorAll('dd')[1].click() | ||||
|     //   } else { | ||||
|     //     let dom = document.getElementsByClassName('input-select-unit')[1] | ||||
|     //     dom && dom.querySelectorAll('dd')[0] && dom.querySelectorAll('dd')[0].click() | ||||
|     //   } | ||||
|     // } | ||||
|   } | ||||
|  | ||||
|  | ||||
|   get heightMode() { | ||||
|     return this.options.heightMode ? this.options.heightMode : 0 | ||||
|   } | ||||
| @ -349,11 +549,11 @@ class CurvelineObject extends Base { | ||||
|         break | ||||
|     } | ||||
|  | ||||
|     this.options.lengthByMeter = this.computeDistance2( | ||||
|       this.smoothHandle(this.options.positions), | ||||
|       2, | ||||
|       ground | ||||
|     ) | ||||
|     // this.options.lengthByMeter = this.computeDistance2( | ||||
|     //   this.smoothHandle(this.options.positions), | ||||
|     //   2, | ||||
|     //   ground | ||||
|     // ) | ||||
|     this.lengthUnit = this.lengthUnit | ||||
|     this._elms.heightMode && (this._elms.heightMode.value = heightModeName) | ||||
|     this._elms.heightModeObject && (this._elms.heightModeObject.legp_searchActive( | ||||
| @ -467,7 +667,7 @@ class CurvelineObject extends Base { | ||||
|   } | ||||
|   set labelShow(v) { | ||||
|     this.options.label.show = v | ||||
|     if (this.show) { | ||||
|     if (this.show && !this.showView || this.showView == 3) { | ||||
|       this.label.show = v | ||||
|       setTimeout(() => { | ||||
|         this.label.position = [ | ||||
| @ -1149,17 +1349,43 @@ class CurvelineObject extends Base { | ||||
|         positions: Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray), | ||||
|         width: that.options.width, | ||||
|         clampToGround: ground, | ||||
|         material: that.getMaterial(that.options.color, that.options.type), | ||||
|         // material: that.getMaterial(that.options.color, that.options.type), | ||||
|         zIndex: that.sdk._entityZIndex | ||||
|       } | ||||
|     }) | ||||
|  | ||||
|     that.entity.polyline.oriWidth = that.options.width | ||||
|     that.judgeLine(that.entity, that.options) | ||||
|  | ||||
|     let params = { ...that.options } | ||||
|     params.speed = that.inputSpeed | ||||
|     that.entity.polyline.material = that.getMaterial( | ||||
|       that.options.color, | ||||
|       that.options.type, | ||||
|       that.entity, | ||||
|       params | ||||
|     ) | ||||
|  | ||||
|     that.sdk._entityZIndex++ | ||||
|     CurvelineObject.createLabel(that) | ||||
|     // that.entity.polyline.positionsLngLat = positions | ||||
|     that.renewPolygon(fromDegreesArray) | ||||
|     that.options.lengthByMeter = that.computeDistance2(that.smoothHandle(positions), 2, ground) | ||||
|     that.lengthUnit = that.options['length-unit'] | ||||
|     syncData(that.sdk, that.options.id) | ||||
|     // that.options.lengthByMeter = that.computeDistance2(that.smoothHandle(positions), 2, ground) | ||||
|     // that.lengthUnit = that.options['length-unit'] | ||||
|     // syncData(that.sdk, that.options.id) | ||||
|     // if (that.options.show) { | ||||
|     //   setSplitDirection(0, that.options.id) | ||||
|     // } | ||||
|  | ||||
|     that.computeDistance( | ||||
|       that.smoothHandle(positions), | ||||
|       2, | ||||
|       that.options['words-name'] | ||||
|     ).then(res => { | ||||
|       that.options.lengthByMeter = res | ||||
|       that.lengthUnit = that.options['length-unit'] | ||||
|       syncData(that.sdk, that.options.id) | ||||
|     }) | ||||
|     if (that.options.show) { | ||||
|       setSplitDirection(0, that.options.id) | ||||
|     } | ||||
| @ -1180,7 +1406,130 @@ class CurvelineObject extends Base { | ||||
|  | ||||
|     let scene = that.sdk.viewer.scene | ||||
|   } | ||||
|   judgeLine(entity, newParam) { | ||||
|     if (!entity.polyline.oriRepeat) { | ||||
|       let param = { | ||||
|         color: newParam.color, | ||||
|         image: this.getSourceRootPath() + `/img/arrow/1.png`, | ||||
|         space: newParam.space, | ||||
|         speed: newParam.speed | ||||
|       } | ||||
|  | ||||
|       param.speed = newParam.rotate ? param.speed : 0 - param.speed | ||||
|  | ||||
|       const canvasEle = document.createElement('canvas'); | ||||
|       const ctx = canvasEle.getContext('2d') | ||||
|       const myImg = new Image() | ||||
|       // myImg.src = that.getSourceRootPath() + '/img/arrow/1.png' | ||||
|       myImg.src = param.image | ||||
|       let that = this | ||||
|       myImg.onload = function () { | ||||
|         canvasEle.width = myImg.width * (param.space + 1) | ||||
|         canvasEle.height = myImg.height | ||||
|  | ||||
|         let oriRepeat = that.getSceenLine(entity, param, canvasEle) | ||||
|         oriRepeat && (entity.polyline.oriRepeat = oriRepeat) | ||||
|  | ||||
|  | ||||
|         var positionProperty = entity.polyline.positions; | ||||
|         var positions = positionProperty.getValue(that.sdk.viewer.clock.currentTime); | ||||
|  | ||||
|         if (!Cesium.defined(positions)) { | ||||
|           return new Cesium.Cartesian2(1.0, 1.0); | ||||
|           // return 1.0; | ||||
|         } | ||||
|  | ||||
|         var distance = 0; | ||||
|         for (var i = 0; i < positions.length - 1; ++i) { | ||||
|           distance += Cesium.Cartesian3.distance(positions[i], positions[i + 1]); | ||||
|         } | ||||
|  | ||||
|         var repeatX = distance / entity.polyline.width.getValue(); | ||||
|         // 根据地图缩放程度调整repeatX | ||||
|         var cameraHeight = that.sdk.viewer.camera.positionCartographic.height; | ||||
|         var boundingSphere = new Cesium.BoundingSphere( | ||||
|           new Cesium.Cartesian3(-1000000, 0, 0), // 中心点坐标 | ||||
|           500000 // 半径(距离) | ||||
|         ); | ||||
|  | ||||
|         // 获取绘图缓冲区的宽度和高度(通常是屏幕的分辨率) | ||||
|         var drawingBufferWidth = that.sdk.viewer.canvas.clientWidth; | ||||
|         var drawingBufferHeight = that.sdk.viewer.canvas.clientHeight; | ||||
|  | ||||
|         // 使用 getPixelSize 方法获取包围球在屏幕上的像素大小 | ||||
|         var groundResolution = that.sdk.viewer.scene.camera.getPixelSize(boundingSphere, drawingBufferWidth, drawingBufferHeight) | ||||
|         repeatX *= groundResolution / cameraHeight / (param.space * (canvasEle.width / canvasEle.height * 5) + 1); | ||||
|         // if (entity.polyline.material.oriRepeat) { | ||||
|  | ||||
|         if (that.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE3D) { | ||||
|           let speed = repeatX / entity.polyline.oriRepeat | ||||
|           entity.polyline.oriSpeed = speed | ||||
|           entity.polyline.oriRepeatX = repeatX | ||||
|         } else { | ||||
|           let sdk3d = get3DView() | ||||
|           let sdk3dEntity = sdk3d.viewer.entities.getById(that.options.id) | ||||
|           entity.polyline.oriSpeed = sdk3dEntity.polyline.oriSpeed | ||||
|           entity.polyline.oriRepeatX = sdk3dEntity.polyline.oriRepeatX | ||||
|         } | ||||
|       } | ||||
|  | ||||
|     } | ||||
|   } | ||||
|   /**获取当前满屏横线速度 */ | ||||
|   getSceenLine(entity, options, canvasEle) { | ||||
|     let point1 = new Cesium.Cartesian2(0, this.sdk.viewer.canvas.clientHeight) | ||||
|     let point2 = new Cesium.Cartesian2(this.sdk.viewer.canvas.clientWidth / 2, this.sdk.viewer.canvas.clientHeight) | ||||
|     // var cartesian1 = this.sdk.viewer.scene.pickPosition(point1) | ||||
|     // var cartesian2 = this.sdk.viewer.scene.pickPosition(point2) | ||||
|  | ||||
|     let ray = this.sdk.viewer.camera.getPickRay(point1); | ||||
|     let cartesian1 = this.sdk.viewer.scene.globe.pick(ray, this.sdk.viewer.scene); | ||||
|  | ||||
|     let ray2 = this.sdk.viewer.camera.getPickRay(point2); | ||||
|     let cartesian2 = this.sdk.viewer.scene.globe.pick(ray2, this.sdk.viewer.scene); | ||||
|     // if (!cartesian1 || !cartesian2) { | ||||
|     //   let ray = this.sdk.viewer.camera.getPickRay(point1); | ||||
|     //   cartesian1 = this.sdk.viewer.scene.globe.pick(ray, this.sdk.viewer.scene); | ||||
|  | ||||
|     //   let ray2 = this.sdk.viewer.camera.getPickRay(point2); | ||||
|     //   cartesian2 = this.sdk.viewer.scene.globe.pick(ray2, this.sdk.viewer.scene); | ||||
|     // } | ||||
|     if (cartesian1 && cartesian2) { | ||||
|  | ||||
|  | ||||
|       var distance = Cesium.Cartesian3.distance(cartesian1, cartesian2); | ||||
|  | ||||
|       var repeatX = distance / entity.polyline.width.getValue(); | ||||
|       // 根据地图缩放程度调整repeatX | ||||
|       var cameraHeight = this.sdk.viewer.camera.positionCartographic.height; | ||||
|       var boundingSphere = new Cesium.BoundingSphere( | ||||
|         new Cesium.Cartesian3(-1000000, 0, 0), // 中心点坐标 | ||||
|         500000 // 半径(距离) | ||||
|       ); | ||||
|  | ||||
|  | ||||
|       // 获取绘图缓冲区的宽度和高度(通常是屏幕的分辨率) | ||||
|       var drawingBufferWidth = this.sdk.viewer.canvas.clientWidth; | ||||
|       var drawingBufferHeight = this.sdk.viewer.canvas.clientHeight; | ||||
|  | ||||
|       // 使用 getPixelSize 方法获取包围球在屏幕上的像素大小 | ||||
|       var groundResolution = this.sdk.viewer.scene.camera.getPixelSize(boundingSphere, drawingBufferWidth, drawingBufferHeight) | ||||
|       // repeatX *= groundResolution / cameraHeight / ((myImg.width / myImg.height * 5) + 1); | ||||
|       if (groundResolution > 700) { | ||||
|         repeatX *= groundResolution / cameraHeight / (options.space * (canvasEle.width / canvasEle.height * 5) + 1); | ||||
|       } else { | ||||
|         repeatX = undefined; | ||||
|       } | ||||
|  | ||||
|       if (this.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE3D) { | ||||
|         return repeatX | ||||
|       } else { | ||||
|         let sdk3d = get3DView() | ||||
|         let sdk3dEntity = sdk3d.viewer.entities.getById(this.options.id) | ||||
|         return sdk3dEntity.polyline.oriRepeatX | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|   /** | ||||
|    * 编辑框 | ||||
|    * @param {boolean} state true打开,false关闭 | ||||
| @ -1255,6 +1604,15 @@ class CurvelineObject extends Base { | ||||
|       this.attributeType = this.options.attributeType | ||||
|       // this.attributeCamera = this.options.attribute.camera.content | ||||
|       // this.attributeGoods = this.options.attribute.goods.content | ||||
|       function tabClick(e) { | ||||
|         if (e === '2' || e === 2) {//点击线条样式 | ||||
|           if (2 < _this.options.type && _this.options.type < 13) {//贴图参数 | ||||
|             document.getElementById('dashTextureDom') && (document.getElementById('dashTextureDom').style.display = 'flex') | ||||
|           } else { | ||||
|             document.getElementById('dashTextureDom') && (document.getElementById('dashTextureDom').style.display = 'none') | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|  | ||||
|       // 创建标签页 | ||||
|       let tabsElm = new cy_tabs( | ||||
| @ -1389,6 +1747,50 @@ class CurvelineObject extends Base { | ||||
|           }) | ||||
|         } | ||||
|  | ||||
|         let nameData = [ | ||||
|           { | ||||
|             name: '空间长度', | ||||
|             value: '空间长度' | ||||
|           }, | ||||
|           { | ||||
|             name: '投影长度', | ||||
|             value: '投影长度' | ||||
|           }, | ||||
|           { | ||||
|             name: '地表长度', | ||||
|             value: '地表长度' | ||||
|           } | ||||
|         ] | ||||
|  | ||||
|         let nameDataLegpObject = legp( | ||||
|           this._DialogObject._element.content.getElementsByClassName( | ||||
|             'input-select-unit-box' | ||||
|           )[0], | ||||
|           '.input-select-unit' | ||||
|         ) | ||||
|         if (nameDataLegpObject) { | ||||
|           nameDataLegpObject.legp_search(nameData) | ||||
|           let nameDataLegpElm = this._DialogObject._element.content | ||||
|             .getElementsByClassName('input-select-unit')[0] | ||||
|             .getElementsByTagName('input')[0] | ||||
|           this._elms.wordsName = [nameDataLegpElm] | ||||
|           nameDataLegpElm.value = this.options['words-name'] | ||||
|           for (let i = 0; i < nameData.length; i++) { | ||||
|             if (nameData[i].value === nameDataLegpElm.value) { | ||||
|               nameDataLegpObject.legp_searchActive(nameData[i].value) | ||||
|               break | ||||
|             } | ||||
|           } | ||||
|           nameDataLegpElm.addEventListener('input', () => { | ||||
|             for (let i = 0; i < nameData.length; i++) { | ||||
|               if (nameData[i].value === nameDataLegpElm.value) { | ||||
|                 this.wordsName = nameData[i].value | ||||
|                 break | ||||
|               } | ||||
|             } | ||||
|           }) | ||||
|         } | ||||
|  | ||||
|         // 原始长度单位 | ||||
|         let unitData = [ | ||||
|           { | ||||
| @ -1405,12 +1807,13 @@ class CurvelineObject extends Base { | ||||
|           this._DialogObject._element.content.getElementsByClassName( | ||||
|             'input-select-unit-box' | ||||
|           )[0], | ||||
|           '.input-select-unit' | ||||
|           '.input-select-unit', | ||||
|           1 | ||||
|         ) | ||||
|         if (unitDataLegpObject) { | ||||
|           unitDataLegpObject.legp_search(unitData) | ||||
|           let unitDataLegpElm = this._DialogObject._element.content | ||||
|             .getElementsByClassName('input-select-unit')[0] | ||||
|             .getElementsByClassName('input-select-unit')[1] | ||||
|             .getElementsByTagName('input')[0] | ||||
|           this._elms.lengthUnit = [unitDataLegpElm] | ||||
|           unitDataLegpElm.value = this.options['length-unit'] | ||||
| @ -1431,61 +1834,124 @@ class CurvelineObject extends Base { | ||||
|         } | ||||
|  | ||||
|         // 拟合长度单位 | ||||
|         let fitUnitData = [ | ||||
|           { | ||||
|             name: '米', | ||||
|             value: '米' | ||||
|           }, | ||||
|           { | ||||
|             name: '千米', | ||||
|             value: '千米' | ||||
|           } | ||||
|         ] | ||||
|         // let fitUnitData = [ | ||||
|         //   { | ||||
|         //     name: '米', | ||||
|         //     value: '米' | ||||
|         //   }, | ||||
|         //   { | ||||
|         //     name: '千米', | ||||
|         //     value: '千米' | ||||
|         //   } | ||||
|         // ] | ||||
|  | ||||
|         let fitUnitDataLegpObject = legp( | ||||
|           this._DialogObject._element.content.getElementsByClassName( | ||||
|             'input-select-fit-unit-box' | ||||
|           )[0], | ||||
|           '.input-select-fit-unit' | ||||
|         ) | ||||
|         if (fitUnitDataLegpObject) { | ||||
|           fitUnitDataLegpObject.legp_search(fitUnitData) | ||||
|           let fitUnitDataLegpElm = this._DialogObject._element.content | ||||
|             .getElementsByClassName('input-select-fit-unit')[0] | ||||
|             .getElementsByTagName('input')[0] | ||||
|           this._elms.fitLengthUnit = [fitUnitDataLegpElm] | ||||
|           fitUnitDataLegpElm.value = this.options['fit-length-unit'] | ||||
|           for (let i = 0; i < fitUnitData.length; i++) { | ||||
|             if (fitUnitData[i].value === fitUnitDataLegpElm.value) { | ||||
|               fitUnitDataLegpObject.legp_searchActive(fitUnitData[i].value) | ||||
|               break | ||||
|             } | ||||
|           } | ||||
|           fitUnitDataLegpElm.addEventListener('input', () => { | ||||
|             for (let i = 0; i < fitUnitData.length; i++) { | ||||
|               if (fitUnitData[i].value === fitUnitDataLegpElm.value) { | ||||
|                 this.fitLengthUnit = fitUnitData[i].value | ||||
|                 break | ||||
|               } | ||||
|             } | ||||
|           }) | ||||
|         } | ||||
|         // let fitUnitDataLegpObject = legp( | ||||
|         //   this._DialogObject._element.content.getElementsByClassName( | ||||
|         //     'input-select-fit-unit-box' | ||||
|         //   )[0], | ||||
|         //   '.input-select-fit-unit' | ||||
|         // ) | ||||
|         // if (fitUnitDataLegpObject) { | ||||
|         //   fitUnitDataLegpObject.legp_search(fitUnitData) | ||||
|         //   let fitUnitDataLegpElm = this._DialogObject._element.content | ||||
|         //     .getElementsByClassName('input-select-fit-unit')[0] | ||||
|         //     .getElementsByTagName('input')[0] | ||||
|         //   this._elms.fitLengthUnit = [fitUnitDataLegpElm] | ||||
|         //   fitUnitDataLegpElm.value = this.options['fit-length-unit'] | ||||
|         //   for (let i = 0; i < fitUnitData.length; i++) { | ||||
|         //     if (fitUnitData[i].value === fitUnitDataLegpElm.value) { | ||||
|         //       fitUnitDataLegpObject.legp_searchActive(fitUnitData[i].value) | ||||
|         //       break | ||||
|         //     } | ||||
|         //   } | ||||
|         //   fitUnitDataLegpElm.addEventListener('input', () => { | ||||
|         //     for (let i = 0; i < fitUnitData.length; i++) { | ||||
|         //       if (fitUnitData[i].value === fitUnitDataLegpElm.value) { | ||||
|         //         this.fitLengthUnit = fitUnitData[i].value | ||||
|         //         break | ||||
|         //       } | ||||
|         //     } | ||||
|         //   }) | ||||
|         // } | ||||
|  | ||||
|         let lineTypeData = [ | ||||
|           { | ||||
|             name: '实线', | ||||
|             name: '<i class="icon line"></i>实线', | ||||
|             value: '实线', | ||||
|             key: 0 | ||||
|             key: 0, | ||||
|             icon: 'line' | ||||
|           }, | ||||
|           { | ||||
|             name: '虚线', | ||||
|             name: '<i class="icon dash-line"></i>虚线', | ||||
|             value: '虚线', | ||||
|             key: 1 | ||||
|             key: 1, | ||||
|             icon: 'dash-line' | ||||
|           }, | ||||
|           { | ||||
|             name: '泛光', | ||||
|             name: '<i class="icon light-line"></i>泛光', | ||||
|             value: '泛光', | ||||
|             key: 2 | ||||
|             key: 2, | ||||
|             icon: 'light-line' | ||||
|           }, | ||||
|           { | ||||
|             name: '<i class="icon tail-line"></i>尾迹光线', | ||||
|             value: '尾迹光线', | ||||
|             key: 3, | ||||
|             icon: 'tail-line' | ||||
|           }, | ||||
|           { | ||||
|             name: '<i class="icon mult-tail-line"></i>多尾迹光线', | ||||
|             value: '多尾迹光线', | ||||
|             key: 4, | ||||
|             icon: 'mult-tail-line' | ||||
|           }, | ||||
|           { | ||||
|             name: '<i class="icon flow-dash-line1"></i>流动虚线1', | ||||
|             value: '流动虚线1', | ||||
|             key: 5, | ||||
|             icon: 'flow-dash-line1' | ||||
|           }, | ||||
|           { | ||||
|             name: '<i class="icon flow-dash-line2"></i>流动虚线2', | ||||
|             value: '流动虚线2', | ||||
|             key: 6, | ||||
|             icon: 'flow-dash-line2' | ||||
|           }, | ||||
|           { | ||||
|             name: '<i class="icon pic-line1"></i>流动箭头1', | ||||
|             value: '流动箭头1', | ||||
|             key: 7, | ||||
|             icon: 'pic-line1' | ||||
|           }, | ||||
|           { | ||||
|             name: '<i class="icon pic-line2"></i>流动箭头2', | ||||
|             value: '流动箭头2', | ||||
|             key: 8, | ||||
|             icon: 'pic-line2' | ||||
|           }, | ||||
|           { | ||||
|             name: '<i class="icon pic-line3"></i>流动箭头3', | ||||
|             value: '流动箭头3', | ||||
|             key: 9, | ||||
|             icon: 'pic-line3' | ||||
|           }, | ||||
|           { | ||||
|             name: '<i class="icon pic-line4"></i>流动箭头4', | ||||
|             value: '流动箭头4', | ||||
|             key: 10, | ||||
|             icon: 'pic-line4' | ||||
|           }, | ||||
|           { | ||||
|             name: '<i class="icon pic-line5"></i>流动箭头5', | ||||
|             value: '流动箭头5', | ||||
|             key: 11, | ||||
|             icon: 'pic-line5' | ||||
|           }, | ||||
|           { | ||||
|             name: '<i class="icon pic-line6"></i>流动箭头6', | ||||
|             value: '流动箭头6', | ||||
|             key: 12, | ||||
|             icon: 'pic-line6' | ||||
|           } | ||||
|         ] | ||||
|         let lineTypeDataLegpObject = legp( | ||||
| @ -1496,6 +1962,11 @@ class CurvelineObject extends Base { | ||||
|         ) | ||||
|         if (lineTypeDataLegpObject) { | ||||
|           lineTypeDataLegpObject.legp_search(lineTypeData) | ||||
|  | ||||
|           let iActiveElm2 = document.createElement('i') | ||||
|           iActiveElm2.className = 'icon icon-active' | ||||
|           this._DialogObject._element.content.getElementsByClassName('input-select-line-type')[0].getElementsByClassName('cy_datalist')[0].appendChild(iActiveElm2) | ||||
|  | ||||
|           let lineTypeDataLegpElm = this._DialogObject._element.content | ||||
|             .getElementsByClassName('input-select-line-type')[0] | ||||
|             .getElementsByTagName('input')[0] | ||||
| @ -1504,6 +1975,7 @@ class CurvelineObject extends Base { | ||||
|             if (lineTypeData[i].key === this.options.type) { | ||||
|               lineTypeDataLegpObject.legp_searchActive(lineTypeData[i].value) | ||||
|               lineTypeDataLegpElm.value = lineTypeData[i].value | ||||
|               iActiveElm2.className = `icon icon-active ${lineTypeData[i].icon}` | ||||
|               break | ||||
|             } | ||||
|           } | ||||
| @ -1511,6 +1983,21 @@ class CurvelineObject extends Base { | ||||
|             for (let i = 0; i < lineTypeData.length; i++) { | ||||
|               if (lineTypeData[i].value === lineTypeDataLegpElm.value) { | ||||
|                 this.lineType = lineTypeData[i].key | ||||
|                 iActiveElm2.className = `icon icon-active ${lineTypeData[i].icon}` | ||||
|  | ||||
|                 //控制参数显隐 | ||||
|                 if (2 < this.lineType && this.lineType < 13) {//贴图参数 | ||||
|                   document.getElementById('dashTextureDom') && (document.getElementById('dashTextureDom').style.display = 'flex') | ||||
|                 } else { | ||||
|                   document.getElementById('dashTextureDom') && (document.getElementById('dashTextureDom').style.display = 'none') | ||||
|                 } | ||||
|                 if (2 < this.lineType && this.lineType < 5) {//尾迹参数 | ||||
|                   document.getElementsByClassName('lineSpace')[0] && (document.getElementsByClassName('lineSpace')[0].style.display = 'none') | ||||
|                   document.getElementsByClassName('lineSpace')[1] && (document.getElementsByClassName('lineSpace')[1].style.display = 'none') | ||||
|                 } else { | ||||
|                   document.getElementsByClassName('lineSpace')[0] && (document.getElementsByClassName('lineSpace')[0].style.display = 'flex') | ||||
|                   document.getElementsByClassName('lineSpace')[1] && (document.getElementsByClassName('lineSpace')[1].style.display = 'flex') | ||||
|                 } | ||||
|                 break | ||||
|               } | ||||
|             } | ||||
| @ -1848,22 +2335,74 @@ class CurvelineObject extends Base { | ||||
|  | ||||
|  | ||||
|     // 计算长度 | ||||
|     let array = [] | ||||
|     for (let i = 0; i < fromDegreesArray.length; i += 3) { | ||||
|       array.push({ | ||||
|         lng: fromDegreesArray[i], | ||||
|         lat: fromDegreesArray[i + 1], | ||||
|         alt: fromDegreesArray[i + 2] | ||||
|     // let array = [] | ||||
|     // for (let i = 0; i < fromDegreesArray.length; i += 3) { | ||||
|     //   array.push({ | ||||
|     //     lng: fromDegreesArray[i], | ||||
|     //     lat: fromDegreesArray[i + 1], | ||||
|     //     alt: fromDegreesArray[i + 2] | ||||
|     //   }) | ||||
|     // } | ||||
|     // this.options.fitLengthByMeter = this.computeDistance2( | ||||
|     //   array, | ||||
|     //   2, | ||||
|     //   ground | ||||
|     // ) | ||||
|     // this.fitLengthUnit = this.options['fit-length-unit'] | ||||
|     // this.options.lengthByMeter = this.computeDistance2(this.smoothHandle(positions), 2, ground) | ||||
|     // this.lengthUnit = this.options['length-unit'] | ||||
|  | ||||
|  | ||||
|     if ( | ||||
|       (this.options['nose-to-tail'] && | ||||
|         this.options['nose-to-tail'] !== 'false') || | ||||
|       (this.options.smooth && this.options.smooth !== 'false') | ||||
|     ) { | ||||
|       let array = [] | ||||
|       for (let i = 0; i < fromDegreesArray.length; i += 3) { | ||||
|         array.push({ | ||||
|           lng: fromDegreesArray[i], | ||||
|           lat: fromDegreesArray[i + 1], | ||||
|           alt: fromDegreesArray[i + 2] | ||||
|         }) | ||||
|       } | ||||
|       // this.options.fitLengthByMeter = this.computeDistance( | ||||
|       //   array, | ||||
|       //   2, | ||||
|       //   ground | ||||
|       // ) | ||||
|       let _this = this | ||||
|       this.computeDistance( | ||||
|         array, | ||||
|         2, | ||||
|         this.options['words-name'] | ||||
|       ).then(res => { | ||||
|         _this.options.fitLengthByMeter = res | ||||
|         _this.lengthUnit = _this.options['length-unit'] | ||||
|       }) | ||||
|     } else { | ||||
|       let _this = this | ||||
|       this.computeDistance( | ||||
|         _this.smoothHandle(positions), | ||||
|         2, | ||||
|         this.options['words-name'] | ||||
|       ).then(res => { | ||||
|         _this.options.fitLengthByMeter = res | ||||
|         _this.lengthUnit = _this.options['length-unit'] | ||||
|  | ||||
|       }) | ||||
|     } | ||||
|     this.options.fitLengthByMeter = this.computeDistance2( | ||||
|       array, | ||||
|  | ||||
|     let _this = this | ||||
|     this.computeDistance( | ||||
|       this.smoothHandle(positions), | ||||
|       2, | ||||
|       ground | ||||
|     ) | ||||
|     this.fitLengthUnit = this.options['fit-length-unit'] | ||||
|     this.options.lengthByMeter = this.computeDistance2(this.smoothHandle(positions), 2, ground) | ||||
|     this.lengthUnit = this.options['length-unit'] | ||||
|       this.options['words-name'] | ||||
|     ).then(res => { | ||||
|       _this.options.lengthByMeter = res | ||||
|       _this.lengthUnit = this.options['length-unit'] | ||||
|     }) | ||||
|  | ||||
|     return fromDegreesArray | ||||
|   } | ||||
|  | ||||
| @ -1942,6 +2481,10 @@ class CurvelineObject extends Base { | ||||
|     this.attributeVr = this.options.attribute.vr.content | ||||
|     this.attributeCamera = this.options.attribute.camera.content | ||||
|     this.attributeGoods = this.options.attribute.goods.content | ||||
|     this.rotate = this.originalOptions.rotate | ||||
|     this.speed = this.originalOptions.speed | ||||
|     this.dashSize = this.originalOptions.dashSize | ||||
|     this.space = this.originalOptions.space | ||||
|     this.cameraSelect && this.cameraSelect() | ||||
|     this.goodsSelect && this.goodsSelect() | ||||
|  | ||||
| @ -2035,7 +2578,7 @@ class CurvelineObject extends Base { | ||||
|       )[0].value | ||||
|     ) { | ||||
|       this.options.attribute.vr.content.push({ | ||||
|         name: '全景图' , | ||||
|         name: '全景图', | ||||
|         url: this._DialogObject._element.content.getElementsByClassName( | ||||
|           'vr_add' | ||||
|         )[0].value | ||||
| @ -2051,7 +2594,7 @@ class CurvelineObject extends Base { | ||||
|  | ||||
|   addAttributeRr(vr) { | ||||
|     this.options.attribute.vr.content.push({ | ||||
|       name: '全景图' , | ||||
|       name: '全景图', | ||||
|       url: vr | ||||
|     }) | ||||
|     this.attributeVr = this.options.attribute.vr.content | ||||
|  | ||||
| @ -24,7 +24,7 @@ class EllipseObject extends Base { | ||||
|    * @param options.name {string} 名称 | ||||
|    * @param options.show=true {boolean} 显示/隐藏 | ||||
|    * @param options.center {object} 位置 | ||||
|    * @param options.color="#ff000080" {string} 颜色 | ||||
|    * @param options.color="rgba(255, 0, 0, 0.5)" {string} 颜色 | ||||
|    * @param options.center.lng {object} 经度 | ||||
|    * @param options.center.lat {object} 维度 | ||||
|    * @param options.semiMinorAxis=10 {number} 短半轴长度 | ||||
| @ -32,14 +32,14 @@ class EllipseObject extends Base { | ||||
|    * @param options.bearing=0 {number} 旋转角度 | ||||
|    * @param options.line {object} 边框 | ||||
|    * @param options.line.width=2 {string} 边框宽 | ||||
|    * @param options.line.color="#ff000080" {string} 边框颜色 | ||||
|    * @param options.line.color="rgba(255, 0, 0, 1)" {string} 边框颜色 | ||||
|    * @param options.label {object} 标注 | ||||
|    * @param options.heightMode=2{number} 高度模式(0:海拔高度;1:相对地表;2:依附模式) | ||||
|    */ | ||||
|   constructor(sdk, options = {}) { | ||||
|     super(sdk, options); | ||||
|     this.options.name = options.name || '未命名对象' | ||||
|     this.options.color = options.color || "#ff000080" | ||||
|     this.options.color = options.color || "rgba(255, 0, 0, 0.5)" | ||||
|     this.options.heightMode = (options.heightMode || options.heightMode == 0) ? options.heightMode : 2 | ||||
|     this.options.semiMinorAxis = (options.semiMinorAxis || options.semiMinorAxis === 0) ? options.semiMinorAxis : 10 | ||||
|     this.options.semiMajorAxis = (options.semiMajorAxis || options.semiMajorAxis === 0) ? options.semiMajorAxis : 20 | ||||
| @ -47,7 +47,7 @@ class EllipseObject extends Base { | ||||
|     this.options.center = options.center || {} | ||||
|     this.options.line = options.line || {} | ||||
|     this.options.line.width = ((this.options.line.width || this.options.line.width === 0) ? this.options.line.width : 3) | ||||
|     this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 0.5)' | ||||
|     this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 1)' | ||||
|     this.options['area-unit'] = options['area-unit'] || '平方米' | ||||
|     options.label = options.label || {} | ||||
|     this._elms = {}; | ||||
| @ -347,7 +347,7 @@ class EllipseObject extends Base { | ||||
|   } | ||||
|   set labelShow(v) { | ||||
|     this.options.label.show = v | ||||
|     if (this.show) { | ||||
|     if (this.show && !this.showView || this.showView == 3) { | ||||
|       this.label.show = v | ||||
|     } | ||||
|     else { | ||||
|  | ||||
| @ -139,6 +139,7 @@ class FlowLine extends Base { | ||||
|       //创建线 | ||||
|       that.viewer.entities.add({ | ||||
|         parent: celiangEntity, | ||||
|         id: that.options.id + '-' + new Date().getTime() + index, | ||||
|         polyline: { | ||||
|           positions: [start, end], | ||||
|           width: that.options.width, | ||||
| @ -215,6 +216,17 @@ class FlowLine extends Base { | ||||
|       this.getLine(this, this.positions) | ||||
|     } | ||||
|   } | ||||
|   get show() { | ||||
|     return this.options.show | ||||
|   } | ||||
|  | ||||
|   set show(v) { | ||||
|     this.options.show = v | ||||
|     let entity = this.viewer.entities.getById(this.options.id) | ||||
|     if (entity) { | ||||
|       entity.show = v | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   get heightDifference() { | ||||
|     return this.options.heightDifference | ||||
| @ -303,9 +315,9 @@ class FlowLine extends Base { | ||||
|           this.reset() | ||||
|           this.Dialog.resetCallBack && this.Dialog.resetCallBack() | ||||
|         }, | ||||
|         // removeCallBack: () => { | ||||
|         //   this.Dialog.removeCallBack && this.Dialog.removeCallBack() | ||||
|         // }, | ||||
|         removeCallBack: () => { | ||||
|           this.Dialog.removeCallBack && this.Dialog.removeCallBack() | ||||
|         }, | ||||
|         closeCallBack: () => { | ||||
|           this.reset() | ||||
|           // this.entity.style = new Cesium.Cesium3DTileStyle({ | ||||
|  | ||||
| @ -162,6 +162,7 @@ class FlyRoam extends Base { | ||||
|           pitch: viewer.camera.pitch, | ||||
|           roll: viewer.camera.roll | ||||
|         } | ||||
|         this.message({text: '操作成功'}) | ||||
|       }) | ||||
|  | ||||
|       let totalTimeElm = contentElm.querySelector("input[name='totalTime']") | ||||
|  | ||||
| @ -8,6 +8,8 @@ | ||||
| import { getHost, getToken } from "../../../on"; | ||||
| import Base from '../index' | ||||
| import Tools from '../../../Tools' | ||||
| import { syncSplitData } from "../../../Global/SplitScreen"; | ||||
| import { syncData, getSdk as get2DSdk } from '../../../Global/MultiViewportMode' | ||||
| import { setActiveViewer, closeRotateAround, closeViewFollow} from '../../../Global/global' | ||||
|  | ||||
| class GeoJson extends Base { | ||||
| @ -26,6 +28,7 @@ class GeoJson extends Base { | ||||
|  | ||||
|     this.primitive = undefined | ||||
|     this.positions = [] | ||||
|      | ||||
|  | ||||
|     this.loading = true | ||||
|   } | ||||
| @ -48,6 +51,27 @@ class GeoJson extends Base { | ||||
|     return this.options.show | ||||
|   } | ||||
|  | ||||
|   // set show(status) { | ||||
|   //   let sdkD = get2DSdk().sdkD | ||||
|   //   if (!this.isShowView || !sdkD) { | ||||
|   //     this.options.show = status | ||||
|   //   } | ||||
|   //   if (this.entity) { | ||||
|   //     if (!this.showView || this.showView == 3 || !sdkD) { | ||||
|   //       for (let i = 0; i < this.entity.entities.values.length; i++) { | ||||
|   //         this.entity.entities.values[i].show = this.options.show | ||||
|   //       } | ||||
|   //     } | ||||
|   //     else { | ||||
|   //       for (let i = 0; i < this.entity.entities.values.length; i++) { | ||||
|   //         this.entity.entities.values[i].show = false | ||||
|   //       } | ||||
|   //     } | ||||
|   //   } | ||||
|   //   syncData(this.sdk, this.options.id) | ||||
|   //   syncSplitData(this.sdk, this.options.id) | ||||
|   //   this.isShowView = false | ||||
|   // } | ||||
|   set show(status) { | ||||
|     this.options.show = status | ||||
|     if (this.entity) { | ||||
| @ -74,6 +98,7 @@ class GeoJson extends Base { | ||||
|     }) | ||||
|     let json = await rsp.json() | ||||
|     this.geojson = json | ||||
|     // this.sdk.addIncetance(this.options.id, this) | ||||
|     return GeoJson.addDataToGlobe(this, json.features) | ||||
|   } | ||||
|  | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| function html() { | ||||
|   return ` | ||||
|     return ` | ||||
|   <span class="custom-divider"></span> | ||||
|   <div class="div-item"> | ||||
|     <div class="row"> | ||||
| @ -7,13 +7,21 @@ function html() { | ||||
|             <span class="label">名称</span> | ||||
|             <input class="input" maxlength="40" type="text" @model="name"> | ||||
|         </div> | ||||
|         <div class="col"> | ||||
|         </div> | ||||
|         <div class="col"></div> | ||||
|     </div> | ||||
|   </div> | ||||
|   <span class="custom-divider"></span> | ||||
|   <div class="div-item"> | ||||
|     <div class="row"> | ||||
|         <div class="col"> | ||||
|             <button class="anchor btn">调整锚点</button> | ||||
|         </div> | ||||
|         <div class="col mode-box"> | ||||
|             <span class="label" style="flex: unset;">军标模式</span> | ||||
|             <div class="mode"></div> | ||||
|         </div> | ||||
|     </div> | ||||
|     <div class="row" mode="0"> | ||||
|         <div class="col"> | ||||
|             <span class="label">旋转角度</span> | ||||
|             <input type="range" max="360" min="0" step="0.1" @model="angle"> | ||||
| @ -24,16 +32,85 @@ function html() { | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
|     <div class="row"> | ||||
|     <div class="row" mode="0"> | ||||
|         <div class="col"> | ||||
|             <span class="label">调整大小</span> | ||||
|             <input type="range" max="99999" min="0" step="0.1" @model="scale"> | ||||
|             <input type="range" max="40000" min="0" step="0.1" @model="scale"> | ||||
|             <div class="input-number input-number-unit-1" style="width: 100px;flex: 0 0 100px;margin-left: 10px;"> | ||||
|                 <input class="input" type="number" title="" min="0" max="99999" step="0.1" @model="scale"> | ||||
|                 <input class="input" type="number" title="" min="0" max="40000" step="0.1" @model="scale"> | ||||
|                 <span class="arrow"></span> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
|         <div class="row" mode="1"> | ||||
|             <div class="col height-mode-box" style="flex: 0 0 155px;margin-right: 10px;"> | ||||
|                 <span class="label" style="flex: 0 0 56px;">高度模式</span> | ||||
|                 <div class="height-mode"></div> | ||||
|             </div> | ||||
|             <div class="col" style="margin: 0 10px;"> | ||||
|                 <div class="height-box" style="display: flex; align-items: center;"> | ||||
|                     <span class="label" style="flex: 0 0 56px;">高度</span> | ||||
|                     <div class="input-number input-number-unit-1"> | ||||
|                         <input class="input height" type="number" title="" min="-9999999" max="999999999"> | ||||
|                         <span class="unit">m</span> | ||||
|                         <span class="arrow"></span> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </div> | ||||
|             <div class="col" style="margin-left: 10px;"> | ||||
|                 <span class="label">图标倍数</span> | ||||
|                 <div class="input-number input-number-unit-1"> | ||||
|                     <input class="input" type="number" title="" data-min="0.1" max="99" @model="billboardScale"> | ||||
|                     <span class="unit">倍</span> | ||||
|                     <span class="arrow"></span> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|         <div class="row" mode="1"> | ||||
|             <div class="col" style="flex: 0 0 155px;margin-right: 10px;"> | ||||
|                 <span class="label">视野缩放</span> | ||||
|                 <input class="btn-switch" type="checkbox" @model="billboardScaleByDistance"> | ||||
|             </div> | ||||
|             <div class="col" style="margin: 0 10px;"> | ||||
|                 <span class="label">最近距离</span> | ||||
|                 <div class="input-number input-number-unit-1"> | ||||
|                     <input class="input" type="number" title="" min="1" max="99999999" @model="billboardNear"> | ||||
|                     <span class="unit">m</span> | ||||
|                     <span class="arrow"></span> | ||||
|                 </div> | ||||
|             </div> | ||||
|             <div class="col" style="margin-left: 10px;"> | ||||
|                 <span class="label">最远距离</span> | ||||
|                 <div class="input-number input-number-unit-1"> | ||||
|                     <input class="input" type="number" title="" min="1" max="99999999" @model="billboardFar"> | ||||
|                     <span class="unit">m</span> | ||||
|                     <span class="arrow"></span> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|                 <h4 mode="1">文字设置</h4> | ||||
|                     <div class="row"  mode="1"> | ||||
|                         <div class="col" style="flex: 0 0 80px;margin: 0 10px;"> | ||||
|                             <span class="label" style="flex: none;">显隐</span> | ||||
|                             <input class="btn-switch" type="checkbox" @model="labelShow"> | ||||
|                         </div> | ||||
|                         <div class="col font-select-box" style="margin: 0 0px;flex: 0 0 150px;"> | ||||
|                             <span class="label" style="flex: none;">字体选择</span> | ||||
|                             <div class="input input-select font-select"></div> | ||||
|                         </div> | ||||
|                         <div class="col" style="margin: 0 10px;"> | ||||
|                             <span class="label">文字大小</span> | ||||
|                             <div class="input-number input-number-unit-2"> | ||||
|                                 <input class="input" type="number" title="" min="1" max="99" @model="labelFontSize" style="width: 70px;"> | ||||
|                                 <span class="unit">px</span> | ||||
|                                 <span class="arrow"></span> | ||||
|                             </div> | ||||
|                         </div> | ||||
|                         <div class="col" style="margin-left: 10px;"> | ||||
|                             <span class="label">文字颜色</span> | ||||
|                             <div class="labelColor"></div> | ||||
|                         </div> | ||||
|                     </div> | ||||
|   </div> | ||||
|   <span class="custom-divider"></span> | ||||
|   ` | ||||
|  | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -54,7 +54,7 @@ function html(that) { | ||||
|         <div class="row"> | ||||
|             <div class="col" style="flex: 5;"> | ||||
|                 <span class="label">文字内容</span> | ||||
|                 <input class="input" type="text" @model="textValue"> | ||||
|                 <input class="input" type="text" @model="textValue" maxlength="30"> | ||||
|             </div> | ||||
|             <div class="col"> | ||||
|                 <button class="btn" @click="textPosPick">设置位置</span> | ||||
|  | ||||
| @ -10,6 +10,7 @@ import { FontLoader } from '../../../../static/3rdparty/three/jsm/loaders/FontLo | ||||
| import { TextGeometry } from '../../../../static/3rdparty/three/jsm/geometries/TextGeometry.js'; | ||||
| import * as variable from '../../../../static/3rdparty/three/fonts/FZZongYi-M05S_regular.typeface.json' | ||||
| import Base from "../index"; | ||||
| import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../Global/global' | ||||
| import { setSplitDirection, syncSplitData, setActiveId } from '../../../Global/SplitScreen' | ||||
|  | ||||
| class GroundSvg extends Base { | ||||
| @ -108,12 +109,18 @@ class GroundSvg extends Base { | ||||
|     this._isdrag = false | ||||
|     this._EventBinding = new EventBinding() | ||||
|  | ||||
|     if(this.sdk.entityMap.get(this.options.id)) { | ||||
|       return | ||||
|     } | ||||
|     this.sdk.addIncetance(this.options.id, this) | ||||
|     this.picking = true | ||||
|  | ||||
|      | ||||
|     if (this.options.show) { | ||||
|       setSplitDirection(0, this.options.id) | ||||
|     } | ||||
|  | ||||
|     this._entityArray = [] | ||||
|      | ||||
|     this.init() | ||||
|   } | ||||
| @ -153,12 +160,18 @@ class GroundSvg extends Base { | ||||
|  | ||||
|   set show(v) { | ||||
|     if (typeof v === "boolean") { | ||||
|       super.show = v | ||||
|       if (this.options.text && this.options.text.show && this.text) { | ||||
|         this.text.show = v | ||||
|       if (this.options.text && this.options.text.show) { | ||||
|         if(this.text) { | ||||
|           if((!this.showView || this.showView == 3)) { | ||||
|             this.text.show = v | ||||
|           } | ||||
|           else { | ||||
|             this.text.show = false | ||||
|           } | ||||
|         } | ||||
|          | ||||
|       } | ||||
|       syncData(this.sdk, this.options.id) | ||||
|       syncSplitData(this.sdk, this.options.id) | ||||
|       super.show = v | ||||
|     } else { | ||||
|       console.error("参数必须为boolean") | ||||
|     } | ||||
| @ -304,7 +317,12 @@ class GroundSvg extends Base { | ||||
|   set textShow(v) { | ||||
|     this.options.text.show = v | ||||
|     if (this.show) { | ||||
|       this.text && (this.text.show = v) | ||||
|       if((!this.showView || this.showView == 3)) { | ||||
|         this.text && (this.text.show = v) | ||||
|       } | ||||
|       else { | ||||
|         this.text && (this.text.show = false) | ||||
|       } | ||||
|       if (this.options.text.position) { | ||||
|         setTimeout(() => { | ||||
|           if (this.options.text.position.alt) { | ||||
| @ -358,7 +376,10 @@ class GroundSvg extends Base { | ||||
|   } | ||||
|   set textFontSize(v) { | ||||
|     this.options.text.fontSize = v | ||||
|     this.text && (this.text.fontSize = v) | ||||
|     if(this.text) { | ||||
|       this.text.fontSize = v | ||||
|       this.text.pixelOffset = v | ||||
|     } | ||||
|     this._elms.textFontSize && this._elms.textFontSize.forEach((item) => { | ||||
|       item.value = v | ||||
|     }) | ||||
| @ -820,8 +841,13 @@ class GroundSvg extends Base { | ||||
|         } | ||||
|         for (let i = 0; i < this.hierarchys.length; i++) { | ||||
|           for (let m = 0; m < this.hierarchys[i].length; m++) { | ||||
|             let id = this.options.id + `-${i}_${m}}` | ||||
|             let oldEntity = this.sdk.viewer.entities.getById(id) | ||||
|             if(oldEntity) { | ||||
|               this.sdk.viewer.entities.remove(oldEntity) | ||||
|             } | ||||
|             let entity = this.sdk.viewer.entities.add({ | ||||
|               id: this.options.id + `-${i}_${m}`, | ||||
|               id: this.options.id + `-${i}_${m}}`, | ||||
|               show: this.options.show, | ||||
|               polygon: { | ||||
|                 hierarchy: new Cesium.CallbackProperty(() => { | ||||
| @ -854,6 +880,7 @@ class GroundSvg extends Base { | ||||
|                 color: this.geojson.features[i].properties.color | ||||
|               } | ||||
|             } | ||||
|             this._entityArray.push(entity) | ||||
|             this.entity.add(entity) | ||||
|           } | ||||
|         } | ||||
| @ -885,11 +912,10 @@ class GroundSvg extends Base { | ||||
|         text: that.options.text.value, | ||||
|         fontSize: that.options.text.fontSize, | ||||
|         color: that.options.text.color, | ||||
|         pixelOffset: that.options.text.pixelOffset, | ||||
|         pixelOffset: that.options.text.fontSize, | ||||
|         backgroundColor: that.options.text.backgroundColor, | ||||
|         lineColor: that.options.text.lineColor, | ||||
|         lineWidth: that.options.text.lineWidth, | ||||
|         pixelOffset: 0, | ||||
|         lineColor: '#ffffff00', | ||||
|         lineWidth: 0, | ||||
|         scaleByDistance: that.options.text.scaleByDistance, | ||||
|         backgroundColor: ['#ffffff00', '#ffffff00'], | ||||
|         near: that.options.text.near, | ||||
| @ -1189,9 +1215,12 @@ class GroundSvg extends Base { | ||||
|   * @param {boolean} status=false 状态 | ||||
|   */ | ||||
|   drag(status, cd) { | ||||
|     if (!this.#loaded) { | ||||
|     if (!this.#loaded || !this.sdk || !this.sdk.viewer || !this.entity || !this.entity.values || this.entity.values.length == 0) { | ||||
|       return | ||||
|     } | ||||
|     let greenImg = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAA+0lEQVR4AZSTPQ7CMAyFk0jAFYCRCbgEbHAKBqRyKCoYOAVs5RLAQseKKxQkwntWVCltJdzK+bO/59ZW6kztGX6mi/F7dhiV0ydWzxH2B8ZquIkSAN47bzNAW2vtBKtY2G8ZIyPOMFUJxuX8DF+C8c+SwAonCSSr9SvxaCawogHrQl2aNwOPLKHWoa5N5O5woNZ575cdNBFKrQsdjgLaA7XSRK2gjWMJeVtA40MJOUvgxdHwDQYlZO5r/akRUTqoda/e4wo+xehqKbXSxKJ/3xlvL+oMYEUDgSTAaorBbY1V8yVpYIGb+G9kVtTFi3Vkh4XAFPZHxsjAVdkPAAD//0PYov0AAAAGSURBVAMA5pZjby819WUAAAAASUVORK5CYII=' | ||||
|     let redImg = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAA1klEQVR4AZST0Q2CQBBEF0qhEfjDKvgwwaIk+kEV8oeFSCs4D4+gB4l7ZIfszc7OLXDkFl2zWSnchJcwB5DDlZHcfgwkvkowCmehENYghxuDZuU3AxUeYlvhX7RBu+iWCUSwc70wvlsdeixXwnN5do6tmaRkgiauJKwbDKqEhlhaYcAbjgvedYGBV3yow2A6rPjICQMOjk++V40Y9HvezfR5ZvaUvBNSo6OXCUzJRd2D4I0h9Gz/goiTuj2TsDNayW0zYJWZMQkH667199chh6uCRuVPvAEAAP//mBlPPAAAAAZJREFUAwAzdy+JgzpBHQAAAABJRU5ErkJggg==' | ||||
|     let yellowImg = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAA8ElEQVR4AZyQMY7CQAxFbbe7W7IH2GrJJaCDU1AgwaFAUHAK6OASQAM9UAJtzLxRBikUKMwo1jjf//0oNnk518t/534uZtdTcbidC6fooxZmL3apBdwv7Ym6rV1kqCp/yUwftTDDk3TuZ0D40tJdR4jvCg/e5IkBVWoviQ3uXsWI8c+kNoBqFhhYM7dBbfLBC6yVLl3JPLDGhjN5gY1LzA2AM3c50uQUrJnKWjIPrJVaLjJ5gbWf1n6j6tNPQ2Bg4xK/WrtxCFiFavqsKkZiANT377ZPKv27woM3eZ4BCKS6ll0VmbNhNIo+amGGBy3VAwAA//9///lSAAAABklEQVQDAADzbcvdBag1AAAAAElFTkSuQmCC' | ||||
|     this.ismove = false | ||||
|     this._isdrag = status | ||||
|     if (this.ScreenSpaceEventHandler) { | ||||
| @ -1256,6 +1285,9 @@ class GroundSvg extends Base { | ||||
|           // 中心点到鼠标的距离 | ||||
|           let distance = turf.rhumbDistance(pointC, point2, options); | ||||
|  | ||||
|           let flag = false | ||||
|           let flag2 = false | ||||
|  | ||||
|           switch (this.pickPoint.id) { | ||||
|             case 'svg-control-points_0': | ||||
|               angle = bearing2_0 - bearing1 | ||||
| @ -1267,22 +1299,72 @@ class GroundSvg extends Base { | ||||
|               bearingH = (((turf.rhumbBearing(pointC, turf.point(controlPoints[2])) + 360) - this.angle) % 360) | ||||
|               angleW = bearing2 - bearingW | ||||
|               angleH = bearing2 - bearingH | ||||
|  | ||||
|               if ((angleW > -360 && angleW < -90) || (angleW < 360 && angleW > 90)) { | ||||
|                 angleW = angleW + 180 | ||||
|                 flag = true | ||||
|               } | ||||
|               if ((angleH > -360 && angleH < -90) || (angleH < 360 && angleH > 90)) { | ||||
|                 angleH = angleH + 180 | ||||
|                 flag2 = true | ||||
|               } | ||||
|  | ||||
|                | ||||
|               radiansW = (Math.PI / 180) * angleW | ||||
|               radiansH = (Math.PI / 180) * angleH | ||||
|               // 矩形高度 | ||||
|               w = (Math.cos(radiansW) * distance) * 2 | ||||
|               h = (Math.cos(radiansH) * distance) * 2 | ||||
|  | ||||
|               if(h<0) { | ||||
|                 flag2 = !flag2 | ||||
|               } | ||||
|               if(w<0) { | ||||
|                 flag = !flag | ||||
|               } | ||||
|               if (flag && flag2) { | ||||
|                 // this.pointEntityCollection.values[1].point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|                 // this.pointEntityCollection.values[3].point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|                 // this.pointEntityCollection.values[7].point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|                 // this.pointEntityCollection.values[9].point.color = Cesium.Color.fromCssColorString('#ff0000') | ||||
|                 this.pointEntityCollection.values[1].billboard.image = greenImg | ||||
|                 this.pointEntityCollection.values[3].billboard.image = greenImg | ||||
|                 this.pointEntityCollection.values[7].billboard.image = greenImg | ||||
|                 this.pointEntityCollection.values[9].billboard.image = redImg | ||||
|               } | ||||
|               else { | ||||
|                 if (flag) { | ||||
|                   // this.pointEntityCollection.values[1].point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|                   // this.pointEntityCollection.values[3].point.color = Cesium.Color.fromCssColorString('#ff0000') | ||||
|                   // this.pointEntityCollection.values[7].point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|                   // this.pointEntityCollection.values[9].point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|                   this.pointEntityCollection.values[1].billboard.image = greenImg | ||||
|                   this.pointEntityCollection.values[3].billboard.image = redImg | ||||
|                   this.pointEntityCollection.values[7].billboard.image = greenImg | ||||
|                   this.pointEntityCollection.values[9].billboard.image = greenImg | ||||
|                 } | ||||
|                 else if (flag2) { | ||||
|                   // this.pointEntityCollection.values[1].point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|                   // this.pointEntityCollection.values[3].point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|                   // this.pointEntityCollection.values[7].point.color = Cesium.Color.fromCssColorString('#ff0000') | ||||
|                   // this.pointEntityCollection.values[9].point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|                   this.pointEntityCollection.values[1].billboard.image = greenImg | ||||
|                   this.pointEntityCollection.values[3].billboard.image = greenImg | ||||
|                   this.pointEntityCollection.values[7].billboard.image = redImg | ||||
|                   this.pointEntityCollection.values[9].billboard.image = greenImg | ||||
|                 } | ||||
|                 else { | ||||
|                   // this.pointEntityCollection.values[1].point.color = Cesium.Color.fromCssColorString('#ff0000') | ||||
|                   // this.pointEntityCollection.values[3].point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|                   // this.pointEntityCollection.values[7].point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|                   // this.pointEntityCollection.values[9].point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|                   this.pointEntityCollection.values[1].billboard.image = redImg | ||||
|                   this.pointEntityCollection.values[3].billboard.image = greenImg | ||||
|                   this.pointEntityCollection.values[7].billboard.image = greenImg | ||||
|                   this.pointEntityCollection.values[9].billboard.image = greenImg | ||||
|                 } | ||||
|               } | ||||
|               // scaleY值 | ||||
|               this.scale.x = w / 3.5 | ||||
|               this.scale.y = h / 3.5 | ||||
|               this.scale.x = Math.abs(w) / 3.5 | ||||
|               this.scale.y = Math.abs(h) / 3.5 | ||||
|               break | ||||
|             case 'svg-control-points_2': | ||||
|             case 'svg-control-points_8': | ||||
| @ -1291,6 +1373,16 @@ class GroundSvg extends Base { | ||||
|  | ||||
|               if ((angleH > -360 && angleH < -90) || (angleH < 360 && angleH > 90)) { | ||||
|                 angleH = angleH + 180 | ||||
|                 // this.pointEntityCollection.values[2].point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|                 // this.pointEntityCollection.values[8].point.color = Cesium.Color.fromCssColorString('#ff0000') | ||||
|                 this.pointEntityCollection.values[2].billboard.image = greenImg | ||||
|                 this.pointEntityCollection.values[8].billboard.image = redImg | ||||
|               } | ||||
|               else { | ||||
|                 // this.pointEntityCollection.values[2].point.color = Cesium.Color.fromCssColorString('#ff0000') | ||||
|                 // this.pointEntityCollection.values[8].point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|                 this.pointEntityCollection.values[2].billboard.image = redImg | ||||
|                 this.pointEntityCollection.values[8].billboard.image = greenImg | ||||
|               } | ||||
|  | ||||
|               radiansH = (Math.PI / 180) * angleH | ||||
| @ -1308,9 +1400,11 @@ class GroundSvg extends Base { | ||||
|  | ||||
|               if ((angleW > -360 && angleW < -90) || (angleW < 360 && angleW > 90)) { | ||||
|                 angleW = angleW + 180 | ||||
|                 flag = true | ||||
|               } | ||||
|               if ((angleH > -360 && angleH < -90) || (angleH < 360 && angleH > 90)) { | ||||
|                 angleH = angleH + 180 | ||||
|                 flag2 = true | ||||
|               } | ||||
|  | ||||
|               radiansW = (Math.PI / 180) * angleW | ||||
| @ -1318,9 +1412,59 @@ class GroundSvg extends Base { | ||||
|               // 矩形高度 | ||||
|               w = (Math.cos(radiansW) * distance) * 2 | ||||
|               h = (Math.cos(radiansH) * distance) * 2 | ||||
|  | ||||
|               if(h<0) { | ||||
|                 flag2 = !flag2 | ||||
|               } | ||||
|               if(w<0) { | ||||
|                 flag = !flag | ||||
|               } | ||||
|  | ||||
|               if (flag && flag2) { | ||||
|                 // this.pointEntityCollection.values[1].point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|                 // this.pointEntityCollection.values[3].point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|                 // this.pointEntityCollection.values[7].point.color = Cesium.Color.fromCssColorString('#ff0000') | ||||
|                 // this.pointEntityCollection.values[9].point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|                 this.pointEntityCollection.values[1].billboard.image = greenImg | ||||
|                 this.pointEntityCollection.values[3].billboard.image = greenImg | ||||
|                 this.pointEntityCollection.values[7].billboard.image = redImg | ||||
|                 this.pointEntityCollection.values[9].billboard.image = greenImg | ||||
|               } | ||||
|               else { | ||||
|                 if (flag) { | ||||
|                   // this.pointEntityCollection.values[1].point.color = Cesium.Color.fromCssColorString('#ff0000') | ||||
|                   // this.pointEntityCollection.values[3].point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|                   // this.pointEntityCollection.values[7].point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|                   // this.pointEntityCollection.values[9].point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|                   this.pointEntityCollection.values[1].billboard.image = redImg | ||||
|                   this.pointEntityCollection.values[3].billboard.image = greenImg | ||||
|                   this.pointEntityCollection.values[7].billboard.image = greenImg | ||||
|                   this.pointEntityCollection.values[9].billboard.image = greenImg | ||||
|                 } | ||||
|                 else if (flag2) { | ||||
|                   // this.pointEntityCollection.values[1].point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|                   // this.pointEntityCollection.values[3].point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|                   // this.pointEntityCollection.values[7].point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|                   // this.pointEntityCollection.values[9].point.color = Cesium.Color.fromCssColorString('#ff0000') | ||||
|                   this.pointEntityCollection.values[1].billboard.image = greenImg | ||||
|                   this.pointEntityCollection.values[3].billboard.image = greenImg | ||||
|                   this.pointEntityCollection.values[7].billboard.image = greenImg | ||||
|                   this.pointEntityCollection.values[9].billboard.image = redImg | ||||
|                 } | ||||
|                 else { | ||||
|                   // this.pointEntityCollection.values[1].point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|                   // this.pointEntityCollection.values[3].point.color = Cesium.Color.fromCssColorString('#ff0000') | ||||
|                   // this.pointEntityCollection.values[7].point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|                   // this.pointEntityCollection.values[9].point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|                   this.pointEntityCollection.values[1].billboard.image = greenImg | ||||
|                   this.pointEntityCollection.values[3].billboard.image = redImg | ||||
|                   this.pointEntityCollection.values[7].billboard.image = greenImg | ||||
|                   this.pointEntityCollection.values[9].billboard.image = greenImg | ||||
|                 } | ||||
|               } | ||||
|               // scaleY值 | ||||
|               this.scale.x = w / 3.5 | ||||
|               this.scale.y = h / 3.5 | ||||
|               this.scale.x = Math.abs(w) / 3.5 | ||||
|               this.scale.y = Math.abs(h) / 3.5 | ||||
|               break | ||||
|             case 'svg-control-points_4': | ||||
|               bearingW = (((turf.rhumbBearing(pointC, turf.point(controlPoints[4])) + 360) - this.angle) % 360) | ||||
| @ -1328,6 +1472,16 @@ class GroundSvg extends Base { | ||||
|  | ||||
|               if ((angleW > -360 && angleW < -90) || (angleW < 360 && angleW > 90)) { | ||||
|                 angleW = angleW + 180 | ||||
|                 // this.pointEntityCollection.values[4].point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|                 // this.pointEntityCollection.values[6].point.color = Cesium.Color.fromCssColorString('#ff0000') | ||||
|                 this.pointEntityCollection.values[4].billboard.image = greenImg | ||||
|                 this.pointEntityCollection.values[6].billboard.image = redImg | ||||
|               } | ||||
|               else { | ||||
|                 // this.pointEntityCollection.values[6].point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|                 // this.pointEntityCollection.values[4].point.color = Cesium.Color.fromCssColorString('#ff0000') | ||||
|                 this.pointEntityCollection.values[6].billboard.image = greenImg | ||||
|                 this.pointEntityCollection.values[4].billboard.image = redImg | ||||
|               } | ||||
|  | ||||
|               radiansW = (Math.PI / 180) * angleW | ||||
| @ -1358,6 +1512,16 @@ class GroundSvg extends Base { | ||||
|  | ||||
|               if ((angleW > -360 && angleW < -90) || (angleW < 360 && angleW > 90)) { | ||||
|                 angleW = angleW + 180 | ||||
|                 // this.pointEntityCollection.values[6].point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|                 // this.pointEntityCollection.values[4].point.color = Cesium.Color.fromCssColorString('#ff0000') | ||||
|                 this.pointEntityCollection.values[6].billboard.image = greenImg | ||||
|                 this.pointEntityCollection.values[4].billboard.image = redImg | ||||
|               } | ||||
|               else { | ||||
|                 // this.pointEntityCollection.values[4].point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|                 // this.pointEntityCollection.values[6].point.color = Cesium.Color.fromCssColorString('#ff0000') | ||||
|                 this.pointEntityCollection.values[4].billboard.image = greenImg | ||||
|                 this.pointEntityCollection.values[6].billboard.image = redImg | ||||
|               } | ||||
|  | ||||
|               radiansW = (Math.PI / 180) * angleW | ||||
| @ -1422,18 +1586,22 @@ class GroundSvg extends Base { | ||||
|           } | ||||
|           for (let i = 0; i < this.pointEntityCollection.values.length; i++) { | ||||
|             if (pickPoint && this.pointEntityCollection.values[i].id === pickPoint.id) { | ||||
|               pickPoint.point.color = Cesium.Color.fromCssColorString('#ffff00') | ||||
|               // pickPoint.point.color = Cesium.Color.fromCssColorString('#ffff00') | ||||
|               pickPoint.billboard.image = yellowImg | ||||
|             } | ||||
|             else { | ||||
|               switch (this.pointEntityCollection.values[i].id) { | ||||
|                 case 'svg-control-points_5': | ||||
|                   this.pointEntityCollection.values[i].point.color = Cesium.Color.fromCssColorString('#ffff00') | ||||
|                   // this.pointEntityCollection.values[i].point.color = Cesium.Color.fromCssColorString('#ffff00') | ||||
|                   this.pointEntityCollection.values[i].billboard.image = yellowImg | ||||
|                   break | ||||
|                 case 'svg-control-points_0': | ||||
|                   this.pointEntityCollection.values[i].point.color = Cesium.Color.fromCssColorString('#ff0000') | ||||
|                   // this.pointEntityCollection.values[i].point.color = Cesium.Color.fromCssColorString('#ff0000') | ||||
|                   this.pointEntityCollection.values[i].billboard.image = redImg | ||||
|                   break | ||||
|                 default: | ||||
|                   this.pointEntityCollection.values[i].point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|                   // this.pointEntityCollection.values[i].point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|                   this.pointEntityCollection.values[i].billboard.image = greenImg | ||||
|               } | ||||
|             } | ||||
|           } | ||||
| @ -1448,7 +1616,8 @@ class GroundSvg extends Base { | ||||
|           ) { | ||||
|             YJ.Global.CameraController(this.sdk, false) | ||||
|             this.pickPoint = pickedObject.primitive._id | ||||
|             this.pickPoint.point.color = Cesium.Color.fromCssColorString('#ff0000') | ||||
|             // this.pickPoint.point.color = Cesium.Color.fromCssColorString('#ff0000') | ||||
|             this.pickPoint.billboard.image = redImg | ||||
|             break | ||||
|           } | ||||
|         } | ||||
| @ -1458,13 +1627,16 @@ class GroundSvg extends Base { | ||||
|           YJ.Global.CameraController(this.sdk, true) | ||||
|           switch (this.pickPoint.id) { | ||||
|             case 'svg-control-points_4': | ||||
|               this.pickPoint.point.color = Cesium.Color.fromCssColorString('#ffff00') | ||||
|               // this.pickPoint.point.color = Cesium.Color.fromCssColorString('#ffff00') | ||||
|               this.pickPoint.billboard.image = yellowImg | ||||
|               break | ||||
|             case 'svg-control-points_9': | ||||
|               this.pickPoint.point.color = Cesium.Color.fromCssColorString('#ff0000') | ||||
|               // this.pickPoint.point.color = Cesium.Color.fromCssColorString('#ff0000') | ||||
|               this.pickPoint.billboard.image = redImg | ||||
|               break | ||||
|             default: | ||||
|               this.pickPoint.point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|               // this.pickPoint.point.color = Cesium.Color.fromCssColorString('#00ff0a') | ||||
|               this.pickPoint.billboard.image = greenImg | ||||
|           } | ||||
|           this.pickPoint = null | ||||
|         } | ||||
| @ -1503,13 +1675,19 @@ class GroundSvg extends Base { | ||||
|       controlPoints[9] = turf.destination(point, wh, 0 + angle, options).geometry.coordinates | ||||
|  | ||||
|       this.controlPoints = controlPoints | ||||
|       if (!this.sdk || !this.sdk.viewer) { | ||||
|         return | ||||
|       } | ||||
|       for (let i = 0; i < this.controlPoints.length; i++) { | ||||
|         let color = '#00ff0a' | ||||
|         let img = greenImg | ||||
|         if (i === 5) { | ||||
|           color = '#ffff00' | ||||
|           img = yellowImg | ||||
|         } | ||||
|         if (i === 0) { | ||||
|           color = '#ff0000' | ||||
|           img = redImg | ||||
|         } | ||||
|         let entity = this.sdk.viewer.entities.getOrCreateEntity('svg-control-points_' + i) | ||||
|         entity.show = true | ||||
| @ -1517,11 +1695,18 @@ class GroundSvg extends Base { | ||||
|         entity.position = new Cesium.CallbackProperty(() => { | ||||
|           return Cesium.Cartesian3.fromDegrees(...this.controlPoints[i]) | ||||
|         }) | ||||
|         entity.point = new Cesium.PointGraphics({ | ||||
|           color: Cesium.Color.fromCssColorString(color), // 点的颜色 | ||||
|           pixelSize: 10, // 点的大小 | ||||
|         // entity.point = new Cesium.PointGraphics({ | ||||
|         //   color: Cesium.Color.fromCssColorString(color), // 点的颜色 | ||||
|         //   pixelSize: 10, // 点的大小 | ||||
|         //   heightReference: Cesium.HeightReference.CLAMP_TO_GROUND, | ||||
|         //   scaleByDistance: new Cesium.NearFarScalar(0.0, 1.0, 1.0e10, 1.0), | ||||
|         //   disableDepthTestDistance: Number.POSITIVE_INFINITY  // 不应用深度测试 | ||||
|         // }) | ||||
|         entity.billboard = new Cesium.BillboardGraphics({ | ||||
|           image: img, | ||||
|           width: 10, | ||||
|           height: 10, | ||||
|           heightReference: Cesium.HeightReference.CLAMP_TO_GROUND, | ||||
|           scaleByDistance: new Cesium.NearFarScalar(0.0, 1.0, 1.0e10, 1.0), | ||||
|           disableDepthTestDistance: Number.POSITIVE_INFINITY  // 不应用深度测试 | ||||
|         }) | ||||
|         this.pointEntityCollection.add(entity) | ||||
| @ -1743,7 +1928,7 @@ class GroundSvg extends Base { | ||||
|     }) | ||||
|     this.hierarchys = [...hierarchys] | ||||
|  | ||||
|     if (!this.entity) { | ||||
|     if (!this.entity || !this.entity.values || this.entity.values.length == 0) { | ||||
|       return | ||||
|     } | ||||
|  | ||||
| @ -1991,21 +2176,25 @@ class GroundSvg extends Base { | ||||
|   } | ||||
|  | ||||
|   async remove() { | ||||
|     this._worker.onmessage = (event) => {} | ||||
|     await this.sdk.removeIncetance(this.options.id) | ||||
|     if (!this.entity) { | ||||
|       return | ||||
|     } | ||||
|     this.drag(false) | ||||
|     if(!this.sdk || !this.sdk.viewer) { | ||||
|       return | ||||
|     } | ||||
|     this.sdk.viewer.entities.remove(this.entity) | ||||
|     this.text && this.text.remove() | ||||
|     for (let i = this.entity.values.length; i >= 0; i--) { | ||||
|       this.sdk.viewer.entities.remove(this.entity.values[i]) | ||||
|     } | ||||
|     this.entity = null | ||||
|     if (this._DialogObject && !this._DialogObject.isDestroy) { | ||||
|       this._DialogObject.close() | ||||
|       this._DialogObject = null | ||||
|     } | ||||
|     await this.sdk.removeIncetance(this.options.id) | ||||
|      | ||||
|     await syncData(this.sdk, this.options.id) | ||||
|   } | ||||
|  | ||||
| @ -2065,6 +2254,59 @@ class GroundSvg extends Base { | ||||
|     } | ||||
|     this._update() | ||||
|   } | ||||
|  | ||||
|   async flyTo(options = {}) { | ||||
|     if (this._error) { | ||||
|       return | ||||
|     } | ||||
|     setActiveViewer(0) | ||||
|     closeRotateAround(this.sdk) | ||||
|     closeViewFollow(this.sdk) | ||||
|  | ||||
|     if (this.options.customView && this.options.customView.relativePosition && this.options.customView.orientation) { | ||||
|       let orientation = { | ||||
|         heading: Cesium.Math.toRadians(this.options.customView.orientation.heading || 0.0), | ||||
|         pitch: Cesium.Math.toRadians(this.options.customView.orientation.pitch || -60.0), | ||||
|         roll: Cesium.Math.toRadians(this.options.customView.orientation.roll || 0.0) | ||||
|       } | ||||
|  | ||||
|       let lng = this.options.customView.relativePosition.lng | ||||
|       let lat = this.options.customView.relativePosition.lat | ||||
|       let alt = this.options.customView.relativePosition.alt | ||||
|       let destination = Cesium.Cartesian3.fromDegrees(lng, lat, alt) | ||||
|  | ||||
|       let position = { ...this.options.position } | ||||
|       // 如果没有高度值,则获取紧贴高度计算 | ||||
|       if (!position.hasOwnProperty('alt')) { | ||||
|         position.alt = await this.getClampToHeight(position) | ||||
|       } | ||||
|       lng = this.options.customView.relativePosition.lng + position.lng | ||||
|       lat = this.options.customView.relativePosition.lat + position.lat | ||||
|       alt = this.options.customView.relativePosition.alt + position.alt | ||||
|       destination = Cesium.Cartesian3.fromDegrees(lng, lat, alt) | ||||
|       this.sdk.viewer.camera.flyTo({ | ||||
|         destination: destination, | ||||
|         orientation: orientation | ||||
|       }) | ||||
|     } | ||||
|     else { | ||||
|       let array = [] | ||||
|       for (let i = 0; i < this.controlPoints.length; i++) { | ||||
|         let height = await this.getClampToHeight({lng: this.controlPoints[i][0], lat: this.controlPoints[i][1]}) | ||||
|         let cartesian = Cesium.Cartesian3.fromDegrees(this.controlPoints[i][0], this.controlPoints[i][1], height) | ||||
|         array.push(cartesian.x, cartesian.y, cartesian.z) | ||||
|       } | ||||
|       let BoundingSphere = Cesium.BoundingSphere.fromVertices(array) | ||||
|  | ||||
|       this.sdk.viewer.camera.flyToBoundingSphere(BoundingSphere, { | ||||
|         offset: options.orientation || { | ||||
|           heading: Cesium.Math.toRadians(0.0), | ||||
|           pitch: Cesium.Math.toRadians(-60.0), | ||||
|           roll: Cesium.Math.toRadians(0.0) | ||||
|         } | ||||
|       }) | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
| export default GroundSvg | ||||
| @ -14,6 +14,8 @@ import { | ||||
|  | ||||
| class LabelObject extends Base { | ||||
|   #updateBillboardImageTimeout | ||||
|   #canvas = document.createElement('canvas') | ||||
|   #canvas2 = document.createElement('canvas') | ||||
|   constructor(sdk, options = {}, model) { | ||||
|     super(sdk, options) | ||||
|     this.model = model | ||||
| @ -65,6 +67,11 @@ class LabelObject extends Base { | ||||
|     } | ||||
|     this.originalOptions = copyObj(this.options) | ||||
|  | ||||
|     let id = this.options.id + '-label' | ||||
|     let oldEntity = this.sdk.viewer.entities.getById(id) | ||||
|     if(oldEntity) { | ||||
|       this.sdk.viewer.entities.remove(oldEntity) | ||||
|     } | ||||
|     this.entity = this.sdk.viewer.entities.add({ | ||||
|       show: this.options.show, | ||||
|       id: this.options.id + '-label', | ||||
| @ -433,11 +440,12 @@ class LabelObject extends Base { | ||||
|     this.updateBillboardImage() | ||||
|   } | ||||
|   updateBillboardImage() { | ||||
|     clearTimeout(this.#updateBillboardImageTimeout) | ||||
|     this.#updateBillboardImageTimeout = setTimeout(() => { | ||||
|       clearTimeout(this.#updateBillboardImageTimeout) | ||||
|       this.entity.billboard.image = this.getcanvas() | ||||
|     }, 500) | ||||
|     this.entity.billboard.image = this.getcanvas() | ||||
|     // clearTimeout(this.#updateBillboardImageTimeout) | ||||
|     // this.#updateBillboardImageTimeout = setTimeout(() => { | ||||
|     //   clearTimeout(this.#updateBillboardImageTimeout) | ||||
|     //   this.entity.billboard.image = this.getcanvas() | ||||
|     // }, 500) | ||||
|   } | ||||
|   get lineColor() { | ||||
|     return this.options.pixelOffset | ||||
| @ -484,9 +492,8 @@ class LabelObject extends Base { | ||||
|   // } | ||||
|  | ||||
|   getcanvas() { | ||||
|     const canvas = document.createElement('canvas') | ||||
|     const ctx = canvas.getContext('2d') | ||||
|  | ||||
|     const ctx = this.#canvas.getContext('2d') | ||||
|     ctx.clearRect(0, 0, this.#canvas.width, this.#canvas.height); | ||||
|     ctx.font = this.options.fontSize + 'px ' + this.font | ||||
|     let texts = this.options.text.split('\n') | ||||
|     let canvasWidth = 0 | ||||
| @ -504,9 +511,8 @@ class LabelObject extends Base { | ||||
|     if (canvasWidth < this.options.lineWidth) { | ||||
|       canvasWidth = this.options.lineWidth | ||||
|     } | ||||
|     canvas.width = canvasWidth | ||||
|  | ||||
|     canvas.height = this.options.pixelOffset + canvasHeight | ||||
|     this.#canvas.width = canvasWidth | ||||
|     this.#canvas.height = this.options.pixelOffset + canvasHeight | ||||
|     const linearGradient = ctx.createLinearGradient( | ||||
|       0, | ||||
|       0, | ||||
| @ -553,15 +559,14 @@ class LabelObject extends Base { | ||||
|     ctx.stroke() | ||||
|     ctx.closePath() | ||||
|  | ||||
|     const canvas2 = document.createElement('canvas') | ||||
|     const ctx2 = canvas2.getContext('2d') | ||||
|     canvas2.width = canvas.width + 10 | ||||
|     canvas2.height = canvas.height + 10 | ||||
|     ctx2.drawImage(canvas, 5, 5); | ||||
|     const ctx2 = this.#canvas2.getContext('2d') | ||||
|     this.#canvas2.width = this.#canvas.width + 10 | ||||
|     this.#canvas2.height = this.#canvas.height + 10 | ||||
|     ctx2.drawImage(this.#canvas, 5, 5); | ||||
|  | ||||
|     // const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); | ||||
|     // ctx.putImageData(imageData, 40, 40); | ||||
|     return canvas2 | ||||
|     return this.#canvas2.toDataURL("image/png") | ||||
|   } | ||||
|  | ||||
|   remove() { | ||||
|  | ||||
| @ -7,7 +7,7 @@ import EventBinding from './eventBinding' | ||||
| import Base from "../../index"; | ||||
| import MouseEvent from '../../../../Event/index' | ||||
| import { syncPrimitives } from '../../../../Global/MultiViewportMode' | ||||
| import { syncData } from '../../../../Global/MultiViewportMode' | ||||
| import { syncData, getSdk as get2DSdk } from '../../../../Global/MultiViewportMode' | ||||
| import MouseTip from '../../../../MouseTip' | ||||
| import { setSplitDirection, syncSplitData, setActiveId } from '../../../../Global/SplitScreen' | ||||
| import { setActiveViewer, closeRotateAround, closeViewFollow} from '../../../../Global/global' | ||||
| @ -82,18 +82,34 @@ class Flame extends Base { | ||||
|  | ||||
|   set show(v) { | ||||
|     if (typeof v === "boolean") { | ||||
|       this.options.show = v | ||||
|       if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) { | ||||
|         this.entity.show = v | ||||
|       let sdkD = get2DSdk().sdkD | ||||
|       if (!this.isShowView || !sdkD) { | ||||
|         this.options.show = v | ||||
|       } | ||||
|       if (!this.showView || this.showView == 3 || !sdkD) { | ||||
|         if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) { | ||||
|           this.entity.show = this.options.show | ||||
|         } | ||||
|         if (this.options.label && this.options.label.show) { | ||||
|           this.label.show = this.options.show | ||||
|         } | ||||
|       } | ||||
|       else { | ||||
|         if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) { | ||||
|           this.entity.show = false | ||||
|         } | ||||
|         if (this.options.label && this.options.label.show) { | ||||
|           this.label.show = false | ||||
|         } | ||||
|       } | ||||
|        | ||||
|       if (this._DialogObject && this._DialogObject.showBtn) { | ||||
|         this._DialogObject.showBtn.checked = v | ||||
|       } | ||||
|       if (this.options.label && this.options.label.show) { | ||||
|         this.label.show = v | ||||
|       } | ||||
|        | ||||
|       syncData(this.sdk, this.options.id) | ||||
|       syncSplitData(this.sdk, this.options.id) | ||||
|       this.isShowView = false | ||||
|     } else { | ||||
|       console.error("参数必须为boolean") | ||||
|     } | ||||
|  | ||||
| @ -6,7 +6,7 @@ import { html } from "./_element"; | ||||
| import EventBinding from './eventBinding' | ||||
| import Base from "../../index"; | ||||
| import MouseEvent from '../../../../Event/index' | ||||
| import { syncData } from '../../../../Global/MultiViewportMode' | ||||
| import { syncData, getSdk as get2DSdk } from '../../../../Global/MultiViewportMode' | ||||
| import MouseTip from '../../../../MouseTip' | ||||
| import { setSplitDirection, syncSplitData, setActiveId } from '../../../../Global/SplitScreen' | ||||
| import { setActiveViewer, closeRotateAround, closeViewFollow} from '../../../../Global/global' | ||||
| @ -83,18 +83,32 @@ class Fountain extends Base { | ||||
|  | ||||
|   set show(v) { | ||||
|     if (typeof v === "boolean") { | ||||
|       this.options.show = v | ||||
|       if(this.entity && this.sdk.viewer.camera.positionCartographic.height <10000000) { | ||||
|         this.entity.show = v | ||||
|       let sdkD = get2DSdk().sdkD | ||||
|       if (!this.isShowView || !sdkD) { | ||||
|         this.options.show = v | ||||
|       } | ||||
|       if (!this.showView || this.showView == 3 || !sdkD) { | ||||
|         if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) { | ||||
|           this.entity.show = this.options.show | ||||
|         } | ||||
|         if (this.options.label && this.options.label.show) { | ||||
|           this.label.show = this.options.show | ||||
|         } | ||||
|       } | ||||
|       else { | ||||
|         if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) { | ||||
|           this.entity.show = false | ||||
|         } | ||||
|         if (this.options.label && this.options.label.show) { | ||||
|           this.label.show = false | ||||
|         } | ||||
|       } | ||||
|       if(this._DialogObject && this._DialogObject.showBtn) { | ||||
|         this._DialogObject.showBtn.checked = v | ||||
|       } | ||||
|       if (this.options.label && this.options.label.show) { | ||||
|         this.label.show = v | ||||
|       } | ||||
|       syncData(this.sdk, this.options.id) | ||||
|       syncSplitData(this.sdk, this.options.id) | ||||
|       this.isShowView = false | ||||
|     } else { | ||||
|       console.error("参数必须为boolean") | ||||
|     } | ||||
|  | ||||
| @ -6,7 +6,7 @@ import { html, css } from "./_element"; | ||||
| import EventBinding from './eventBinding' | ||||
| import Base from "../../index"; | ||||
| import MouseEvent from '../../../../Event/index' | ||||
| import { syncData } from '../../../../Global/MultiViewportMode' | ||||
| import { syncData, getSdk as get2DSdk } from '../../../../Global/MultiViewportMode' | ||||
| import MouseTip from '../../../../MouseTip' | ||||
| import { setSplitDirection, syncSplitData, setActiveId } from '../../../../Global/SplitScreen' | ||||
| import { setActiveViewer, closeRotateAround, closeViewFollow} from '../../../../Global/global' | ||||
| @ -81,18 +81,32 @@ class Smoke extends Base { | ||||
|  | ||||
|   set show(v) { | ||||
|     if (typeof v === "boolean") { | ||||
|       this.options.show = v | ||||
|       if(this.entity && this.sdk.viewer.camera.positionCartographic.height <10000000) { | ||||
|         this.entity.show = v | ||||
|       let sdkD = get2DSdk().sdkD | ||||
|       if (!this.isShowView || !sdkD) { | ||||
|         this.options.show = v | ||||
|       } | ||||
|       if (!this.showView || this.showView == 3 || !sdkD) { | ||||
|         if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) { | ||||
|           this.entity.show = this.options.show | ||||
|         } | ||||
|         if (this.options.label && this.options.label.show) { | ||||
|           this.label.show = this.options.show | ||||
|         } | ||||
|       } | ||||
|       else { | ||||
|         if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) { | ||||
|           this.entity.show = false | ||||
|         } | ||||
|         if (this.options.label && this.options.label.show) { | ||||
|           this.label.show = false | ||||
|         } | ||||
|       } | ||||
|       if(this._DialogObject && this._DialogObject.showBtn) { | ||||
|         this._DialogObject.showBtn.checked = v | ||||
|       } | ||||
|       if (this.options.label && this.options.label.show) { | ||||
|         this.label.show = v | ||||
|       } | ||||
|       syncData(this.sdk, this.options.id) | ||||
|       syncSplitData(this.sdk, this.options.id) | ||||
|       this.isShowView = false | ||||
|     } else { | ||||
|       console.error("参数必须为boolean") | ||||
|     } | ||||
|  | ||||
| @ -5,7 +5,7 @@ import Dialog from '../../../Element/Dialog'; | ||||
| import { html, css } from "./_element"; | ||||
| import Base from "../../index"; | ||||
| import MouseEvent from '../../../../Event/index' | ||||
| import { syncData } from '../../../../Global/MultiViewportMode' | ||||
| import { syncData, getSdk as get2DSdk } from '../../../../Global/MultiViewportMode' | ||||
| import MouseTip from '../../../../MouseTip' | ||||
| import { setSplitDirection, syncSplitData, setActiveId } from '../../../../Global/SplitScreen' | ||||
| import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../../Global/global' | ||||
| @ -84,18 +84,32 @@ class Spout extends Base { | ||||
|  | ||||
|   set show(v) { | ||||
|     if (typeof v === "boolean") { | ||||
|       this.options.show = v | ||||
|       if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) { | ||||
|         this.entity.show = v | ||||
|       let sdkD = get2DSdk().sdkD | ||||
|       if (!this.isShowView || !sdkD) { | ||||
|         this.options.show = v | ||||
|       } | ||||
|       if (this._DialogObject && this._DialogObject.showBtn) { | ||||
|       if (!this.showView || this.showView == 3 || !sdkD) { | ||||
|         if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) { | ||||
|           this.entity.show = this.options.show | ||||
|         } | ||||
|         if (this.options.label && this.options.label.show) { | ||||
|           this.label.show = this.options.show | ||||
|         } | ||||
|       } | ||||
|       else { | ||||
|         if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) { | ||||
|           this.entity.show = false | ||||
|         } | ||||
|         if (this.options.label && this.options.label.show) { | ||||
|           this.label.show = false | ||||
|         } | ||||
|       } | ||||
|       if(this._DialogObject && this._DialogObject.showBtn) { | ||||
|         this._DialogObject.showBtn.checked = v | ||||
|       } | ||||
|       if (this.options.label && this.options.label.show) { | ||||
|         this.label.show = v | ||||
|       } | ||||
|       syncData(this.sdk, this.options.id) | ||||
|       syncSplitData(this.sdk, this.options.id) | ||||
|       this.isShowView = false | ||||
|     } else { | ||||
|       console.error("参数必须为boolean") | ||||
|     } | ||||
|  | ||||
| @ -40,7 +40,7 @@ class PincerArrowObject extends Base { | ||||
|     this.options.heightMode = (options.heightMode || options.heightMode == 0) ? options.heightMode : 2 | ||||
|     this.options.line = options.line || {} | ||||
|     this.options.line.width = ((this.options.line.width || this.options.line.width === 0) ? this.options.line.width : 3) | ||||
|     this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 0.5)' | ||||
|     this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 1)' | ||||
|     this.options['area-unit'] = options['area-unit'] || '平方米' | ||||
|     this.options.height = options.height | ||||
|     this.options.loop = options.loop || false | ||||
| @ -334,7 +334,7 @@ class PincerArrowObject extends Base { | ||||
|   } | ||||
|   set labelShow(v) { | ||||
|     this.options.label.show = v | ||||
|     if (this.show) { | ||||
|     if (this.show && !this.showView || this.showView == 3) { | ||||
|       this.label.show = v | ||||
|     } | ||||
|     else { | ||||
|  | ||||
| @ -47,7 +47,7 @@ class PolygonObject extends Base { | ||||
|     this.options.line = options.line || {} | ||||
|     this.options.line.width = ((this.options.line.width || this.options.line.width === 0) ? this.options.line.width : 3) | ||||
|     this.options.line.color = | ||||
|       this.options.line.color || 'rgba(255, 0, 0, 0.5)' | ||||
|       this.options.line.color || 'rgba(255, 0, 0, 1)' | ||||
|     this.options['area-unit'] = options['area-unit'] || '平方米' | ||||
|     this.entity | ||||
|     this.event = new MouseEvent(this.sdk) | ||||
| @ -355,7 +355,7 @@ class PolygonObject extends Base { | ||||
|   } | ||||
|   set labelShow(v) { | ||||
|     this.options.label.show = v | ||||
|     if (this.show) { | ||||
|     if (this.show && !this.showView || this.showView == 3) { | ||||
|       this.label.show = v | ||||
|     } else { | ||||
|       this.label.show = false | ||||
| @ -1216,7 +1216,6 @@ class PolygonObject extends Base { | ||||
|             alt: this.label.position[2] | ||||
|           } | ||||
|           this.originalOptions = this.deepCopyObj(this.options) | ||||
|           console.log('000000000000',this.options.label.scaleByDistance) | ||||
|           this._DialogObject.close() | ||||
|           this.Dialog.confirmCallBack && | ||||
|             this.Dialog.confirmCallBack(this.originalOptions) | ||||
|  | ||||
| @ -21,6 +21,7 @@ class eventBinding { | ||||
|       let Event = [] | ||||
|       let isEvent = false | ||||
|       let removeName = [] | ||||
|       let blurEvent = () => { } | ||||
|       if (!elements[i] || !elements[i].attributes) { | ||||
|         continue  | ||||
|       } | ||||
| @ -36,7 +37,8 @@ class eventBinding { | ||||
|               Event.push((e) => { | ||||
|                 let value = e.target.value | ||||
|                 if (e.target.type == 'number') { | ||||
|                   if (e.data != '.' && (e.data != '-' || e.target.value)) { | ||||
|                   let str = e.target.value + '' | ||||
|                   if (e.data != '.' && (e.data != '-' || e.target.value) && !(str.charAt(str.length - 1) == '0' && e.target.value.toString().includes('.')) && e.target.value != '0') { | ||||
|                     value = Number(value) | ||||
|                     if((e.target.max) && value>Number(e.target.max)) { | ||||
|                       value = Number(e.target.max) | ||||
| @ -57,6 +59,22 @@ class eventBinding { | ||||
|                   that[m.value] = value | ||||
|                 } | ||||
|               }) | ||||
|               blurEvent = (e) => { | ||||
|                 let value = e.target.value | ||||
|                 if ((e.target.type == 'number') && (e.target.value || (e.target.dataset.null !== 'undefined' && e.target.dataset.null !== '' && !Boolean(e.target.dataset.null)))) { | ||||
|                   value = Number(value) | ||||
|                   if ((e.target.max) && value > Number(e.target.max)) { | ||||
|                     value = Number(e.target.max) | ||||
|                   } | ||||
|                   if ((e.target.min) && value < Number(e.target.min)) { | ||||
|                     value = Number(e.target.min) | ||||
|                   } | ||||
|                   if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) { | ||||
|                     value = Number(e.target.dataset.min) | ||||
|                   } | ||||
|                 } | ||||
|                 that[m.value] = value | ||||
|               } | ||||
|               if(elements[i].nodeName=='IMG') { | ||||
|                 elements[i].src = that[m.value] | ||||
|               } | ||||
| @ -114,6 +132,7 @@ class eventBinding { | ||||
|             Event[t](e) | ||||
|           } | ||||
|         }); | ||||
|         elements[i].addEventListener('blur', blurEvent) | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|  | ||||
| @ -517,7 +517,7 @@ class PolyhedronObject extends Base { | ||||
|   } | ||||
|   set labelShow(v) { | ||||
|     this.options.label.show = v | ||||
|     if (this.show) { | ||||
|     if (this.show && !this.showView || this.showView == 3) { | ||||
|       this.label.show = v | ||||
|     } | ||||
|     else { | ||||
|  | ||||
| @ -90,27 +90,6 @@ function html(that) { | ||||
|                         <div class="col" style="flex: 0 0 37%;"> | ||||
|                         </div> | ||||
|                     </div> | ||||
|                     <div class="row" id="dashTextureDom"> | ||||
|                         <div class="col"> | ||||
|                             <span class="label">动画顺向</span> | ||||
|                             <input class="btn-switch" type="checkbox" @model="rotate"> | ||||
|                         </div> | ||||
|                         <div class="col" style="flex: 0 0 33%;"> | ||||
|                             <span class="label">流动速率</span> | ||||
|                             <div class="input-number input-number-unit-1" style="width: 80px;"> | ||||
|                                 <input class="input" type="number" title="" min="0" max="999999" step="1" @model="speed"> | ||||
|                                 <span class="arrow"></span> | ||||
|                             </div> | ||||
|                         </div> | ||||
|                         <div class="col" style="flex: 0 0 37%;"> | ||||
|                               <span class="label lineSpace">间距</span> | ||||
|                               <div class="input-number input-number-unit-1 lineSpace" style="width: 80px;"> | ||||
|                                   <input class="input" type="number" title="" min="0" max="4.5" step="0.1" @model="space"> | ||||
|                                   <span class="unit">倍</span> | ||||
|                                   <span class="arrow"></span> | ||||
|                               </div> | ||||
|                         </div> | ||||
|                     </div> | ||||
|                     <div class="row"> | ||||
|                         <div class="col"> | ||||
|                             <span class="label">线段缓冲</span> | ||||
| @ -129,6 +108,27 @@ function html(that) { | ||||
|                             <div class="extendColor"></div> | ||||
|                         </div> | ||||
|                     </div> | ||||
|                     <div class="row" id="dashTextureDom"> | ||||
|                         <div class="col"> | ||||
|                             <span class="label">首尾反向</span> | ||||
|                             <input class="btn-switch" type="checkbox" @model="rotate"> | ||||
|                         </div> | ||||
|                         <div class="col" style="flex: 0 0 33%;"> | ||||
|                             <span class="label">流动速率</span> | ||||
|                             <div class="input-number input-number-unit-1" style="width: 80px;"> | ||||
|                                 <input class="input" type="number" title="" min="0" max="999999" step="1" @model="speed"> | ||||
|                                 <span class="arrow"></span> | ||||
|                             </div> | ||||
|                         </div> | ||||
|                         <div class="col" style="flex: 0 0 37%;"> | ||||
|                               <span class="label lineSpace">线条间距</span> | ||||
|                               <div class="input-number input-number-unit-1 lineSpace" style="width: 80px;"> | ||||
|                                   <input class="input" type="number" title="" min="0" max="4.5" step="0.1" @model="space"> | ||||
|                                   <span class="unit">倍</span> | ||||
|                                   <span class="arrow"></span> | ||||
|                               </div> | ||||
|                         </div> | ||||
|                     </div> | ||||
|                 </DIV-cy-tab-pane> | ||||
|                 <DIV-cy-tab-pane label="标注风格"> | ||||
|                     ${labelStyleElm1()} | ||||
|  | ||||
| @ -11,12 +11,14 @@ import LabelObject from '../LabelObject' | ||||
| import MouseEvent from '../../../Event/index' | ||||
| import MouseTip from '../../../MouseTip' | ||||
| import Controller from '../../../Controller/index' | ||||
| import { syncData } from '../../../Global/MultiViewportMode' | ||||
| import { syncData, get3DView } from '../../../Global/MultiViewportMode' | ||||
| import { legp } from '../../Element/datalist' | ||||
| import { getFontList, getFontFamilyName } from '../../Element/fontSelect' | ||||
| import { setSplitDirection, syncSplitData, setActiveId } from '../../../Global/SplitScreen' | ||||
| import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../Global/global' | ||||
|  | ||||
| class PolylineObject extends Base { | ||||
|   #unitDataLegpObject | ||||
|   /** | ||||
|    * @constructor | ||||
|    * @param sdk | ||||
| @ -30,8 +32,8 @@ class PolylineObject extends Base { | ||||
|    * @param options['nose-to-tail']=false {boolean} 首尾相连 | ||||
|    * @param options.smooth=false {boolean} 线段圆滑 | ||||
|    * @param options.extend=false {boolean} 线缓冲 | ||||
|    * @param options['extend-width']=1 {number} 线缓冲宽度 | ||||
|    * @param options['extend-color']=#ffde00 {number} 线缓冲颜色 | ||||
|    * @param options['extend-width']=10 {number} 线缓冲宽度 | ||||
|    * @param options['extend-color']=rgba(255,255,80,0.3) {number} 线缓冲颜色 | ||||
|    * @param options.show=true {boolean} 显隐 | ||||
|    * @param {Array.<object>} options.positions 坐标数组 [{lng,lat},...] | ||||
|    * @param options.label {object} 标注 | ||||
| @ -67,8 +69,8 @@ class PolylineObject extends Base { | ||||
|     this.options['extend-width'] = | ||||
|       options['extend-width'] || options['extend-width'] === 0 | ||||
|         ? options['extend-width'] | ||||
|         : 1 | ||||
|     this.options['extend-color'] = options['extend-color'] || '#ffde00' | ||||
|         : 10 | ||||
|     this.options['extend-color'] = options['extend-color'] || 'rgba(255,255,80,0.3)' | ||||
|     this.options.show = | ||||
|       options.show || options.show === false ? options.show : true | ||||
|     this.options.heightMode = (options.heightMode || options.heightMode == 0) ? options.heightMode : 2 | ||||
| @ -82,6 +84,7 @@ class PolylineObject extends Base { | ||||
|         options.label.fontSize || options.label.fontSize === 0 | ||||
|           ? options.label.fontSize | ||||
|           : 20, | ||||
|       fontFamily: options.label.fontFamily ? options.label.fontFamily : 0, | ||||
|       color: options.label.color || '#ffffff', | ||||
|       lineWidth: | ||||
|         options.label.lineWidth || options.label.lineWidth === 0 | ||||
| @ -122,6 +125,7 @@ class PolylineObject extends Base { | ||||
|     this.operate = {} | ||||
|     this.nodePoints = [] | ||||
|     this.unitNum = 0 | ||||
|     this.inputSpeed = (options.speed && Math.pow(options.speed, -1) * 100) || 10 | ||||
|     this.Dialog = _Dialog | ||||
|     if (!this.options.positions || this.options.positions.length < 2) { | ||||
|       this._error = '线段最少需要两个坐标!' | ||||
| @ -150,7 +154,10 @@ class PolylineObject extends Base { | ||||
|   } | ||||
|   set color(v) { | ||||
|     this.options.color = v || '#ff0000' | ||||
|     this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, this.options) | ||||
|     let params = { ...this.options } | ||||
|     params.speed = this.inputSpeed | ||||
|     // this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, this.options) | ||||
|     this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, params) | ||||
|     if (this._elms.color) { | ||||
|       this._elms.color.forEach((item, i) => { | ||||
|         let colorPicker = new YJColorPicker({ | ||||
| @ -177,9 +184,13 @@ class PolylineObject extends Base { | ||||
|   } | ||||
|  | ||||
|   set speed(v) { | ||||
|     // this.options.speed = v | ||||
|     this.options.speed = v !== 0 ? Math.pow(v, -1) * 100 : 0 | ||||
|     this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, this.options) | ||||
|     this.options.speed = v | ||||
|     this.inputSpeed = v !== 0 ? Math.pow(v, -1) * 100 : 0 | ||||
|     let params = { ...this.options } | ||||
|     params.speed = this.inputSpeed | ||||
|     // this.options.speed = v !== 0 ? Math.pow(v, -1) * 100 : 0 | ||||
|     // this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, this.options) | ||||
|     this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, params) | ||||
|   } | ||||
|   get dashSize() { | ||||
|     return this.options.dashSize | ||||
| @ -187,7 +198,10 @@ class PolylineObject extends Base { | ||||
|  | ||||
|   set dashSize(v) { | ||||
|     this.options.dashSize = v | ||||
|     this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, this.options) | ||||
|     let params = { ...this.options } | ||||
|     params.speed = this.inputSpeed | ||||
|     // this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, this.options) | ||||
|     this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, params) | ||||
|   } | ||||
|  | ||||
|   get rotate() { | ||||
| @ -203,7 +217,10 @@ class PolylineObject extends Base { | ||||
|       }) | ||||
|  | ||||
|     this.options.rotate = v | ||||
|     this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, this.options) | ||||
|     let params = { ...this.options } | ||||
|     params.speed = this.inputSpeed | ||||
|     // this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, this.options) | ||||
|     this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, params) | ||||
|   } | ||||
|  | ||||
|   get space() { | ||||
| @ -212,7 +229,10 @@ class PolylineObject extends Base { | ||||
|  | ||||
|   set space(v) { | ||||
|     this.options.space = v | ||||
|     this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, this.options) | ||||
|     let params = { ...this.options } | ||||
|     params.speed = this.inputSpeed | ||||
|     // this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, this.options) | ||||
|     this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, params) | ||||
|   } | ||||
|  | ||||
|   get length() { | ||||
| @ -251,6 +271,7 @@ class PolylineObject extends Base { | ||||
|       this._elms.lengthUnit.forEach(item => { | ||||
|         item.value = v | ||||
|       }) | ||||
|     this.#unitDataLegpObject && this.#unitDataLegpObject.legp_searchActive(v) | ||||
|     if (this.options.lengthByMeter) { | ||||
|       if (this.unitNum > 2) { | ||||
|         switch (v) { | ||||
| @ -287,14 +308,16 @@ class PolylineObject extends Base { | ||||
|         2, | ||||
|         v | ||||
|       ).then(res => { | ||||
|         // _this.options.lengthByMeter = res | ||||
|         // if (res > 1000 || res == 1000) { | ||||
|         //   _this.length = (res / 1000).toFixed(5) | ||||
|         //   _this.lengthUnit = '千米' | ||||
|         // } else { | ||||
|         //   _this.length = res | ||||
|         //   _this.lengthUnit = '米' | ||||
|         // } | ||||
|         _this.options.lengthByMeter = res | ||||
|         if (res > 1000 || res == 1000) { | ||||
|           _this.length = (res / 1000).toFixed(5) | ||||
|           _this.lengthUnit = '千米' | ||||
|         } else { | ||||
|           _this.length = res | ||||
|           _this.lengthUnit = '米' | ||||
|         } | ||||
|         _this.lengthUnit = _this.options['length-unit'] | ||||
|       }) | ||||
|     } else { | ||||
|       let fromDegreesArray = this.renewPositions(this.options.positions) | ||||
| @ -437,28 +460,30 @@ class PolylineObject extends Base { | ||||
|           this._elms.lineType.forEach(item => { | ||||
|             item.value = lineTypeData[i].value | ||||
|             if (2 < item.value && item.value < 13) {//贴图参数 | ||||
|               document.getElementById('dashTextureDom').style.display = 'flex' | ||||
|               document.getElementById('dashTextureDom') && (document.getElementById('dashTextureDom').style.display = 'flex') | ||||
|             } else { | ||||
|               document.getElementById('dashTextureDom').style.display = 'none' | ||||
|               document.getElementById('dashTextureDom') && (document.getElementById('dashTextureDom').style.display = 'none') | ||||
|             } | ||||
|             if (2 < item.value && item.value < 5) {//尾迹参数 | ||||
|               document.getElementsByClassName('lineSpace')[0].style.display = 'none' | ||||
|               document.getElementsByClassName('lineSpace')[1].style.display = 'none' | ||||
|               document.getElementsByClassName('lineSpace')[0] && (document.getElementsByClassName('lineSpace')[0].style.display = 'none') | ||||
|               document.getElementsByClassName('lineSpace')[1] && (document.getElementsByClassName('lineSpace')[1].style.display = 'none') | ||||
|             } else { | ||||
|               document.getElementsByClassName('lineSpace')[0].style.display = 'flex' | ||||
|               document.getElementsByClassName('lineSpace')[1].style.display = 'flex' | ||||
|               document.getElementsByClassName('lineSpace')[0] && (document.getElementsByClassName('lineSpace')[0].style.display = 'flex') | ||||
|               document.getElementsByClassName('lineSpace')[1] && (document.getElementsByClassName('lineSpace')[1].style.display = 'flex') | ||||
|             } | ||||
|           }) | ||||
|         break | ||||
|       } | ||||
|     } | ||||
|     let params = { ...this.options } | ||||
|     params.speed = this.inputSpeed | ||||
|     this.entity && | ||||
|       this.entity.polyline && | ||||
|       (this.entity.polyline.material = this.getMaterial( | ||||
|         this.options.color, | ||||
|         this.options.type, | ||||
|         this.entity, | ||||
|         this.options | ||||
|         params | ||||
|       )) | ||||
|   } | ||||
|   get noseToTail() { | ||||
| @ -479,24 +504,25 @@ class PolylineObject extends Base { | ||||
|       ) | ||||
|       this.renewPolygon(fromDegreesArray) | ||||
|     } | ||||
|     if (v) { | ||||
|       if (this.options.fitLengthByMeter > 1000 || this.options.fitLengthByMeter == 1000) { | ||||
|         let dom = document.getElementsByClassName('input-select-unit')[1] | ||||
|         dom && dom.querySelectorAll('dd')[1] && dom.querySelectorAll('dd')[1].click() | ||||
|       } else { | ||||
|         let dom = document.getElementsByClassName('input-select-unit')[1] | ||||
|         dom && dom.querySelectorAll('dd')[0] && dom.querySelectorAll('dd')[0].click() | ||||
|       } | ||||
|     this.lengthUnit = this.options['length-unit'] | ||||
|     // if (v) { | ||||
|     //   if (this.options.fitLengthByMeter > 1000 || this.options.fitLengthByMeter == 1000) { | ||||
|     //     let dom = document.getElementsByClassName('input-select-unit')[1] | ||||
|     //     dom && dom.querySelectorAll('dd')[1] && dom.querySelectorAll('dd')[1].click() | ||||
|     //   } else { | ||||
|     //     let dom = document.getElementsByClassName('input-select-unit')[1] | ||||
|     //     dom && dom.querySelectorAll('dd')[0] && dom.querySelectorAll('dd')[0].click() | ||||
|     //   } | ||||
|  | ||||
|     } else { | ||||
|       if (this.options.lengthByMeter > 1000 || this.options.lengthByMeter == 1000) { | ||||
|         let dom = document.getElementsByClassName('input-select-unit')[1] | ||||
|         dom && dom.querySelectorAll('dd')[1] && dom.querySelectorAll('dd')[1].click() | ||||
|       } else { | ||||
|         let dom = document.getElementsByClassName('input-select-unit')[1] | ||||
|         dom && dom.querySelectorAll('dd')[0] && dom.querySelectorAll('dd')[0].click() | ||||
|       } | ||||
|     } | ||||
|     // } else { | ||||
|     //   if (this.options.lengthByMeter > 1000 || this.options.lengthByMeter == 1000) { | ||||
|     //     let dom = document.getElementsByClassName('input-select-unit')[1] | ||||
|     //     dom && dom.querySelectorAll('dd')[1] && dom.querySelectorAll('dd')[1].click() | ||||
|     //   } else { | ||||
|     //     let dom = document.getElementsByClassName('input-select-unit')[1] | ||||
|     //     dom && dom.querySelectorAll('dd')[0] && dom.querySelectorAll('dd')[0].click() | ||||
|     //   } | ||||
|     // } | ||||
|   } | ||||
|  | ||||
|   get smooth() { | ||||
| @ -675,7 +701,7 @@ class PolylineObject extends Base { | ||||
|   } | ||||
|   set labelShow(v) { | ||||
|     this.options.label.show = v | ||||
|     if (this.show) { | ||||
|     if (this.show && !this.showView || this.showView == 3) { | ||||
|       this.label.show = v | ||||
|       setTimeout(() => { | ||||
|         this.label.position = [ | ||||
| @ -693,6 +719,21 @@ class PolylineObject extends Base { | ||||
|       }) | ||||
|   } | ||||
|  | ||||
|   get labelFontFamily() { | ||||
|     return this.options.label.fontFamily | ||||
|   } | ||||
|  | ||||
|   set labelFontFamily(v) { | ||||
|     this.options.label.fontFamily = v || 0 | ||||
|     this.label && (this.label.fontFamily = this.options.label.fontFamily) | ||||
|  | ||||
|     let name = getFontFamilyName(this.labelFontFamily) || '' | ||||
|     this._elms.labelFontFamily && | ||||
|       this._elms.labelFontFamily.forEach(item => { | ||||
|         item.value = name | ||||
|       }) | ||||
|   } | ||||
|  | ||||
|   get labelColor() { | ||||
|     return this.options.label.color | ||||
|   } | ||||
| @ -817,6 +858,29 @@ class PolylineObject extends Base { | ||||
|           }, //点击确认按钮事件回调 | ||||
|           clear: () => { | ||||
|             this.labelLineColor = 'rgba(0,255,255,0.5)' | ||||
|           } //点击清空按钮事件回调 | ||||
|         }) | ||||
|         this._elms.labelLineColor[i] = lineColorPicker | ||||
|       }) | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   get labelBackgroundColorStart() { | ||||
|     return this.options.label.backgroundColor[0] | ||||
|   } | ||||
|   set labelBackgroundColorStart(v) { | ||||
|     this.options.label.backgroundColor[0] = v | ||||
|     this.label.backgroundColor = [v, this.label.backgroundColor[1]] | ||||
|     if (this._elms.labelBackgroundColorStart) { | ||||
|       this._elms.labelBackgroundColorStart.forEach((item, i) => { | ||||
|         let labelBackgroundColorStartPicker = new YJColorPicker({ | ||||
|           el: item.el, | ||||
|           size: 'mini', //颜色box类型 | ||||
|           alpha: true, //是否开启透明度 | ||||
|           defaultColor: this.labelBackgroundColorStart, | ||||
|           disabled: false, //是否禁止打开颜色选择器 | ||||
|           openPickerAni: 'opacity', //打开颜色选择器动画 | ||||
|           sure: color => { | ||||
|             this.labelBackgroundColorStart = color | ||||
|           }, //点击确认按钮事件回调 | ||||
|           clear: () => { | ||||
| @ -1289,6 +1353,7 @@ class PolylineObject extends Base { | ||||
|       ], | ||||
|       text: that.options.name, | ||||
|       fontSize: that.options.label.fontSize, | ||||
|       fontFamily: that.options.label.fontFamily, | ||||
|       color: that.options.label.color, | ||||
|       pixelOffset: that.options.label.pixelOffset, | ||||
|       backgroundColor: that.options.label.backgroundColor, | ||||
| @ -1302,6 +1367,7 @@ class PolylineObject extends Base { | ||||
|   } | ||||
|  | ||||
|   static create(that) { | ||||
|  | ||||
|     let ground | ||||
|     if (that.heightMode == 2) { | ||||
|       ground = true | ||||
| @ -1317,12 +1383,21 @@ class PolylineObject extends Base { | ||||
|         positions: Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray), | ||||
|         width: that.options.width, | ||||
|         clampToGround: ground, | ||||
|         material: that.getMaterial(that.options.color, that.options.type, that.entity, that.options), | ||||
|         // material: that.getMaterial(that.options.color, that.options.type, that.entity, that.options), | ||||
|         zIndex: that.sdk._entityZIndex | ||||
|       } | ||||
|     }) | ||||
|  | ||||
|     that.entity.polyline.oriWidth = that.options.width | ||||
|     that.judgeLine(that.entity, that.options) | ||||
|     let params = { ...that.options } | ||||
|     params.speed = that.inputSpeed | ||||
|     that.entity.polyline.material = that.getMaterial( | ||||
|       that.options.color, | ||||
|       that.options.type, | ||||
|       that.entity, | ||||
|       params | ||||
|     ) | ||||
|     that.sdk._entityZIndex++ | ||||
|     PolylineObject.createLabel(that) | ||||
|     // that.entity.polyline.positionsLngLat = positions | ||||
| @ -1335,10 +1410,10 @@ class PolylineObject extends Base { | ||||
|       that.options.lengthByMeter = res | ||||
|       that.lengthUnit = that.options['length-unit'] | ||||
|       syncData(that.sdk, that.options.id) | ||||
|       if (that.options.show) { | ||||
|         setSplitDirection(0, that.options.id) | ||||
|       } | ||||
|     }) | ||||
|     if (that.options.show) { | ||||
|       setSplitDirection(0, that.options.id) | ||||
|     } | ||||
|  | ||||
|  | ||||
|     // if (this.options['nose-to-tail']) { | ||||
| @ -1411,9 +1486,17 @@ class PolylineObject extends Base { | ||||
|         var groundResolution = that.sdk.viewer.scene.camera.getPixelSize(boundingSphere, drawingBufferWidth, drawingBufferHeight) | ||||
|         repeatX *= groundResolution / cameraHeight / (param.space * (canvasEle.width / canvasEle.height * 5) + 1); | ||||
|         // if (entity.polyline.material.oriRepeat) { | ||||
|         let speed = repeatX / entity.polyline.oriRepeat | ||||
|         entity.polyline.oriSpeed = speed | ||||
|         entity.polyline.oriRepeatX = repeatX | ||||
|  | ||||
|         if (that.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE3D) { | ||||
|           let speed = repeatX / entity.polyline.oriRepeat | ||||
|           entity.polyline.oriSpeed = speed | ||||
|           entity.polyline.oriRepeatX = repeatX | ||||
|         } else { | ||||
|           let sdk3d = get3DView() | ||||
|           let sdk3dEntity = sdk3d.viewer.entities.getById(that.options.id) | ||||
|           entity.polyline.oriSpeed = sdk3dEntity.polyline.oriSpeed | ||||
|           entity.polyline.oriRepeatX = sdk3dEntity.polyline.oriRepeatX | ||||
|         } | ||||
|       } | ||||
|  | ||||
|  | ||||
| @ -1425,33 +1508,56 @@ class PolylineObject extends Base { | ||||
|   getSceenLine(entity, options, canvasEle) { | ||||
|     let point1 = new Cesium.Cartesian2(0, this.sdk.viewer.canvas.clientHeight) | ||||
|     let point2 = new Cesium.Cartesian2(this.sdk.viewer.canvas.clientWidth / 2, this.sdk.viewer.canvas.clientHeight) | ||||
|     var cartesian1 = this.sdk.viewer.scene.pickPosition(point1) | ||||
|     var cartesian2 = this.sdk.viewer.scene.pickPosition(point2) | ||||
|     // var cartesian1 = this.sdk.viewer.scene.pickPosition(point1) | ||||
|     // var cartesian2 = this.sdk.viewer.scene.pickPosition(point2) | ||||
|  | ||||
|     var distance = Cesium.Cartesian3.distance(cartesian1, cartesian2); | ||||
|     let ray = this.sdk.viewer.camera.getPickRay(point1); | ||||
|     let cartesian1 = this.sdk.viewer.scene.globe.pick(ray, this.sdk.viewer.scene); | ||||
|  | ||||
|     var repeatX = distance / entity.polyline.width.getValue(); | ||||
|     // 根据地图缩放程度调整repeatX | ||||
|     var cameraHeight = this.sdk.viewer.camera.positionCartographic.height; | ||||
|     var boundingSphere = new Cesium.BoundingSphere( | ||||
|       new Cesium.Cartesian3(-1000000, 0, 0), // 中心点坐标 | ||||
|       500000 // 半径(距离) | ||||
|     ); | ||||
|     let ray2 = this.sdk.viewer.camera.getPickRay(point2); | ||||
|     let cartesian2 = this.sdk.viewer.scene.globe.pick(ray2, this.sdk.viewer.scene); | ||||
|     // if (!cartesian1 || !cartesian2) { | ||||
|     //   let ray = this.sdk.viewer.camera.getPickRay(point1); | ||||
|     //   cartesian1 = this.sdk.viewer.scene.globe.pick(ray, this.sdk.viewer.scene); | ||||
|  | ||||
|     // 获取绘图缓冲区的宽度和高度(通常是屏幕的分辨率) | ||||
|     var drawingBufferWidth = this.sdk.viewer.canvas.clientWidth; | ||||
|     var drawingBufferHeight = this.sdk.viewer.canvas.clientHeight; | ||||
|     //   let ray2 = this.sdk.viewer.camera.getPickRay(point2); | ||||
|     //   cartesian2 = this.sdk.viewer.scene.globe.pick(ray2, this.sdk.viewer.scene); | ||||
|     // } | ||||
|     if (cartesian1 && cartesian2) { | ||||
|  | ||||
|     // 使用 getPixelSize 方法获取包围球在屏幕上的像素大小 | ||||
|     var groundResolution = this.sdk.viewer.scene.camera.getPixelSize(boundingSphere, drawingBufferWidth, drawingBufferHeight) | ||||
|     // repeatX *= groundResolution / cameraHeight / ((myImg.width / myImg.height * 5) + 1); | ||||
|     if (groundResolution > 700) { | ||||
|       repeatX *= groundResolution / cameraHeight / (options.space * (canvasEle.width / canvasEle.height * 5) + 1); | ||||
|     } else { | ||||
|       repeatX = undefined; | ||||
|  | ||||
|       var distance = Cesium.Cartesian3.distance(cartesian1, cartesian2); | ||||
|  | ||||
|       var repeatX = distance / entity.polyline.width.getValue(); | ||||
|       // 根据地图缩放程度调整repeatX | ||||
|       var cameraHeight = this.sdk.viewer.camera.positionCartographic.height; | ||||
|       var boundingSphere = new Cesium.BoundingSphere( | ||||
|         new Cesium.Cartesian3(-1000000, 0, 0), // 中心点坐标 | ||||
|         500000 // 半径(距离) | ||||
|       ); | ||||
|  | ||||
|  | ||||
|       // 获取绘图缓冲区的宽度和高度(通常是屏幕的分辨率) | ||||
|       var drawingBufferWidth = this.sdk.viewer.canvas.clientWidth; | ||||
|       var drawingBufferHeight = this.sdk.viewer.canvas.clientHeight; | ||||
|  | ||||
|       // 使用 getPixelSize 方法获取包围球在屏幕上的像素大小 | ||||
|       var groundResolution = this.sdk.viewer.scene.camera.getPixelSize(boundingSphere, drawingBufferWidth, drawingBufferHeight) | ||||
|       // repeatX *= groundResolution / cameraHeight / ((myImg.width / myImg.height * 5) + 1); | ||||
|       if (groundResolution > 700) { | ||||
|         repeatX *= groundResolution / cameraHeight / (options.space * (canvasEle.width / canvasEle.height * 5) + 1); | ||||
|       } else { | ||||
|         repeatX = undefined; | ||||
|       } | ||||
|  | ||||
|       if (this.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE3D) { | ||||
|         return repeatX | ||||
|       } else { | ||||
|         let sdk3d = get3DView() | ||||
|         let sdk3dEntity = sdk3d.viewer.entities.getById(this.options.id) | ||||
|         return sdk3dEntity.polyline.oriRepeatX | ||||
|       } | ||||
|     } | ||||
|  | ||||
|     return repeatX | ||||
|   } | ||||
|   /** | ||||
|    * 编辑框 | ||||
| @ -1501,6 +1607,9 @@ class PolylineObject extends Base { | ||||
|           } | ||||
|           this.nodePoints = [] | ||||
|           this.positionEditing = false | ||||
|           YJ.Measure.SetMeasureStatus(false) | ||||
|           this.event && this.event.destroy() | ||||
|           this.tip && this.tip.destroy() | ||||
|         }, | ||||
|         showCallBack: show => { | ||||
|           this.options.show = show | ||||
| @ -1529,10 +1638,20 @@ class PolylineObject extends Base { | ||||
|       // this.attributeCamera = this.options.attribute.camera.content | ||||
|       // this.attributeGoods = this.options.attribute.goods.content | ||||
|  | ||||
|       function tabClick(e) { | ||||
|         if (e === '2' || e === 2) {//点击线条样式 | ||||
|           if (2 < _this.options.type && _this.options.type < 13) {//贴图参数 | ||||
|             document.getElementById('dashTextureDom') && (document.getElementById('dashTextureDom').style.display = 'flex') | ||||
|           } else { | ||||
|             document.getElementById('dashTextureDom') && (document.getElementById('dashTextureDom').style.display = 'none') | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|  | ||||
|       // 创建标签页 | ||||
|       let tabsElm = new cy_tabs( | ||||
|         'polyline-object-edit-tabs', | ||||
|         undefined, | ||||
|         tabClick, | ||||
|         this.sdk | ||||
|       ) | ||||
|       // 颜色组件 | ||||
| @ -1592,7 +1711,7 @@ class PolylineObject extends Base { | ||||
|           this.labelLineColor = 'rgba(255,255,255,1)' | ||||
|         } //点击清空按钮事件回调 | ||||
|       }) | ||||
|       let labelBackgroundColorStartPicker = new YJColorPicker({ | ||||
|       _this.labelBackgroundColorStartPicker = new YJColorPicker({ | ||||
|         el: contentElm.getElementsByClassName('labelBackgroundColorStart')[0], | ||||
|         size: 'mini', | ||||
|         alpha: true, | ||||
| @ -1627,7 +1746,7 @@ class PolylineObject extends Base { | ||||
|       this._elms.labelColor = [labelColorPicker] | ||||
|       this._elms.extendColor = [extendColorPicker] | ||||
|       this._elms.labelLineColor = [lineColorPicker] | ||||
|       this._elms.labelBackgroundColorStart = [labelBackgroundColorStartPicker] | ||||
|       this._elms.labelBackgroundColorStart = [_this.labelBackgroundColorStartPicker] | ||||
|       this._elms.labelBackgroundColorEnd = [labelBackgroundColorEndPicker] | ||||
|  | ||||
|       setTimeout(() => { | ||||
| @ -1725,6 +1844,7 @@ class PolylineObject extends Base { | ||||
|           '.input-select-unit', | ||||
|           1 | ||||
|         ) | ||||
|         this.#unitDataLegpObject = unitDataLegpObject | ||||
|         if (unitDataLegpObject) { | ||||
|           unitDataLegpObject.legp_search(unitData) | ||||
|           let unitDataLegpElm = this._DialogObject._element.content | ||||
| @ -1904,16 +2024,16 @@ class PolylineObject extends Base { | ||||
|  | ||||
|                 //控制参数显隐 | ||||
|                 if (2 < this.lineType && this.lineType < 13) {//贴图参数 | ||||
|                   document.getElementById('dashTextureDom').style.display = 'flex' | ||||
|                   document.getElementById('dashTextureDom') && (document.getElementById('dashTextureDom').style.display = 'flex') | ||||
|                 } else { | ||||
|                   document.getElementById('dashTextureDom').style.display = 'none' | ||||
|                   document.getElementById('dashTextureDom') && (document.getElementById('dashTextureDom').style.display = 'none') | ||||
|                 } | ||||
|                 if (2 < this.lineType && this.lineType < 5) {//尾迹参数 | ||||
|                   document.getElementsByClassName('lineSpace')[0].style.display = 'none' | ||||
|                   document.getElementsByClassName('lineSpace')[1].style.display = 'none' | ||||
|                   document.getElementsByClassName('lineSpace')[0] && (document.getElementsByClassName('lineSpace')[0].style.display = 'none') | ||||
|                   document.getElementsByClassName('lineSpace')[1] && (document.getElementsByClassName('lineSpace')[1].style.display = 'none') | ||||
|                 } else { | ||||
|                   document.getElementsByClassName('lineSpace')[0].style.display = 'flex' | ||||
|                   document.getElementsByClassName('lineSpace')[1].style.display = 'flex' | ||||
|                   document.getElementsByClassName('lineSpace')[0] && (document.getElementsByClassName('lineSpace')[0].style.display = 'flex') | ||||
|                   document.getElementsByClassName('lineSpace')[1] && (document.getElementsByClassName('lineSpace')[1].style.display = 'flex') | ||||
|                 } | ||||
|                 break | ||||
|               } | ||||
| @ -2147,6 +2267,37 @@ class PolylineObject extends Base { | ||||
|           this._elms.altInput.push(altInput) | ||||
|           tBodyElm.appendChild(tr) | ||||
|         } | ||||
|  | ||||
|  | ||||
|         let fontData = getFontList() | ||||
|         let fontObject = legp( | ||||
|           this._DialogObject._element.content.getElementsByClassName( | ||||
|             'font-select-box' | ||||
|           )[0], | ||||
|           '.font-select' | ||||
|         ) | ||||
|         if (fontObject) { | ||||
|           fontObject.legp_search(fontData) | ||||
|           let fontDataLegpElm = this._DialogObject._element.content | ||||
|             .getElementsByClassName('font-select')[0] | ||||
|             .getElementsByTagName('input')[0] | ||||
|           fontDataLegpElm.value = fontData[this.labelFontFamily].value | ||||
|           for (let i = 0; i < fontData.length; i++) { | ||||
|             if (fontData[i].value == fontDataLegpElm.value) { | ||||
|               fontObject.legp_searchActive(fontData[i].value) | ||||
|               break | ||||
|             } | ||||
|           } | ||||
|           fontDataLegpElm.addEventListener('input', () => { | ||||
|             for (let i = 0; i < fontData.length; i++) { | ||||
|               if (fontData[i].value === fontDataLegpElm.value) { | ||||
|                 this.labelFontFamily = fontData[i].key | ||||
|                 break | ||||
|               } | ||||
|             } | ||||
|           }) | ||||
|           this._elms.labelFontFamily = [fontDataLegpElm] | ||||
|         } | ||||
|       }, 0) | ||||
|     } else { | ||||
|       if (this._DialogObject && this._DialogObject.close) { | ||||
| @ -2348,6 +2499,7 @@ class PolylineObject extends Base { | ||||
|     this.labelShow = this.originalOptions.label.show | ||||
|     this.labelColor = this.originalOptions.label.color | ||||
|     this.labelFontSize = this.originalOptions.label.fontSize | ||||
|     this.labelFontFamily = this.originalOptions.label.fontFamily | ||||
|     this.labelLineWidth = this.originalOptions.label.lineWidth | ||||
|     this.labelPixelOffset = this.originalOptions.label.pixelOffset | ||||
|     this.labelLineColor = this.originalOptions.label.lineColor | ||||
|  | ||||
| @ -6,7 +6,7 @@ import EventBinding from '../../Element/Dialog/eventBinding'; | ||||
| import richText from "../../Element/richText"; | ||||
| import MouseEvent from '../../../Event/index' | ||||
| import LabelObject from '../LabelObject' | ||||
| import { syncData } from '../../../Global/MultiViewportMode' | ||||
| import { syncData, getSdk as get2DSdk } from '../../../Global/MultiViewportMode' | ||||
| import { legp } from '../../Element/datalist'; | ||||
| import { getFontList, getFontFamilyName } from '../../Element/fontSelect' | ||||
| import MouseTip from '../../../MouseTip' | ||||
| @ -138,7 +138,7 @@ class RadarScan extends Base { | ||||
|     }) | ||||
|     that.sdk._entityZIndex++ | ||||
|     if (that.sdk.viewer._element.className === 'cesium-viewer 2d') { | ||||
|       that.entity.ellipse.height = 1000000 | ||||
|       that.entity.ellipse.height = 1 | ||||
|     } | ||||
|     RadarScan.createLabel(that) | ||||
|     syncData(that.sdk, that.options.id) | ||||
| @ -246,16 +246,29 @@ class RadarScan extends Base { | ||||
|  | ||||
|   set show(v) { | ||||
|     if (typeof v === "boolean") { | ||||
|       this.options.show = v | ||||
|       this.entity.show = v | ||||
|       let sdkD = get2DSdk().sdkD | ||||
|       if (!this.isShowView || !sdkD) { | ||||
|         this.options.show = v | ||||
|       } | ||||
|       if (!this.showView || this.showView == 3 || !sdkD) { | ||||
|         this.entity.show = this.options.show | ||||
|         if (this.options.label.show && this.label) { | ||||
|           this.label.show = this.options.show | ||||
|         } | ||||
|       } | ||||
|       else { | ||||
|         this.entity.show = false | ||||
|         if (this.options.label.show && this.label) { | ||||
|           this.label.show = false | ||||
|         } | ||||
|       } | ||||
|       if (this._DialogObject && this._DialogObject.showBtn) { | ||||
|         this._DialogObject.showBtn.checked = v | ||||
|       } | ||||
|       if (this.options.label.show && this.label) { | ||||
|         this.label.show = v | ||||
|       } | ||||
|        | ||||
|       syncData(this.sdk, this.options.id) | ||||
|       syncSplitData(this.sdk, this.options.id) | ||||
|       this.isShowView = false | ||||
|     } else { | ||||
|       console.error("参数必须为boolean") | ||||
|     } | ||||
| @ -448,8 +461,9 @@ class RadarScan extends Base { | ||||
|     return this.options.label.show | ||||
|   } | ||||
|   set labelShow(v) { | ||||
|     let sdkD = get2DSdk().sdkD | ||||
|     this.options.label.show = v | ||||
|     if (this.show) { | ||||
|     if (this.show && (!this.showView || this.showView == 3 || !sdkD)) { | ||||
|       this.label.show = v | ||||
|     } | ||||
|     else { | ||||
| @ -1374,7 +1388,7 @@ class RadarScan extends Base { | ||||
|   } | ||||
|  | ||||
|   async remove() { | ||||
|     this.label.remove() | ||||
|     this.label && this.label.remove() | ||||
|     this.entity && this.sdk.viewer.entities.remove(this.entity) | ||||
|     this.entity2 && this.sdk.viewer.entities.remove(this.entity2) | ||||
|     this.entity = null | ||||
|  | ||||
| @ -424,7 +424,7 @@ class RadarScanStereoscopic extends Base { | ||||
|   } | ||||
|   set labelShow(v) { | ||||
|     this.options.label.show = v | ||||
|     if (this.show) { | ||||
|     if (this.show && !this.showView || this.showView == 3) { | ||||
|       this.label.show = v | ||||
|     } | ||||
|     else { | ||||
|  | ||||
| @ -5,7 +5,7 @@ class Corridor extends Base { | ||||
|   // /** | ||||
|   //  * @constructor | ||||
|   //  * @description 道路 | ||||
|   //  * @param sdk  | ||||
|   //  * @param sdk | ||||
|   //  * @param options {object} 属性 | ||||
|   //  * @param options.name{string} 名称 | ||||
|   //  * @param options.image{string | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement} 指定 Image、URL、Canvas 或 Video 的属性 | ||||
| @ -67,7 +67,7 @@ class Corridor extends Base { | ||||
|     //     material: new Cesium.ImageMaterialProperty({ | ||||
|     //       image: this.options.image, | ||||
|     //       repeat: new Cesium.Cartesian2(100, 1.0), | ||||
|     //       color: Cesium.Color.TOMATO  | ||||
|     //       color: Cesium.Color.TOMATO | ||||
|     //     }) | ||||
|     //   } | ||||
|     // }); | ||||
| @ -217,10 +217,10 @@ class Corridor extends Base { | ||||
|       let aa = 0 | ||||
|  | ||||
|       const shader = ` | ||||
|         uniform sampler2D image;  | ||||
|         uniform sampler2D image; | ||||
|         uniform vec4 color; | ||||
|         uniform vec2 repeat; | ||||
|        | ||||
|  | ||||
|         czm_material czm_getMaterial(czm_materialInput materialInput){ | ||||
|         czm_material material=czm_getDefaultMaterial(materialInput); | ||||
|         mat2 rotationMatrix = mat2(cos(radians(-rotate)), sin(radians(-rotate)), -sin(radians(-rotate)), cos(radians(-rotate))); | ||||
|  | ||||
							
								
								
									
										39
									
								
								src/Obj/Base/RoadObject/_element.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								src/Obj/Base/RoadObject/_element.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,39 @@ | ||||
| function html() { | ||||
|   return ` | ||||
|     <span class="custom-divider"></span> | ||||
|     <div class="div-item"> | ||||
|         <div class="row"> | ||||
|             <div class="col"> | ||||
|                 <span class="label">名称</span> | ||||
|                 <input class="input" maxlength="40" type="text" @model="name"> | ||||
|             </div> | ||||
|             <div class="col road-box"> | ||||
|                 <span class="label" style="flex: 0 0 56px;">道路类型</span> | ||||
|                 <div class="road-type"></div> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
|     <span class="custom-divider"></span> | ||||
|     <div class="div-item"> | ||||
|         <div class="row"> | ||||
|             <div class="col"> | ||||
|                 <span class="label">车道宽度</span> | ||||
|                 <div class="input-number input-number-unit-1"> | ||||
|                     <input class="input" type="number" title="" max="99999" min="1" step="1" @model="carRoadWidth"> | ||||
|                     <span class="arrow"></span> | ||||
|                 </div> | ||||
|             </div> | ||||
|             <div class="col"> | ||||
|                 <span class="label">人行道宽度</span> | ||||
|                 <div class="input-number input-number-unit-1"> | ||||
|                     <input class="input" type="number" title="" max="99999" min="1" step="1" @model="sideWidth"> | ||||
|                     <span class="arrow"></span> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
|     <span class="custom-divider"></span> | ||||
|     ` | ||||
| } | ||||
|  | ||||
| export { html } | ||||
							
								
								
									
										92
									
								
								src/Obj/Base/RoadObject/eventBinding.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										92
									
								
								src/Obj/Base/RoadObject/eventBinding.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,92 @@ | ||||
| class eventBinding { | ||||
|   constructor() { | ||||
|     this.element = {} | ||||
|   } | ||||
|   static event = {} | ||||
|  | ||||
|   getEvent(name) { | ||||
|     return eventBinding.event[name] | ||||
|   } | ||||
|  | ||||
|   getEventAll() { | ||||
|     return eventBinding.event | ||||
|   } | ||||
|  | ||||
|   setEvent(name, event) { | ||||
|     eventBinding.event[name] = event | ||||
|   } | ||||
|  | ||||
|   on(that, elements) { | ||||
|     for (let i = 0; i < elements.length; i++) { | ||||
|       let Event = [] | ||||
|       let isEvent = false | ||||
|       let removeName = [] | ||||
|       if (!elements[i] || !elements[i].attributes) { | ||||
|         continue; | ||||
|       } | ||||
|       for (let m of elements[i].attributes) { | ||||
|         switch (m.name) { | ||||
|           case '@model': { | ||||
|             isEvent = true | ||||
|             if (elements[i].type == 'checkbox') { | ||||
|               Event.push((e) => { that[m.value] = e.target.checked }) | ||||
|               elements[i].checked = that[m.value] | ||||
|             } | ||||
|             else { | ||||
|               Event.push((e) => { | ||||
|                 let value = e.target.value | ||||
|                 if (e.target.type == 'number') { | ||||
|                   value = Number(value) | ||||
|                 } | ||||
|                 that[m.value] = value | ||||
|               }) | ||||
|               if (elements[i].nodeName == 'IMG') { | ||||
|                 elements[i].src = that[m.value] | ||||
|               } | ||||
|               else { | ||||
|                 elements[i].value = that[m.value] | ||||
|               } | ||||
|             } | ||||
|             if (this.element[m.value]) { | ||||
|               this.element[m.value].push(elements[i]) | ||||
|             } | ||||
|             else { | ||||
|               this.element[m.value] = [elements[i]] | ||||
|             } | ||||
|             removeName.push(m.name) | ||||
|             break; | ||||
|           } | ||||
|           case '@click': { | ||||
|             elements[i].addEventListener('click', (e) => { | ||||
|               if (typeof (that.Dialog[m.value]) === 'function') { | ||||
|                 that.Dialog[m.value](e) | ||||
|               } | ||||
|             }); | ||||
|             removeName.push(m.name) | ||||
|             // elements[i].attributes.removeNamedItem(m.name) | ||||
|             break; | ||||
|           } | ||||
|         } | ||||
|         // elements[i].attributes[m] = undefined | ||||
|       } | ||||
|       for (let n = 0; n < removeName.length; n++) { | ||||
|         elements[i].attributes.removeNamedItem(removeName[n]) | ||||
|       } | ||||
|  | ||||
|       if (isEvent) { | ||||
|         let ventType = 'input' | ||||
|         if (elements[i].tagName != 'INPUT' || elements[i].type == 'checkbox') { | ||||
|           ventType = 'change' | ||||
|         } | ||||
|         elements[i].addEventListener(ventType, (e) => { | ||||
|           for (let t = 0; t < Event.length; t++) { | ||||
|             Event[t](e) | ||||
|           } | ||||
|         }); | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
| const EventBinding = new eventBinding(); | ||||
| export default EventBinding; | ||||
							
								
								
									
										1549
									
								
								src/Obj/Base/RoadObject/index-8.4.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1549
									
								
								src/Obj/Base/RoadObject/index-8.4.js
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										1704
									
								
								src/Obj/Base/RoadObject/index-last.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1704
									
								
								src/Obj/Base/RoadObject/index-last.js
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										889
									
								
								src/Obj/Base/RoadObject/index-拐角连接.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										889
									
								
								src/Obj/Base/RoadObject/index-拐角连接.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,889 @@ | ||||
| /** | ||||
|  * @description 道路 | ||||
|  */ | ||||
| import Dialog from '../../Element/Dialog'; | ||||
| import { html } from "./_element"; | ||||
| import EventBinding from '../../Element/Dialog/eventBinding'; | ||||
| import Base from "../index"; | ||||
| import { syncData } from '../../../Global/MultiViewportMode' | ||||
| import { setSplitDirection, syncSplitData, setActiveId } from '../../../Global/SplitScreen' | ||||
| import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../Global/global' | ||||
|  | ||||
| class Road extends Base { | ||||
|   /** | ||||
|    * @constructor | ||||
|    * @param sdk | ||||
|    * @description 道路 | ||||
|    * @param options {object} 道路属性 | ||||
|    * @param options.name=未命名对象 {string} 名称 | ||||
|    * @param options.carRoadWidth=2 {number} 车道宽度 | ||||
|    * @param options.sideWidth=2 {number} 人行道宽度 | ||||
|    * @param options.positions=[] {array} 道路positions | ||||
|    * @param options.roadImage='' {string} 车道贴图 | ||||
|    * @param options.sideImage='' {string} 人行道贴图 | ||||
|    * @param Dialog {object} 弹框对象 | ||||
|    * @param Dialog.confirmCallBack {function} 弹框确认时的回调 | ||||
|    * */ | ||||
|   constructor(sdk, options = {}, _Dialog = {}) { | ||||
|     super(sdk, options); | ||||
|     this.viewer = this.sdk.viewer | ||||
|     this.options.name = options.name || '道路' | ||||
|     this.options.carRoadWidth = options.carRoadWidth || 10 | ||||
|     this.options.sideWidth = options.sideWidth || 5 | ||||
|     this.options.positions = options.positions || [] | ||||
|     this.options.roadImage = options.roadImage || (this.getSourceRootPath() + '/img/roadPhoto.png') | ||||
|     this.options.sideImage = options.sideImage || (this.getSourceRootPath() + '/img/sidePhoto.png') | ||||
|     this.options.show = (options.show || options.show === false) ? options.show : true | ||||
|     this.Dialog = _Dialog | ||||
|     this._EventBinding = new EventBinding() | ||||
|     this._elms = {}; | ||||
|     this.positionArea = [] | ||||
|     this.positions = [] | ||||
|     this.lineEntity = '' | ||||
|  | ||||
|     this.sdk.addIncetance(this.options.id, this) | ||||
|     Road.create(this) | ||||
|   } | ||||
|  | ||||
|   // 创建道路 | ||||
|   static create(that) { | ||||
|     let positions = [] | ||||
|     that.options.positions.forEach(v => { | ||||
|       positions.push(new Cesium.Cartesian3.fromDegrees(v.lng, v.lat, v.alt)) | ||||
|     }) | ||||
|  | ||||
|     let area = [[], [], []] | ||||
|     area[1] = that.createLineBufferPolygon2(positions, that.options.carRoadWidth / 2) | ||||
|     area[0] = that.createLineBufferPolygonSide(area[1][2], -that.options.sideWidth) | ||||
|     area[2] = that.createLineBufferPolygonSide(area[1][1], that.options.sideWidth) | ||||
|  | ||||
|     //判断道路边是否相交 | ||||
|     for (let i = 0; i < area[0].length - 1; i++) { | ||||
|  | ||||
|       let leftItem = area[0][i] | ||||
|       let leftItem2 = area[0][i + 1] | ||||
|       let rightItem = area[2][i] | ||||
|       let rightItem2 = area[2][i + 1] | ||||
|       let carItem = area[1][0][i] | ||||
|       let carItem2 = area[1][0][i + 1] | ||||
|       let leftLine = that.getIntersects(leftItem[1], leftItem[2], leftItem2[1], leftItem2[2]) | ||||
|       let rightLine = that.getIntersects(rightItem[1], rightItem[2], rightItem2[1], rightItem2[2]) | ||||
|  | ||||
|       console.log(leftLine, 'leftLine') | ||||
|       if (leftLine) {//左侧相交 | ||||
|         //获取右侧延长交点 | ||||
|         let point1 = that.getExtendPoint(rightItem[1], rightItem[2], 1000) | ||||
|         let point2 = that.getExtendPoint(rightItem2[2], rightItem2[1], 1000) | ||||
|         let rightIntersection = that.getIntersects(rightItem[2], point1, rightItem2[1], point2) | ||||
|         //将其他几条边都延长 | ||||
|         let leftLineNeiPoint = that.getExtendPoint(leftItem[0], leftItem[3], 1000) | ||||
|         let carLeftPoint = that.getExtendPoint(carItem[3], carItem[2], 1000) | ||||
|         let carRightPoint = that.getExtendPoint(carItem[0], carItem[1], 1000) | ||||
|         let rightLineNeiPoint = that.getExtendPoint(rightItem[0], rightItem[3], 1000) | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|         //跟左侧里相交点 | ||||
|         let leftLineNei = that.getIntersects(leftLine, rightIntersection, leftItem[0], leftLineNeiPoint) | ||||
|         //跟车道左侧相交点 | ||||
|         let carLeft = that.getIntersects(leftLine, rightIntersection, carItem[3], carLeftPoint) | ||||
|         //跟车道右侧相交点 | ||||
|         let carRight = that.getIntersects(leftLine, rightIntersection, carItem[0], carRightPoint) | ||||
|         let rightLineNei = that.getIntersects(leftLine, rightIntersection, rightItem[0], rightLineNeiPoint) | ||||
|  | ||||
|         // let leftLineNei = that.getIntersects(leftLine, rightItem[2], leftItem[0], leftItem[3]) | ||||
|         // let carLeft = that.getIntersects(leftLine, rightItem[2], carItem[3], carItem[2]) | ||||
|         // let carRight = that.getIntersects(leftLine, rightItem[2], carItem[0], carItem[1]) | ||||
|         // let rightLineNei = that.getIntersects(leftLine, rightItem[2], rightItem[0], rightItem[3]) | ||||
|  | ||||
|         // let leftLineNei = that.getIntersects(leftLine, intersection, leftItem[0], leftItem[3]) | ||||
|         // //跟车道左侧相交点 | ||||
|         // let carLeft = that.getIntersects(leftLine, intersection, carItem[3], carItem[2]) | ||||
|         // //跟车道右侧相交点 | ||||
|         // let carRight = that.getIntersects(leftLine, intersection, carItem[0], carItem[1]) | ||||
|         // let rightLineNei = that.getIntersects(leftLine, intersection, rightItem[0], rightItem[3]) | ||||
|  | ||||
|         leftItem[2] = leftLine | ||||
|         leftItem[3] = leftLineNei | ||||
|         carItem[2] = carLeft | ||||
|         carItem[1] = carRight | ||||
|         rightItem[3] = rightLineNei | ||||
|         rightItem[2] = rightIntersection | ||||
|         console.log(leftItem, carItem, rightItem, 'leftItemleft') | ||||
|  | ||||
|  | ||||
|         //将其他几条边都延长 | ||||
|         let leftLineNeiPoint2 = that.getExtendPoint(leftItem2[3], leftItem2[0], 1000) | ||||
|         let carLeftPoint2 = that.getExtendPoint(carItem2[2], carItem2[3], 1000) | ||||
|         let carRightPoint2 = that.getExtendPoint(carItem2[1], carItem2[0], 1000) | ||||
|         let rightLineNeiPoint2 = that.getExtendPoint(rightItem2[3], rightItem2[0], 1000) | ||||
|  | ||||
|         // let leftLineNei2 = that.getIntersects(leftLine, rightItem2[1], leftItem2[0], leftItem2[3]) | ||||
|         // let carLeft2 = that.getIntersects(leftLine, rightItem2[1], carItem2[3], carItem2[2]) | ||||
|         // let carRight2 = that.getIntersects(leftLine, rightItem2[1], carItem2[0], carItem2[1]) | ||||
|         // let rightLineNei2 = that.getIntersects(leftLine, rightItem2[1], rightItem2[0], rightItem2[3]) | ||||
|  | ||||
|  | ||||
|  | ||||
|         let leftLineNei2 = that.getIntersects(leftLine, rightIntersection, leftItem2[3], leftLineNeiPoint2) | ||||
|         let carLeft2 = that.getIntersects(leftLine, rightIntersection, carItem2[2], carLeftPoint2) | ||||
|         let carRight2 = that.getIntersects(leftLine, rightIntersection, carItem2[1], carRightPoint2) | ||||
|         let rightLineNei2 = that.getIntersects(leftLine, rightIntersection, rightItem2[3], rightLineNeiPoint2) | ||||
|  | ||||
|         // let arr = [leftLine, rightIntersection, leftItem2[3], leftLineNeiPoint2] | ||||
|         // arr.forEach((item, index) => { | ||||
|         //   that.sdk.viewer.entities.add({ | ||||
|         //     name: 'node-secondary-edit-point', | ||||
|         //     index: i, | ||||
|         //     position: item, | ||||
|         //     billboard: { | ||||
|         //       image: that.getSourceRootPath() + '/img/point.png', | ||||
|         //       width: 15, | ||||
|         //       height: 15, | ||||
|         //       disableDepthTestDistance: Number.POSITIVE_INFINITY, | ||||
|         //       color: Cesium.Color.WHITE.withAlpha(0.99) | ||||
|         //     }, | ||||
|         //     label: { | ||||
|         //       text: '' + index, | ||||
|         //       pixelOffset: { x: 0, y: -20 }, | ||||
|         //     }, | ||||
|         //   }) | ||||
|         // }) | ||||
|  | ||||
|         // let leftLineNei2 = that.getIntersects(leftLine, intersection, leftItem2[0], leftItem2[3]) | ||||
|         // //跟车道左侧相交点 | ||||
|         // let carLeft2 = that.getIntersects(leftLine, intersection, carItem2[3], carItem2[2]) | ||||
|         // //跟车道右侧相交点 | ||||
|         // let carRight2 = that.getIntersects(leftLine, intersection, carItem2[0], carItem2[1]) | ||||
|         // let rightLineNei2 = that.getIntersects(leftLine, intersection, rightItem2[0], rightItem2[3]) | ||||
|  | ||||
|         leftItem2[1] = leftLine | ||||
|         leftItem2[0] = leftLineNei2 | ||||
|         carItem2[3] = carLeft2 | ||||
|         carItem2[0] = carRight2 | ||||
|         rightItem2[0] = rightLineNei2 | ||||
|         rightItem2[1] = rightIntersection | ||||
|         console.log(leftItem2, carItem2, rightItem2, 'leftItem2left') | ||||
|  | ||||
|       } else if (rightLine) {//右侧相交 | ||||
|  | ||||
|         //获取左侧延长交点 | ||||
|         let point1 = that.getExtendPoint(leftItem[1], leftItem[2], 1000) | ||||
|         let point2 = that.getExtendPoint(leftItem2[2], leftItem2[1], 1000) | ||||
|         let rightIntersection = that.getIntersects(leftItem[2], point1, leftItem2[1], point2) | ||||
|         //将其他几条边都延长 | ||||
|         let leftLineNeiPoint = that.getExtendPoint(leftItem[0], leftItem[3], 1000) | ||||
|         let carLeftPoint = that.getExtendPoint(carItem[3], carItem[2], 1000) | ||||
|         let carRightPoint = that.getExtendPoint(carItem[0], carItem[1], 1000) | ||||
|         let rightLineNeiPoint = that.getExtendPoint(rightItem[0], rightItem[3], 1000) | ||||
|  | ||||
|         // //跟左侧里相交点 | ||||
|         let leftLineNei = that.getIntersects(rightLine, rightIntersection, leftItem[0], leftLineNeiPoint) | ||||
|         //跟车道左侧相交点 | ||||
|         let carLeft = that.getIntersects(rightLine, rightIntersection, carItem[3], carLeftPoint) | ||||
|         //跟车道右侧相交点 | ||||
|         let carRight = that.getIntersects(rightLine, rightIntersection, carItem[0], carRightPoint) | ||||
|         let rightLineNei = that.getIntersects(rightLine, rightIntersection, rightItem[0], rightLineNeiPoint) | ||||
|         // //跟左侧里相交点 | ||||
|         // let leftLineNei = that.getIntersects(rightLine, leftItem[2], leftItem[0], leftItem[3]) | ||||
|         // //跟车道左侧相交点 | ||||
|         // let carLeft = that.getIntersects(rightLine, leftItem[2], carItem[3], carItem[2]) | ||||
|         // //跟车道右侧相交点 | ||||
|         // let carRight = that.getIntersects(rightLine, leftItem[2], carItem[0], carItem[1]) | ||||
|         // let rightLineNei = that.getIntersects(rightLine, leftItem[2], rightItem[0], rightItem[3]) | ||||
|  | ||||
|  | ||||
|         leftItem[2] = rightIntersection | ||||
|         leftItem[3] = leftLineNei | ||||
|         carItem[2] = carLeft | ||||
|         carItem[1] = carRight | ||||
|         rightItem[3] = rightLineNei | ||||
|         rightItem[2] = rightLine | ||||
|         console.log(leftItem, carItem, rightItem, 'leftItemright') | ||||
|  | ||||
|         //将其他几条边都延长 | ||||
|         let leftLineNeiPoint2 = that.getExtendPoint(leftItem2[3], leftItem2[0], 1000) | ||||
|         let carLeftPoint2 = that.getExtendPoint(carItem2[2], carItem2[3], 1000) | ||||
|         let carRightPoint2 = that.getExtendPoint(carItem2[1], carItem2[0], 1000) | ||||
|         let rightLineNeiPoint2 = that.getExtendPoint(rightItem2[3], rightItem2[0], 1000) | ||||
|  | ||||
|         let leftLineNei2 = that.getIntersects(rightLine, rightIntersection, leftItem2[3], leftLineNeiPoint2) | ||||
|         //跟车道左侧相交点 | ||||
|         let carLeft2 = that.getIntersects(rightLine, rightIntersection, carItem2[2], carLeftPoint2) | ||||
|         //跟车道右侧相交点 | ||||
|         let carRight2 = that.getIntersects(rightLine, rightIntersection, carItem2[1], carRightPoint2) | ||||
|         let rightLineNei2 = that.getIntersects(rightLine, rightIntersection, rightItem2[3], rightLineNeiPoint2) | ||||
|         // let leftLineNei2 = that.getIntersects(rightLine, leftItem2[1], leftItem2[0], leftItem2[3]) | ||||
|         // //跟车道左侧相交点 | ||||
|         // let carLeft2 = that.getIntersects(rightLine, leftItem2[1], carItem2[3], carItem2[2]) | ||||
|         // //跟车道右侧相交点 | ||||
|         // let carRight2 = that.getIntersects(rightLine, leftItem2[1], carItem2[0], carItem2[1]) | ||||
|         // let rightLineNei2 = that.getIntersects(rightLine, leftItem2[1], rightItem2[0], rightItem2[3]) | ||||
|  | ||||
|         leftItem2[1] = rightIntersection | ||||
|         leftItem2[0] = leftLineNei2 | ||||
|         carItem2[3] = carLeft2 | ||||
|         carItem2[0] = carRight2 | ||||
|         rightItem2[0] = rightLineNei2 | ||||
|         rightItem2[1] = rightLine | ||||
|         console.log(leftItem2, carItem2, rightItem2, 'leftItem2right') | ||||
|  | ||||
|       } | ||||
|     } | ||||
|  | ||||
|  | ||||
|     console.log(area[0], 'area') | ||||
|  | ||||
|     if (that.viewer.entities.getById(that.options.id)) { | ||||
|       that.viewer.entities.getById(that.options.id)._children.forEach((item) => { | ||||
|         that.viewer.entities.remove(item); | ||||
|       }); | ||||
|       that.viewer.entities.remove(that.viewer.entities.getById(that.options.id)) | ||||
|     } | ||||
|     that.lineEntity = that.viewer.entities.add(new Cesium.Entity({ id: that.options.id, show: that.options.show })) | ||||
|  | ||||
|     const myImg = new Image() | ||||
|     myImg.src = that.options.roadImage | ||||
|     myImg.onload = function () { | ||||
|       console.log(area[1][0], 'arr') | ||||
|       area[1][0].forEach((item, index) => { | ||||
|         that.viewer.entities.add({ | ||||
|           // id: that.options.id, | ||||
|           parent: that.lineEntity, | ||||
|           polygon: { | ||||
|             hierarchy: new Cesium.PolygonHierarchy(item), | ||||
|             material: new Cesium.ImageMaterialProperty({ | ||||
|               image: that.options.roadImage, | ||||
|               transparent: true,// 如果图片有透明部分,需要设置为 true | ||||
|               repeat: that.calculateTextureRepeat(item, myImg) | ||||
|             }), | ||||
|             stRotation: that.calculateRoadAngle(positions[index], positions[index + 1]) | ||||
|           } | ||||
|         }); | ||||
|       }) | ||||
|     } | ||||
|  | ||||
|     const myImg2 = new Image() | ||||
|     myImg2.src = that.options.sideImage | ||||
|     myImg2.onload = function () { | ||||
|       area[0].forEach((item, index) => { | ||||
|         that.viewer.entities.add({ | ||||
|           parent: that.lineEntity, | ||||
|           polygon: { | ||||
|             hierarchy: new Cesium.PolygonHierarchy(item), | ||||
|             material: new Cesium.ImageMaterialProperty({ | ||||
|               image: that.options.sideImage, | ||||
|               transparent: true,// 如果图片有透明部分,需要设置为 true | ||||
|               repeat: that.calculateTextureRepeat(item, myImg2) | ||||
|             }), | ||||
|             stRotation: that.calculateRoadAngle(positions[index], positions[index + 1]) | ||||
|           } | ||||
|         }); | ||||
|       }) | ||||
|  | ||||
|       area[2].forEach((item, index) => { | ||||
|         that.viewer.entities.add({ | ||||
|           polygon: { | ||||
|             hierarchy: new Cesium.PolygonHierarchy(item), | ||||
|             material: new Cesium.ImageMaterialProperty({ | ||||
|               image: that.options.sideImage, | ||||
|               transparent: true,// 如果图片有透明部分,需要设置为 true | ||||
|               repeat: that.calculateTextureRepeat(item, myImg2) | ||||
|             }), | ||||
|             stRotation: that.calculateRoadAngle(positions[index], positions[index + 1]) | ||||
|           } | ||||
|         }); | ||||
|       }) | ||||
|  | ||||
|     } | ||||
|  | ||||
|   } | ||||
|   getExtendPoint(position1, position2, distance) { | ||||
|     // let position1 = Cesium.Cartesian3.fromDegrees(p1[0], p1[1], 0); | ||||
|     // let position2 = Cesium.Cartesian3.fromDegrees(p2[0], p2[1], 0); | ||||
|     let pot = Cesium.Cartesian3.subtract(position2, position1, new Cesium.Cartesian3());//方向 | ||||
|     var dir = Cesium.Cartesian3.normalize(pot, new Cesium.Cartesian3());//向量归一化 | ||||
|  | ||||
|     var ray = new Cesium.Ray(position1, dir); | ||||
|     let np = Cesium.Ray.getPoint(ray, distance * 10);//计算延长点 | ||||
|     return np | ||||
|   } | ||||
|   getArr(arr1, arr2) { | ||||
|     arr2 = arr2.reverse() | ||||
|     let polygon = [] | ||||
|     for (let index = 0; index < arr1.length - 1; index++) { | ||||
|       polygon.push([arr1[index], arr1[index + 1], arr2[index + 1], arr2[index]]) | ||||
|     } | ||||
|     return polygon | ||||
|   } | ||||
|  | ||||
|   calculateRoadAngle(startPoint, endPoint) { | ||||
|     // 1. 获取地表法向量 | ||||
|     const normal = Cesium.Ellipsoid.WGS84.geodeticSurfaceNormal(startPoint); | ||||
|  | ||||
|     // 2. 构建精确ENU坐标系 | ||||
|     const enuMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(startPoint, undefined, normal); | ||||
|     const inverseMatrix = Cesium.Matrix4.inverse(enuMatrix, new Cesium.Matrix4()); | ||||
|  | ||||
|     // 3. 转换终点并计算水平向量 | ||||
|     const localEnd = Cesium.Matrix4.multiplyByPoint(inverseMatrix, endPoint, new Cesium.Cartesian3()); | ||||
|     const horizontalVec = new Cesium.Cartesian2(localEnd.x, localEnd.y); | ||||
|     Cesium.Cartesian2.normalize(horizontalVec, horizontalVec); | ||||
|  | ||||
|     const north = new Cesium.Cartesian2(1, 0); | ||||
|  | ||||
|     const angle = Cesium.Cartesian2.angleBetween(north, horizontalVec); | ||||
|     const cross = Cesium.Cartesian2.cross(north, horizontalVec, new Cesium.Cartesian2()); | ||||
|     return cross < 0 ? angle : -angle; | ||||
|   } | ||||
|  | ||||
|   calculatePolygonOrientation(positions) { | ||||
|  | ||||
|     // 假设 position 是 Cesium.Cartesian3 对象,表示地球上的某个点 | ||||
|     var position = positions[0] | ||||
|     // 获取东、北、上坐标系 | ||||
|     var eastNorthUp = Cesium.Transforms.eastNorthUpToFixedFrame(position); | ||||
|     // northAxis 是北方向向量 | ||||
|     var northAxis = eastNorthUp.getColumn(1, new Cesium.Cartesian3()); | ||||
|     Cesium.Cartesian3.normalize(northAxis, northAxis); | ||||
|  | ||||
|     const direction = Cesium.Cartesian3.subtract(positions[0], positions[1], new Cesium.Cartesian3()); | ||||
|     Cesium.Cartesian3.normalize(direction, direction); | ||||
|  | ||||
|  | ||||
|     const dot = Cesium.Cartesian3.dot(northAxis, direction); | ||||
|     const magA = Cesium.Cartesian3.magnitude(northAxis); | ||||
|     const magB = Cesium.Cartesian3.magnitude(direction); | ||||
|     return Math.acos(dot / (magA * magB)); | ||||
|   } | ||||
|   calculateTextureRepeat(polygonPositions, textureSize, meterPerPixel = 0.01) { | ||||
|     // 验证纹理尺寸 | ||||
|     if (!textureSize.width || !textureSize.height) { | ||||
|       throw new Error('Texture size must contain width and height in pixels'); | ||||
|     } | ||||
|  | ||||
|     // 创建多边形几何体 | ||||
|     const geometry = Cesium.PolygonGeometry.createGeometry( | ||||
|       new Cesium.PolygonGeometry({ | ||||
|         polygonHierarchy: new Cesium.PolygonHierarchy(polygonPositions), | ||||
|         vertexFormat: Cesium.VertexFormat.POSITION_ONLY | ||||
|       }) | ||||
|     ); | ||||
|  | ||||
|     // 计算多边形面积(平方米) | ||||
|     let area = 0; | ||||
|     const indices = geometry.indices; | ||||
|     const positions = geometry.attributes.position.values; | ||||
|     for (let i = 0; i < indices.length; i += 3) { | ||||
|       const i0 = indices[i] * 3; | ||||
|       const i1 = indices[i + 1] * 3; | ||||
|       const i2 = indices[i + 2] * 3; | ||||
|  | ||||
|       const p0 = new Cesium.Cartesian3(positions[i0], positions[i0 + 1], positions[i0 + 2]); | ||||
|       const p1 = new Cesium.Cartesian3(positions[i1], positions[i1 + 1], positions[i1 + 2]); | ||||
|       const p2 = new Cesium.Cartesian3(positions[i2], positions[i2 + 1], positions[i2 + 2]); | ||||
|  | ||||
|       const cross = Cesium.Cartesian3.cross( | ||||
|         Cesium.Cartesian3.subtract(p1, p0, new Cesium.Cartesian3()), | ||||
|         Cesium.Cartesian3.subtract(p2, p0, new Cesium.Cartesian3()), | ||||
|         new Cesium.Cartesian3() | ||||
|       ); | ||||
|       area += Cesium.Cartesian3.magnitude(cross) * 0.5; | ||||
|     } | ||||
|  | ||||
|     // 将像素尺寸转换为实际尺寸(平方米) | ||||
|     const textureWidthMeters = textureSize.width * meterPerPixel; | ||||
|     const textureHeightMeters = textureSize.height * meterPerPixel; | ||||
|     const textureArea = textureWidthMeters * textureHeightMeters; | ||||
|  | ||||
|     // 计算各轴向重复次数 | ||||
|     const repeatX = Math.sqrt(area) / textureWidthMeters; | ||||
|     const repeatY = Math.sqrt(area) / textureHeightMeters; | ||||
|  | ||||
|     return new Cesium.Cartesian2(Math.max(1, Math.ceil(repeatX)), 1.0); | ||||
|   } | ||||
|   swapLastElements(arr1, arr2) { | ||||
|     const last = arr1[arr1.length - 1] | ||||
|     const first = arr2[0] | ||||
|     arr1[arr1.length - 1] = first | ||||
|     arr2[0] = last | ||||
|  | ||||
|     return [arr1, arr2]; | ||||
|   } | ||||
|   createLineBufferPolygonSide(positions, width) { | ||||
|     let area = [] | ||||
|     for (let i = 0; i < positions.length; i++) { | ||||
|       const posi = positions[i]; | ||||
|  | ||||
|       const dir = Cesium.Cartesian3.subtract(posi[1], posi[0], new Cesium.Cartesian3()); | ||||
|       Cesium.Cartesian3.normalize(dir, dir); | ||||
|  | ||||
|       // 获取垂直向量(基于Z轴) | ||||
|       const perp = Cesium.Cartesian3.cross(dir, Cesium.Cartesian3.UNIT_Z, new Cesium.Cartesian3()); | ||||
|       Cesium.Cartesian3.normalize(perp, perp); | ||||
|  | ||||
|       // 生成偏移向量 | ||||
|       const offset = Cesium.Cartesian3.multiplyByScalar(perp, width, new Cesium.Cartesian3()); | ||||
|       let point1 = Cesium.Cartesian3.add(posi[0], offset, new Cesium.Cartesian3()) | ||||
|       let point3 = Cesium.Cartesian3.add(posi[1], offset, new Cesium.Cartesian3()) | ||||
|  | ||||
|       // i == positions.length - 2 ? area.push(start, point1, end, point3) : area.push(start, point1) | ||||
|       area.push([posi[0], point1, point3, posi[1]]) | ||||
|     } | ||||
|     // let arr = [] | ||||
|     // for (let i = 0; i < area.length - 2; i += 2) { | ||||
|     //   arr.push([area[i], area[i + 1], area[i + 3], area[i + 2]]) | ||||
|     // } | ||||
|     return area | ||||
|   } | ||||
|   createLineBufferPolygon2(positions, width) { | ||||
|     let area = [] | ||||
|     let leftPositions = []; | ||||
|     let rightPositions = []; | ||||
|  | ||||
|     for (let i = 0; i < positions.length - 1; i++) { | ||||
|       const start = positions[i]; | ||||
|       // const end = positions[i + 1] || positions[i - 1]; | ||||
|       const end = positions[i + 1]; | ||||
|  | ||||
|       const dir = Cesium.Cartesian3.subtract(end, start, new Cesium.Cartesian3()); | ||||
|       Cesium.Cartesian3.normalize(dir, dir); | ||||
|  | ||||
|       // 获取垂直向量(基于Z轴) | ||||
|       const perp = Cesium.Cartesian3.cross(dir, Cesium.Cartesian3.UNIT_Z, new Cesium.Cartesian3()); | ||||
|       Cesium.Cartesian3.normalize(perp, perp); | ||||
|  | ||||
|       const dir2 = Cesium.Cartesian3.subtract(start, end, new Cesium.Cartesian3()); | ||||
|       Cesium.Cartesian3.normalize(dir2, dir2); | ||||
|  | ||||
|       // 获取垂直向量(基于Z轴) | ||||
|       const perp2 = Cesium.Cartesian3.cross(dir2, Cesium.Cartesian3.UNIT_Z, new Cesium.Cartesian3()); | ||||
|       Cesium.Cartesian3.normalize(perp2, perp2); | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|       // 生成偏移向量 | ||||
|       const offset = Cesium.Cartesian3.multiplyByScalar(perp, width, new Cesium.Cartesian3()); | ||||
|       const offset2 = Cesium.Cartesian3.multiplyByScalar(perp, -width, new Cesium.Cartesian3()); | ||||
|  | ||||
|       const offsetEnd = Cesium.Cartesian3.multiplyByScalar(perp2, -width, new Cesium.Cartesian3()); | ||||
|       const offsetEnd2 = Cesium.Cartesian3.multiplyByScalar(perp2, width, new Cesium.Cartesian3()); | ||||
|  | ||||
|       let point1 = Cesium.Cartesian3.add(start, offset, new Cesium.Cartesian3()) | ||||
|       let point2 = Cesium.Cartesian3.add(start, offset2, new Cesium.Cartesian3()) | ||||
|       let point3 = Cesium.Cartesian3.add(end, offsetEnd, new Cesium.Cartesian3()) | ||||
|       let point4 = Cesium.Cartesian3.add(end, offsetEnd2, new Cesium.Cartesian3()) | ||||
|  | ||||
|       area.push([point1, point3, point4, point2]) | ||||
|  | ||||
|       rightPositions.push([point1, point3]) | ||||
|       leftPositions.push([point2, point4]) | ||||
|  | ||||
|       // if (i == positions.length - 2) { | ||||
|       //   area.push(point1, point2, point3, point4) | ||||
|       //   rightPositions.push(point1) | ||||
|       //   leftPositions.push(point2) | ||||
|       //   leftPositions.push(point4) | ||||
|       //   rightPositions.push(point3) | ||||
|       // } else { | ||||
|       //   area.push(point1, point2) | ||||
|       //   rightPositions.push(point1) | ||||
|       //   leftPositions.push(point2) | ||||
|       // } | ||||
|     } | ||||
|     // let arr = [] | ||||
|     // for (let i = 0; i < area.length - 2; i += 2) { | ||||
|     //   arr.push([area[i], area[i + 1], area[i + 3], area[i + 2]]) | ||||
|     // } | ||||
|     console.log(area, rightPositions, 'rightPositions') | ||||
|     let that = this | ||||
|     // return [arr, rightPositions, leftPositions] | ||||
|     return [area, rightPositions, leftPositions] | ||||
|   } | ||||
|   getIntersects(point1, point2, point3, point4) { | ||||
|     let carPoint1 = this.getLonLat(point1) | ||||
|     let carPoint2 = this.getLonLat(point2) | ||||
|     let carPoint3 = this.getLonLat(point3) | ||||
|     let carPoint4 = this.getLonLat(point4) | ||||
|     var line1 = turf.lineString([ | ||||
|       [carPoint1.lon, carPoint1.lat], | ||||
|       [carPoint2.lon, carPoint2.lat] | ||||
|     ]); | ||||
|     var line2 = turf.lineString([ | ||||
|       [carPoint3.lon, carPoint3.lat], | ||||
|       [carPoint4.lon, carPoint4.lat] | ||||
|     ]); | ||||
|     var intersects = turf.lineIntersect(line1, line2); | ||||
|     if (intersects.features.length > 0) { | ||||
|       console.log(intersects.features, 'ooooo') | ||||
|       return Cesium.Cartesian3.fromDegrees(intersects.features[0].geometry.coordinates[0], intersects.features[0].geometry.coordinates[1]) | ||||
|     } | ||||
|   } | ||||
|   getLonLat(point) { | ||||
|     let pointDe = Cesium.Cartographic.fromCartesian(point) | ||||
|     const longitude = Cesium.Math.toDegrees(pointDe.longitude); | ||||
|     const latitude = Cesium.Math.toDegrees(pointDe.latitude); | ||||
|     return { lon: longitude, lat: latitude } | ||||
|  | ||||
|   } | ||||
|   createLineBufferPolygon(viewer, positions, width) { | ||||
|     // 计算每个线段的左右偏移点 | ||||
|     const leftPositions = []; | ||||
|     const rightPositions = []; | ||||
|  | ||||
|     for (let i = 0; i < positions.length; i++) { | ||||
|       const start = positions[i]; | ||||
|       const end = positions[i + 1] || positions[i - 1]; | ||||
|  | ||||
|       // 计算线段方向向量 | ||||
|       const direction = Cesium.Cartesian3.subtract(end, start, new Cesium.Cartesian3()); | ||||
|       // const direction = Cesium.Cartesian3.subtract(start, end, new Cesium.Cartesian3()); | ||||
|       Cesium.Cartesian3.normalize(direction, direction); | ||||
|  | ||||
|       // 计算垂直向量(使用上向量叉积) | ||||
|       const up = Cesium.Cartesian3.UNIT_Z; | ||||
|       const perpendicular = Cesium.Cartesian3.cross(direction, up, new Cesium.Cartesian3()); | ||||
|       Cesium.Cartesian3.normalize(perpendicular, perpendicular); | ||||
|  | ||||
|       // 计算左右偏移点 | ||||
|       const leftOffset = Cesium.Cartesian3.multiplyByScalar( | ||||
|         perpendicular, | ||||
|         width, | ||||
|         new Cesium.Cartesian3() | ||||
|       ); | ||||
|  | ||||
|       if (width > 0) { | ||||
|         rightPositions.unshift(Cesium.Cartesian3.add(start, leftOffset, new Cesium.Cartesian3())); | ||||
|       } else if (width < 0) { | ||||
|         rightPositions.push(Cesium.Cartesian3.add(start, leftOffset, new Cesium.Cartesian3())); | ||||
|       } | ||||
|  | ||||
|     } | ||||
|     return rightPositions | ||||
|   } | ||||
|   //计算角度 | ||||
|   calculateAangle(arr) { | ||||
|     // let fromDegreesArray = that.calSector(that.options.center, that.options.radius, that.options.startAngle, that.options.endAngle, 360, true) | ||||
|  | ||||
|     function getAangle(start, end) { | ||||
|       let rad = Math.PI / 180, | ||||
|         lat1 = start.y * rad, | ||||
|         lat2 = end.y * rad, | ||||
|         lon1 = start.x * rad, | ||||
|         lon2 = end.x * rad; | ||||
|       const a = Math.sin(lon2 - lon1) * Math.cos(lat2); | ||||
|       const b = | ||||
|         Math.cos(lat1) * Math.sin(lat2) - | ||||
|         Math.sin(lat1) * Math.cos(lat2) * Math.cos(lon2 - lon1); | ||||
|       const radians = Math.atan2(a, b) | ||||
|       const degrees = radians % (2 * Math.PI); | ||||
|       let bearing = 450 - ((degrees * 180) / Math.PI < 0 | ||||
|         ? 360 + (degrees * 180) / Math.PI | ||||
|         : (degrees * 180) / Math.PI) - 90; | ||||
|       return 360 - (bearing % 360) | ||||
|     } | ||||
|  | ||||
|     let center = arr[0] | ||||
|     let pos84_1 = arr[1] | ||||
|     let pos84_2 = arr[2] | ||||
|  | ||||
|     let start = { x: center.lng, y: center.lat } | ||||
|     let end1 = { x: pos84_1.lng, y: pos84_1.lat } | ||||
|     let end2 = { x: pos84_2.lng, y: pos84_2.lat } | ||||
|  | ||||
|     let angle1 = getAangle(start, end1) | ||||
|     let angle2 = getAangle(start, end2) | ||||
|  | ||||
|     return { | ||||
|       angle1, | ||||
|       angle2 | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   get carRoadWidth() { | ||||
|     return this.options.carRoadWidth | ||||
|   } | ||||
|  | ||||
|   set carRoadWidth(v) { | ||||
|     this.options.carRoadWidth = v | ||||
|     Road.create(this) | ||||
|  | ||||
|   } | ||||
|   get sideWidth() { | ||||
|     return this.options.sideWidth | ||||
|   } | ||||
|   set sideWidth(v) { | ||||
|     this.options.sideWidth = v | ||||
|     Road.create(this) | ||||
|   } | ||||
|   /** | ||||
|    * @description 编辑框 | ||||
|    * @param state=false {boolean} 状态: true打开, false关闭 | ||||
|    */ | ||||
|   async edit(state = false) { | ||||
|     let _this = this | ||||
|     this.originalOptions = this.deepCopyObj(this.options) | ||||
|  | ||||
|     if (this._DialogObject && this._DialogObject.close) { | ||||
|       this._DialogObject.close() | ||||
|       this._DialogObject = null | ||||
|     } | ||||
|  | ||||
|     if (state) { | ||||
|       this._DialogObject = await new Dialog(this.sdk, this.originalOptions, { | ||||
|         title: '道路属性', left: '180px', top: '100px', | ||||
|         confirmCallBack: (options) => { | ||||
|           this.name = this.name.trim() | ||||
|           if (!this.name) { | ||||
|             this.name = '道路' | ||||
|           } | ||||
|           this.originalOptions = this.deepCopyObj(this.options) | ||||
|           this._DialogObject.close() | ||||
|           this.Dialog.confirmCallBack && this.Dialog.confirmCallBack(this.originalOptions) | ||||
|           syncData(this.sdk, this.options.id) | ||||
|           syncSplitData(this.sdk, this.options.id) | ||||
|         }, | ||||
|         resetCallBack: () => { | ||||
|           this.reset() | ||||
|           this.Dialog.resetCallBack && this.Dialog.resetCallBack() | ||||
|         }, | ||||
|         closeCallBack: () => { | ||||
|           this.reset() | ||||
|           this.Dialog.closeCallBack && this.Dialog.closeCallBack() | ||||
|         }, | ||||
|         showCallBack: (show) => { | ||||
|           this.show = show | ||||
|           this.Dialog.showCallBack && this.Dialog.showCallBack() | ||||
|         } | ||||
|       }, true) | ||||
|       this._DialogObject._element.body.className = this._DialogObject._element.body.className + ' road-surface' | ||||
|       let contentElm = document.createElement('div'); | ||||
|       contentElm.innerHTML = html() | ||||
|       this._DialogObject.contentAppChild(contentElm) | ||||
|  | ||||
|  | ||||
|       // 下拉选项 | ||||
|       // let heightModeData = [ | ||||
|       //   { | ||||
|       //     name: '海拔高度', | ||||
|       //     value: '海拔高度', | ||||
|       //     key: '0', | ||||
|       //   }, | ||||
|       //   { | ||||
|       //     name: '相对地表', | ||||
|       //     value: '相对地表', | ||||
|       //     key: '1', | ||||
|       //   }, | ||||
|       //   { | ||||
|       //     name: '依附模型', | ||||
|       //     value: '依附模型', | ||||
|       //     key: '2', | ||||
|       //   } | ||||
|       // ] | ||||
|       // let heightModeObject = legp( | ||||
|       //   this._DialogObject._element.content.getElementsByClassName( | ||||
|       //     'road-box' | ||||
|       //   )[0], | ||||
|       //   '.road-type' | ||||
|       // ) | ||||
|       // if (heightModeObject) { | ||||
|       //   heightModeObject.legp_search(heightModeData) | ||||
|       //   let heightModeDataLegpElm = this._DialogObject._element.content | ||||
|       //     .getElementsByClassName('road-type')[0] | ||||
|       //     .getElementsByTagName('input')[0] | ||||
|       //   for (let i = 0; i < heightModeData.length; i++) { | ||||
|       //     if (heightModeData[i].key == this.heightMode) { | ||||
|       //       heightModeDataLegpElm.value = heightModeData[i].value | ||||
|       //       heightModeObject.legp_searchActive( | ||||
|       //         heightModeData[i].value | ||||
|       //       ) | ||||
|       //       break | ||||
|       //     } | ||||
|       //   } | ||||
|       //   heightModeDataLegpElm.addEventListener('input', () => { | ||||
|       //     for (let i = 0; i < heightModeData.length; i++) { | ||||
|       //       if (heightModeData[i].value === heightModeDataLegpElm.value) { | ||||
|       //         this.heightMode = heightModeData[i].key | ||||
|       //         break | ||||
|       //       } | ||||
|       //     } | ||||
|       //   }) | ||||
|  | ||||
|  | ||||
|       //   this._elms.height = heightElm | ||||
|       //   this._elms.heightBox = heightBoxElm | ||||
|       //   this._elms.heightMode = heightModeDataLegpElm | ||||
|       //   this._elms.heightConfirm = heightConfirmElm | ||||
|       //   this._elms.heightModeObject = heightModeObject | ||||
|  | ||||
|       //   heightConfirmElm.addEventListener('click', () => { | ||||
|       //     this.positionEditing = false | ||||
|       //     for (let i = 0; i < this.options.positions.length; i++) { | ||||
|       //       this.options.positions[i].alt = Number((this.options.positions[i].alt + Number(heightElm.value)).toFixed(2)) | ||||
|       //       this._elms.alt[i].innerHTML = this.options.positions[i].alt | ||||
|       //     } | ||||
|       //     let fromDegreesArray = this.renewPositions(this.options.positions) | ||||
|       //     this.entity.polyline.positions = Cesium.Cartesian3.fromDegreesArrayHeights( | ||||
|       //       fromDegreesArray | ||||
|       //     ) | ||||
|  | ||||
|       //     this.positionEditing = false | ||||
|       //     PolylineObject.closeNodeEdit(this) | ||||
|       //   }) | ||||
|       // } | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|       let all_elm = contentElm.getElementsByTagName("*") | ||||
|       this._EventBinding.on(this, all_elm) | ||||
|       this._elms = this._EventBinding.element | ||||
|     } else { | ||||
|       // if (this._element_style) { | ||||
|       //   document.getElementsByTagName('head')[0].removeChild(this._element_style) | ||||
|       //   this._element_style = null | ||||
|       // } | ||||
|       // if (this._DialogObject && this._DialogObject.remove) { | ||||
|       //   this._DialogObject.remove() | ||||
|       //   this._DialogObject = null | ||||
|       // } | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   reset() { | ||||
|     if (!this.viewer.entities.getById(this.options.id)) { | ||||
|       return | ||||
|     } | ||||
|     this.name = this.originalOptions.name | ||||
|     this.carRoadWidth = this.originalOptions.carRoadWidth | ||||
|     this.sideWidth = this.originalOptions.sideWidth | ||||
|     this.positions = this.originalOptions.positions | ||||
|     this.roadImage = this.originalOptions.roadImage | ||||
|     this.sideImage = this.originalOptions.sideImage | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * 飞到对应实体 | ||||
|    */ | ||||
|   async flyTo(options = {}) { | ||||
|     setActiveViewer(0) | ||||
|     closeRotateAround(this.sdk) | ||||
|     closeViewFollow(this.sdk) | ||||
|  | ||||
|     if (this.options.customView && this.options.customView.relativePosition && this.options.customView.orientation) { | ||||
|       let orientation = { | ||||
|         heading: Cesium.Math.toRadians(this.options.customView.orientation.heading || 0.0), | ||||
|         pitch: Cesium.Math.toRadians(this.options.customView.orientation.pitch || -60.0), | ||||
|         roll: Cesium.Math.toRadians(this.options.customView.orientation.roll || 0.0) | ||||
|       } | ||||
|  | ||||
|       let lng = this.options.customView.relativePosition.lng | ||||
|       let lat = this.options.customView.relativePosition.lat | ||||
|       let alt = this.options.customView.relativePosition.alt | ||||
|       let destination = Cesium.Cartesian3.fromDegrees(lng, lat, alt) | ||||
|  | ||||
|       let position = { lng: 0, lat: 0 } | ||||
|       if (this.options.position) { | ||||
|         position = { ...this.options.position } | ||||
|       } | ||||
|       else if (this.options.positions) { | ||||
|         position = { ...this.options.positions[0] } | ||||
|       } | ||||
|       else if (this.options.center) { | ||||
|         position = { ...this.options.center } | ||||
|       } | ||||
|       else if (this.options.start) { | ||||
|         position = { ...this.options.start } | ||||
|       } | ||||
|       else { | ||||
|         if (this.options.hasOwnProperty('lng')) { | ||||
|           position.lng = this.options.lng | ||||
|         } | ||||
|         if (this.options.hasOwnProperty('lat')) { | ||||
|           position.lat = this.options.lat | ||||
|         } | ||||
|         if (this.options.hasOwnProperty('alt')) { | ||||
|           position.alt = this.options.alt | ||||
|         } | ||||
|       } | ||||
|       // 如果没有高度值,则获取紧贴高度计算 | ||||
|       // if (!position.hasOwnProperty('alt')) { | ||||
|       //   position.alt = await this.getClampToHeight(position) | ||||
|       // } | ||||
|       lng = this.options.customView.relativePosition.lng + position.lng | ||||
|       lat = this.options.customView.relativePosition.lat + position.lat | ||||
|       alt = this.options.customView.relativePosition.alt + position.alt | ||||
|       destination = Cesium.Cartesian3.fromDegrees(lng, lat, alt) | ||||
|       this.sdk.viewer.camera.flyTo({ | ||||
|         destination: destination, | ||||
|         orientation: orientation | ||||
|       }) | ||||
|     } | ||||
|     else { | ||||
|       let positionArray = [] | ||||
|       for (let i = 0; i < this.positions.length; i++) { | ||||
|         let a = Cesium.Cartesian3.fromDegrees( | ||||
|           this.positions[i][0], | ||||
|           this.positions[i][1], | ||||
|           this.options.height + this.options.heightDifference / 2 | ||||
|         ) | ||||
|         positionArray.push(a.x, a.y, a.z) | ||||
|       } | ||||
|       let BoundingSphere = Cesium.BoundingSphere.fromVertices(positionArray) | ||||
|       this.viewer.camera.flyToBoundingSphere(BoundingSphere, { | ||||
|         offset: { | ||||
|           heading: Cesium.Math.toRadians(0.0), | ||||
|           pitch: Cesium.Math.toRadians(-20.0), | ||||
|           roll: Cesium.Math.toRadians(0.0) | ||||
|         } | ||||
|       }) | ||||
|  | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   getSphere() { | ||||
|     return new Promise((resolve) => { | ||||
|       // entity没有加载完成时 state 不会等于0 所以设置定时器直到获取到为止 | ||||
|       const interval = setInterval(() => { | ||||
|         const sphere = new Cesium.BoundingSphere() | ||||
|         const state = this.sdk.viewer._dataSourceDisplay.getBoundingSphere( | ||||
|           this.viewer.entities.getById(this.options.id), | ||||
|           false, | ||||
|           sphere | ||||
|         ) | ||||
|         if (state === Cesium.BoundingSphereState.DONE) { | ||||
|           clearInterval(interval) | ||||
|         } | ||||
|       }, 1000) | ||||
|     }) | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * 删除 | ||||
|    */ | ||||
|   async remove() { | ||||
|     this.positions = [] | ||||
|     this.lineEntity = null | ||||
|  | ||||
|     if (this.viewer.entities.getById(this.options.id)) { | ||||
|       this.viewer.entities.getById(this.options.id)._children.forEach((item) => { | ||||
|         this.viewer.entities.remove(item); | ||||
|       }); | ||||
|       this.viewer.entities.remove(this.viewer.entities.getById(this.options.id)) | ||||
|     } | ||||
|  | ||||
|     if (this._DialogObject && !this._DialogObject.isDestroy) { | ||||
|       this._DialogObject.close() | ||||
|       this._DialogObject = null | ||||
|     } | ||||
|     await this.sdk.removeIncetance(this.options.id) | ||||
|     await syncData(this.sdk, this.options.id) | ||||
|   } | ||||
|  | ||||
|   flicker() { } | ||||
| } | ||||
|  | ||||
| export default Road | ||||
							
								
								
									
										615
									
								
								src/Obj/Base/RoadObject/index-直接连接.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										615
									
								
								src/Obj/Base/RoadObject/index-直接连接.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,615 @@ | ||||
| /** | ||||
|  * @description 道路 | ||||
|  */ | ||||
| import Dialog from '../../Element/Dialog'; | ||||
| import { html } from "./_element"; | ||||
| import EventBinding from '../../Element/Dialog/eventBinding'; | ||||
| import Base from "../index"; | ||||
| import { syncData } from '../../../Global/MultiViewportMode' | ||||
| import { setSplitDirection, syncSplitData, setActiveId } from '../../../Global/SplitScreen' | ||||
| import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../Global/global' | ||||
|  | ||||
| class Road extends Base { | ||||
|   /** | ||||
|    * @constructor | ||||
|    * @param sdk | ||||
|    * @description 道路 | ||||
|    * @param options {object} 道路属性 | ||||
|    * @param options.name=未命名对象 {string} 名称 | ||||
|    * @param options.carRoadWidth=2 {number} 车道宽度 | ||||
|    * @param options.sideWidth=2 {number} 人行道宽度 | ||||
|    * @param options.positions=[] {array} 道路positions | ||||
|    * @param options.roadImage='' {string} 车道贴图 | ||||
|    * @param options.sideImage='' {string} 人行道贴图 | ||||
|    * @param Dialog {object} 弹框对象 | ||||
|    * @param Dialog.confirmCallBack {function} 弹框确认时的回调 | ||||
|    * */ | ||||
|   constructor(sdk, options = {}, _Dialog = {}) { | ||||
|     super(sdk, options); | ||||
|     this.viewer = this.sdk.viewer | ||||
|     this.options.name = options.name || '道路' | ||||
|     this.options.carRoadWidth = options.carRoadWidth || 10 | ||||
|     this.options.sideWidth = options.sideWidth || 5 | ||||
|     this.options.positions = options.positions || [] | ||||
|     this.options.roadImage = options.roadImage || (this.getSourceRootPath() + '/img/roadPhoto.png') | ||||
|     this.options.sideImage = options.sideImage || (this.getSourceRootPath() + '/img/sidePhoto.png') | ||||
|     this.options.show = (options.show || options.show === false) ? options.show : true | ||||
|     this.Dialog = _Dialog | ||||
|     this._EventBinding = new EventBinding() | ||||
|     this._elms = {}; | ||||
|     this.positionArea = [] | ||||
|     this.positions = [] | ||||
|     this.lineEntity = '' | ||||
|  | ||||
|     this.sdk.addIncetance(this.options.id, this) | ||||
|     Road.create(this) | ||||
|   } | ||||
|  | ||||
|   // 创建道路 | ||||
|   static create(that) { | ||||
|     let positions = [] | ||||
|     that.options.positions.forEach(v => { | ||||
|       positions.push(new Cesium.Cartesian3.fromDegrees(v.lng, v.lat, v.alt)) | ||||
|     }) | ||||
|  | ||||
|     let area = [[], [], []] | ||||
|     area[1] = that.createLineBufferPolygon2(positions, that.options.carRoadWidth / 2) | ||||
|     area[0] = that.createLineBufferPolygonSide(area[1][2], -that.options.sideWidth) | ||||
|     area[2] = that.createLineBufferPolygonSide(area[1][1], that.options.sideWidth) | ||||
|  | ||||
|     if (that.viewer.entities.getById(that.options.id)) { | ||||
|       that.viewer.entities.getById(that.options.id)._children.forEach((item) => { | ||||
|         that.viewer.entities.remove(item); | ||||
|       }); | ||||
|       that.viewer.entities.remove(that.viewer.entities.getById(that.options.id)) | ||||
|     } | ||||
|     that.lineEntity = that.viewer.entities.add(new Cesium.Entity({ id: that.options.id, show: that.options.show })) | ||||
|  | ||||
|     const myImg = new Image() | ||||
|     myImg.src = that.options.roadImage | ||||
|     myImg.onload = function () { | ||||
|       area[1][0].forEach((item, index) => { | ||||
|         that.viewer.entities.add({ | ||||
|           // id: that.options.id, | ||||
|           parent: that.lineEntity, | ||||
|           polygon: { | ||||
|             hierarchy: new Cesium.PolygonHierarchy(item), | ||||
|             material: new Cesium.ImageMaterialProperty({ | ||||
|               image: that.options.roadImage, | ||||
|               transparent: true,// 如果图片有透明部分,需要设置为 true | ||||
|               repeat: that.calculateTextureRepeat(item, myImg) | ||||
|             }), | ||||
|             stRotation: that.calculateRoadAngle(positions[index], positions[index + 1]) | ||||
|           } | ||||
|         }); | ||||
|       }) | ||||
|     } | ||||
|  | ||||
|     const myImg2 = new Image() | ||||
|     myImg2.src = that.options.sideImage | ||||
|     myImg2.onload = function () { | ||||
|       area[0].forEach((item, index) => { | ||||
|         that.viewer.entities.add({ | ||||
|           parent: that.lineEntity, | ||||
|           polygon: { | ||||
|             hierarchy: new Cesium.PolygonHierarchy(item), | ||||
|             material: new Cesium.ImageMaterialProperty({ | ||||
|               image: that.options.sideImage, | ||||
|               transparent: true,// 如果图片有透明部分,需要设置为 true | ||||
|               repeat: that.calculateTextureRepeat(item, myImg2) | ||||
|             }), | ||||
|             stRotation: that.calculateRoadAngle(positions[index], positions[index + 1]) | ||||
|           } | ||||
|         }); | ||||
|       }) | ||||
|  | ||||
|       area[2].forEach((item, index) => { | ||||
|         that.viewer.entities.add({ | ||||
|           polygon: { | ||||
|             hierarchy: new Cesium.PolygonHierarchy(item), | ||||
|             material: new Cesium.ImageMaterialProperty({ | ||||
|               image: that.options.sideImage, | ||||
|               transparent: true,// 如果图片有透明部分,需要设置为 true | ||||
|               repeat: that.calculateTextureRepeat(item, myImg2) | ||||
|             }), | ||||
|             stRotation: that.calculateRoadAngle(positions[index], positions[index + 1]) | ||||
|           } | ||||
|         }); | ||||
|       }) | ||||
|  | ||||
|     } | ||||
|  | ||||
|   } | ||||
|   getArr(arr1, arr2) { | ||||
|     arr2 = arr2.reverse() | ||||
|     let polygon = [] | ||||
|     for (let index = 0; index < arr1.length - 1; index++) { | ||||
|       polygon.push([arr1[index], arr1[index + 1], arr2[index + 1], arr2[index]]) | ||||
|     } | ||||
|     return polygon | ||||
|   } | ||||
|  | ||||
|   calculateRoadAngle(startPoint, endPoint) { | ||||
|     // 1. 获取地表法向量 | ||||
|     const normal = Cesium.Ellipsoid.WGS84.geodeticSurfaceNormal(startPoint); | ||||
|  | ||||
|     // 2. 构建精确ENU坐标系 | ||||
|     const enuMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(startPoint, undefined, normal); | ||||
|     const inverseMatrix = Cesium.Matrix4.inverse(enuMatrix, new Cesium.Matrix4()); | ||||
|  | ||||
|     // 3. 转换终点并计算水平向量 | ||||
|     const localEnd = Cesium.Matrix4.multiplyByPoint(inverseMatrix, endPoint, new Cesium.Cartesian3()); | ||||
|     const horizontalVec = new Cesium.Cartesian2(localEnd.x, localEnd.y); | ||||
|     Cesium.Cartesian2.normalize(horizontalVec, horizontalVec); | ||||
|  | ||||
|     const north = new Cesium.Cartesian2(1, 0); | ||||
|  | ||||
|     const angle = Cesium.Cartesian2.angleBetween(north, horizontalVec); | ||||
|     const cross = Cesium.Cartesian2.cross(north, horizontalVec, new Cesium.Cartesian2()); | ||||
|     return cross < 0 ? angle : -angle; | ||||
|   } | ||||
|  | ||||
|   calculatePolygonOrientation(positions) { | ||||
|  | ||||
|     // 假设 position 是 Cesium.Cartesian3 对象,表示地球上的某个点 | ||||
|     var position = positions[0] | ||||
|     // 获取东、北、上坐标系 | ||||
|     var eastNorthUp = Cesium.Transforms.eastNorthUpToFixedFrame(position); | ||||
|     // northAxis 是北方向向量 | ||||
|     var northAxis = eastNorthUp.getColumn(1, new Cesium.Cartesian3()); | ||||
|     Cesium.Cartesian3.normalize(northAxis, northAxis); | ||||
|  | ||||
|     const direction = Cesium.Cartesian3.subtract(positions[0], positions[1], new Cesium.Cartesian3()); | ||||
|     Cesium.Cartesian3.normalize(direction, direction); | ||||
|  | ||||
|  | ||||
|     const dot = Cesium.Cartesian3.dot(northAxis, direction); | ||||
|     const magA = Cesium.Cartesian3.magnitude(northAxis); | ||||
|     const magB = Cesium.Cartesian3.magnitude(direction); | ||||
|     return Math.acos(dot / (magA * magB)); | ||||
|   } | ||||
|   calculateTextureRepeat(polygonPositions, textureSize, meterPerPixel = 0.01) { | ||||
|     // 验证纹理尺寸 | ||||
|     if (!textureSize.width || !textureSize.height) { | ||||
|       throw new Error('Texture size must contain width and height in pixels'); | ||||
|     } | ||||
|  | ||||
|     // 创建多边形几何体 | ||||
|     const geometry = Cesium.PolygonGeometry.createGeometry( | ||||
|       new Cesium.PolygonGeometry({ | ||||
|         polygonHierarchy: new Cesium.PolygonHierarchy(polygonPositions), | ||||
|         vertexFormat: Cesium.VertexFormat.POSITION_ONLY | ||||
|       }) | ||||
|     ); | ||||
|  | ||||
|     // 计算多边形面积(平方米) | ||||
|     let area = 0; | ||||
|     const indices = geometry.indices; | ||||
|     const positions = geometry.attributes.position.values; | ||||
|     for (let i = 0; i < indices.length; i += 3) { | ||||
|       const i0 = indices[i] * 3; | ||||
|       const i1 = indices[i + 1] * 3; | ||||
|       const i2 = indices[i + 2] * 3; | ||||
|  | ||||
|       const p0 = new Cesium.Cartesian3(positions[i0], positions[i0 + 1], positions[i0 + 2]); | ||||
|       const p1 = new Cesium.Cartesian3(positions[i1], positions[i1 + 1], positions[i1 + 2]); | ||||
|       const p2 = new Cesium.Cartesian3(positions[i2], positions[i2 + 1], positions[i2 + 2]); | ||||
|  | ||||
|       const cross = Cesium.Cartesian3.cross( | ||||
|         Cesium.Cartesian3.subtract(p1, p0, new Cesium.Cartesian3()), | ||||
|         Cesium.Cartesian3.subtract(p2, p0, new Cesium.Cartesian3()), | ||||
|         new Cesium.Cartesian3() | ||||
|       ); | ||||
|       area += Cesium.Cartesian3.magnitude(cross) * 0.5; | ||||
|     } | ||||
|  | ||||
|     // 将像素尺寸转换为实际尺寸(平方米) | ||||
|     const textureWidthMeters = textureSize.width * meterPerPixel; | ||||
|     const textureHeightMeters = textureSize.height * meterPerPixel; | ||||
|     const textureArea = textureWidthMeters * textureHeightMeters; | ||||
|  | ||||
|     // 计算各轴向重复次数 | ||||
|     const repeatX = Math.sqrt(area) / textureWidthMeters; | ||||
|     const repeatY = Math.sqrt(area) / textureHeightMeters; | ||||
|  | ||||
|     return new Cesium.Cartesian2(Math.max(1, Math.ceil(repeatX)), 1.0); | ||||
|   } | ||||
|   swapLastElements(arr1, arr2) { | ||||
|     const last = arr1[arr1.length - 1] | ||||
|     const first = arr2[0] | ||||
|     arr1[arr1.length - 1] = first | ||||
|     arr2[0] = last | ||||
|  | ||||
|     return [arr1, arr2]; | ||||
|   } | ||||
|   createLineBufferPolygonSide(positions, width) { | ||||
|     let area = [] | ||||
|     for (let i = 0; i < positions.length - 1; i++) { | ||||
|       const start = positions[i]; | ||||
|       const end = positions[i + 1]; | ||||
|  | ||||
|       const dir = Cesium.Cartesian3.subtract(end, start, new Cesium.Cartesian3()); | ||||
|       Cesium.Cartesian3.normalize(dir, dir); | ||||
|  | ||||
|       // 获取垂直向量(基于Z轴) | ||||
|       const perp = Cesium.Cartesian3.cross(dir, Cesium.Cartesian3.UNIT_Z, new Cesium.Cartesian3()); | ||||
|       Cesium.Cartesian3.normalize(perp, perp); | ||||
|  | ||||
|       // 生成偏移向量 | ||||
|       const offset = Cesium.Cartesian3.multiplyByScalar(perp, width, new Cesium.Cartesian3()); | ||||
|       let point1 = Cesium.Cartesian3.add(start, offset, new Cesium.Cartesian3()) | ||||
|       let point3 = Cesium.Cartesian3.add(end, offset, new Cesium.Cartesian3()) | ||||
|  | ||||
|       i == positions.length - 2 ? area.push(start, point1, end, point3) : area.push(start, point1) | ||||
|     } | ||||
|     let arr = [] | ||||
|     for (let i = 0; i < area.length - 2; i += 2) { | ||||
|       arr.push([area[i], area[i + 1], area[i + 3], area[i + 2]]) | ||||
|     } | ||||
|     return arr | ||||
|   } | ||||
|   createLineBufferPolygon2(positions, width) { | ||||
|     let area = [] | ||||
|     let leftPositions = []; | ||||
|     let rightPositions = []; | ||||
|  | ||||
|     for (let i = 0; i < positions.length - 1; i++) { | ||||
|       const start = positions[i]; | ||||
|       // const end = positions[i + 1] || positions[i - 1]; | ||||
|       const end = positions[i + 1]; | ||||
|  | ||||
|       const dir = Cesium.Cartesian3.subtract(end, start, new Cesium.Cartesian3()); | ||||
|       Cesium.Cartesian3.normalize(dir, dir); | ||||
|  | ||||
|       // 获取垂直向量(基于Z轴) | ||||
|       const perp = Cesium.Cartesian3.cross(dir, Cesium.Cartesian3.UNIT_Z, new Cesium.Cartesian3()); | ||||
|       Cesium.Cartesian3.normalize(perp, perp); | ||||
|  | ||||
|  | ||||
|       // 生成偏移向量 | ||||
|       const offset = Cesium.Cartesian3.multiplyByScalar(perp, width, new Cesium.Cartesian3()); | ||||
|       const offset2 = Cesium.Cartesian3.multiplyByScalar(perp, -width, new Cesium.Cartesian3()); | ||||
|       let point1 = Cesium.Cartesian3.add(start, offset, new Cesium.Cartesian3()) | ||||
|       let point2 = Cesium.Cartesian3.add(start, offset2, new Cesium.Cartesian3()) | ||||
|       let point3 = Cesium.Cartesian3.add(end, offset, new Cesium.Cartesian3()) | ||||
|       let point4 = Cesium.Cartesian3.add(end, offset2, new Cesium.Cartesian3()) | ||||
|  | ||||
|       if (i == positions.length - 2) { | ||||
|         area.push(point1, point2, point3, point4) | ||||
|         rightPositions.push(point1) | ||||
|         leftPositions.push(point2) | ||||
|         leftPositions.push(point4) | ||||
|         rightPositions.push(point3) | ||||
|       } else { | ||||
|         area.push(point1, point2) | ||||
|         rightPositions.push(point1) | ||||
|         leftPositions.push(point2) | ||||
|       } | ||||
|     } | ||||
|     let arr = [] | ||||
|     for (let i = 0; i < area.length - 2; i += 2) { | ||||
|       arr.push([area[i], area[i + 1], area[i + 3], area[i + 2]]) | ||||
|     } | ||||
|     return [arr, rightPositions, leftPositions] | ||||
|   } | ||||
|   createLineBufferPolygon(viewer, positions, width) { | ||||
|     // 计算每个线段的左右偏移点 | ||||
|     const leftPositions = []; | ||||
|     const rightPositions = []; | ||||
|  | ||||
|     for (let i = 0; i < positions.length; i++) { | ||||
|       const start = positions[i]; | ||||
|       const end = positions[i + 1] || positions[i - 1]; | ||||
|  | ||||
|       // 计算线段方向向量 | ||||
|       const direction = Cesium.Cartesian3.subtract(end, start, new Cesium.Cartesian3()); | ||||
|       // const direction = Cesium.Cartesian3.subtract(start, end, new Cesium.Cartesian3()); | ||||
|       Cesium.Cartesian3.normalize(direction, direction); | ||||
|  | ||||
|       // 计算垂直向量(使用上向量叉积) | ||||
|       const up = Cesium.Cartesian3.UNIT_Z; | ||||
|       const perpendicular = Cesium.Cartesian3.cross(direction, up, new Cesium.Cartesian3()); | ||||
|       Cesium.Cartesian3.normalize(perpendicular, perpendicular); | ||||
|  | ||||
|       // 计算左右偏移点 | ||||
|       const leftOffset = Cesium.Cartesian3.multiplyByScalar( | ||||
|         perpendicular, | ||||
|         width, | ||||
|         new Cesium.Cartesian3() | ||||
|       ); | ||||
|  | ||||
|       if (width > 0) { | ||||
|         rightPositions.unshift(Cesium.Cartesian3.add(start, leftOffset, new Cesium.Cartesian3())); | ||||
|       } else if (width < 0) { | ||||
|         rightPositions.push(Cesium.Cartesian3.add(start, leftOffset, new Cesium.Cartesian3())); | ||||
|       } | ||||
|  | ||||
|     } | ||||
|     return rightPositions | ||||
|   } | ||||
|  | ||||
|   get carRoadWidth() { | ||||
|     return this.options.carRoadWidth | ||||
|   } | ||||
|  | ||||
|   set carRoadWidth(v) { | ||||
|     this.options.carRoadWidth = v | ||||
|     Road.create(this) | ||||
|  | ||||
|   } | ||||
|   get sideWidth() { | ||||
|     return this.options.sideWidth | ||||
|   } | ||||
|   set sideWidth(v) { | ||||
|     this.options.sideWidth = v | ||||
|     Road.create(this) | ||||
|   } | ||||
|   /** | ||||
|    * @description 编辑框 | ||||
|    * @param state=false {boolean} 状态: true打开, false关闭 | ||||
|    */ | ||||
|   async edit(state = false) { | ||||
|     let _this = this | ||||
|     this.originalOptions = this.deepCopyObj(this.options) | ||||
|  | ||||
|     if (this._DialogObject && this._DialogObject.close) { | ||||
|       this._DialogObject.close() | ||||
|       this._DialogObject = null | ||||
|     } | ||||
|  | ||||
|     if (state) { | ||||
|       this._DialogObject = await new Dialog(this.sdk, this.originalOptions, { | ||||
|         title: '道路属性', left: '180px', top: '100px', | ||||
|         confirmCallBack: (options) => { | ||||
|           this.name = this.name.trim() | ||||
|           if (!this.name) { | ||||
|             this.name = '道路' | ||||
|           } | ||||
|           this.originalOptions = this.deepCopyObj(this.options) | ||||
|           this._DialogObject.close() | ||||
|           this.Dialog.confirmCallBack && this.Dialog.confirmCallBack(this.originalOptions) | ||||
|           syncData(this.sdk, this.options.id) | ||||
|           syncSplitData(this.sdk, this.options.id) | ||||
|         }, | ||||
|         resetCallBack: () => { | ||||
|           this.reset() | ||||
|           this.Dialog.resetCallBack && this.Dialog.resetCallBack() | ||||
|         }, | ||||
|         closeCallBack: () => { | ||||
|           this.reset() | ||||
|           this.Dialog.closeCallBack && this.Dialog.closeCallBack() | ||||
|         }, | ||||
|         showCallBack: (show) => { | ||||
|           this.show = show | ||||
|           this.Dialog.showCallBack && this.Dialog.showCallBack() | ||||
|         } | ||||
|       }, true) | ||||
|       this._DialogObject._element.body.className = this._DialogObject._element.body.className + ' road-surface' | ||||
|       let contentElm = document.createElement('div'); | ||||
|       contentElm.innerHTML = html() | ||||
|       this._DialogObject.contentAppChild(contentElm) | ||||
|  | ||||
|  | ||||
|       // 下拉选项 | ||||
|       // let heightModeData = [ | ||||
|       //   { | ||||
|       //     name: '海拔高度', | ||||
|       //     value: '海拔高度', | ||||
|       //     key: '0', | ||||
|       //   }, | ||||
|       //   { | ||||
|       //     name: '相对地表', | ||||
|       //     value: '相对地表', | ||||
|       //     key: '1', | ||||
|       //   }, | ||||
|       //   { | ||||
|       //     name: '依附模型', | ||||
|       //     value: '依附模型', | ||||
|       //     key: '2', | ||||
|       //   } | ||||
|       // ] | ||||
|       // let heightModeObject = legp( | ||||
|       //   this._DialogObject._element.content.getElementsByClassName( | ||||
|       //     'road-box' | ||||
|       //   )[0], | ||||
|       //   '.road-type' | ||||
|       // ) | ||||
|       // if (heightModeObject) { | ||||
|       //   heightModeObject.legp_search(heightModeData) | ||||
|       //   let heightModeDataLegpElm = this._DialogObject._element.content | ||||
|       //     .getElementsByClassName('road-type')[0] | ||||
|       //     .getElementsByTagName('input')[0] | ||||
|       //   for (let i = 0; i < heightModeData.length; i++) { | ||||
|       //     if (heightModeData[i].key == this.heightMode) { | ||||
|       //       heightModeDataLegpElm.value = heightModeData[i].value | ||||
|       //       heightModeObject.legp_searchActive( | ||||
|       //         heightModeData[i].value | ||||
|       //       ) | ||||
|       //       break | ||||
|       //     } | ||||
|       //   } | ||||
|       //   heightModeDataLegpElm.addEventListener('input', () => { | ||||
|       //     for (let i = 0; i < heightModeData.length; i++) { | ||||
|       //       if (heightModeData[i].value === heightModeDataLegpElm.value) { | ||||
|       //         this.heightMode = heightModeData[i].key | ||||
|       //         break | ||||
|       //       } | ||||
|       //     } | ||||
|       //   }) | ||||
|  | ||||
|  | ||||
|       //   this._elms.height = heightElm | ||||
|       //   this._elms.heightBox = heightBoxElm | ||||
|       //   this._elms.heightMode = heightModeDataLegpElm | ||||
|       //   this._elms.heightConfirm = heightConfirmElm | ||||
|       //   this._elms.heightModeObject = heightModeObject | ||||
|  | ||||
|       //   heightConfirmElm.addEventListener('click', () => { | ||||
|       //     this.positionEditing = false | ||||
|       //     for (let i = 0; i < this.options.positions.length; i++) { | ||||
|       //       this.options.positions[i].alt = Number((this.options.positions[i].alt + Number(heightElm.value)).toFixed(2)) | ||||
|       //       this._elms.alt[i].innerHTML = this.options.positions[i].alt | ||||
|       //     } | ||||
|       //     let fromDegreesArray = this.renewPositions(this.options.positions) | ||||
|       //     this.entity.polyline.positions = Cesium.Cartesian3.fromDegreesArrayHeights( | ||||
|       //       fromDegreesArray | ||||
|       //     ) | ||||
|  | ||||
|       //     this.positionEditing = false | ||||
|       //     PolylineObject.closeNodeEdit(this) | ||||
|       //   }) | ||||
|       // } | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|       let all_elm = contentElm.getElementsByTagName("*") | ||||
|       this._EventBinding.on(this, all_elm) | ||||
|       this._elms = this._EventBinding.element | ||||
|     } else { | ||||
|       // if (this._element_style) { | ||||
|       //   document.getElementsByTagName('head')[0].removeChild(this._element_style) | ||||
|       //   this._element_style = null | ||||
|       // } | ||||
|       // if (this._DialogObject && this._DialogObject.remove) { | ||||
|       //   this._DialogObject.remove() | ||||
|       //   this._DialogObject = null | ||||
|       // } | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   reset() { | ||||
|     if (!this.viewer.entities.getById(this.options.id)) { | ||||
|       return | ||||
|     } | ||||
|     this.name = this.originalOptions.name | ||||
|     this.carRoadWidth = this.originalOptions.carRoadWidth | ||||
|     this.sideWidth = this.originalOptions.sideWidth | ||||
|     this.positions = this.originalOptions.positions | ||||
|     this.roadImage = this.originalOptions.roadImage | ||||
|     this.sideImage = this.originalOptions.sideImage | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * 飞到对应实体 | ||||
|    */ | ||||
|   async flyTo(options = {}) { | ||||
|     setActiveViewer(0) | ||||
|     closeRotateAround(this.sdk) | ||||
|     closeViewFollow(this.sdk) | ||||
|  | ||||
|     if (this.options.customView && this.options.customView.relativePosition && this.options.customView.orientation) { | ||||
|       let orientation = { | ||||
|         heading: Cesium.Math.toRadians(this.options.customView.orientation.heading || 0.0), | ||||
|         pitch: Cesium.Math.toRadians(this.options.customView.orientation.pitch || -60.0), | ||||
|         roll: Cesium.Math.toRadians(this.options.customView.orientation.roll || 0.0) | ||||
|       } | ||||
|  | ||||
|       let lng = this.options.customView.relativePosition.lng | ||||
|       let lat = this.options.customView.relativePosition.lat | ||||
|       let alt = this.options.customView.relativePosition.alt | ||||
|       let destination = Cesium.Cartesian3.fromDegrees(lng, lat, alt) | ||||
|  | ||||
|       let position = { lng: 0, lat: 0 } | ||||
|       if (this.options.position) { | ||||
|         position = { ...this.options.position } | ||||
|       } | ||||
|       else if (this.options.positions) { | ||||
|         position = { ...this.options.positions[0] } | ||||
|       } | ||||
|       else if (this.options.center) { | ||||
|         position = { ...this.options.center } | ||||
|       } | ||||
|       else if (this.options.start) { | ||||
|         position = { ...this.options.start } | ||||
|       } | ||||
|       else { | ||||
|         if (this.options.hasOwnProperty('lng')) { | ||||
|           position.lng = this.options.lng | ||||
|         } | ||||
|         if (this.options.hasOwnProperty('lat')) { | ||||
|           position.lat = this.options.lat | ||||
|         } | ||||
|         if (this.options.hasOwnProperty('alt')) { | ||||
|           position.alt = this.options.alt | ||||
|         } | ||||
|       } | ||||
|       // 如果没有高度值,则获取紧贴高度计算 | ||||
|       // if (!position.hasOwnProperty('alt')) { | ||||
|       //   position.alt = await this.getClampToHeight(position) | ||||
|       // } | ||||
|       lng = this.options.customView.relativePosition.lng + position.lng | ||||
|       lat = this.options.customView.relativePosition.lat + position.lat | ||||
|       alt = this.options.customView.relativePosition.alt + position.alt | ||||
|       destination = Cesium.Cartesian3.fromDegrees(lng, lat, alt) | ||||
|       this.sdk.viewer.camera.flyTo({ | ||||
|         destination: destination, | ||||
|         orientation: orientation | ||||
|       }) | ||||
|     } | ||||
|     else { | ||||
|       let positionArray = [] | ||||
|       for (let i = 0; i < this.positions.length; i++) { | ||||
|         let a = Cesium.Cartesian3.fromDegrees( | ||||
|           this.positions[i][0], | ||||
|           this.positions[i][1], | ||||
|           this.options.height + this.options.heightDifference / 2 | ||||
|         ) | ||||
|         positionArray.push(a.x, a.y, a.z) | ||||
|       } | ||||
|       let BoundingSphere = Cesium.BoundingSphere.fromVertices(positionArray) | ||||
|       this.viewer.camera.flyToBoundingSphere(BoundingSphere, { | ||||
|         offset: { | ||||
|           heading: Cesium.Math.toRadians(0.0), | ||||
|           pitch: Cesium.Math.toRadians(-20.0), | ||||
|           roll: Cesium.Math.toRadians(0.0) | ||||
|         } | ||||
|       }) | ||||
|  | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   getSphere() { | ||||
|     return new Promise((resolve) => { | ||||
|       // entity没有加载完成时 state 不会等于0 所以设置定时器直到获取到为止 | ||||
|       const interval = setInterval(() => { | ||||
|         const sphere = new Cesium.BoundingSphere() | ||||
|         const state = this.sdk.viewer._dataSourceDisplay.getBoundingSphere( | ||||
|           this.viewer.entities.getById(this.options.id), | ||||
|           false, | ||||
|           sphere | ||||
|         ) | ||||
|         if (state === Cesium.BoundingSphereState.DONE) { | ||||
|           clearInterval(interval) | ||||
|         } | ||||
|       }, 1000) | ||||
|     }) | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * 删除 | ||||
|    */ | ||||
|   async remove() { | ||||
|     this.positions = [] | ||||
|     this.lineEntity = null | ||||
|  | ||||
|     if (this.viewer.entities.getById(this.options.id)) { | ||||
|       this.viewer.entities.getById(this.options.id)._children.forEach((item) => { | ||||
|         this.viewer.entities.remove(item); | ||||
|       }); | ||||
|       this.viewer.entities.remove(this.viewer.entities.getById(this.options.id)) | ||||
|     } | ||||
|  | ||||
|     if (this._DialogObject && !this._DialogObject.isDestroy) { | ||||
|       this._DialogObject.close() | ||||
|       this._DialogObject = null | ||||
|     } | ||||
|     await this.sdk.removeIncetance(this.options.id) | ||||
|     await syncData(this.sdk, this.options.id) | ||||
|   } | ||||
|  | ||||
|   flicker() { } | ||||
| } | ||||
|  | ||||
| export default Road | ||||
							
								
								
									
										1023
									
								
								src/Obj/Base/RoadObject/index-面大小一致.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1023
									
								
								src/Obj/Base/RoadObject/index-面大小一致.js
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										1207
									
								
								src/Obj/Base/RoadObject/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1207
									
								
								src/Obj/Base/RoadObject/index.js
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -23,7 +23,7 @@ class SectorObject extends Base { | ||||
|    * @param options.id {string} 标注id | ||||
|    * @param options.name {string} 名称 | ||||
|    * @param options.show=true {boolean} 显示/隐藏 | ||||
|    * @param options.color="#ff000080" {string} 颜色 | ||||
|    * @param options.color="rgba(255, 0, 0, 0.5)" {string} 颜色 | ||||
|    * @param options.center {object} 位置 | ||||
|    * @param options.center.lng {object} 经度 | ||||
|    * @param options.center.lat {object} 维度 | ||||
| @ -39,7 +39,7 @@ class SectorObject extends Base { | ||||
|   constructor(sdk, options = {}) { | ||||
|     super(sdk, options); | ||||
|     this.options.name = options.name || '未命名对象' | ||||
|     this.options.color = options.color || "#ff000080" | ||||
|     this.options.color = options.color || "rgba(255, 0, 0, 0.5)" | ||||
|     this.options.heightMode = (options.heightMode || options.heightMode == 0) ? options.heightMode : 2 | ||||
|     this.options.semiMinorAxis = (options.semiMinorAxis || options.semiMinorAxis === 0) ? options.semiMinorAxis : 10 | ||||
|     this.options.semiMajorAxis = (options.semiMajorAxis || options.semiMajorAxis === 0) ? options.semiMajorAxis : 20 | ||||
| @ -47,7 +47,7 @@ class SectorObject extends Base { | ||||
|     this.options.center = options.center || {} | ||||
|     this.options.line = options.line || {} | ||||
|     this.options.line.width = ((this.options.line.width || this.options.line.width === 0) ? this.options.line.width : 3) | ||||
|     this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 0.5)' | ||||
|     this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 1)' | ||||
|     this.options['area-unit'] = options['area-unit'] || '平方米' | ||||
|     options.label = options.label || {} | ||||
|     this._elms = {}; | ||||
| @ -293,7 +293,7 @@ class SectorObject extends Base { | ||||
|     return this.options.line.width | ||||
|   } | ||||
|   set lineWidth(v) { | ||||
|     this.options.line.width =  ((v || v === 0) ? v : 3) | ||||
|     this.options.line.width = ((v || v === 0) ? v : 3) | ||||
|     this.entity.polyline.width = this.options.line.width | ||||
|     this._elms.lineWidth && this._elms.lineWidth.forEach((item) => { | ||||
|       item.value = this.options.line.width | ||||
| @ -344,7 +344,7 @@ class SectorObject extends Base { | ||||
|   } | ||||
|   set labelShow(v) { | ||||
|     this.options.label.show = v | ||||
|     if (this.show) { | ||||
|     if (this.show && !this.showView || this.showView == 3) { | ||||
|       this.label.show = v | ||||
|     } | ||||
|     else { | ||||
| @ -1560,7 +1560,7 @@ class SectorObject extends Base { | ||||
|   _addRr() { | ||||
|     if (this._DialogObject._element.content.getElementsByClassName('vr_add')[0].value) { | ||||
|       this.options.attribute.vr.content.push({ | ||||
|         name: '全景图' , | ||||
|         name: '全景图', | ||||
|         url: this._DialogObject._element.content.getElementsByClassName('vr_add')[0].value | ||||
|       }) | ||||
|       this._DialogObject._element.content.getElementsByClassName('vr_add')[0].value = '' | ||||
| @ -1573,7 +1573,7 @@ class SectorObject extends Base { | ||||
|  | ||||
|   addAttributeRr(vr) { | ||||
|     this.options.attribute.vr.content.push({ | ||||
|       name: '全景图' , | ||||
|       name: '全景图', | ||||
|       url: vr | ||||
|     }) | ||||
|     this.attributeVr = this.options.attribute.vr.content | ||||
| @ -1922,6 +1922,19 @@ class SectorObject extends Base { | ||||
|         that.cartesian3Towgs84(positions[1], that.sdk.viewer), | ||||
|         that.cartesian3Towgs84(positions[positions.length - 4], that.sdk.viewer) | ||||
|       ] | ||||
|       let objectsToExclude = [...that.sdk.viewer.entities.values] | ||||
|       that | ||||
|         .getClampToHeight({ | ||||
|           lng: that.options.center.lng, | ||||
|           lat: that.options.center.lat | ||||
|         }, objectsToExclude) | ||||
|         .then(height => { | ||||
|           that.label.position = [ | ||||
|             that.options.center.lng, | ||||
|             that.options.center.lat, | ||||
|             height | ||||
|           ] | ||||
|         }) | ||||
|       setTimeout(() => { | ||||
|         createNodePoints(positions[1], 'sector-start') | ||||
|         createNodePoints(positions[positions.length - 4], 'sector-end') | ||||
|  | ||||
| @ -40,7 +40,7 @@ class StraightArrowObject extends Base { | ||||
|     this.options.positions = options.positions || [] | ||||
|     this.options.line = options.line || {} | ||||
|     this.options.line.width = ((this.options.line.width || this.options.line.width === 0) ? this.options.line.width : 3) | ||||
|     this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 0.5)' | ||||
|     this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 1)' | ||||
|     this.options['area-unit'] = options['area-unit'] || '平方米' | ||||
|     this.entity | ||||
|     this.event = new MouseEvent(this.sdk) | ||||
| @ -321,7 +321,7 @@ class StraightArrowObject extends Base { | ||||
|   } | ||||
|   set labelShow(v) { | ||||
|     this.options.label.show = v | ||||
|     if (this.show) { | ||||
|     if (this.show && !this.showView || this.showView == 3) { | ||||
|       this.label.show = v | ||||
|     } | ||||
|     else { | ||||
|  | ||||
							
								
								
									
										294
									
								
								src/Obj/Base/TextBox/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										294
									
								
								src/Obj/Base/TextBox/index.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,294 @@ | ||||
| /** | ||||
|  * 文本框 | ||||
|  */ | ||||
| import Base from "../index"; | ||||
| import { syncData, getSdk } from '../../../Global/MultiViewportMode' | ||||
| import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../Global/global' | ||||
| class TextBox extends Base { | ||||
|   /** | ||||
|    * @constructor | ||||
|    * @param sdk | ||||
|    * @description 文本框 | ||||
|    * @param options {object} 属性 | ||||
|    * @param options.id=id | ||||
|    * @param options.position=[]位置 | ||||
|    * @param options.text=文本框内容 | ||||
|    * @param options.show=true {boolean}是否显示 | ||||
|    * @param callback=方法回调 | ||||
|    * @param Dialog {object} 弹框对象 | ||||
|    * @param Dialog.confirmCallBack {function} 弹框确认时的回调 | ||||
|    * */ | ||||
|   constructor(sdk, options = {}, callback = null) { | ||||
|     // this.sdk = { ...sdk } | ||||
|     // this.options = { ...options } | ||||
|     super(sdk, options) | ||||
|     this.options.position = options.position || [] | ||||
|     this.options.text = options.text || '' | ||||
|     this.options.show = (options.show || options.show === false) ? options.show : true | ||||
|     this.clickTextDom = undefined | ||||
|     this.handler = undefined | ||||
|     this.textDom = undefined | ||||
|     this.create(this) | ||||
|     this.sdk.addIncetance(this.options.id, this) | ||||
|  | ||||
|     this.callback = callback | ||||
|  | ||||
|     syncData(this.sdk, this.options.id) | ||||
|  | ||||
|   } | ||||
|  | ||||
|   get type() { | ||||
|     return 'TextBox' | ||||
|   } | ||||
|  | ||||
|   async create(that) { | ||||
|     let viewer = that.sdk.viewer | ||||
|     // 创建div元素 | ||||
|     let dom = document.createElement('span'); | ||||
|     dom.id = that.options.id | ||||
|     dom.className = 'popup-textarea' | ||||
|     dom.style.zIndex = 1 | ||||
|     // 创建textarea元素 | ||||
|     var textarea = document.createElement('textarea'); | ||||
|     textarea.className = 'textarea' | ||||
|     textarea.value = that.options.text; | ||||
|     // 设置textarea的属性,例如行数和列数 | ||||
|     textarea.rows = 6; | ||||
|     textarea.style.resize = 'none' | ||||
|     // 将textarea添加到div中 | ||||
|     dom.appendChild(textarea); | ||||
|     (!that.options.show) && (dom.style.display = 'none') | ||||
|     // 将div添加到body中 | ||||
|     // document.body.appendChild(dom); | ||||
|  | ||||
|     // 配置CSS样式和内容结构 | ||||
|     viewer.cesiumWidget.container.appendChild(dom); | ||||
|     let posi = Cesium.Cartesian3.fromDegrees(that.options.position.lng, that.options.position.lat, that.options.position.alt) | ||||
|     that.handler = function () { | ||||
|       const position = Cesium.SceneTransforms.wgs84ToWindowCoordinates( | ||||
|         viewer.scene, posi | ||||
|       ); | ||||
|       if (position) { | ||||
|         let width = dom.clientWidth * 1 | ||||
|         let height = dom.clientHeight * 1 | ||||
|         dom.style.left = `${position.x - width / 2}px`; | ||||
|         dom.style.top = `${position.y - height}px`; | ||||
|       } | ||||
|     } | ||||
|     viewer.scene.postRender.addEventListener(that.handler); | ||||
|     that.textDom = dom; | ||||
|  | ||||
|   } | ||||
|   async isClick(posi, id) { | ||||
|     let params = [ | ||||
|       { | ||||
|         position: posi | ||||
|       }, | ||||
|       id, | ||||
|       null | ||||
|     ] | ||||
|  | ||||
|     this.clickCallBack({ position: posi }, id, null) | ||||
|   } | ||||
|   async setHandeler(data) { | ||||
|     let that = this | ||||
|  | ||||
|     let cartesian = this.sdk.viewer.scene.pickPosition(new Cesium.Cartesian2(data.x, data.y)); //屏幕坐标转为笛卡尔空间坐标 | ||||
|     // if (!cartesian) return; | ||||
|  | ||||
|     // let c = Cesium.Cartographic.fromCartesian(position); | ||||
|     if (!cartesian) { | ||||
|       const ray = this.sdk.viewer.camera.getPickRay(new Cesium.Cartesian2(data.x, data.y)); | ||||
|       cartesian = this.sdk.viewer.scene.globe.pick(ray, this.sdk.viewer.scene); | ||||
|     } | ||||
|  | ||||
|     if (Cesium.defined(cartesian)) { | ||||
|       that.sdk.viewer.scene.postRender.removeEventListener(that.handler); | ||||
|  | ||||
|       var cartographic = Cesium.Cartographic.fromCartesian(cartesian); | ||||
|       var longitude = Cesium.Math.toDegrees(cartographic.longitude); | ||||
|       var latitude = Cesium.Math.toDegrees(cartographic.latitude); | ||||
|  | ||||
|       let height = await that.getClampToHeight({ lng: longitude, lat: latitude }) | ||||
|       that.position = { | ||||
|         lng: longitude, | ||||
|         lat: latitude, | ||||
|         alt: cartographic.height | ||||
|         // alt: height | ||||
|       } | ||||
|       let posi = Cesium.Cartesian3.fromDegrees(longitude, latitude, cartographic.height) | ||||
|  | ||||
|       that.handler = function () { | ||||
|         const position = Cesium.SceneTransforms.wgs84ToWindowCoordinates( | ||||
|           that.sdk.viewer.scene, posi | ||||
|         ); | ||||
|         if (position) { | ||||
|           let width = that.textDom.clientWidth * 1 | ||||
|           let height = that.textDom.clientHeight * 1 | ||||
|           that.textDom.style.left = `${position.x - width / 2}px`; | ||||
|           that.textDom.style.top = `${position.y - height}px`; | ||||
|         } | ||||
|       } | ||||
|       that.sdk.viewer.scene.postRender.addEventListener(that.handler); | ||||
|     } | ||||
|   } | ||||
|   async getwords(words) { | ||||
|     this.options.text = words | ||||
|  | ||||
|     let { sdkP } = getSdk() | ||||
|     if (this.sdk === sdkP && sdkP) {//三维 | ||||
|       this.callback(this.options) | ||||
|       syncData(this.sdk, this.options.id) | ||||
|     } | ||||
|     else if (sdkP) {//二维 | ||||
|       sdkP.entityMap.get(this.options.id).text = words | ||||
|       sdkP.entityMap.get(this.options.id).twoToThree(this.options.position) | ||||
|     } else if (!sdkP) { | ||||
|       this.callback(this.options) | ||||
|       syncData(this.sdk, this.options.id) | ||||
|     } | ||||
|   } | ||||
|   async twoToThree(position) { | ||||
|     let that = this | ||||
|     that.sdk.viewer.scene.postRender.removeEventListener(that.handler); | ||||
|     let posi = Cesium.Cartesian3.fromDegrees(position.lng, position.lat, position.alt) | ||||
|  | ||||
|     that.handler = function () { | ||||
|       const position = Cesium.SceneTransforms.wgs84ToWindowCoordinates( | ||||
|         that.sdk.viewer.scene, posi | ||||
|       ); | ||||
|       if (position) { | ||||
|         let width = that.textDom.clientWidth * 1 | ||||
|         let height = that.textDom.clientHeight * 1 | ||||
|         that.textDom.style.left = `${position.x - width / 2}px`; | ||||
|         that.textDom.style.top = `${position.y - height}px`; | ||||
|       } | ||||
|     } | ||||
|     that.sdk.viewer.scene.postRender.addEventListener(that.handler); | ||||
|   } | ||||
|   async returnFun() { | ||||
|     return this.handler | ||||
|   } | ||||
|   get text() { | ||||
|     return this.options.text | ||||
|   } | ||||
|   set text(val) { | ||||
|     this.options.text = val | ||||
|     this.textDom.querySelector('textarea').value = val | ||||
|     this.callback(this.options) | ||||
|   } | ||||
|   get onClick() { | ||||
|     return this.clickCallBack | ||||
|   } | ||||
|   set onClick(val) { | ||||
|     if (val && typeof val !== 'function') { | ||||
|       console.error('val:', val, '不是一个function') | ||||
|     } else { | ||||
|       this.clickCallBack = val | ||||
|     } | ||||
|   } | ||||
|   get show() { | ||||
|     return this.options.show | ||||
|   } | ||||
|   set show(v) { | ||||
|     this.options.show = v | ||||
|     this.textDom && (this.textDom.style.display = v ? 'block' : 'none'); | ||||
|     syncData(this.sdk, this.options.id) | ||||
|   } | ||||
|   get position() { | ||||
|     return this.options.position | ||||
|   } | ||||
|   set position(v) { | ||||
|     this.options.position = v | ||||
|   } | ||||
|   async flyTo(options = {}) { | ||||
|     setActiveViewer(0) | ||||
|     closeRotateAround(this.sdk) | ||||
|     closeViewFollow(this.sdk) | ||||
|  | ||||
|     if (this.options.customView && this.options.customView.relativePosition && this.options.customView.orientation) { | ||||
|       let orientation = { | ||||
|         heading: Cesium.Math.toRadians(this.options.customView.orientation.heading || 0.0), | ||||
|         pitch: Cesium.Math.toRadians(this.options.customView.orientation.pitch || -60.0), | ||||
|         roll: Cesium.Math.toRadians(this.options.customView.orientation.roll || 0.0) | ||||
|       } | ||||
|  | ||||
|       let lng = this.options.customView.relativePosition.lng | ||||
|       let lat = this.options.customView.relativePosition.lat | ||||
|       let alt = this.options.customView.relativePosition.alt | ||||
|       let destination = Cesium.Cartesian3.fromDegrees(lng, lat, alt) | ||||
|  | ||||
|       let position = { lng: 0, lat: 0 } | ||||
|       if (this.options.position) { | ||||
|         position = { ...this.options.position } | ||||
|       } | ||||
|       else if (this.options.position) { | ||||
|         position = { ...this.options.position[0] } | ||||
|       } | ||||
|       else if (this.options.center) { | ||||
|         position = { ...this.options.center } | ||||
|       } | ||||
|       else if (this.options.start) { | ||||
|         position = { ...this.options.start } | ||||
|       } | ||||
|       else { | ||||
|         if (this.options.hasOwnProperty('lng')) { | ||||
|           position.lng = this.options.lng | ||||
|         } | ||||
|         if (this.options.hasOwnProperty('lat')) { | ||||
|           position.lat = this.options.lat | ||||
|         } | ||||
|         if (this.options.hasOwnProperty('alt')) { | ||||
|           position.alt = this.options.alt | ||||
|         } | ||||
|       } | ||||
|       // 如果没有高度值,则获取紧贴高度计算 | ||||
|       // if (!position.hasOwnProperty('alt')) { | ||||
|       //   position.alt = await this.getClampToHeight(position) | ||||
|       // } | ||||
|       lng = this.options.customView.relativePosition.lng + position.lng | ||||
|       lat = this.options.customView.relativePosition.lat + position.lat | ||||
|       alt = this.options.customView.relativePosition.alt + position.alt | ||||
|       destination = Cesium.Cartesian3.fromDegrees(lng, lat, alt) | ||||
|       this.sdk.viewer.camera.flyTo({ | ||||
|         destination: destination, | ||||
|         orientation: orientation | ||||
|       }) | ||||
|     } | ||||
|     else { | ||||
|       let positionArray = [] | ||||
|       let a = Cesium.Cartesian3.fromDegrees( | ||||
|         this.position.lng, | ||||
|         this.position.lat, | ||||
|         this.position.alt | ||||
|       ) | ||||
|       positionArray.push(a.x, a.y, a.z) | ||||
|  | ||||
|       let BoundingSphere = Cesium.BoundingSphere.fromVertices(positionArray) | ||||
|       this.viewer.camera.flyToBoundingSphere(BoundingSphere, { | ||||
|         offset: { | ||||
|           heading: Cesium.Math.toRadians(0.0), | ||||
|           pitch: Cesium.Math.toRadians(-20.0), | ||||
|           roll: Cesium.Math.toRadians(0.0) | ||||
|         } | ||||
|       }) | ||||
|  | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   async remove() { | ||||
|     if (this.handler) { | ||||
|       this.sdk.viewer.scene.postRender.removeEventListener(this.handler); | ||||
|       this.handler = undefined | ||||
|     } | ||||
|     if (this.textDom && this.textDom.parentNode) { | ||||
|       this.sdk.viewer.cesiumWidget.container.removeChild(this.textDom); | ||||
|     } | ||||
|     await this.sdk.removeIncetance(this.options.id) | ||||
|     syncData(this.sdk, this.options.id) | ||||
|   } | ||||
|  | ||||
|   flicker() { } | ||||
| } | ||||
|  | ||||
| export default TextBox | ||||
| @ -649,7 +649,7 @@ class GroundText extends Base { | ||||
|       ctx.font = 200 + 'px serif' | ||||
|       ctx.fillStyle = 'rgba(255, 255, 255, 0)' | ||||
|       ctx.fillRect(0, 0, maxWidth + 30, 210) | ||||
|       ctx.fillStyle = this.options.color | ||||
|       ctx.fillStyle = 'rgba(255, 255, 255, 1)' | ||||
|       ctx.font = '200px serif' | ||||
|       ctx.fillText(textArray[i], 0, 210 * (i + 1)) | ||||
|     } | ||||
|  | ||||
| @ -417,71 +417,11 @@ class StandText extends Base { | ||||
|           this.color = 'rgba(255,255,255,1)' | ||||
|         },//点击清空按钮事件回调 | ||||
|       }) | ||||
|       let labelColorPicker = new YJColorPicker({ | ||||
|         el: contentElm.getElementsByClassName("labelColor")[0], | ||||
|         size: 'mini',//颜色box类型 | ||||
|         alpha: true,//是否开启透明度 | ||||
|         defaultColor: this.labelColor, | ||||
|         disabled: false,//是否禁止打开颜色选择器 | ||||
|         openPickerAni: 'opacity',//打开颜色选择器动画 | ||||
|         sure: (color) => { | ||||
|           this.labelColor = color | ||||
|         },//点击确认按钮事件回调 | ||||
|         clear: () => { | ||||
|           this.labelColor = 'rgba(255,255,255,1)' | ||||
|         },//点击清空按钮事件回调 | ||||
|       }) | ||||
|       let lineColorPicker = new YJColorPicker({ | ||||
|         el: contentElm.getElementsByClassName("labelLineColor")[0], | ||||
|         size: 'mini',//颜色box类型 | ||||
|         alpha: true,//是否开启透明度 | ||||
|         defaultColor: this.labelLineColor, | ||||
|         disabled: false,//是否禁止打开颜色选择器 | ||||
|         openPickerAni: 'opacity',//打开颜色选择器动画 | ||||
|         sure: (color) => { | ||||
|           this.labelLineColor = color | ||||
|         },//点击确认按钮事件回调 | ||||
|         clear: () => { | ||||
|           this.labelLineColor = 'rgba(255,255,255,1)' | ||||
|         },//点击清空按钮事件回调 | ||||
|       }) | ||||
|       let labelBackgroundColorStartPicker = new YJColorPicker({ | ||||
|         el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0], | ||||
|         size: 'mini', | ||||
|         alpha: true, | ||||
|         defaultColor: this.labelBackgroundColorStart, | ||||
|         disabled: false, | ||||
|         openPickerAni: 'opacity', | ||||
|         sure: (color) => { | ||||
|           this.labelBackgroundColorStart = color | ||||
|         }, | ||||
|         clear: () => { | ||||
|           this.labelBackgroundColorStart = 'rgba(255,255,255,1)' | ||||
|         }, | ||||
|       }) | ||||
|       let labelBackgroundColorEndPicker = new YJColorPicker({ | ||||
|         el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0], | ||||
|         size: 'mini', | ||||
|         alpha: true, | ||||
|         defaultColor: this.labelBackgroundColorEnd, | ||||
|         disabled: false, | ||||
|         openPickerAni: 'opacity', | ||||
|         sure: (color) => { | ||||
|           this.labelBackgroundColorEnd = color | ||||
|         }, | ||||
|         clear: () => { | ||||
|           this.labelBackgroundColorEnd = 'rgba(255,255,255,1)' | ||||
|         }, | ||||
|       }) | ||||
|  | ||||
|       let all_elm = contentElm.getElementsByTagName("*") | ||||
|       this._EventBinding.on(this, all_elm) | ||||
|       this._elms = this._EventBinding.element | ||||
|       this._elms.color = [colorPicker] | ||||
|       this._elms.labelColor = [labelColorPicker] | ||||
|       this._elms.labelLineColor = [lineColorPicker] | ||||
|       this._elms.labelBackgroundColorStart = [labelBackgroundColorStartPicker] | ||||
|       this._elms.labelBackgroundColorEnd = [labelBackgroundColorEndPicker] | ||||
|     } else { | ||||
|       if (this._DialogObject && this._DialogObject.remove) { | ||||
|         this._DialogObject.remove() | ||||
| @ -568,7 +508,7 @@ class StandText extends Base { | ||||
|       ctx.font = 200 + "px serif"; | ||||
|       ctx.fillStyle = 'rgba(255, 255, 255, 0)' | ||||
|       ctx.fillRect(0, 0, maxWidth + 30, 210) | ||||
|       ctx.fillStyle = this.options.color; | ||||
|       ctx.fillStyle = 'rgba(255, 255, 255, 1)'; | ||||
|       ctx.font = "200px serif"; | ||||
|       ctx.fillText(textArray[i], 0, 210 * (i+1)); | ||||
|     } | ||||
|  | ||||
| @ -182,6 +182,23 @@ function html() { | ||||
|       </div> | ||||
|     </div> | ||||
|     <span class="custom-divider"></span> | ||||
|     <div class="div-item"> | ||||
|       <div class="row"> | ||||
|         <div class="col"> | ||||
|           <span class="label">油耗</span> | ||||
|           <div class="input-number input-number-unit-6" style="width: 170px;"> | ||||
|             <input class="input" type="number" title="" min="0" max="99999999" @model="unitFuelConsumption"> | ||||
|             <span class="unit">L/100km</span> | ||||
|             <span class="arrow"></span> | ||||
|           </div> | ||||
|         </div> | ||||
|         <div class="col" style="flex: 0 0 0;"> | ||||
|           <span class="label">总油耗</span> | ||||
|           <input class="btn-switch" type="checkbox" @model="fuelShow"> | ||||
|         </div> | ||||
|       </div> | ||||
|     </div> | ||||
|     <span class="custom-divider"></span> | ||||
|     ` | ||||
| } | ||||
|  | ||||
|  | ||||
| @ -78,6 +78,7 @@ class TrajectoryMotion extends Base { | ||||
|     this.options.line.smooth = options.line.smooth ? options.line.smooth : false | ||||
|     this.options.line.noseToTail = options.line.noseToTail ? options.line.noseToTail : false | ||||
|     this.positions_smooth = [] | ||||
|     this.options.unitFuelConsumption = options.unitFuelConsumption || 0 | ||||
|     this.options.ground = options.ground || false | ||||
|     this.options.state = (options.state || options.state === false) ? options.state : true | ||||
|     this.options.routeDirection = (options.routeDirection || options.routeDirection === false) ? options.routeDirection : true | ||||
| @ -99,7 +100,7 @@ class TrajectoryMotion extends Base { | ||||
|       color: options.label.color || '#ffffff', | ||||
|       lineWidth: (options.label.lineWidth || options.label.lineWidth === 0) ? options.label.lineWidth : 4, | ||||
|       pixelOffset: (options.label.pixelOffset || options.label.pixelOffset === 0) ? options.label.pixelOffset : 20, | ||||
|       backgroundColor: options.label.backgroundColor || ['#42c6ef', '#42c6ef'], | ||||
|       backgroundColor: options.label.backgroundColor || ['#00ffff80', '#00ffff80'], | ||||
|       lineColor: options.label.lineColor || '#00ffff80', | ||||
|       scaleByDistance: options.label.scaleByDistance || false, | ||||
|       near: (options.label.near || options.label.near === 0) ? options.label.near : 2000, | ||||
| @ -144,37 +145,56 @@ class TrajectoryMotion extends Base { | ||||
|  | ||||
|   set show(v) { | ||||
|     if (typeof v === "boolean") { | ||||
|       this.options.show = v | ||||
|       if (this.originalOptions) { | ||||
|         this.originalOptions.show = v | ||||
|       let sdkD = get2DView() | ||||
|       if (!this.isShowView || !sdkD) { | ||||
|         this.options.show = v | ||||
|         if (this.originalOptions) { | ||||
|           this.originalOptions.show = v | ||||
|         } | ||||
|       } | ||||
|       if (v) { | ||||
|       if (this.options.show) { | ||||
|         if (this.firstPersonView) { | ||||
|           this.model.show = false | ||||
|         } | ||||
|         else { | ||||
|           this.model.show = this.modelShow | ||||
|           this.model.show = (!this.showView || this.showView == 3 || !sdkD) ? this.modelShow : false | ||||
|         } | ||||
|  | ||||
|         this.line.polyline.material = this.lineShow ? new Cesium.PolylineDashMaterialProperty({ | ||||
|           color: new Cesium.Color.fromCssColorString('#00ffff'), | ||||
|           dashLength: 20, | ||||
|         }) : new Cesium.PolylineDashMaterialProperty({ | ||||
|           color: new Cesium.Color.fromCssColorString('#00ffff00'), | ||||
|           dashLength: 20, | ||||
|         }) | ||||
|         if ((!this.showView || this.showView == 3 || !sdkD)) { | ||||
|           this.line.polyline.material = this.lineShow ? new Cesium.PolylineDashMaterialProperty({ | ||||
|             color: new Cesium.Color.fromCssColorString('#00ffff'), | ||||
|             dashLength: 20, | ||||
|           }) : new Cesium.PolylineDashMaterialProperty({ | ||||
|             color: new Cesium.Color.fromCssColorString('#00ffff00'), | ||||
|             dashLength: 20, | ||||
|           }) | ||||
|         } | ||||
|         else { | ||||
|           this.line.polyline.material = new Cesium.PolylineDashMaterialProperty({ | ||||
|             color: new Cesium.Color.fromCssColorString('#00ffff00'), | ||||
|             dashLength: 20, | ||||
|           }) | ||||
|         } | ||||
|         for (let i = 0; i < this.keyPoints.length; i++) { | ||||
|           this.keyPoints[i].show = this.keyPointShow | ||||
|           this.keyPoints[i].show = (!this.showView || this.showView == 3 || !sdkD) ? this.keyPointShow : false | ||||
|         } | ||||
|         if (this.realTimeRoute) { | ||||
|           this.realTimeLine && (this.realTimeLine.show = true) | ||||
|           this.realTimeLine && (this.realTimeLine.show = (!this.showView || this.showView == 3 || !sdkD) ? true : false) | ||||
|         } | ||||
|         this.label && (this.label.show = this.options.label.show) | ||||
|         this.label && (this.label.show = (!this.showView || this.showView == 3) ? this.options.label.show : false) | ||||
|         this.fuelLabel && (this.fuelLabel.show = (!this.showView || this.showView == 3) ? this.options.fuelShow : false) | ||||
|       } | ||||
|       else { | ||||
|         this.model.show = v | ||||
|         this.model.show = (!this.showView || this.showView == 3 || !sdkD) ? this.options.show : false | ||||
|         let show = this.options.show | ||||
|         if ((!this.showView || this.showView == 3 || !sdkD)) { | ||||
|           show = this.options.show | ||||
|         } | ||||
|         else { | ||||
|           show = false | ||||
|         } | ||||
|         this.realTimeLine && (this.realTimeLine.show = false) | ||||
|         this.line.polyline.material = v ? new Cesium.PolylineDashMaterialProperty({ | ||||
|         this.line.polyline.material = show ? new Cesium.PolylineDashMaterialProperty({ | ||||
|           color: new Cesium.Color.fromCssColorString('#00ffff'), | ||||
|           dashLength: 20, | ||||
|         }) : new Cesium.PolylineDashMaterialProperty({ | ||||
| @ -182,9 +202,10 @@ class TrajectoryMotion extends Base { | ||||
|           dashLength: 20, | ||||
|         }) | ||||
|         for (let i = 0; i < this.keyPoints.length; i++) { | ||||
|           this.keyPoints[i].show = v | ||||
|           this.keyPoints[i].show = (!this.showView || this.showView == 3) ? show : false | ||||
|         } | ||||
|         this.label && (this.label.show = false) | ||||
|         this.fuelLabel && (this.fuelLabel.show = false) | ||||
|         this.viewFollow = false | ||||
|       } | ||||
|  | ||||
| @ -193,6 +214,7 @@ class TrajectoryMotion extends Base { | ||||
|       } | ||||
|       syncData(this.sdk, this.options.id) | ||||
|       syncSplitData(this.sdk, this.options.id) | ||||
|       this.isShowView = false | ||||
|     } else { | ||||
|       console.error("参数必须为boolean") | ||||
|     } | ||||
| @ -238,14 +260,17 @@ class TrajectoryMotion extends Base { | ||||
|       // Cesium.Matrix4.multiplyByTranslation(this.model.modelMatrix, new Cesium.Cartesian3(0, 0, -difference), this.model.modelMatrix) | ||||
|       // Cesium.Matrix4.getTranslation(this.model.modelMatrix, this.model.position) | ||||
|       this.label && (this.label.show = this.label.show) | ||||
|       this.fuelLabel && (this.fuelLabel.show = this.fuelLabel.show) | ||||
|       if (this.options.label.position) { | ||||
|         setTimeout(() => { | ||||
|           if (this.options.label.position.alt) { | ||||
|             this.label && (this.label.position = [this.options.label.position.lng, this.options.label.position.lat, this.options.label.position.alt]) | ||||
|             this.fuelLabel && (this.fuelLabel.position = [this.options.label.position.lng, this.options.label.position.lat, this.options.label.position.alt]) | ||||
|           } | ||||
|           else { | ||||
|             this.getClampToHeight({ lng: this.options.label.position.lng, lat: this.options.label.position.lat }).then((height) => { | ||||
|               this.label && (this.label.position = [this.options.label.position.lng, this.options.label.position.lat, height]) | ||||
|               this.fuelLabel && (this.fuelLabel.position = [this.options.label.position.lng, this.options.label.position.lat, height]) | ||||
|             }) | ||||
|           } | ||||
|         }, 0) | ||||
| @ -636,7 +661,7 @@ class TrajectoryMotion extends Base { | ||||
|         }) | ||||
|         this.TweenAnimate.pause() | ||||
|         setTimeout(() => { | ||||
|           _this.model.isMove = false | ||||
|           _this.model && (_this.model.isMove = false) | ||||
|         }, 200); | ||||
|       } | ||||
|     } | ||||
| @ -655,9 +680,17 @@ class TrajectoryMotion extends Base { | ||||
|     return this.options.model.show | ||||
|   } | ||||
|   set modelShow(v) { | ||||
|     let sdkD = get2DView() | ||||
|     this.options.model.show = v | ||||
|     let show = v | ||||
|     if (this.show && (!this.showView || this.showView == 3 || !sdkD)) { | ||||
|       show = v | ||||
|     } | ||||
|     else { | ||||
|       show = false | ||||
|     } | ||||
|     if (this.model && this.show) { | ||||
|       this.model.show = v | ||||
|       this.model.show = show | ||||
|     } | ||||
|     this._elms.modelShow && this._elms.modelShow.forEach((item) => { | ||||
|       item.checked = v | ||||
| @ -723,8 +756,16 @@ class TrajectoryMotion extends Base { | ||||
|       this.realTimeRoute = false | ||||
|     } | ||||
|     this.options.line.show = v | ||||
|     let show = v | ||||
|     let sdkD = get2DView() | ||||
|     if ((!this.showView || this.showView == 3 || !sdkD)) { | ||||
|       show = v | ||||
|     } | ||||
|     else { | ||||
|       show = false | ||||
|     } | ||||
|     if (this.line && this.show) { | ||||
|       this.line.polyline.material = v ? new Cesium.PolylineDashMaterialProperty({ | ||||
|       this.line.polyline.material = show ? new Cesium.PolylineDashMaterialProperty({ | ||||
|         color: new Cesium.Color.fromCssColorString('#00ffff'), | ||||
|         dashLength: 20, //短划线长度 | ||||
|       }) : new Cesium.PolylineDashMaterialProperty({ | ||||
| @ -941,6 +982,7 @@ class TrajectoryMotion extends Base { | ||||
|  | ||||
|   set firstPersonView(v) { | ||||
|     // this.state = true | ||||
|     let sdkD = get2DView() | ||||
|     let splitSdk = getSdk() | ||||
|     if (get2DView() || splitSdk.sdkD || !this.show) { | ||||
|       v = false | ||||
| @ -994,7 +1036,14 @@ class TrajectoryMotion extends Base { | ||||
|     else { | ||||
|       CameraController(this.sdk, true) | ||||
|       if (this.model && this.modelShow && this.show) { | ||||
|         this.model.show = true | ||||
|         let show = true | ||||
|         if (this.show && (!this.showView || this.showView == 3 || !sdkD)) { | ||||
|           show = true | ||||
|         } | ||||
|         else { | ||||
|           show = false | ||||
|         } | ||||
|         this.model.show = show | ||||
|       } | ||||
|       if (this._DialogObject && this._DialogObject._element.content) { | ||||
|         let e_firstPerson = this._DialogObject._element.content.querySelectorAll("button[name='firstPerson']") | ||||
| @ -1116,19 +1165,30 @@ class TrajectoryMotion extends Base { | ||||
|   } | ||||
|   set labelShow(v) { | ||||
|     this.options.label.show = v | ||||
|     let sdkD = get2DView() | ||||
|     let show = v | ||||
|     if (this.show && (!this.showView || this.showView == 3 || !sdkD)) { | ||||
|       show = v | ||||
|     } | ||||
|     else { | ||||
|       show = false | ||||
|     } | ||||
|     if (this.show) { | ||||
|       this.label && (this.label.show = v) | ||||
|       if (this.options.label.position) { | ||||
|         setTimeout(() => { | ||||
|           if (this.options.label.position.alt) { | ||||
|             this.label && (this.label.position = [this.options.label.position.lng, this.options.label.position.lat, this.options.label.position.alt]) | ||||
|           } | ||||
|           else { | ||||
|             this.getClampToHeight({ lng: this.options.label.position.lng, lat: this.options.label.position.lat }).then((height) => { | ||||
|               this.label && (this.label.position = [this.options.label.position.lng, this.options.label.position.lat, height]) | ||||
|             }) | ||||
|           } | ||||
|         }, 0); | ||||
|       if (this.label) { | ||||
|         this.label.show = show | ||||
|         this.label.pixelOffset = this.options.label.pixelOffset + (this.fuelShow ? this.labelFontSize + 20 : 0) | ||||
|         if (this.options.label.position) { | ||||
|           setTimeout(() => { | ||||
|             if (this.options.label.position.alt) { | ||||
|               this.label && (this.label.position = [this.options.label.position.lng, this.options.label.position.lat, this.options.label.position.alt]) | ||||
|             } | ||||
|             else { | ||||
|               this.getClampToHeight({ lng: this.options.label.position.lng, lat: this.options.label.position.lat }).then((height) => { | ||||
|                 this.label && (this.label.position = [this.options.label.position.lng, this.options.label.position.lat, height]) | ||||
|               }) | ||||
|             } | ||||
|           }, 0); | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|     else { | ||||
| @ -1146,6 +1206,7 @@ class TrajectoryMotion extends Base { | ||||
|   set labelFontFamily(v) { | ||||
|     this.options.label.fontFamily = v || 0 | ||||
|     this.label && (this.label.fontFamily = this.options.label.fontFamily) | ||||
|     this.fuelLabel && (this.fuelLabel.fontFamily = this.options.label.fontFamily) | ||||
|  | ||||
|     let name = getFontFamilyName(this.labelFontFamily) || '' | ||||
|     this._elms.labelFontFamily && | ||||
| @ -1160,6 +1221,7 @@ class TrajectoryMotion extends Base { | ||||
|   set labelColor(v) { | ||||
|     this.options.label.color = v | ||||
|     this.label && (this.label.color = v) | ||||
|     this.fuelLabel && (this.fuelLabel.color = v) | ||||
|     if (this._elms.labelColor) { | ||||
|       this._elms.labelColor.forEach((item, i) => { | ||||
|         let labelColorPicker = new YJColorPicker({ | ||||
| @ -1187,6 +1249,13 @@ class TrajectoryMotion extends Base { | ||||
|   set labelFontSize(v) { | ||||
|     this.options.label.fontSize = v | ||||
|     this.label && (this.label.fontSize = v) | ||||
|     if (this.fuelLabel) { | ||||
|       this.fuelLabel.fontSize = v | ||||
|       this.label.pixelOffset = this.options.label.pixelOffset + v + 20 | ||||
|     } | ||||
|     else { | ||||
|       this.label.pixelOffset = this.options.label.pixelOffset | ||||
|     } | ||||
|     this._elms.labelFontSize && this._elms.labelFontSize.forEach((item) => { | ||||
|       item.value = v | ||||
|     }) | ||||
| @ -1198,6 +1267,7 @@ class TrajectoryMotion extends Base { | ||||
|   set labelScaleByDistance(v) { | ||||
|     this.options.label.scaleByDistance = v | ||||
|     this.label && (this.label.scaleByDistance = v) | ||||
|     this.fuelLabel && (this.fuelLabel.scaleByDistance = v) | ||||
|     this._elms.labelScaleByDistance && this._elms.labelScaleByDistance.forEach((item) => { | ||||
|       item.checked = v | ||||
|     }) | ||||
| @ -1213,6 +1283,7 @@ class TrajectoryMotion extends Base { | ||||
|     } | ||||
|     this.options.label.near = near | ||||
|     this.label && (this.label.near = near) | ||||
|     this.fuelLabel && (this.fuelLabel.near = near) | ||||
|     this._elms.labelNear && this._elms.labelNear.forEach((item) => { | ||||
|       item.value = near | ||||
|     }) | ||||
| @ -1228,11 +1299,66 @@ class TrajectoryMotion extends Base { | ||||
|     } | ||||
|     this.options.label.far = far | ||||
|     this.label && (this.label.far = far) | ||||
|     this.fuelLabel && (this.fuelLabel.far = far) | ||||
|     this._elms.labelFar && this._elms.labelFar.forEach((item) => { | ||||
|       item.value = far | ||||
|     }) | ||||
|   } | ||||
|  | ||||
|   get unitFuelConsumption() { | ||||
|     return this.options.unitFuelConsumption | ||||
|   } | ||||
|  | ||||
|   set unitFuelConsumption(v) { | ||||
|     this.options.unitFuelConsumption = v | ||||
|     this._elms.unitFuelConsumption && this._elms.unitFuelConsumption.forEach((item) => { | ||||
|       item.value = v | ||||
|     }) | ||||
|   } | ||||
|  | ||||
|   get fuelShow() { | ||||
|     return this.options.fuelShow | ||||
|   } | ||||
|  | ||||
|   set fuelShow(v) { | ||||
|     this.options.fuelShow = v | ||||
|     let show = v | ||||
|     if (this.show && (!this.showView || this.showView == 3)) { | ||||
|       show = v | ||||
|     } | ||||
|     else { | ||||
|       show = false | ||||
|     } | ||||
|     if (this.show) { | ||||
|       if (this.fuelLabel) { | ||||
|         this.fuelLabel.show = show | ||||
|         this.label.pixelOffset = this.options.label.pixelOffset + (show ? this.labelFontSize + 20 : 0) | ||||
|       } | ||||
|       else { | ||||
|         this.label.pixelOffset = this.options.label.pixelOffset | ||||
|       } | ||||
|       if (this.options.label.position) { | ||||
|         setTimeout(() => { | ||||
|           if (this.options.label.position.alt) { | ||||
|             this.fuelLabel && (this.fuelLabel.position = [this.options.label.position.lng, this.options.label.position.lat, this.options.label.position.alt]) | ||||
|           } | ||||
|           else { | ||||
|             this.getClampToHeight({ lng: this.options.label.position.lng, lat: this.options.label.position.lat }).then((height) => { | ||||
|               this.fuelLabel && (this.fuelLabel.position = [this.options.label.position.lng, this.options.label.position.lat, height]) | ||||
|             }) | ||||
|           } | ||||
|         }, 0); | ||||
|       } | ||||
|     } | ||||
|     else { | ||||
|       this.fuelLabel && (this.fuelLabel.show = false) | ||||
|       this.label.pixelOffset = this.options.label.pixelOffset | ||||
|     } | ||||
|     this._elms.fuelShow && this._elms.fuelShow.forEach((item) => { | ||||
|       item.checked = v | ||||
|     }) | ||||
|   } | ||||
|  | ||||
|   // 创建路径 | ||||
|   static addLine(that) { | ||||
|     let positions_smooth = that.renewLinePositions(that.options.line.positions) | ||||
| @ -1351,6 +1477,7 @@ class TrajectoryMotion extends Base { | ||||
|     } | ||||
|     let pos = that.smooth ? that.positions_smooth : Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArrayHeights) | ||||
|     TrajectoryMotion.createLabel(that) | ||||
|     TrajectoryMotion.createFuelLabel(that) | ||||
|     that.modelMove(pos) | ||||
|  | ||||
|  | ||||
| @ -1360,13 +1487,13 @@ class TrajectoryMotion extends Base { | ||||
|   static async createLabel(that) { | ||||
|     let labelPosition = that.cartesian3Towgs84(that.model.position, that.sdk.viewer) | ||||
|     that.label = new LabelObject(that.sdk, { | ||||
|       show: that.options.show ? (that.options.model.show ? that.options.label.show : false) : false, | ||||
|       show: that.options.show ? (that.options.label.show ? true : false) : false, | ||||
|       position: [labelPosition.lng, labelPosition.lat, labelPosition.alt], | ||||
|       text: that.options.name, | ||||
|       fontSize: that.options.label.fontSize, | ||||
|       fontFamily: that.options.label.fontFamily, | ||||
|       color: that.options.label.color, | ||||
|       pixelOffset: that.options.label.pixelOffset, | ||||
|       pixelOffset: that.options.label.pixelOffset + (that.options.fuelShow ? that.options.label.fontSize + 20 : 0), | ||||
|       backgroundColor: that.options.label.backgroundColor, | ||||
|       lineColor: that.options.label.lineColor, | ||||
|       lineWidth: that.options.label.lineWidth, | ||||
| @ -1376,6 +1503,26 @@ class TrajectoryMotion extends Base { | ||||
|     }, that.model) | ||||
|   } | ||||
|  | ||||
|   static async createFuelLabel(that) { | ||||
|     let labelPosition = that.cartesian3Towgs84(that.model.position, that.sdk.viewer) | ||||
|     that.fuelLabel = new LabelObject(that.sdk, { | ||||
|       show: that.options.show ? (that.options.fuelShow ? true : false) : false, | ||||
|       // show: true, | ||||
|       position: [labelPosition.lng, labelPosition.lat, labelPosition.alt], | ||||
|       text: '总油耗:', | ||||
|       fontSize: that.options.label.fontSize, | ||||
|       fontFamily: that.options.label.fontFamily, | ||||
|       color: that.options.label.color, | ||||
|       pixelOffset: 0, | ||||
|       backgroundColor: ['#6e6e6e', '#6e6e6e'], | ||||
|       lineColor: '#00ffff00', | ||||
|       lineWidth: 0, | ||||
|       scaleByDistance: that.options.label.scaleByDistance, | ||||
|       near: that.options.label.near, | ||||
|       far: that.options.label.far | ||||
|     }, that.model) | ||||
|   } | ||||
|  | ||||
|   // 创建关键点 | ||||
|   static async addKeyPoint(that) { | ||||
|     for (let i = 0; i < that.options.line.positions.length; i++) { | ||||
| @ -1481,7 +1628,7 @@ class TrajectoryMotion extends Base { | ||||
|       setPosition(startDistance) | ||||
|       setTimeout(() => { | ||||
|         _this.model.isMove = false | ||||
|       }, 500); | ||||
|       }, 1000); | ||||
|  | ||||
|  | ||||
|       animateUpdate() | ||||
| @ -1504,6 +1651,8 @@ class TrajectoryMotion extends Base { | ||||
|     } | ||||
|  | ||||
|     async function setPosition(distance) { | ||||
|       _this.totalFuelConsumption = Number((distance / 100 * _this.unitFuelConsumption).toFixed(2)) | ||||
|       _this.fuelLabel.text = '总油耗:' + _this.totalFuelConsumption + ' L' | ||||
|       _this.model.isMove = true | ||||
|       let sdk2D = get2DView() | ||||
|       let splitSdk = getSdk() | ||||
| @ -1615,9 +1764,10 @@ class TrajectoryMotion extends Base { | ||||
|         if (!cartesian3) { | ||||
|           return | ||||
|         } | ||||
|         coordinates = _this.cartesian3Towgs84(cartesian3, viewer); | ||||
|         let pos84 = _this.cartesian3Towgs84(cartesian3, viewer); | ||||
|         coordinates = [pos84.lng, pos84.lat, pos84.alt + 1.8] | ||||
|         position = cartesian3 | ||||
|         positionCamera = Cesium.Cartesian3.fromDegrees(coordinates.lng, coordinates.lat, coordinates.alt + 1.8) | ||||
|         positionCamera = Cesium.Cartesian3.fromDegrees(coordinates[0], coordinates[1], coordinates[2]) | ||||
|         let positions_smooth = [] | ||||
|         for (let i = 0; i <= 1000; i++) { | ||||
|           if ((i / 1000) > (distance / _this.distance)) { | ||||
| @ -1715,6 +1865,7 @@ class TrajectoryMotion extends Base { | ||||
|       } | ||||
|       let labelPosition = _this.cartesian3Towgs84(position, _this.sdk.viewer) | ||||
|       _this.label.position = [labelPosition.lng, labelPosition.lat, labelPosition.alt] | ||||
|       _this.fuelLabel.position = [labelPosition.lng, labelPosition.lat, labelPosition.alt] | ||||
|       lastDistance = distance | ||||
|       // console.log(position) | ||||
|       _this.realTimeRouteArray.push(position) | ||||
| @ -1740,7 +1891,7 @@ class TrajectoryMotion extends Base { | ||||
|           else { | ||||
|             if (_this.sdk.viewer.trackedEntity) { | ||||
|               _this.sdk.viewer.camera.setView({ | ||||
|                 destination: Cesium.Cartesian3.fromDegrees(coordinates.lng, coordinates.lat, _this.sdk.viewer.camera.positionCartographic.height), | ||||
|                 destination: Cesium.Cartesian3.fromDegrees(coordinates[0], coordinates[1], _this.sdk.viewer.camera.positionCartographic.height), | ||||
|                 orientation: { | ||||
|                   heading: Cesium.Math.toRadians(-90), | ||||
|                   pitch: 0, | ||||
| @ -1888,10 +2039,10 @@ class TrajectoryMotion extends Base { | ||||
|           this.tip && this.tip.destroy() | ||||
|           this.tip = null | ||||
|           this.ControllerObject.destroy() | ||||
|           if(this.firstPersonView !== this.originalOptions.firstPersonView) { | ||||
|           if (this.firstPersonView !== this.originalOptions.firstPersonView) { | ||||
|             this.firstPersonView = this.originalOptions.firstPersonView; | ||||
|           } | ||||
|           if(this.firstPersonView && this.modelShow) { | ||||
|           if (this.firstPersonView && this.modelShow) { | ||||
|             this.model && (this.model.show = false) | ||||
|           } | ||||
|         }, | ||||
| @ -2036,7 +2187,7 @@ class TrajectoryMotion extends Base { | ||||
|       rubricElm.style.color = '#ff5733'; | ||||
|       rubricElm.style.display = 'none' | ||||
|  | ||||
|       rubricElm.innerHTML = `场景正北方向为轨迹前进正方向<div x-arrow="" class="custom__popper__arrow" style="left: 59px;"></div>` | ||||
|       rubricElm.innerHTML = `场景正东方向为轨迹前进正方向<div x-arrow="" class="custom__popper__arrow" style="left: 59px;"></div>` | ||||
|       let iconRubric = contentElm.getElementsByClassName('icon-rubric')[0] | ||||
|       iconRubric.addEventListener('mouseenter', (e) => { | ||||
|         rubricElm.style.display = 'block' | ||||
| @ -2111,6 +2262,7 @@ class TrajectoryMotion extends Base { | ||||
|     this.sdk.viewer.entities.remove(this.line) | ||||
|     this.sdk.viewer.entities.remove(this.realTimeLine) | ||||
|     this.label && this.label.remove() | ||||
|     this.fuelLabel && this.fuelLabel.remove() | ||||
|     for (let i = 0; i < this.keyPointShow.length; i++) { | ||||
|       this.sdk.viewer.entities.remove(this.keyPointShow[i]) | ||||
|     } | ||||
| @ -2118,6 +2270,7 @@ class TrajectoryMotion extends Base { | ||||
|     this.realTimeLine = null | ||||
|     this.model = null | ||||
|     this.label = null | ||||
|     this.fuelLabel = null | ||||
|     if (this._DialogObject && !this._DialogObject.isDestroy) { | ||||
|       this._DialogObject.close() | ||||
|       this._DialogObject = null | ||||
| @ -2164,13 +2317,14 @@ class TrajectoryMotion extends Base { | ||||
|     this.modelAnimate = this.originalOptions.model.animate; | ||||
|     this.delay = this.originalOptions.delay; | ||||
|     (this.ground !== this.originalOptions.ground) && (this.ground = this.originalOptions.ground); | ||||
|     if(this.firstPersonView !== this.originalOptions.firstPersonView) { | ||||
|     if (this.firstPersonView !== this.originalOptions.firstPersonView) { | ||||
|       this.firstPersonView = this.originalOptions.firstPersonView; | ||||
|     } | ||||
|     if(this.firstPersonView && this.modelShow) { | ||||
|     if (this.firstPersonView && this.modelShow) { | ||||
|       this.model && (this.model.show = false) | ||||
|     } | ||||
|     this.labelShow = this.originalOptions.label.show | ||||
|     this.fuelShow = this.originalOptions.fuelShow | ||||
|     this.labelColor = this.originalOptions.label.color | ||||
|     this.labelFontSize = this.originalOptions.label.fontSize | ||||
|     this.labelFontFamily = this.originalOptions.label.fontFamily | ||||
| @ -2229,7 +2383,6 @@ class TrajectoryMotion extends Base { | ||||
|           this._DialogObject._element.content.getElementsByClassName('model-rotate-btn')[0].innerHTML = '结束调整' | ||||
|           this._DialogObject._element.content.getElementsByClassName('model-rotate-btn')[0].className = 'btn model-rotate-btn is-active' | ||||
|         } | ||||
|         console.log(this._DialogObject._element.content, this._DialogObject._element.content.getElementsByClassName('model-rotate-btn')[0]) | ||||
|         this.state = false | ||||
|         this.editObj = new EditGltf(this.sdk, this.model) | ||||
|         this.editObj.editRtation() | ||||
|  | ||||
| @ -21,6 +21,7 @@ class eventBinding { | ||||
|       let Event = [] | ||||
|       let isEvent = false | ||||
|       let removeName = [] | ||||
|       let blurEvent = ()=>{} | ||||
|       if (!elements[i] ||!elements[i].attributes) { | ||||
|         continue;  | ||||
|       } | ||||
| @ -37,14 +38,14 @@ class eventBinding { | ||||
|                 let value = e.target.value | ||||
|                 if (e.target.type == 'number') { | ||||
|                   if (e.data != '.' && (e.data != '-' || e.target.value)) { | ||||
|                     value = Number(value) | ||||
|                     if((e.target.max) && value>Number(e.target.max)) { | ||||
|                     let v = Number(value) | ||||
|                     if((e.target.max) && v>Number(e.target.max)) { | ||||
|                       value = Number(e.target.max) | ||||
|                     } | ||||
|                     if((e.target.min) && value<Number(e.target.min)) { | ||||
|                     if((e.target.min) && v<Number(e.target.min)) { | ||||
|                       value = Number(e.target.min) | ||||
|                     } | ||||
|                     if((e.target.dataset.min) && value<Number(e.target.dataset.min)) { | ||||
|                     if((e.target.dataset.min) && v<Number(e.target.dataset.min)) { | ||||
|                       value = Number(e.target.dataset.min) | ||||
|                     } | ||||
|                     that[m.value] = value | ||||
| @ -54,6 +55,22 @@ class eventBinding { | ||||
|                   that[m.value] = value | ||||
|                 } | ||||
|               }) | ||||
|               blurEvent = (e) => { | ||||
|                 let value = e.target.value | ||||
|                 if ((e.target.type == 'number') && (e.target.value || (e.target.dataset.null !== 'undefined' && e.target.dataset.null !== '' && !Boolean(e.target.dataset.null)))) { | ||||
|                   value = Number(value) | ||||
|                   if ((e.target.max) && value > Number(e.target.max)) { | ||||
|                     value = Number(e.target.max) | ||||
|                   } | ||||
|                   if ((e.target.min) && value < Number(e.target.min)) { | ||||
|                     value = Number(e.target.min) | ||||
|                   } | ||||
|                   if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) { | ||||
|                     value = Number(e.target.dataset.min) | ||||
|                   } | ||||
|                 } | ||||
|                 that[m.value] = value | ||||
|               } | ||||
|               if(elements[i].nodeName=='IMG') { | ||||
|                 elements[i].src = that[m.value] | ||||
|               } | ||||
| @ -111,6 +128,9 @@ class eventBinding { | ||||
|             Event[t](e) | ||||
|           } | ||||
|         }); | ||||
|         elements[i].addEventListener('blur', (e) => { | ||||
|           blurEvent(e) | ||||
|         }); | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|  | ||||
| @ -253,7 +253,7 @@ class WallRealStereoscopic extends Base { | ||||
|   } | ||||
|   set labelShow(v) { | ||||
|     this.options.label.show = v | ||||
|     if (this.show) { | ||||
|     if (this.show && !this.showView || this.showView == 3) { | ||||
|       this.label.show = v | ||||
|     } | ||||
|     else { | ||||
|  | ||||
| @ -157,7 +157,7 @@ class WallStereoscopic extends Base { | ||||
|   } | ||||
|   set labelShow(v) { | ||||
|     this.options.label.show = v | ||||
|     if (this.show) { | ||||
|     if (this.show && !this.showView || this.showView == 3) { | ||||
|       this.label.show = v | ||||
|     } | ||||
|     else { | ||||
|  | ||||
| @ -243,7 +243,7 @@ class WallRealStereoscopic extends Base { | ||||
|   } | ||||
|   set labelShow(v) { | ||||
|     this.options.label.show = v | ||||
|     if (this.show) { | ||||
|     if (this.show && !this.showView || this.showView == 3) { | ||||
|       this.label.show = v | ||||
|     } | ||||
|     else { | ||||
|  | ||||
| @ -21,8 +21,9 @@ class eventBinding { | ||||
|       let Event = [] | ||||
|       let isEvent = false | ||||
|       let removeName = [] | ||||
|       if (!elements[i] ||!elements[i].attributes) { | ||||
|         continue;  | ||||
|       let blurEvent = () => { } | ||||
|       if (!elements[i] || !elements[i].attributes) { | ||||
|         continue; | ||||
|       } | ||||
|       for (let m of elements[i].attributes) { | ||||
|         switch (m.name) { | ||||
| @ -37,11 +38,11 @@ class eventBinding { | ||||
|                 let value = e.target.value | ||||
|                 if (e.target.type == 'number') { | ||||
|                   if (e.data != '.' && (e.data != '-' || e.target.value)) { | ||||
|                     value = Number(value) | ||||
|                     if((e.target.max) && value>Number(e.target.max)) { | ||||
|                     let v = Number(value) | ||||
|                     if ((e.target.max) && v > Number(e.target.max)) { | ||||
|                       value = Number(e.target.max) | ||||
|                     } | ||||
|                     if((e.target.min) && value<Number(e.target.min)) { | ||||
|                     if ((e.target.min) && v < Number(e.target.min)) { | ||||
|                       value = Number(e.target.min) | ||||
|                     } | ||||
|                     that[m.value] = value | ||||
| @ -51,14 +52,32 @@ class eventBinding { | ||||
|                   that[m.value] = value | ||||
|                 } | ||||
|               }) | ||||
|               if(elements[i].nodeName=='IMG') { | ||||
|               blurEvent = (e) => { | ||||
|                 let value = e.target.value | ||||
|                 if ((e.target.type == 'number') && (e.target.value || (e.target.dataset.null !== 'undefined' && e.target.dataset.null !== '' && !Boolean(e.target.dataset.null)))) { | ||||
|                   value = Number(value) | ||||
|                   if ((e.target.max) && value > Number(e.target.max)) { | ||||
|                     value = Number(e.target.max) | ||||
|                   } | ||||
|                   if ((e.target.min) && value < Number(e.target.min)) { | ||||
|                     value = Number(e.target.min) | ||||
|                   } | ||||
|                   if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) { | ||||
|                     value = Number(e.target.dataset.min) | ||||
|                   } | ||||
|                 } | ||||
|                 that[m.value] = value | ||||
|               } | ||||
|  | ||||
|  | ||||
|               if (elements[i].nodeName == 'IMG') { | ||||
|                 elements[i].src = that[m.value] | ||||
|               } | ||||
|               else { | ||||
|                 elements[i].value = that[m.value] | ||||
|               } | ||||
|             } | ||||
|             if(this.element[m.value]) { | ||||
|             if (this.element[m.value]) { | ||||
|               this.element[m.value].push(elements[i]) | ||||
|             } | ||||
|             else { | ||||
| @ -81,7 +100,7 @@ class eventBinding { | ||||
|             isEvent = true | ||||
|             Event.push((e) => { | ||||
|               let value = e.target.value | ||||
|               if(e.target.type == 'number' && value!='') { | ||||
|               if (e.target.type == 'number' && value != '') { | ||||
|                 value = Number(value) | ||||
|                 e.target.value = value | ||||
|               } | ||||
| @ -94,7 +113,7 @@ class eventBinding { | ||||
|         } | ||||
|         // elements[i].attributes[m] = undefined | ||||
|       } | ||||
|       for(let n=0;n<removeName.length;n++) { | ||||
|       for (let n = 0; n < removeName.length; n++) { | ||||
|         elements[i].attributes.removeNamedItem(removeName[n]) | ||||
|       } | ||||
|  | ||||
| @ -108,6 +127,9 @@ class eventBinding { | ||||
|             Event[t](e) | ||||
|           } | ||||
|         }); | ||||
|         elements[i].addEventListener('blur', (e) => { | ||||
|           blurEvent(e) | ||||
|         }); | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|  | ||||
| @ -88,6 +88,10 @@ class WallStereoscopic extends Base { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   get type() { | ||||
|     return 'wallStereoscopic' | ||||
|   } | ||||
|  | ||||
|   static createLabel(that) { | ||||
|     // 标签 | ||||
|     that.label = new LabelObject(that.sdk, { | ||||
| @ -191,7 +195,7 @@ class WallStereoscopic extends Base { | ||||
|   } | ||||
|   set labelShow(v) { | ||||
|     this.options.label.show = v | ||||
|     if (this.show) { | ||||
|     if (this.show && !this.showView || this.showView == 3) { | ||||
|       this.label.show = v | ||||
|     } | ||||
|     else { | ||||
|  | ||||
| @ -35,7 +35,8 @@ class eventBinding { | ||||
|             else { | ||||
|               Event.push((e) => { | ||||
|                 let value = e.target.value | ||||
|                 if (e.target.type == 'number') { | ||||
|                 let str = e.target.value + '' | ||||
|                 if (e.target.type == 'number' && !(str.charAt(str.length - 1) == '0' && e.target.value.toString().includes('.'))) { | ||||
|                   value = Number(value) | ||||
|                 } | ||||
|                 that[m.value] = value | ||||
|  | ||||
| @ -9,11 +9,14 @@ import Tools from "../../Tools"; | ||||
| import { getHost, getToken } from "../../on"; | ||||
| import { regLeftClickCallback, regRightClickCallback, regMoveCallback } from "../../Global/ClickCallback"; | ||||
| import { regLeftClickCallback as regLeftClickCallback2, regRightClickCallback as regRightClickCallback2, regMoveCallback as regMoveCallback2 } from "../../Global/SplitScreen/ClickCallback"; | ||||
| import { regLeftClickCallback as regLeftClickCallback3, regRightClickCallback as regRightClickCallback3, regMoveCallback as regMoveCallback3 } from "../../Global/MultiViewportMode/ClickCallback"; | ||||
| import { setSplitDirection, syncSplitData, getSdk } from "../../Global/SplitScreen"; | ||||
| import { syncData } from '../../Global/MultiViewportMode' | ||||
| import { syncData, getSdk as get2DSdk } from '../../Global/MultiViewportMode' | ||||
| import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../Global/global' | ||||
|  | ||||
| class Base extends Tools { | ||||
|   #_showView | ||||
|   #_isShowView | ||||
|   constructor(sdk, options = {}) { | ||||
|     super(sdk, options); | ||||
|     if (!sdk || !sdk.viewer) { | ||||
| @ -29,6 +32,7 @@ class Base extends Tools { | ||||
|     this.rightClickCallBack = null | ||||
|     this.picking = true | ||||
|     this.options.host = this.options.host || getHost() | ||||
|     // this.#_showView = this.options.showView || 0 | ||||
|     this.setDefaultValue() | ||||
|  | ||||
|     // this.sdk.addIncetance(this.options.id, this) | ||||
| @ -55,6 +59,60 @@ class Base extends Tools { | ||||
|   //   setSplitDirection(this._splitDirection, this.options.id) | ||||
|   // } | ||||
|  | ||||
|   get showView() { | ||||
|     return this.#_showView | ||||
|   } | ||||
|  | ||||
|   set showView(v) { | ||||
|  | ||||
|  | ||||
|     let sdk2D = get2DSdk().sdkD | ||||
|     if (!sdk2D) { | ||||
|       this.#_showView = v | ||||
|       if (this.entity) { | ||||
|         this.entity._showView = v | ||||
|       } | ||||
|       return | ||||
|     } | ||||
|     if (this.sdk === sdk2D) { | ||||
|       this.#_showView = 0 | ||||
|       return | ||||
|     } | ||||
|     if (!this.#_showView && !this.show) { | ||||
|       return | ||||
|     } | ||||
|     if (this.sdk === sdk2D) { | ||||
|       this.#_showView = 0 | ||||
|       return | ||||
|     } | ||||
|     if (v != 2 && v != 3) { | ||||
|       this.#_showView = 0 | ||||
|     } | ||||
|     else { | ||||
|       this.#_showView = v | ||||
|     } | ||||
|  | ||||
|     this.isShowView = true | ||||
|  | ||||
|     // if(!this.show) { | ||||
|     //   return | ||||
|     // } | ||||
|  | ||||
|     if (!this.#_showView) { | ||||
|       this.show = true | ||||
|     } | ||||
|     else { | ||||
|       if (v == 2) { | ||||
|         this.show = false | ||||
|       } | ||||
|       else { | ||||
|         this.show = true | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|  | ||||
|  | ||||
|  | ||||
|   get name() { | ||||
|     return this.options.name | ||||
|   } | ||||
| @ -72,19 +130,60 @@ class Base extends Tools { | ||||
|  | ||||
|   set show(v) { | ||||
|     if (typeof v === "boolean") { | ||||
|       this.options.show = v | ||||
|       if (this.originalOptions) { | ||||
|         this.originalOptions.show = v | ||||
|       let sdkD = get2DSdk().sdkD | ||||
|       if (!this.isShowView || !sdkD) { | ||||
|         this.options.show = v | ||||
|         if (this.originalOptions) { | ||||
|           this.originalOptions.show = v | ||||
|         } | ||||
|       } | ||||
|       this.entity && (this.entity.show = v) | ||||
|       this.entity && (this.entity._showView = this.showView) | ||||
|       if (this.type == 'layer') { | ||||
|         if (this.entity) { | ||||
|           this.entity._objectState = this.options.show | ||||
|         } | ||||
|       } | ||||
|       if (!this.showView || this.showView == 3 || !sdkD) { | ||||
|         this.entity && (this.entity.show = this.options.show) | ||||
|         if (this.options.label && this.options.label.show && this.label) { | ||||
|           this.label.show = this.options.show | ||||
|         } | ||||
|       } | ||||
|       else { | ||||
|         this.entity && (this.entity.show = false) | ||||
|         if (this.options.label && this.options.label.show && this.label) { | ||||
|           this.label.show = false | ||||
|         } | ||||
|       } | ||||
|  | ||||
|       if (this._DialogObject && this._DialogObject.showBtn) { | ||||
|         this._DialogObject.showBtn.checked = v | ||||
|       } | ||||
|       if (this.options.label && this.options.label.show && this.label) { | ||||
|         this.label.show = v | ||||
|         this._DialogObject.showBtn.checked = this.options.show | ||||
|       } | ||||
|  | ||||
|  | ||||
|       syncData(this.sdk, this.options.id) | ||||
|       syncSplitData(this.sdk, this.options.id) | ||||
|       this.isShowView = false | ||||
|  | ||||
|       if (this.type == 'layer' && sdkD) { | ||||
|         let layer2d = sdkD.viewer.imageryLayers._layers[this.layerIndex] | ||||
|         let layer3d = this.entity | ||||
|  | ||||
|         if (!layer2d) { | ||||
|           return | ||||
|         } | ||||
|         if (layer3d._objectState) { | ||||
|           if (!layer3d._showView || layer3d._showView == 2) { | ||||
|             layer2d.show = true | ||||
|           } | ||||
|           if (layer3d._showView == 3) { | ||||
|             layer2d.show = false | ||||
|           } | ||||
|         } | ||||
|         else { | ||||
|           layer2d.show = this.options.show | ||||
|         } | ||||
|       } | ||||
|     } else { | ||||
|       console.error("参数必须为boolean") | ||||
|     } | ||||
| @ -192,7 +291,7 @@ class Base extends Tools { | ||||
|       let destination = Cesium.Cartesian3.fromDegrees(lng, lat, alt) | ||||
|  | ||||
|       let position = { lng: 0, lat: 0 } | ||||
|       if (this.options.position) { | ||||
|       if (this.options.position && Object.prototype.toString.call(this.options.position) === '[object Object]') { | ||||
|         position = { ...this.options.position } | ||||
|       } | ||||
|       else if (this.options.positions) { | ||||
| @ -263,12 +362,17 @@ class Base extends Tools { | ||||
|       console.error('val:', val, '不是一个function') | ||||
|     } else { | ||||
|       let sdkD = getSdk().sdkD | ||||
|       if(sdkD && this.sdk === sdkD) { | ||||
|       let sdk2D = get2DSdk().sdkD | ||||
|       if (sdkD && this.sdk === sdkD) { | ||||
|         if (this.clickCallBack == null && this.options && this.options.id) { | ||||
|           regLeftClickCallback2(this.options.id, this.leftClickCB, this) | ||||
|         } | ||||
|       } | ||||
|       else { | ||||
|       else if (sdk2D && this.sdk === sdk2D) { | ||||
|         if (this.clickCallBack == null && this.options && this.options.id) { | ||||
|           regLeftClickCallback3(this.options.id, this.leftClickCB, this) | ||||
|         } | ||||
|       } else { | ||||
|         if (this.clickCallBack == null && this.options && this.options.id) { | ||||
|           regLeftClickCallback(this.options.id, this.leftClickCB, this) | ||||
|         } | ||||
| @ -286,12 +390,17 @@ class Base extends Tools { | ||||
|       console.error('val:', val, '不是一个function') | ||||
|     } else { | ||||
|       let sdkD = getSdk().sdkD | ||||
|       if(sdkD && this.sdk === sdkD) { | ||||
|       let sdk2D = get2DSdk().sdkD | ||||
|       if (sdkD && this.sdk === sdkD) { | ||||
|         if (this.rightClickCallBack == null && this.entity && this.entity.id) { | ||||
|           regRightClickCallback2(this.entity.id, this.rightClickCB, this) | ||||
|         } | ||||
|       } | ||||
|       else { | ||||
|       else if (sdk2D && this.sdk === sdk2D) { | ||||
|         if (this.clickCallBack == null && this.options && this.options.id) { | ||||
|           regRightClickCallback3(this.options.id, this.leftClickCB, this) | ||||
|         } | ||||
|       } else { | ||||
|         if (this.rightClickCallBack == null && this.entity && this.entity.id) { | ||||
|           regRightClickCallback(this.entity.id, this.rightClickCB, this) | ||||
|         } | ||||
| @ -309,12 +418,17 @@ class Base extends Tools { | ||||
|       console.error('val:', val, '不是一个function') | ||||
|     } else { | ||||
|       let sdkD = getSdk().sdkD | ||||
|       if(sdkD && this.sdk === sdkD) { | ||||
|       let sdk2D = get2DSdk().sdkD | ||||
|       if (sdkD && this.sdk === sdkD) { | ||||
|         if (this.mouseMoveCallBack == null && this.entity && this.entity.id) { | ||||
|           regMoveCallback2(this.entity.id, this.mouseMoveCB, this) | ||||
|         } | ||||
|       } | ||||
|       else { | ||||
|       else if (sdk2D && this.sdk === sdk2D) { | ||||
|         if (this.clickCallBack == null && this.options && this.options.id) { | ||||
|           regMoveCallback3(this.options.id, this.leftClickCB, this) | ||||
|         } | ||||
|       } else { | ||||
|         if (this.mouseMoveCallBack == null && this.entity && this.entity.id) { | ||||
|           regMoveCallback(this.entity.id, this.mouseMoveCB, this) | ||||
|         } | ||||
| @ -338,7 +452,7 @@ class Base extends Tools { | ||||
|  | ||||
|       let position = { lng: 0, lat: 0 } | ||||
|       let relativePosition = { ...cameraPosition84 } | ||||
|       if (this.options.position) { | ||||
|       if (this.options.position && Object.prototype.toString.call(this.options.position) === '[object Object]') { | ||||
|         position = { ...this.options.position } | ||||
|       } | ||||
|       else if (this.options.positions) { | ||||
|  | ||||
| @ -45,8 +45,14 @@ class EventBinding { | ||||
|                     let value = e.target.value | ||||
|                     value = Number(value) | ||||
|                     if (e.data != '.' && (e.data != '-' || e.target.value)) { | ||||
|                       if (((!e.target.max) && (!e.target.min)) || ((value <= Number(e.target.max)) && value >= Number(e.target.min))) { | ||||
|                         that[m.value] = value | ||||
|                       if ((e.target.max) && value > Number(e.target.max)) { | ||||
|                         value = Number(e.target.max) | ||||
|                       } | ||||
|                       if ((e.target.min) && value < Number(e.target.min)) { | ||||
|                         value = Number(e.target.min) | ||||
|                       } | ||||
|                       if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) { | ||||
|                         value = Number(e.target.dataset.min) | ||||
|                       } | ||||
|                     } | ||||
|                   } | ||||
|  | ||||
| @ -2,13 +2,10 @@ import BaseDialog from '../../../BaseDialog'; | ||||
|  | ||||
| class Dialog extends BaseDialog { | ||||
|   constructor(sdk, info, options, only) { | ||||
|     super(sdk.viewer._container, options); | ||||
|     super(sdk.viewer._container, options, only); | ||||
|     this.sdk = sdk | ||||
|     this.viewer = sdk.viewer | ||||
|     this.info = info | ||||
|     if (only) { | ||||
|       this.closeAll() | ||||
|     } | ||||
|     this._init() | ||||
|   } | ||||
|  | ||||
|  | ||||
| @ -1,76 +1,86 @@ | ||||
| class cy_tabs { | ||||
|     constructor(id, clickTabCallBack, sdk) { | ||||
|         let elm = document.getElementById(id); | ||||
|         let pane = elm.getElementsByTagName('DIV-cy-tab-pane') | ||||
|   constructor(boxElm, clickTabCallBack, sdk) { | ||||
|     let elm | ||||
|     if(typeof boxElm === 'string') { | ||||
|       elm = document.getElementById(boxElm); | ||||
|     } | ||||
|     else { | ||||
|       elm = boxElm | ||||
|     } | ||||
|     // let elm = document.getElementById(id); | ||||
|     let pane = elm.getElementsByTagName('DIV-cy-tab-pane') | ||||
|  | ||||
|         let tabTop = `<div class="DIV-cy-tab-top">` | ||||
|         let tabContent = `<div class="DIV-cy-tab-content">` | ||||
|         let tabindex = 0 | ||||
|         for (let i = 0; i < pane.length; i++) { | ||||
|             let flag = false | ||||
|             if (sdk && sdk.tabHide && Array.isArray(sdk.tabHide)) { | ||||
|                 for (let m = 0; m < sdk.tabHide.length; m++) { | ||||
|                     if (pane[i].getAttribute('label') === sdk.tabHide[m]) { | ||||
|                         flag = true | ||||
|                         break | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|             if (flag) { | ||||
|                 continue | ||||
|             } | ||||
|             let style = 'display: none;' | ||||
|             let active = '' | ||||
|             if (tabindex == 0) { | ||||
|                 style = '' | ||||
|                 active = 'is-active' | ||||
|             } | ||||
|             tabTop = tabTop + ` | ||||
|     let tabTop = `<div class="DIV-cy-tab-top">` | ||||
|     let tabContent = `<div class="DIV-cy-tab-content">` | ||||
|     let tabindex = 0 | ||||
|     for (let i = 0; i < pane.length; i++) { | ||||
|       let flag = false | ||||
|       if (sdk && sdk.tabHide && Array.isArray(sdk.tabHide)) { | ||||
|         for (let m = 0; m < sdk.tabHide.length; m++) { | ||||
|           if (pane[i].getAttribute('label') === sdk.tabHide[m]) { | ||||
|             flag = true | ||||
|             break | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|       if (flag) { | ||||
|         continue | ||||
|       } | ||||
|       let style = 'display: none;' | ||||
|       let active = '' | ||||
|       if (tabindex == 0) { | ||||
|         style = '' | ||||
|         active = 'is-active' | ||||
|       } | ||||
|       tabTop = tabTop + ` | ||||
|             <div class="DIV-cy-tab-pane-title"> | ||||
|                 <div class="DIV-cy-tab-pane-title-p `+ active + `" tabindex="` + tabindex + `"><span>` + pane[i].getAttribute('label') + `</span></div> | ||||
|             </div> | ||||
|             ` | ||||
|             tabContent = tabContent + `<div class="DIV-cy-tab-content-pane ${pane[i].className}" style="` + style + `">` + pane[i].innerHTML + `</div>` | ||||
|             tabindex++ | ||||
|       tabContent = tabContent + `<div class="DIV-cy-tab-content-pane ${pane[i].className}" style="` + style + `">` + pane[i].innerHTML + `</div>` | ||||
|       tabindex++ | ||||
|     } | ||||
|     tabTop = tabTop + `</div>` | ||||
|     tabContent = tabContent + `</div>` | ||||
|  | ||||
|     let BoxElm = document.createElement('div'); | ||||
|     if(typeof boxElm === 'string') { | ||||
|       BoxElm.setAttribute('id', boxElm) | ||||
|     } | ||||
|     BoxElm.setAttribute('class', 'DIV-cy-tabs') | ||||
|     BoxElm.innerHTML = tabTop + tabContent | ||||
|     elm.parentNode.insertBefore(BoxElm, elm); | ||||
|     elm.parentNode.removeChild(elm); | ||||
|  | ||||
|     // 点击事件 | ||||
|     let tabs = BoxElm.getElementsByClassName('DIV-cy-tab-pane-title-p') | ||||
|     for (let i = 0; i < tabs.length; i++) { | ||||
|       tabs[i].addEventListener('click', (e) => { | ||||
|         let tabindex = e.target.getAttribute('tabindex') | ||||
|         let contentElm = BoxElm.getElementsByClassName('DIV-cy-tab-content-pane') | ||||
|         clickTabCallBack && clickTabCallBack(tabindex) | ||||
|         for (let i = 0; i < contentElm.length; i++) { | ||||
|           if (i === parseInt(tabindex)) { | ||||
|             contentElm[i].style.display = '' | ||||
|             tabs[i].className = 'DIV-cy-tab-pane-title-p is-active' | ||||
|           } | ||||
|           else { | ||||
|             contentElm[i].style.display = 'none' | ||||
|             tabs[i].className = 'DIV-cy-tab-pane-title-p' | ||||
|           } | ||||
|         } | ||||
|         tabTop = tabTop + `</div>` | ||||
|         tabContent = tabContent + `</div>` | ||||
|  | ||||
|         let BoxElm = document.createElement('div'); | ||||
|         BoxElm.setAttribute('id', id) | ||||
|         BoxElm.setAttribute('class', 'DIV-cy-tabs') | ||||
|         BoxElm.innerHTML = tabTop + tabContent | ||||
|         elm.parentNode.insertBefore(BoxElm, elm); | ||||
|         elm.parentNode.removeChild(elm); | ||||
|  | ||||
|         // 点击事件 | ||||
|         let tabs = BoxElm.getElementsByClassName('DIV-cy-tab-pane-title-p') | ||||
|         for (let i = 0; i < tabs.length; i++) { | ||||
|             tabs[i].addEventListener('click', (e) => { | ||||
|                 let tabindex = e.target.getAttribute('tabindex') | ||||
|                 let contentElm = BoxElm.getElementsByClassName('DIV-cy-tab-content-pane') | ||||
|                 for (let i = 0; i < contentElm.length; i++) { | ||||
|                     if (i === parseInt(tabindex)) { | ||||
|                         contentElm[i].style.display = '' | ||||
|                         tabs[i].className = 'DIV-cy-tab-pane-title-p is-active' | ||||
|                     } | ||||
|                     else { | ||||
|                         contentElm[i].style.display = 'none' | ||||
|                         tabs[i].className = 'DIV-cy-tab-pane-title-p' | ||||
|                     } | ||||
|                 } | ||||
|                 contentElm[parseInt(tabindex)].style.display = '' | ||||
|             }) | ||||
|         } | ||||
|  | ||||
|         this.clickTabCallBack = clickTabCallBack | ||||
|         contentElm[parseInt(tabindex)].style.display = '' | ||||
|       }) | ||||
|     } | ||||
|  | ||||
|     clickTabCallBack() { | ||||
|         if (this.clickTabCallBack) { | ||||
|             this.clickTabCallBack() | ||||
|         } | ||||
|     this.clickTabCallBack = clickTabCallBack | ||||
|   } | ||||
|  | ||||
|   clickTabCallBack() { | ||||
|     if (this.clickTabCallBack) { | ||||
|       this.clickTabCallBack() | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
| export default cy_tabs | ||||
| export default cy_tabs | ||||
|  | ||||
| @ -100,7 +100,7 @@ function attributeElm(that) { | ||||
|                   let tr = ` | ||||
|                     <div class="tr"> | ||||
|                       <div class="td"> | ||||
|                         <input type="checkbox" value="${'ID' in data.data.list[i] ? data.data.list[i].ID : data.data.list[i].id}"> | ||||
|                         <input type="checkbox" value="${data.data.list[i].deviceId}"> | ||||
|                         <span>绑定</span> | ||||
|                       </div> | ||||
|                       <div class="td">${data.data.list[i].cameraName}</div> | ||||
| @ -126,11 +126,8 @@ function attributeElm(that) { | ||||
|                     } | ||||
|                     else { | ||||
|                       let newArray = that.attributeCamera.filter((item) => { | ||||
|                         if ('ID' in data.data.list[i]) { | ||||
|                           return item.ID !== data.data.list[i].ID | ||||
|                         } | ||||
|                         else { | ||||
|                           return item.id !== data.data.list[i].id | ||||
|                         if ('deviceId' in data.data.list[i]) { | ||||
|                           return item.deviceId !== data.data.list[i].deviceId | ||||
|                         } | ||||
|                       }) | ||||
|                       that.attributeCamera = newArray | ||||
| @ -139,7 +136,7 @@ function attributeElm(that) { | ||||
|                   tableContent.appendChild(trElm) | ||||
|  | ||||
|                   for (let m = 0; m < that.attributeCamera.length; m++) { | ||||
|                     if (('ID' in data.data.list[i]) ? (that.attributeCamera[m].ID === data.data.list[i].ID) : (that.attributeCamera[m].id === data.data.list[i].id)) { | ||||
|                     if (('deviceId' in data.data.list[i]) ? (that.attributeCamera[m].deviceId === data.data.list[i].deviceId):false) { | ||||
|                       checkbox.checked = true | ||||
|                       break | ||||
|                     } | ||||
| @ -200,17 +197,9 @@ function attributeElm(that) { | ||||
|                   for (let i = that.attributeCamera.length - 1; i >= 0; i--) { | ||||
|                     let flag = false | ||||
|                     for (let m = 0; m < data.data.list.length; m++) { | ||||
|                       if ('ID' in data.data.list[m]) { | ||||
|                         if (that.attributeCamera[i].ID === data.data.list[m].ID) { | ||||
|                           flag = true | ||||
|                           break | ||||
|                         } | ||||
|                       } | ||||
|                       if ('id' in data.data.list[m]) { | ||||
|                         if (that.attributeCamera[i].id === data.data.list[m].id) { | ||||
|                           flag = true | ||||
|                           break | ||||
|                         } | ||||
|                       if (that.attributeCamera[i].deviceId === data.data.list[m].deviceId) { | ||||
|                         flag = true | ||||
|                         break | ||||
|                       } | ||||
|                     } | ||||
|                     if (!flag) { | ||||
|  | ||||
| @ -56,8 +56,8 @@ class richText { | ||||
|       MENU_CONF: { | ||||
|         uploadImage: { | ||||
|           fieldName: 'file', | ||||
|           maxFileSize: 50 * 1024 * 1024, | ||||
|           base64LimitSize: 50 * 1024 * 1024, // 50M 以下插入 base64 | ||||
|           // maxFileSize: 50 * 1024 * 1024, | ||||
|           // base64LimitSize: 50 * 1024 * 1024, // 50M 以下插入 base64 | ||||
|           server: this.uploadImageServer, | ||||
|           // // 上传之前触发 | ||||
|           // onBeforeUpload(file) { // TS 语法 | ||||
| @ -95,18 +95,18 @@ class richText { | ||||
|           //   console.log(`${file.name} 上传出错`, err, res) | ||||
|           // }, | ||||
|  | ||||
|           // // 自定义上传 | ||||
|           // async customUpload(file, insertFn) {  // TS 语法 | ||||
|           //   // async customUpload(file, insertFn) {                   // JS 语法 | ||||
|           //   // file 即选中的文件 | ||||
|           //   // 自己实现上传,并得到图片 url alt href | ||||
|           //   // 最后插入图片 | ||||
|           //   console.log(file, insertFn) | ||||
|           //   insertFn(url, file.name) | ||||
|           // } | ||||
|           // 自定义上传 | ||||
|           async customUpload(file, insertFn) {  // TS 语法 | ||||
|             // async customUpload(file, insertFn) {                   // JS 语法 | ||||
|             // file 即选中的文件 | ||||
|             // 自己实现上传,并得到图片 url alt href | ||||
|             // 最后插入图片 | ||||
|             let url = await _this.upload(file) | ||||
|             insertFn((_this.host = _this.host || getHost()) + '/' + url) | ||||
|           } | ||||
|         }, | ||||
|         uploadVideo: { | ||||
|           maxFileSize: 500 * 1024 * 1024, | ||||
|           // maxFileSize: 500 * 1024 * 1024, | ||||
|           server: this.uploadVideoServer, | ||||
|           allowedFileTypes: ['video/mp4', 'video/mp3', 'video/ogg', 'video/webm', 'video/avi'], | ||||
|           // 自定义上传 | ||||
|  | ||||
| @ -1,4 +1,4 @@ | ||||
| let list = ['icon-py', 'icon-edit', 'icon-add', 'icon-add2', 'icon-minus', 'icon-play', 'icon-pause', 'icon-updateheight', 'icon-draw', 'icon-positions', 'icon-reset', 'icon-xj', 'icon-yj', 'icon-zj', 'icon-close', 'icon-query', 'icon-route', 'icon-copy', 'icon-load', 'icon-rubric', 'icon-pen', 'icon-cross'] | ||||
| let list = ['icon-py', 'icon-edit', 'icon-add', 'icon-add2', 'icon-minus', 'icon-play', 'icon-pause', 'icon-updateheight', 'icon-draw', 'icon-positions', 'icon-reset', 'icon-xj', 'icon-yj', 'icon-zj', 'icon-close', 'icon-query', 'icon-route', 'icon-copy', 'icon-load', 'icon-rubric', 'icon-pen', 'icon-cross', 'icom-confirm'] | ||||
| function setSvg() { | ||||
|   let svgElm = document.createElement('svg'); | ||||
|   svgElm.xmlns = 'http://www.w3.org/2000/svg' | ||||
|  | ||||
| @ -1,7 +1,11 @@ | ||||
| class YJColorPicker { | ||||
|   constructor(options = {}) { | ||||
|     let _this = this | ||||
|     let pickAlphaInput | ||||
|     let RInput | ||||
|     let GInput | ||||
|     let BInput | ||||
|     let AInput | ||||
|  | ||||
|     let config = { | ||||
|       el: options.el, | ||||
|       size: "mini", | ||||
| @ -12,18 +16,22 @@ class YJColorPicker { | ||||
|       hasClear: true, | ||||
|       openPickerAni: 'opacity', | ||||
|       defaultColor: options.defaultColor, | ||||
|       pickerInputChange: pickerInputChange, | ||||
|       startMainCallback: (t) => { | ||||
|         customizeStyle() | ||||
|         _this.colorPicker && (_this.colorPicker.picker.style.opacity = 0) | ||||
|         setTimeout(() => { | ||||
|           customizeStyle() | ||||
|         }, 0); | ||||
|       } | ||||
|     } | ||||
|     this.el = options.el | ||||
|     if (options.sure) { | ||||
|       config.sure = (color) => { | ||||
|         this.colorPicker.config.defaultColor = this.colorPicker.pickerInput.value | ||||
|         // this.colorPicker.config.defaultColor = this.colorPicker.pickerInput.value | ||||
|         let c = Cesium.Color.fromCssColorString(color) | ||||
|         if (pickAlphaInput) { | ||||
|           c = c.withAlpha(pickAlphaInput.value / 100) | ||||
|           this.pickAlphaInputValue = pickAlphaInput.value | ||||
|         if (AInput) { | ||||
|           c = c.withAlpha(AInput.value) | ||||
|           this.pickAlphaInputValue = AInput.value | ||||
|         } | ||||
|         color = c.toCssHexString() | ||||
|         if (typeof options.sure == 'function') { | ||||
| @ -34,8 +42,8 @@ class YJColorPicker { | ||||
|     } | ||||
|     if (options.clear) { | ||||
|       config.clear = () => { | ||||
|         if (pickAlphaInput) { | ||||
|           pickAlphaInput.value = this.pickAlphaInputValue = 100 | ||||
|         if (AInput) { | ||||
|           AInput.value = this.pickAlphaInputValue = 1 | ||||
|         } | ||||
|         this.colorPicker.config.defaultColor = '' | ||||
|         customizeStyle() | ||||
| @ -53,7 +61,7 @@ class YJColorPicker { | ||||
|       } | ||||
|     } | ||||
|     let CesiumColor | ||||
|     if(config.defaultColor) { | ||||
|     if (config.defaultColor) { | ||||
|       CesiumColor = Cesium.Color.fromCssColorString(config.defaultColor) | ||||
|     } | ||||
|     // if (options.predefineColor) { | ||||
| @ -66,42 +74,172 @@ class YJColorPicker { | ||||
|     customizeStyle() | ||||
|  | ||||
|     function customizeStyle() { | ||||
|       if (!_this.colorPicker) { | ||||
|       if (!_this.colorPicker || !_this.colorPicker.picker) { | ||||
|         return | ||||
|       } | ||||
|       let isSubtract = false | ||||
|       let box = _this.colorPicker.box | ||||
|       let picker = _this.colorPicker.picker | ||||
|       let x = box.getBoundingClientRect().x | ||||
|       let y = box.getBoundingClientRect().y | ||||
|       let height = 0 | ||||
|  | ||||
|       // if (picker.style.display === 'none') { | ||||
|       //   picker.style.display = 'block' | ||||
|       //   height = picker.offsetHeight | ||||
|       //   console.log('picker.style.display.opacity', picker.style.display.opacity) | ||||
|       //   picker.style.display = 'none' | ||||
|       // } | ||||
|       // console.log('===========================================') | ||||
|       // console.log((y + box.offsetHeight + 4),  height, window.innerHeight) | ||||
|       // if ((y + box.offsetHeight + 4) + height > window.innerHeight) { | ||||
|       //   console.log(y, height) | ||||
|       //   picker.style.top = y - height + 'px' | ||||
|       // } | ||||
|       // else { | ||||
|       //   picker.style.top = (y + box.offsetHeight + 4) + 'px' | ||||
|       // } | ||||
|  | ||||
|       picker.style.left = x + 'px' | ||||
|       picker.style.minWidth = '325px' | ||||
|       let pickerContent = picker.getElementsByClassName('ew-color-picker-content')[0] | ||||
|       // let pickerContent = picker.getElementsByClassName('ew-color-picker-content')[0] | ||||
|       let pickAlphaSliderBar = picker.getElementsByClassName('ew-alpha-slider-bar')[0] | ||||
|       if (pickAlphaSliderBar) { | ||||
|         pickAlphaSliderBar.parentNode.style.width = '16px' | ||||
|         pickAlphaSliderBar.parentNode.removeChild(pickAlphaSliderBar) | ||||
|       } | ||||
|       // let customDivider = document.createElement('span') | ||||
|       // customDivider.className = 'custom-divider' | ||||
|       // customDivider.style.margin = '10px 0' | ||||
|       // pickerContent.parentNode.insertBefore(customDivider, pickerContent.nextSibling) | ||||
|  | ||||
|       let pickPen = document.createElement('div') | ||||
|       pickPen.className = 'icon-pen-box' | ||||
|       pickPen.innerHTML = '<svg class="icon-pen"><use xlink:href="#yj-icon-pen"></use></svg>' | ||||
|  | ||||
|       /** 为完成、暂时隐藏 */////// | ||||
|       pickPen.style.display = 'none' | ||||
|       pickPen.style.cursor = 'unset' | ||||
|  | ||||
|  | ||||
|  | ||||
|       let pickerInput = _this.colorPicker.pickerInput | ||||
|       pickerInput.parentNode.insertBefore(pickPen, pickerInput) | ||||
|       pickerInput.style.width = '188px' | ||||
|       pickerInput.style.display = 'none' | ||||
|  | ||||
|       let colorInputBox = document.createElement('div') | ||||
|       let row1Elm = document.createElement('div') | ||||
|       row1Elm.className = 'row' | ||||
|       row1Elm.style.margin = '6px 0 0 0' | ||||
|       row1Elm.innerHTML = ` | ||||
|           <div class="col">R</div> | ||||
|           <div class="col">G</div> | ||||
|           <div class="col">B</div> | ||||
|           <div class="col" style="flex: 0 0 92px;"></div> | ||||
|       ` | ||||
|       let row2Elm = document.createElement('div') | ||||
|       row2Elm.className = 'row' | ||||
|       row2Elm.innerHTML = ` | ||||
|           <div class="col"> | ||||
|             <input type="number" step="1" min="0" max="255"> | ||||
|           </div> | ||||
|           <div class="col"> | ||||
|             <input type="number" step="1" min="0" max="255"> | ||||
|           </div> | ||||
|           <div class="col"> | ||||
|             <input type="number" step="1" min="0" max="255"> | ||||
|           </div> | ||||
|       ` | ||||
|       colorInputBox.appendChild(row1Elm) | ||||
|       colorInputBox.appendChild(row2Elm) | ||||
|       let Inputs = row2Elm.getElementsByTagName('input') | ||||
|       Inputs[0].style.width = '72px' | ||||
|       Inputs[1].style.width = '72px' | ||||
|       Inputs[2].style.width = '72px' | ||||
|       RInput = Inputs[0] | ||||
|       GInput = Inputs[1] | ||||
|       BInput = Inputs[2] | ||||
|  | ||||
|       let dropbtns = picker.getElementsByClassName('ew-color-dropbtns')[0] | ||||
|       picker.insertBefore(colorInputBox, dropbtns) | ||||
|  | ||||
|       RInput.addEventListener('blur', (e) => { | ||||
|         let value = e.target.value | ||||
|         if (e.target.value || (e.target.dataset.null !== 'undefined' && e.target.dataset.null !== '' && !Boolean(e.target.dataset.null))) { | ||||
|           value = Number(value) | ||||
|           if ((e.target.max) && value > Number(e.target.max)) { | ||||
|             value = Number(e.target.max) | ||||
|           } | ||||
|           if ((e.target.min) && value < Number(e.target.min)) { | ||||
|             value = Number(e.target.min) | ||||
|           } | ||||
|           if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) { | ||||
|             value = Number(e.target.dataset.min) | ||||
|           } | ||||
|           RInput.value = parseInt(value) | ||||
|           _this.colorPicker.hsba = colorRgbaToHsba(`rgb(${RInput.value}, ${GInput.value}, ${BInput.value})`) | ||||
|           _this.colorPicker.changeColor(_this.colorPicker, _this.colorPicker.pickerPanel.offsetWidth,_this.colorPicker.pickerPanel.offsetHeight) | ||||
|         } | ||||
|       }) | ||||
|       GInput.addEventListener('blur', (e) => { | ||||
|         let value = e.target.value | ||||
|         if (e.target.value || (e.target.dataset.null !== 'undefined' && e.target.dataset.null !== '' && !Boolean(e.target.dataset.null))) { | ||||
|           value = Number(value) | ||||
|           if ((e.target.max) && value > Number(e.target.max)) { | ||||
|             value = Number(e.target.max) | ||||
|           } | ||||
|           if ((e.target.min) && value < Number(e.target.min)) { | ||||
|             value = Number(e.target.min) | ||||
|           } | ||||
|           if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) { | ||||
|             value = Number(e.target.dataset.min) | ||||
|           } | ||||
|           GInput.value = parseInt(value) | ||||
|           _this.colorPicker.hsba = colorRgbaToHsba(`rgb(${RInput.value}, ${GInput.value}, ${BInput.value})`) | ||||
|           _this.colorPicker.changeColor(_this.colorPicker, _this.colorPicker.pickerPanel.offsetWidth,_this.colorPicker.pickerPanel.offsetHeight) | ||||
|         } | ||||
|       }) | ||||
|       BInput.addEventListener('blur', (e) => { | ||||
|         let value = e.target.value | ||||
|         if (e.target.value || (e.target.dataset.null !== 'undefined' && e.target.dataset.null !== '' && !Boolean(e.target.dataset.null))) { | ||||
|           value = Number(value) | ||||
|           if ((e.target.max) && value > Number(e.target.max)) { | ||||
|             value = Number(e.target.max) | ||||
|           } | ||||
|           if ((e.target.min) && value < Number(e.target.min)) { | ||||
|             value = Number(e.target.min) | ||||
|           } | ||||
|           if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) { | ||||
|             value = Number(e.target.dataset.min) | ||||
|           } | ||||
|           BInput.value = parseInt(value) | ||||
|           _this.colorPicker.hsba = colorRgbaToHsba(`rgb(${RInput.value}, ${GInput.value}, ${BInput.value})`) | ||||
|           _this.colorPicker.changeColor(_this.colorPicker, _this.colorPicker.pickerPanel.offsetWidth,_this.colorPicker.pickerPanel.offsetHeight) | ||||
|         } | ||||
|       }) | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|       if (options.alpha) { | ||||
|         Inputs[0].style.width = '52px' | ||||
|         Inputs[1].style.width = '52px' | ||||
|         Inputs[2].style.width = '52px' | ||||
|         let pickAlpha = document.createElement('div') | ||||
|         pickAlpha.className = 'input-number input-number-unit-1 color-alpha' | ||||
|         pickAlpha.className = 'input-number input-number-unit color-alpha' | ||||
|         pickAlpha.innerHTML = ` | ||||
|         <input class="input" type="number" title="" step="0.01" min="0" max="100"> | ||||
|         <span class="unit">%</span> | ||||
|         <input class="input" type="number" title="" step="0.01" min="0" max="1"> | ||||
|         <span class="arrow"></span>` | ||||
|         pickerInput.parentNode.insertBefore(pickAlpha, pickerInput.nextSibling) | ||||
|         pickerInput.style.width = '106px' | ||||
|         pickAlpha.style.width = '80px' | ||||
|         pickAlphaInput = pickAlpha.getElementsByClassName('input')[0] | ||||
|         pickAlphaInput.addEventListener('blur', (e) => { | ||||
|         pickAlpha.style.width = '66px' | ||||
|         pickAlpha.style.margin = '0 6px 0 0' | ||||
|         AInput = pickAlpha.getElementsByClassName('input')[0] | ||||
|         row1Elm.innerHTML = ` | ||||
|           <div class="col">R</div> | ||||
|           <div class="col">G</div> | ||||
|           <div class="col">B</div> | ||||
|           <div class="col">A</div> | ||||
|           <div class="col" style="flex: 0 0 106px;"></div> | ||||
|         ` | ||||
|         row2Elm.appendChild(pickAlpha) | ||||
|         AInput.addEventListener('blur', (e) => { | ||||
|           let value = e.target.value | ||||
|           if (e.target.value || (e.target.dataset.null !== 'undefined' && e.target.dataset.null !== '' && !Boolean(e.target.dataset.null))) { | ||||
|             value = Number(value) | ||||
| @ -114,23 +252,26 @@ class YJColorPicker { | ||||
|             if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) { | ||||
|               value = Number(e.target.dataset.min) | ||||
|             } | ||||
|             pickAlphaInput.value = Number(value.toFixed(2)) | ||||
|             AInput.value = parseInt(value * 100) / 100 | ||||
|           } | ||||
|         }) | ||||
|         if (_this.pickAlphaInputValue || _this.pickAlphaInputValue === 0 || _this.pickAlphaInputValue === '0') { | ||||
|           pickAlphaInput.value = Number(Number(_this.pickAlphaInputValue).toFixed(2)) | ||||
|           AInput.value = parseInt(_this.pickAlphaInputValue * 100) / 100 | ||||
|         } | ||||
|         else { | ||||
|           pickAlphaInput.value = CesiumColor ? Number((CesiumColor.alpha * 100).toFixed(2)) : 100 | ||||
|           AInput.value = CesiumColor ? parseInt(Number(CesiumColor.alpha.toFixed(2)) * 100) / 100 : 1 | ||||
|         } | ||||
|         _this.pickAlphaInputValue = pickAlphaInput.value | ||||
|         box.style.background = Cesium.Color.fromCssColorString(_this.colorPicker.config.defaultColor || '#ffffff').withAlpha(pickAlphaInput.value / 100).toCssColorString() | ||||
|         _this.pickAlphaInputValue = AInput.value | ||||
|         box.style.background = Cesium.Color.fromCssColorString(_this.colorPicker.config.defaultColor || '#ffffff').withAlpha(AInput.value).toCssColorString() | ||||
|       } | ||||
|       else { | ||||
|         CesiumColor = CesiumColor ? CesiumColor.withAlpha(1) : '' | ||||
|         box.style.background = Cesium.Color.fromCssColorString(_this.colorPicker.config.defaultColor || '#ffffff').toCssColorString() | ||||
|       } | ||||
|  | ||||
|       let btngroup = picker.getElementsByClassName('ew-color-dropbtngroup')[0] | ||||
|       row2Elm.appendChild(btngroup) | ||||
|  | ||||
|       let defineColorContainer = picker.getElementsByClassName('ew-pre-define-color-container')[0] | ||||
|       if (defineColorContainer) { | ||||
|         let colorList = localStorage.getItem('custom-color') | ||||
| @ -157,8 +298,10 @@ class YJColorPicker { | ||||
|         addColorBtn.className = 'yj-pre-collect-color add' | ||||
|  | ||||
|         let subtractColorBtn = document.createElement('div') | ||||
|         subtractColorBtn.innerHTML = '<svg class="icon-minus"><use xlink:href="#yj-icon-minus"></use></svg>' | ||||
|         subtractColorBtn.innerHTML = '<svg class="icon-minus" style="display: unset;"><use xlink:href="#yj-icon-minus"></use></svg><svg class="icon-confirm" style="display: none;"><use xlink:href="#yj-icom-confirm"></use></svg>' | ||||
|         subtractColorBtn.className = 'yj-pre-collect-color subtract' | ||||
|         let minusIcon = subtractColorBtn.getElementsByClassName('icon-minus')[0] | ||||
|         let confirmIcon = subtractColorBtn.getElementsByClassName('icon-confirm')[0] | ||||
|         collectColorContainer.appendChild(addColorBtn) | ||||
|         collectColorContainer.appendChild(subtractColorBtn) | ||||
|  | ||||
| @ -217,8 +360,8 @@ class YJColorPicker { | ||||
|  | ||||
|           let color = colorRgbaToHex(colorHsbaToRgba(_this.colorPicker.hsba)) | ||||
|           let c = Cesium.Color.fromCssColorString(color || '#ffffff') | ||||
|           if (pickAlphaInput) { | ||||
|             c = c.withAlpha(pickAlphaInput.value / 100) | ||||
|           if (AInput) { | ||||
|             c = c.withAlpha(AInput.value) | ||||
|           } | ||||
|           let colorString = c.toCssHexString() | ||||
|           colorItemElm.style.backgroundColor = colorString | ||||
| @ -252,23 +395,43 @@ class YJColorPicker { | ||||
|         subtractColorBtn.addEventListener('click', () => { | ||||
|           isSubtract = !isSubtract | ||||
|           if (isSubtract) { | ||||
|             minusIcon.style.display = 'none' | ||||
|             confirmIcon.style.display = 'unset' | ||||
|             for (let i = 0; i < subtractElmList.length; i++) { | ||||
|               subtractElmList[i].style.display = 'block' | ||||
|             } | ||||
|           } | ||||
|           else { | ||||
|             minusIcon.style.display = 'unset' | ||||
|             confirmIcon.style.display = 'none' | ||||
|             for (let i = 0; i < subtractElmList.length; i++) { | ||||
|               subtractElmList[i].style.display = 'none' | ||||
|             } | ||||
|           } | ||||
|         }) | ||||
|       } | ||||
|  | ||||
|       height = picker.offsetHeight | ||||
|       if (picker.style.display === 'none') { | ||||
|         picker.style.display = 'block' | ||||
|         height = picker.offsetHeight | ||||
|         picker.style.display = 'none' | ||||
|       } | ||||
|       if ((y + box.offsetHeight + 4) + height > window.innerHeight) { | ||||
|         picker.style.top = y - height + 'px' | ||||
|       } | ||||
|       else { | ||||
|         picker.style.top = (y + box.offsetHeight + 4) + 'px' | ||||
|       } | ||||
|       _this.colorPicker.pancelTop = parseFloat(picker.style.top) - 2 | ||||
|  | ||||
|       pickerInputChange(Cesium.Color.fromCssColorString(_this.colorPicker.config.defaultColor || '#ffffff').toCssHexString()) | ||||
|     } | ||||
|  | ||||
|     function clickDefineColor(color) { | ||||
|       if (pickAlphaInput) { | ||||
|       if (AInput) { | ||||
|         let c = Cesium.Color.fromCssColorString(color) | ||||
|         pickAlphaInput.value = Number((c.alpha * 100).toFixed(2)) | ||||
|         AInput.value = parseInt(Number(c.alpha.toFixed(2)) * 100) / 100 | ||||
|       } | ||||
|     } | ||||
|  | ||||
| @ -321,6 +484,84 @@ class YJColorPicker { | ||||
|           "#" + n | ||||
|       } | ||||
|     } | ||||
|  | ||||
|     function colorHexToRgba(hex, alpha) { | ||||
|       let a = alpha || 1, | ||||
|         hColor = hex.toLowerCase(), | ||||
|         hLen = hex.length, | ||||
|         rgbaColor = []; | ||||
|       hColor = Cesium.Color.fromCssColorString(hColor).toCssHexString().substring(0, 7) | ||||
|       const colorRegExp = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/; | ||||
|       if (hex && colorRegExp.test(hColor)) { | ||||
|         //the hex length may be 4 or 7,contained the symbol of # | ||||
|         if (hLen === 4) { | ||||
|           let hSixColor = '#'; | ||||
|  | ||||
|           for (let i = 1; i < hLen; i++) { | ||||
|             let sColor = hColor.slice(i, i + 1); | ||||
|             hSixColor += sColor.concat(sColor); | ||||
|           } | ||||
|  | ||||
|           hColor = hSixColor; | ||||
|         } | ||||
|  | ||||
|         for (let j = 1, len = hColor.length; j < len; j += 2) { | ||||
|           rgbaColor.push(parseInt('0X' + hColor.slice(j, j + 2), 16)); | ||||
|         } | ||||
|  | ||||
|         // return "rgba(" + rgbaColor.join(",") + ',' + a + ")"; | ||||
|         return rgbaColor; | ||||
|       } else { | ||||
|         return; | ||||
|       } | ||||
|     } | ||||
|  | ||||
|     function colorRgbaToHsba(e) { | ||||
|       var t = e.slice(e.indexOf("(") + 1, e.lastIndexOf(")")).split(",") | ||||
|         , r = t.length < 4 ? 1 : Number(t[3]) | ||||
|         , n = Number(t[0]) / 255 | ||||
|         , o = Number(t[1]) / 255 | ||||
|         , i = Number(t[2]) / 255 | ||||
|         , a = void 0 | ||||
|         , s = void 0 | ||||
|         , l = void 0 | ||||
|         , c = Math.min(n, o, i) | ||||
|         , d = l = Math.max(n, o, i) | ||||
|         , u = d - c; | ||||
|       if (d === c) | ||||
|           a = 0; | ||||
|       else { | ||||
|           switch (d) { | ||||
|           case n: | ||||
|               a = (o - i) / u + (o < i ? 6 : 0); | ||||
|               break; | ||||
|           case o: | ||||
|               a = 2 + (i - n) / u; | ||||
|               break; | ||||
|           case i: | ||||
|               a = 4 + (n - o) / u | ||||
|           } | ||||
|           a = Math.round(60 * a) | ||||
|       } | ||||
|       s = 0 === d ? 0 : 1 - c / d; | ||||
|       return s = Math.round(100 * s), | ||||
|       l = Math.round(100 * l), | ||||
|       { | ||||
|           h: a, | ||||
|           s: s, | ||||
|           b: l, | ||||
|           a: r | ||||
|       } | ||||
|   } | ||||
|  | ||||
|     function pickerInputChange(v) { | ||||
|       if (_this.colorPicker && _this.colorPicker.pickerInput) { | ||||
|         let rgbaColor = colorHexToRgba(v || _this.colorPicker.pickerInput.value) | ||||
|         RInput.value = rgbaColor[0] | ||||
|         GInput.value = rgbaColor[1] | ||||
|         BInput.value = rgbaColor[2] | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
|  | ||||
| @ -50,7 +50,8 @@ export default class CircleDiffuseMaterialProperty { | ||||
|       let color = this.colors[ratio[i]] | ||||
|       _sourceColor = _sourceColor + ` | ||||
|         if(dis < float(${Number(ratio[i]) / 2})) { | ||||
|           material.diffuse = 1.5 * vec4(${color.red},${color.green},${color.blue},${color.alpha}).rgb; | ||||
|           material.diffuse = vec4(0.0,0.0,0.0,0.0).rgb; | ||||
|           material.emission = 1.0 * vec4(${color.red},${color.green},${color.blue},${color.alpha}).rgb; | ||||
|         } | ||||
|         ` | ||||
|     } | ||||
| @ -110,7 +111,7 @@ export default class CircleDiffuseMaterialProperty { | ||||
|             transparency: 1, | ||||
|             count: 4, | ||||
|             gradient: 0.2, | ||||
|             frameNumber:  Cesium.getTimestamp(), | ||||
|             frameNumber: Cesium.getTimestamp(), | ||||
|           }, | ||||
|           source: this._source, | ||||
|         }, | ||||
|  | ||||
							
								
								
									
										113
									
								
								src/Obj/Materail/RoadTextureMaterialProperty.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										113
									
								
								src/Obj/Materail/RoadTextureMaterialProperty.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,113 @@ | ||||
| /* | ||||
|  * @Description: 流动线 | ||||
|  */ | ||||
| function RoadTexture() { | ||||
|   class RoadTextureMaterialProperty { | ||||
|     constructor(options) { | ||||
|       this._definitionChanged = new Cesium.Event(); | ||||
|       this._image = undefined; | ||||
|       this._repeat = undefined; | ||||
|       this._stRotation = undefined; | ||||
|       this._repeatLength = undefined; | ||||
|       this.image = options.image || ""; | ||||
|       this.repeat = options.repeat || 1.0; | ||||
|       this.stRotation = options.stRotation || 0.0; | ||||
|       // this.rotations = options.rotations || new Array(100).fill(0.0); | ||||
|     } | ||||
|  | ||||
|     get isConstant() { | ||||
|       return false; | ||||
|     } | ||||
|  | ||||
|     get definitionChanged() { | ||||
|       return this._definitionChanged; | ||||
|     } | ||||
|  | ||||
|     getType(time) { | ||||
|       return Cesium.Material.RoadTextureMaterialType; | ||||
|     } | ||||
|  | ||||
|     getValue(time, result) { | ||||
|       if (!Cesium.defined(result)) { | ||||
|         result = {}; | ||||
|       } | ||||
|       result.image = Cesium.Property.getValueOrDefault( | ||||
|         this._image, | ||||
|         time, | ||||
|         "", | ||||
|         result.image | ||||
|       ); | ||||
|       result.repeat = Cesium.Property.getValueOrDefault( | ||||
|         this._repeat, | ||||
|         time, | ||||
|         1.0, | ||||
|         result.repeat | ||||
|       ); | ||||
|       result.stRotation = Cesium.Property.getValueOrDefault( | ||||
|         this._stRotation, | ||||
|         time, | ||||
|         0.0, | ||||
|         result.stRotation | ||||
|       ); | ||||
|       console.log(result, 'result') | ||||
|       return result; | ||||
|     } | ||||
|  | ||||
|     equals(other) { | ||||
|       return ( | ||||
|         this === other || | ||||
|         (other instanceof RoadTextureMaterialProperty && | ||||
|           Cesium.Property.equals(this._image, other._image) && | ||||
|           Cesium.Property.equals(this._repeat, other._repeat) && | ||||
|           // Cesium.Property.equals(this._rotations, other._rotations) && | ||||
|           Cesium.Property.equals(this._stRotation, other._stRotation) | ||||
|         ) | ||||
|       ); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   Object.defineProperties(RoadTextureMaterialProperty.prototype, { | ||||
|     image: Cesium.createPropertyDescriptor("image"), | ||||
|     repeat: Cesium.createPropertyDescriptor("repeat"), | ||||
|     repeatLength: Cesium.createPropertyDescriptor("stRotation"), | ||||
|   }); | ||||
|  | ||||
|   Cesium.RoadTextureMaterialProperty = RoadTextureMaterialProperty; | ||||
|   Cesium.Material.RoadTextureMaterialProperty = "RoadTextureMaterialProperty"; | ||||
|   Cesium.Material.RoadTextureMaterialType = "RoadTextureMaterialType"; | ||||
|   Cesium.Material.RoadTextureMaterialSource = ` | ||||
|         uniform sampler2D image; | ||||
|         uniform float repeat; | ||||
|         czm_material czm_getMaterial(czm_materialInput materialInput) | ||||
|         { | ||||
|           czm_material material = czm_getDefaultMaterial(materialInput); | ||||
|           vec2 st = materialInput.st; | ||||
|           st.s *= repeat; | ||||
|           mat2 rot = mat2(cos(stRotation), -sin(stRotation), sin(stRotation), cos(stRotation)); | ||||
|           vec2 newSt = rot * (st - 0.5) + 0.5; | ||||
|  | ||||
|           vec4 colorImage = texture2D(image, newSt); | ||||
|           material.diffuse = colorImage.rgb; | ||||
|           return material; | ||||
|         } | ||||
|        `; | ||||
|   Cesium.Material._materialCache.addMaterial( | ||||
|     Cesium.Material.RoadTextureMaterialType, | ||||
|     { | ||||
|       fabric: { | ||||
|         type: Cesium.Material.RoadTextureMaterialType, | ||||
|         uniforms: { | ||||
|           image: '', | ||||
|           repeat: 1.0, | ||||
|           stRotation: 0.0, | ||||
|         }, | ||||
|         source: Cesium.Material.RoadTextureMaterialSource, | ||||
|       }, | ||||
|       translucent: function (material) { | ||||
|         return true; | ||||
|       }, | ||||
|     } | ||||
|   ); | ||||
| } | ||||
|  | ||||
| export { RoadTexture } | ||||
| @ -70,7 +70,7 @@ function StreamWall1() { | ||||
|       fragColor.rgb = color.rgb / 1.0;\n\ | ||||
|       fragColor = czm_gammaCorrect(fragColor);\n\ | ||||
|       material.alpha = colorImage.a * color.a;\n\ | ||||
|       material.diffuse = (colorImage.rgb+color.rgb)/2.0;\n\ | ||||
|       material.diffuse = color.rgb/20.0;\n\ | ||||
|       material.emission = fragColor.rgb;\n\ | ||||
|       return material;\n\ | ||||
|       }"; | ||||
| @ -208,6 +208,14 @@ function StreamWall2() { | ||||
|           Property.equals(this.repeat, other._repeat) && | ||||
|           Property.equals(this.repeats, other._repeats) | ||||
|       }; | ||||
|       // let code2 = 'material.diffuse = color.rgb*1.0;' | ||||
|       // if (uniforms.is2D) { | ||||
|       //   code2 = ` | ||||
|       //     material.diffuse = color.rgb*0.0; | ||||
|       //     material.emission = color.rgb * 1.0; | ||||
|       //   ` | ||||
|       // } | ||||
|       // console.log(code2, uniforms.is2D) | ||||
|       // 将定义的材质对象添加到cesium的材质队列中 | ||||
|       Material._materialCache.addMaterial(MaterialType, { | ||||
|         fabric: { | ||||
| @ -230,8 +238,8 @@ function StreamWall2() { | ||||
|               else { | ||||
|                 material.alpha = 1.0; | ||||
|               } | ||||
|               material.diffuse = colorImage.rgb*color.rgb*0.0; | ||||
|               material.emission = colorImage.rgb*color.rgb * 1.4; | ||||
|               material.diffuse = colorImage.rgb * color.rgb*0.0; | ||||
|               material.emission = colorImage.rgb * color.rgb * 1.0; | ||||
|               return material; | ||||
|           }`, | ||||
|           components: { | ||||
|  | ||||
| @ -7,6 +7,7 @@ import { PolylineFlow } from './PolylineFlowMaterialProperty' | ||||
| import { PolylineFlowMult } from './PolylineFlowMultMaterialProperty' | ||||
| import { FlowDashedLine } from './FlowDashedLineFlowMaterialProperty' | ||||
| import { LineTexture } from './LineTextureMaterialProperty' | ||||
| import { RoadTexture } from './RoadTextureMaterialProperty' | ||||
|  | ||||
| function init_material() { | ||||
|   StreamWall1() | ||||
| @ -19,6 +20,7 @@ function init_material() { | ||||
|   PolylineFlowMult() | ||||
|   FlowDashedLine() | ||||
|   LineTexture() | ||||
|   RoadTexture() | ||||
| } | ||||
|  | ||||
| export { init_material } | ||||
|  | ||||
| @ -11,6 +11,7 @@ import { open as projConvertOpen, close as projConvertClose } from './projConver | ||||
| import { open as projectionConvertOpen, close as projectionConvertClose } from './projectionConvert' | ||||
| import { setActiveViewer, closeRotateAround, closeViewFollow } from '../Global/global' | ||||
| import FlowPictureMaterialProperty from '../Obj/Materail/FlowPictureMaterialProperty' | ||||
| import { syncData, get3DView } from '../Global/MultiViewportMode' | ||||
|  | ||||
| class Tools { | ||||
|   /** | ||||
| @ -597,7 +598,6 @@ class Tools { | ||||
|     if (entity) { | ||||
|       arr[type + ''] ? (entity.polyline.width = entity.polyline.oriWidth + arr[type + '']) : (entity.polyline.width = entity.polyline.oriWidth) | ||||
|     } | ||||
|  | ||||
|     switch (Number(type)) { | ||||
|  | ||||
|       case 1: //虚线 | ||||
| @ -638,7 +638,7 @@ class Tools { | ||||
|       // break | ||||
|       case 6: //流动虚线2 | ||||
|         let that = this | ||||
|  | ||||
|         let repeatX | ||||
|         material = new Cesium.FlowDashedLineFlowMaterialProperty({ | ||||
|           color: color, | ||||
|           uType: type == 5 ? 0 : 1, | ||||
| @ -646,26 +646,52 @@ class Tools { | ||||
|           // dashSize: newParam.dashSize, | ||||
|           space: newParam.space, | ||||
|           scale: new Cesium.CallbackProperty(function () { | ||||
|             var oriPositions = entity.polyline.positions.getValue(); | ||||
|  | ||||
|             if (!Cesium.defined(oriPositions)) { | ||||
|               return 1.0; | ||||
|             if (that.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE3D) { | ||||
|               let oriPositions = entity.polyline.positions.getValue(); | ||||
|  | ||||
|               if (!Cesium.defined(oriPositions)) { | ||||
|                 return 1.0; | ||||
|               } | ||||
|               let distance = 0; | ||||
|               for (let i = 0; i < oriPositions.length - 1; ++i) { | ||||
|                 distance += Cesium.Cartesian3.distance(oriPositions[i], oriPositions[i + 1]); | ||||
|               } | ||||
|               //屏幕坐标 | ||||
|               let point1 = new Cesium.Cartesian2(0, that.sdk.viewer.canvas.clientHeight) | ||||
|               let point2 = new Cesium.Cartesian2(that.sdk.viewer.canvas.clientWidth / 2, that.sdk.viewer.canvas.clientHeight) | ||||
|               let cartesian1 = that.sdk.viewer.scene.pickPosition(point1) | ||||
|               let cartesian2 = that.sdk.viewer.scene.pickPosition(point2) | ||||
|               if (cartesian1 && cartesian2) { | ||||
|                 let distance2 = Cesium.Cartesian3.distance(cartesian1, cartesian2); | ||||
|                 repeatX = distance2 * 2 / distance | ||||
|               } | ||||
|               return repeatX; | ||||
|             } else { | ||||
|               let sdk3d = get3DView() | ||||
|               let sdk3dEntity = sdk3d.viewer.entities.getById(that.options.id) | ||||
|               let oriPositions = sdk3dEntity.polyline.positions.getValue(); | ||||
|  | ||||
|               if (!Cesium.defined(oriPositions)) { | ||||
|                 return 1.0; | ||||
|               } | ||||
|               let distance = 0; | ||||
|               for (let i = 0; i < oriPositions.length - 1; ++i) { | ||||
|                 distance += Cesium.Cartesian3.distance(oriPositions[i], oriPositions[i + 1]); | ||||
|               } | ||||
|               //屏幕坐标 | ||||
|               let point1 = new Cesium.Cartesian2(0, sdk3d.viewer.canvas.clientHeight) | ||||
|               let point2 = new Cesium.Cartesian2(sdk3d.viewer.canvas.clientWidth / 2, sdk3d.viewer.canvas.clientHeight) | ||||
|               let cartesian1 = sdk3d.viewer.scene.pickPosition(point1) | ||||
|               let cartesian2 = sdk3d.viewer.scene.pickPosition(point2) | ||||
|               if (cartesian1 && cartesian2) { | ||||
|                 let distance2 = Cesium.Cartesian3.distance(cartesian1, cartesian2); | ||||
|                 repeatX = distance2 * 2 / distance | ||||
|               } | ||||
|               return repeatX; | ||||
|             } | ||||
|             var distance = 0; | ||||
|             for (var i = 0; i < oriPositions.length - 1; ++i) { | ||||
|               distance += Cesium.Cartesian3.distance(oriPositions[i], oriPositions[i + 1]); | ||||
|             } | ||||
|             //屏幕坐标 | ||||
|             let point1 = new Cesium.Cartesian2(0, that.sdk.viewer.canvas.clientHeight) | ||||
|             let point2 = new Cesium.Cartesian2(that.sdk.viewer.canvas.clientWidth / 2, that.sdk.viewer.canvas.clientHeight) | ||||
|             var cartesian1 = that.sdk.viewer.scene.pickPosition(point1) | ||||
|             var cartesian2 = that.sdk.viewer.scene.pickPosition(point2) | ||||
|  | ||||
|             var distance2 = Cesium.Cartesian3.distance(cartesian1, cartesian2); | ||||
|  | ||||
|             let repeatX = distance2 * 2 / distance | ||||
|  | ||||
|             return repeatX; | ||||
|           }) | ||||
|         }) | ||||
|  | ||||
| @ -731,51 +757,109 @@ class Tools { | ||||
|           image: canvasEle, | ||||
|           speed: options.speed, | ||||
|           repeat: new Cesium.CallbackProperty(function () { | ||||
|             var positionProperty = entity.polyline.positions; | ||||
|             var positions = positionProperty.getValue(that.sdk.viewer.clock.currentTime); | ||||
|  | ||||
|             if (!Cesium.defined(positions)) { | ||||
|               return new Cesium.Cartesian2(1.0, 1.0); | ||||
|               // return 1.0; | ||||
|             } | ||||
|             if (that.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE3D) { | ||||
|               let positionProperty = entity.polyline.positions; | ||||
|               let positions = positionProperty.getValue(that.sdk.viewer.clock.currentTime); | ||||
|  | ||||
|             var distance = 0; | ||||
|             for (var i = 0; i < positions.length - 1; ++i) { | ||||
|               distance += Cesium.Cartesian3.distance(positions[i], positions[i + 1]); | ||||
|             } | ||||
|               if (!Cesium.defined(positions)) { | ||||
|                 return new Cesium.Cartesian2(1.0, 1.0); | ||||
|                 // return 1.0; | ||||
|               } | ||||
|  | ||||
|             var repeatX = distance / entity.polyline.width.getValue(); | ||||
|             // 根据地图缩放程度调整repeatX | ||||
|             var cameraHeight = that.sdk.viewer.camera.positionCartographic.height; | ||||
|             var boundingSphere = new Cesium.BoundingSphere( | ||||
|               new Cesium.Cartesian3(-1000000, 0, 0), // 中心点坐标 | ||||
|               500000 // 半径(距离) | ||||
|             ); | ||||
|               let distance = 0; | ||||
|               for (let i = 0; i < positions.length - 1; ++i) { | ||||
|                 // if (that.sdk.viewer.scene.mode===Cesium.SceneMode.SCENE2D){} | ||||
|                 distance += Cesium.Cartesian3.distance(positions[i], positions[i + 1]); | ||||
|               } | ||||
|  | ||||
|               let repeatX = distance / entity.polyline.width.getValue(); | ||||
|               // 根据地图缩放程度调整repeatX | ||||
|               let cameraHeight = that.sdk.viewer.camera.positionCartographic.height; | ||||
|               let boundingSphere = new Cesium.BoundingSphere( | ||||
|                 new Cesium.Cartesian3(-1000000, 0, 0), // 中心点坐标 | ||||
|                 500000 // 半径(距离) | ||||
|               ); | ||||
|  | ||||
|               // 获取绘图缓冲区的宽度和高度(通常是屏幕的分辨率) | ||||
|               let drawingBufferWidth = that.sdk.viewer.canvas.clientWidth; | ||||
|               let drawingBufferHeight = that.sdk.viewer.canvas.clientHeight; | ||||
|  | ||||
|               // 使用 getPixelSize 方法获取包围球在屏幕上的像素大小 | ||||
|               let groundResolution = that.sdk.viewer.scene.camera.getPixelSize(boundingSphere, drawingBufferWidth, drawingBufferHeight) | ||||
|               let result | ||||
|               if (groundResolution > 700) { | ||||
|                 repeatX *= groundResolution / cameraHeight / (options.space * (canvasEle.width / canvasEle.height * 5) + 1); | ||||
|                 // if (entity.polyline.material.oriRepeat) { | ||||
|                 let speed = repeatX / entity.polyline.oriRepeat | ||||
|                 entity.polyline.oriSpeed = speed | ||||
|                 entity.polyline.oriRepeatX = repeatX | ||||
|                 // } else { | ||||
|                 //   entity.polyline.material.oriRepeat = repeatX | ||||
|                 // } | ||||
|                 beforeSpeed = speed | ||||
|                 repeat = repeatX | ||||
|                 result = new Cesium.Cartesian2(repeatX, speed || 1.0) | ||||
|               } else { | ||||
|                 result = new Cesium.Cartesian2(repeat || entity.polyline.oriRepeatX, beforeSpeed || entity.polyline.oriSpeed) | ||||
|               } | ||||
|  | ||||
|               return result; | ||||
|  | ||||
|             // 获取绘图缓冲区的宽度和高度(通常是屏幕的分辨率) | ||||
|             var drawingBufferWidth = that.sdk.viewer.canvas.clientWidth; | ||||
|             var drawingBufferHeight = that.sdk.viewer.canvas.clientHeight; | ||||
|  | ||||
|             // 使用 getPixelSize 方法获取包围球在屏幕上的像素大小 | ||||
|             var groundResolution = that.sdk.viewer.scene.camera.getPixelSize(boundingSphere, drawingBufferWidth, drawingBufferHeight) | ||||
|             let result | ||||
|             if (groundResolution > 700) { | ||||
|               repeatX *= groundResolution / cameraHeight / (options.space * (canvasEle.width / canvasEle.height * 5) + 1); | ||||
|               // if (entity.polyline.material.oriRepeat) { | ||||
|               let speed = repeatX / entity.polyline.oriRepeat | ||||
|               entity.polyline.oriSpeed = speed | ||||
|               entity.polyline.oriRepeatX = repeatX | ||||
|               // } else { | ||||
|               //   entity.polyline.material.oriRepeat = repeatX | ||||
|               // } | ||||
|               beforeSpeed = speed | ||||
|               repeat = repeatX | ||||
|               result = new Cesium.Cartesian2(repeatX, speed || 1.0) | ||||
|             } else { | ||||
|               result = new Cesium.Cartesian2(repeat || entity.polyline.oriRepeatX, beforeSpeed || entity.polyline.oriSpeed) | ||||
|               let sdk3d = get3DView() | ||||
|               let sdk3dEntity = sdk3d.viewer.entities.getById(that.options.id) | ||||
|               let positionProperty = sdk3dEntity.polyline.positions; | ||||
|               let positions = positionProperty.getValue(sdk3d.viewer.clock.currentTime); | ||||
|  | ||||
|               if (!Cesium.defined(positions)) { | ||||
|                 return new Cesium.Cartesian2(1.0, 1.0); | ||||
|                 // return 1.0; | ||||
|               } | ||||
|  | ||||
|               let distance = 0; | ||||
|               for (let i = 0; i < positions.length - 1; ++i) { | ||||
|                 // if (that.sdk.viewer.scene.mode===Cesium.SceneMode.SCENE2D){} | ||||
|                 distance += Cesium.Cartesian3.distance(positions[i], positions[i + 1]); | ||||
|               } | ||||
|  | ||||
|               let repeatX = distance / sdk3dEntity.polyline.width.getValue(); | ||||
|               // 根据地图缩放程度调整repeatX | ||||
|               let cameraHeight = sdk3d.viewer.camera.positionCartographic.height; | ||||
|               let boundingSphere = new Cesium.BoundingSphere( | ||||
|                 new Cesium.Cartesian3(-1000000, 0, 0), // 中心点坐标 | ||||
|                 500000 // 半径(距离) | ||||
|               ); | ||||
|  | ||||
|               // 获取绘图缓冲区的宽度和高度(通常是屏幕的分辨率) | ||||
|               let drawingBufferWidth = sdk3d.viewer.canvas.clientWidth; | ||||
|               let drawingBufferHeight = sdk3d.viewer.canvas.clientHeight; | ||||
|  | ||||
|               // 使用 getPixelSize 方法获取包围球在屏幕上的像素大小 | ||||
|               let groundResolution = sdk3d.viewer.scene.camera.getPixelSize(boundingSphere, drawingBufferWidth, drawingBufferHeight) | ||||
|               let result | ||||
|               if (groundResolution > 700) { | ||||
|                 repeatX *= groundResolution / cameraHeight / (options.space * (canvasEle.width / canvasEle.height * 5) + 1); | ||||
|                 // if (entity.polyline.material.oriRepeat) { | ||||
|                 let speed = repeatX / sdk3dEntity.polyline.oriRepeat | ||||
|                 sdk3dEntity.polyline.oriSpeed = speed | ||||
|                 sdk3dEntity.polyline.oriRepeatX = repeatX | ||||
|                 // } else { | ||||
|                 //   entity.polyline.material.oriRepeat = repeatX | ||||
|                 // } | ||||
|                 beforeSpeed = speed | ||||
|                 repeat = repeatX | ||||
|                 result = new Cesium.Cartesian2(repeatX, speed || 1.0) | ||||
|               } else { | ||||
|                 result = new Cesium.Cartesian2(repeat || sdk3dEntity.polyline.oriRepeatX, beforeSpeed || sdk3dEntity.polyline.oriSpeed) | ||||
|               } | ||||
|  | ||||
|               return result; | ||||
|             } | ||||
|  | ||||
|             return result; | ||||
|  | ||||
|  | ||||
|             // return repeatX; | ||||
|           }) | ||||
|         } | ||||
| @ -788,33 +872,45 @@ class Tools { | ||||
|   getSceenLine(entity, options, canvasEle) { | ||||
|     let point1 = new Cesium.Cartesian2(0, this.sdk.viewer.canvas.clientHeight) | ||||
|     let point2 = new Cesium.Cartesian2(this.sdk.viewer.canvas.clientWidth / 2, this.sdk.viewer.canvas.clientHeight) | ||||
|     var cartesian1 = this.sdk.viewer.scene.pickPosition(point1) | ||||
|     var cartesian2 = this.sdk.viewer.scene.pickPosition(point2) | ||||
|     // var cartesian1 = this.sdk.viewer.scene.pickPosition(point1) | ||||
|     // var cartesian2 = this.sdk.viewer.scene.pickPosition(point2) | ||||
|     let ray = this.sdk.viewer.camera.getPickRay(point1); | ||||
|     let cartesian1 = this.sdk.viewer.scene.globe.pick(ray, this.sdk.viewer.scene); | ||||
|  | ||||
|     var distance = Cesium.Cartesian3.distance(cartesian1, cartesian2); | ||||
|     let ray2 = this.sdk.viewer.camera.getPickRay(point2); | ||||
|     let cartesian2 = this.sdk.viewer.scene.globe.pick(ray2, this.sdk.viewer.scene); | ||||
|     if (cartesian1 && cartesian2) { | ||||
|       var distance = Cesium.Cartesian3.distance(cartesian1, cartesian2); | ||||
|  | ||||
|     var repeatX = distance / entity.polyline.width.getValue(); | ||||
|     // 根据地图缩放程度调整repeatX | ||||
|     var cameraHeight = this.sdk.viewer.camera.positionCartographic.height; | ||||
|     var boundingSphere = new Cesium.BoundingSphere( | ||||
|       new Cesium.Cartesian3(-1000000, 0, 0), // 中心点坐标 | ||||
|       500000 // 半径(距离) | ||||
|     ); | ||||
|       var repeatX = distance / entity.polyline.width.getValue(); | ||||
|       // 根据地图缩放程度调整repeatX | ||||
|       var cameraHeight = this.sdk.viewer.camera.positionCartographic.height; | ||||
|       var boundingSphere = new Cesium.BoundingSphere( | ||||
|         new Cesium.Cartesian3(-1000000, 0, 0), // 中心点坐标 | ||||
|         500000 // 半径(距离) | ||||
|       ); | ||||
|  | ||||
|     // 获取绘图缓冲区的宽度和高度(通常是屏幕的分辨率) | ||||
|     var drawingBufferWidth = this.sdk.viewer.canvas.clientWidth; | ||||
|     var drawingBufferHeight = this.sdk.viewer.canvas.clientHeight; | ||||
|       // 获取绘图缓冲区的宽度和高度(通常是屏幕的分辨率) | ||||
|       var drawingBufferWidth = this.sdk.viewer.canvas.clientWidth; | ||||
|       var drawingBufferHeight = this.sdk.viewer.canvas.clientHeight; | ||||
|  | ||||
|     // 使用 getPixelSize 方法获取包围球在屏幕上的像素大小 | ||||
|     var groundResolution = this.sdk.viewer.scene.camera.getPixelSize(boundingSphere, drawingBufferWidth, drawingBufferHeight) | ||||
|     // repeatX *= groundResolution / cameraHeight / ((myImg.width / myImg.height * 5) + 1); | ||||
|     if (groundResolution > 700) { | ||||
|       repeatX *= groundResolution / cameraHeight / (options.space * (canvasEle.width / canvasEle.height * 5) + 1); | ||||
|     } else { | ||||
|       repeatX = undefined; | ||||
|       // 使用 getPixelSize 方法获取包围球在屏幕上的像素大小 | ||||
|       var groundResolution = this.sdk.viewer.scene.camera.getPixelSize(boundingSphere, drawingBufferWidth, drawingBufferHeight) | ||||
|       // repeatX *= groundResolution / cameraHeight / ((myImg.width / myImg.height * 5) + 1); | ||||
|       if (groundResolution > 700) { | ||||
|         repeatX *= groundResolution / cameraHeight / (options.space * (canvasEle.width / canvasEle.height * 5) + 1); | ||||
|       } else { | ||||
|         repeatX = undefined; | ||||
|       } | ||||
|  | ||||
|       if (this.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE3D) { | ||||
|         return repeatX | ||||
|       } else { | ||||
|         let sdk3d = get3DView() | ||||
|         let sdk3dEntity = sdk3d.viewer.entities.getById(this.options.id) | ||||
|         return sdk3dEntity.polyline.oriRepeatX | ||||
|       } | ||||
|     } | ||||
|  | ||||
|     return repeatX | ||||
|   } | ||||
|  | ||||
|   /*创建直箭头图片*/ | ||||
| @ -1397,6 +1493,30 @@ class Tools { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   message(option = {}) { | ||||
|     let type = option.type || 'success' | ||||
|     let text = option.text || '' | ||||
|     let duration = option.duration || 1500 | ||||
|  | ||||
|     let message = document.getElementById('YJ-custom-message'); | ||||
|     if (message) { | ||||
|       document.body.removeChild(message) | ||||
|     } | ||||
|     message = document.createElement('div') | ||||
|     message.id = 'YJ-custom-message' | ||||
|     if (type == 'success') { | ||||
|       message.innerHTML = ` | ||||
|       <i><?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1755929961282" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5064" width="16" height="16" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M874.119618 149.859922A510.816461 510.816461 0 0 0 511.997 0.00208a509.910462 509.910462 0 0 0-362.119618 149.857842c-199.817789 199.679789-199.817789 524.581447 0 724.260236a509.969462 509.969462 0 0 0 362.119618 149.857842A508.872463 508.872463 0 0 0 874.119618 874.120158c199.836789-199.679789 199.836789-524.581447 0-724.260236zM814.94268 378.210681L470.999043 744.132295a15.359984 15.359984 0 0 1-5.887994 4.095996c-1.751998 1.180999-2.913997 2.362998-5.276994 2.913997a34.499964 34.499964 0 0 1-13.469986 2.914997 45.547952 45.547952 0 0 1-12.897986-2.303998l-4.095996-2.363997a45.291952 45.291952 0 0 1-7.009992-4.095996l-196.902793-193.789796a34.126964 34.126964 0 0 1-10.555989-25.186973c0-9.37399 3.583996-18.74698 9.98399-25.186974a36.429962 36.429962 0 0 1 50.372947 0l169.98382 167.423824L763.389735 330.220732a37.059961 37.059961 0 0 1 50.371947-1.732998 33.647965 33.647965 0 0 1 11.165988 25.186973 35.544963 35.544963 0 0 1-9.98399 24.575974v-0.04z m0 0" fill="#52C41A" p-id="5065"></path></svg></i>${text} | ||||
|     ` | ||||
|     } else if (type == 'warning') { | ||||
|       message.innerHTML = ` | ||||
|       <i><?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1756093599258" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1648" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16"><path d="M512.002558 64.24521c-247.292176 0-447.75786 200.464661-447.75786 447.756837 0 247.287059 200.464661 447.752744 447.75786 447.752744 247.286036 0 447.75172-200.464661 447.75172-447.752744C959.754279 264.710894 759.288594 64.24521 512.002558 64.24521zM512.010745 735.87586c-20.602224 0-37.319977-16.718777-37.319977-37.323047 0-20.597107 16.717753-37.319977 37.319977-37.319977 20.60427 0 37.297464 16.72287 37.297464 37.319977C549.308209 719.158107 532.613992 735.87586 512.010745 735.87586zM549.308209 567.969733c0 20.600177-16.693194 37.293371-37.297464 37.293371-20.602224 0-37.319977-16.693194-37.319977-37.293371L474.690768 325.420581c0-20.605294 16.717753-37.297464 37.319977-37.297464 20.60427 0 37.297464 16.693194 37.297464 37.297464L549.308209 567.969733z" fill="#e98f36" p-id="1649"></path></svg></i>${text} | ||||
|     ` | ||||
|     } | ||||
|  | ||||
|     document.body.appendChild(message) | ||||
|     message.classList.add(type) | ||||
|   } | ||||
|  | ||||
| } | ||||
|  | ||||
|  | ||||
| @ -10,6 +10,7 @@ import AModelLoader from '../Obj/Base/LoadObjModel/AModelLoader' | ||||
| import { setSvg } from '../Obj/Element/svg' | ||||
| import Tools from '../Tools' | ||||
| import { Proj } from '../Tools/proj' | ||||
| import { syncData, getSdk } from '../Global/MultiViewportMode' | ||||
| import { | ||||
|   unRegLeftClickCallback, | ||||
|   unRegRightClickCallback, | ||||
| @ -46,23 +47,25 @@ class YJEarth { | ||||
|     // setCesiumIndexedDBMaxSize(getCesiumIndexedDBMaxSize()) | ||||
|     setCesiumManageIndexexDBState(getCesiumManageIndexexDBState()) | ||||
|     this.proj = new Proj() | ||||
|     this.clickTextDom = undefined | ||||
|     this.isLeftClick = false | ||||
|     this.init() | ||||
|     setSvg() | ||||
|   } | ||||
|  | ||||
|   addIncetance(id, obj) { | ||||
|     this.entityMap.set(id, obj) | ||||
|     this.entityMap.set(id + '', obj) | ||||
|   } | ||||
|  | ||||
|   getIncetance(id) { | ||||
|     return this.entityMap.get(id) | ||||
|     return this.entityMap.get(id + '') | ||||
|   } | ||||
|  | ||||
|   removeIncetance(id) { | ||||
|     this.entityMap.delete(id) | ||||
|     unRegLeftClickCallback(id) | ||||
|     unRegRightClickCallback(id) | ||||
|     unregMoveCallback(id) | ||||
|     unRegLeftClickCallback(this, id) | ||||
|     unRegRightClickCallback(this, id) | ||||
|     unregMoveCallback(this, id) | ||||
|  | ||||
|     syncSplitData(this, id) | ||||
|   } | ||||
| @ -149,7 +152,7 @@ class YJEarth { | ||||
|     } | ||||
|     this.options.contextOptions = { | ||||
|       webgl: { | ||||
|         alpha: true, | ||||
|         // alpha: true, | ||||
|         depth: true, | ||||
|         stencil: true, | ||||
|         antialias: true, | ||||
| @ -221,11 +224,11 @@ class YJEarth { | ||||
|  | ||||
|     document.fonts.ready.then(() => { | ||||
|       for (let [id, obj] of this.entityMap) { | ||||
|         if('labelFontFamily' in obj) { | ||||
|         if ('labelFontFamily' in obj) { | ||||
|           obj.labelFontFamily = obj.labelFontFamily | ||||
|         } | ||||
|       } | ||||
|        | ||||
|  | ||||
|     }); | ||||
|  | ||||
|     // const font = new FontFace( | ||||
| @ -413,6 +416,114 @@ class YJEarth { | ||||
|         }) | ||||
|       ) | ||||
|     } | ||||
|  | ||||
|  | ||||
|     let ClickHandler = new Cesium.ScreenSpaceEventHandler(_this.viewer.canvas) | ||||
|     ClickHandler.setInputAction((movement) => { | ||||
|       // let textList = document.getElementsByClassName('popup-textarea') | ||||
|       let textList = _this.viewer._element.getElementsByClassName('popup-textarea') | ||||
|       _this.isLeftClick = false | ||||
|       for (let i = textList.length - 1; i > -1; i--) { | ||||
|         let left = returnNumber(textList[i].style.left) | ||||
|         let top = returnNumber(textList[i].style.top) | ||||
|         let width = textList[i].clientWidth * 1 | ||||
|         let height = textList[i].clientHeight * 1 | ||||
|         let x = movement.position.x | ||||
|         let y = movement.position.y | ||||
|         if (x > left && x < left + width && y > top && y < top + height) { | ||||
|           if (_this.clickTextDom) { | ||||
|             _this.clickTextDom.style['pointer-events'] = 'none' | ||||
|             _this.clickTextDom.querySelector('textarea').removeEventListener('blur', _this.blurFun) | ||||
|           } | ||||
|  | ||||
|           _this.clickTextDom = textList[i] | ||||
|           textList[i].style['pointer-events'] = 'all' | ||||
|           textList[i].querySelector('textarea').focus() | ||||
|           _this.isLeftClick = true | ||||
|           _this.entityMap.get(_this.clickTextDom.id).isClick(movement.position, _this.clickTextDom.id) | ||||
|           _this.blurFun = () => { | ||||
|             // let { sdkP } = getSdk() | ||||
|             // if (_this == sdkP && sdkP) {//二维 | ||||
|             //   _this.entityMap.get(_this.clickTextDom.id).getwords(_this.clickTextDom.getElementsByTagName('textarea')[0].value) | ||||
|             // } else if (!sdkP) { | ||||
|             _this.entityMap.get(_this.clickTextDom.id).getwords(_this.clickTextDom.getElementsByTagName('textarea')[0].value) | ||||
|             // } | ||||
|             _this.clickTextDom.querySelector('textarea').removeEventListener('blur', _this.blurFun) | ||||
|           } | ||||
|           _this.clickTextDom.querySelector('textarea').addEventListener('blur', _this.blurFun) | ||||
|           break; | ||||
|         } | ||||
|       } | ||||
|  | ||||
|       let mousedown = undefined | ||||
|       let mousemove = undefined | ||||
|       let mouseup = undefined | ||||
|       let fun = undefined | ||||
|       let handler = undefined | ||||
|  | ||||
|       if (_this.isLeftClick) { | ||||
|         let click = false | ||||
|         let layerX = 0 | ||||
|         let layerY = 0 | ||||
|  | ||||
|         mousedown = function (e) { | ||||
|           layerX = e.layerX | ||||
|           layerY = e.layerY | ||||
|           click = true | ||||
|         } | ||||
|         mousemove = function (e) { | ||||
|           if (!click || !_this.clickTextDom) { | ||||
|             return | ||||
|           } | ||||
|           let width = _this.clickTextDom.clientWidth * 1 | ||||
|           let height = _this.clickTextDom.clientHeight * 1 | ||||
|           let param = { | ||||
|             x: e.clientX - layerX + width / 2, | ||||
|             y: e.clientY - layerY + height, | ||||
|           } | ||||
|           let { sdkP } = getSdk() | ||||
|           if (_this != sdkP && sdkP) {//二维 | ||||
|             let num = sdkP.viewer._element.clientWidth | ||||
|             param.x = param.x - num | ||||
|           } | ||||
|           _this.entityMap.get(_this.clickTextDom.id).setHandeler(param) | ||||
|  | ||||
|         } | ||||
|         mouseup = function (e) { | ||||
|           if (!click) { | ||||
|             return | ||||
|           } | ||||
|           click = false | ||||
|         } | ||||
|  | ||||
|         _this.clickTextDom.addEventListener('mousedown', mousedown); | ||||
|         _this.viewer._element.addEventListener('mousemove', mousemove); | ||||
|         _this.viewer._element.addEventListener('mouseup', mouseup); | ||||
|       } | ||||
|       // 点击其他地方取消 | ||||
|       if (!_this.isLeftClick && _this.clickTextDom) { | ||||
|         _this.clickTextDom.removeEventListener('mousedown', mousedown); | ||||
|         _this.viewer._element.removeEventListener('mousemove', mousemove); | ||||
|         _this.viewer._element.removeEventListener('mouseup', mouseup); | ||||
|         // _this.entityMap.get(_this.clickTextDom.id).getwords(_this.clickTextDom.getElementsByTagName('textarea')[0].value) | ||||
|  | ||||
|         _this.clickTextDom.style['pointer-events'] = 'none' | ||||
|         _this.clickTextDom = undefined | ||||
|  | ||||
|       } | ||||
|     }, Cesium.ScreenSpaceEventType.LEFT_CLICK) | ||||
|  | ||||
|     // ClickHandler.setInputAction((movement) => { | ||||
|     //   if (_this.clickTextDom) { | ||||
|     //     _this.clickTextDom.style['pointer-events'] = 'none' | ||||
|     //     _this.clickTextDom = undefined | ||||
|     //   } | ||||
|     // }, Cesium.ScreenSpaceEventType.LEFT_CLICK) | ||||
|     function returnNumber(str) { | ||||
|       let index = str.indexOf('px') | ||||
|       return Number(str.slice(0, index)) | ||||
|     } | ||||
|  | ||||
|   } | ||||
|  | ||||
|   destroy() { | ||||
|  | ||||
							
								
								
									
										33
									
								
								static/3rdparty/ewPlugins.min.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										33
									
								
								static/3rdparty/ewPlugins.min.js
									
									
									
									
										vendored
									
									
								
							| @ -746,6 +746,7 @@ | ||||
|         o.colorHsbaToRgba)(e.hsba) : e.pickerInput.value = (0, | ||||
|         o.colorRgbaToHex)((0, | ||||
|         o.colorHsbaToRgba)(e.hsba)) | ||||
|         e.config.pickerInputChange && e.config.pickerInputChange() | ||||
|     } | ||||
|     function f(e) { | ||||
|         if (this.pickerFlag = !1, | ||||
| @ -795,6 +796,8 @@ | ||||
|                 n.isFunction)(e.sure) ? e.sure : null, | ||||
|                 clear: (0, | ||||
|                 n.isFunction)(e.clear) ? e.clear : null, | ||||
|                 pickerInputChange: (0, | ||||
|                     n.isFunction)(e.pickerInputChange) ? e.pickerInputChange : null, | ||||
|                 startMainCallback: (0, | ||||
|                   n.isFunction)(e.startMainCallback) ? e.startMainCallback : null, | ||||
|                 clickDefineColor: (0, | ||||
| @ -807,8 +810,10 @@ | ||||
|             else | ||||
|                 this.init(o, this.config) | ||||
|         } | ||||
|         this.changeColor = g | ||||
|         this.close = () => { | ||||
|           this.pickerFlag = !this.pickerFlag, | ||||
|           this.picker.style.opacity = 0 | ||||
|           this.render(this.box.parentNode, this.config), | ||||
|           d(this), | ||||
|           g(this, this.panelWidth, this.panelHeight) | ||||
| @ -890,6 +895,7 @@ | ||||
|             var u = i - e.hsba.a * i; | ||||
|             c(e.alphaBarThumb, "top", u + "px") | ||||
|         } | ||||
|         e.config.pickerInputChange && e.config.pickerInputChange() | ||||
|     } | ||||
|     function b(e, t) { | ||||
|         var r = e.hueBar.offsetHeight | ||||
| @ -965,6 +971,7 @@ | ||||
|     } | ||||
|     , | ||||
|     f.prototype.startMain = function(e, t) { | ||||
|         // console.log(e,t) | ||||
|         var r = this; | ||||
|         this.box = l(e, "ew-color-picker-box"), | ||||
|         this.box.setAttribute("color-box-id", this.uid), | ||||
| @ -1002,8 +1009,21 @@ | ||||
|             c += s.offsetParent.offsetTop, | ||||
|             f += s.offsetParent.offsetLeft, | ||||
|             s = s.offsetParent; | ||||
|         this.pancelLeft = f, | ||||
|         this.pancelTop = c + e.offsetHeight, | ||||
|         this.pancelLeft = f; | ||||
|         let defineColorContainer = this.picker.getElementsByClassName('ew-pre-define-color-container')[0] | ||||
|         let customColorHeight = 0 | ||||
|         if(defineColorContainer) { | ||||
|             let colorList = localStorage.getItem('custom-color') || '{}' | ||||
|             colorList = JSON.parse(colorList) | ||||
|             customColorHeight = (Math.floor((Object.keys(colorList).length+2) / 11)+1) * 30 | ||||
|         } | ||||
|         this.picker.style.display = 'block' | ||||
|         this.pancelTop = e.getBoundingClientRect().y + (e.offsetHeight + customColorHeight) + 2 | ||||
|         if((this.picker.offsetHeight + customColorHeight) + this.pancelTop > window.innerHeight) { | ||||
|             this.pancelTop = e.getBoundingClientRect().y - (this.picker.offsetHeight + customColorHeight) | ||||
|             this.picker.style.top = this.pancelTop + 2 + 'px' | ||||
|         } | ||||
|         this.picker.style.display = 'none' | ||||
|         this.preDefineItem = l(e, "ew-pre-define-color", !0), | ||||
|         this.preDefineItem.length && (0, | ||||
|         n.ewObjToArray)(this.preDefineItem).map(function(e) { | ||||
| @ -1054,7 +1074,7 @@ | ||||
|         }, !1), | ||||
|         this.pickerClear.addEventListener("click", function() { | ||||
|             !function(e, t) { | ||||
|                 t.config.defaultColor = "rgba(255,255,255,1)", | ||||
|                 t.config.defaultColor = "", | ||||
|                 t.pickerFlag = !t.pickerFlag, | ||||
|                 t.render(e, t.config), | ||||
|                 d(t), | ||||
| @ -1070,6 +1090,9 @@ | ||||
|                 o.colorHsbaToRgba)(e.hsba) : (0, | ||||
|                 o.colorRgbaToHex)((0, | ||||
|                 o.colorHsbaToRgba)(e.hsba)); | ||||
|                 e.config.defaultColor = e.pickerInput.value | ||||
|                 e.config.pickerInputChange && e.config.pickerInputChange() | ||||
|                 e.render(e.box.parentNode, e.config), | ||||
|                 e.config.sure(t, e) | ||||
|             }(r) | ||||
|         }), | ||||
| @ -1097,6 +1120,7 @@ | ||||
|             }(r, e) | ||||
|         }, !1), | ||||
|         this.bindEvent(this.pickerCursor, function(e, t, r, n) { | ||||
|             // console.log(e) | ||||
|           r=r-7 | ||||
|           n=n-7 | ||||
|             u(e, Math.max(0, Math.min(r - e.pancelLeft, i)), Math.max(0, Math.min(n - e.pancelTop, a)), i, a) | ||||
| @ -1119,7 +1143,8 @@ | ||||
|                 a = i, | ||||
|                 o.moveX = n.eventType[0].indexOf("touch") > -1 ? a.changedTouches[0].clientX : a.clientX, | ||||
|                 o.moveY = n.eventType[0].indexOf("touch") > -1 ? a.changedTouches[0].clientY : a.clientY, | ||||
|                 r ? t(o, o.moveX, o.moveY) : t(o, e, o.moveX, o.moveY) | ||||
|                 r ? t(o, o.moveX, o.moveY) : t(o, e, o.moveX, o.moveY); | ||||
|                 // console.log('222222', i, t,e,  o.moveX, o.moveY) | ||||
|             }; | ||||
|             document.addEventListener(n.eventType[1], a, { | ||||
|                 capture: !1, | ||||
|  | ||||
| @ -68,7 +68,6 @@ | ||||
|   z-index: 999999; | ||||
|   background: linear-gradient(0deg, var(--color-sdk-bg-gradual)), rgba(0, 0, 0, 0.6); | ||||
|   border: 1.5px solid; | ||||
|   backdrop-filter: blur(2px); | ||||
|   border-image: linear-gradient(to bottom, var(--color-sdk-gradual)) 1; | ||||
|   text-align: left; | ||||
|   font-family: 'sy-boldface'; | ||||
| @ -1033,16 +1032,31 @@ | ||||
|   background: linear-gradient(0deg, var(--color-sdk-bg-gradual)), rgba(0, 0, 0, 0.6); | ||||
|   border-image: linear-gradient(to bottom, var(--color-sdk-gradual)) 1; | ||||
|   padding: 5px; | ||||
|   position: fixed !important; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog .ew-color-picker>.ew-color-picker-content { | ||||
| .YJ-custom-base-dialog>.content .ew-color-picker input { | ||||
|   font-size: 14px; | ||||
|   line-height: 28px; | ||||
|   height: 28px; | ||||
|   padding: 0 8px; | ||||
|   font-weight: 400; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog>.content .ew-color-picker .input-number-unit input[type=number] { | ||||
|   padding: 0 20px 0 8px; | ||||
|   width: 66px; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog.ew-color-picker>.ew-color-picker-content { | ||||
|   margin-bottom: 10px; | ||||
| } | ||||
| .YJ-custom-base-dialog .ew-color-picker>.ew-color-picker-content>.ew-color-panel  { | ||||
|  | ||||
| .YJ-custom-base-dialog .ew-color-picker>.ew-color-picker-content>.ew-color-panel { | ||||
|   width: 302px; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog .ew-color-picker> .ew-color-input { | ||||
| .YJ-custom-base-dialog .ew-color-picker>.ew-color-input { | ||||
|   margin-top: 1px; | ||||
|   font-size: 14px; | ||||
|   background-color: rgba(0, 0, 0, 0.5); | ||||
| @ -1058,13 +1072,16 @@ | ||||
| .YJ-custom-base-dialog .ew-color-picker .icon-pen-box { | ||||
|   display: inline-block; | ||||
|   /* cursor: pointer; */ | ||||
|   cursor: no-drop; | ||||
|   width: 24px; | ||||
|   height: 24px; | ||||
|   text-align: center; | ||||
|   line-height: 24px; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog>.content>div .ew-color-picker .row>.col { | ||||
|   margin: 0 !important; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog .ew-color-picker .icon-pen-box .icon-pen { | ||||
|   margin: 0; | ||||
| } | ||||
| @ -1080,9 +1097,9 @@ | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog .ew-color-picker .color-alpha>input { | ||||
|   font-weight: 400; | ||||
|   font-family: Arial; | ||||
|   font-size: 14px; | ||||
|   font-weight: 400 !important; | ||||
|   font-family: Arial !important; | ||||
|   font-size: 14px !important; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog .ew-color-picker>.ew-pre-define-color-container { | ||||
| @ -1095,6 +1112,7 @@ | ||||
|   margin: 0 0 8px 8px; | ||||
|   border: 1px solid #9b979b; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog .ew-color-picker>.ew-pre-define-color-container>.ew-pre-define-color:nth-child(11n+1) { | ||||
|   width: 22px; | ||||
|   height: 22px; | ||||
| @ -1124,6 +1142,7 @@ | ||||
|   text-align: center; | ||||
|   background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAIAAADZF8uwAAAAGUlEQVQYV2M4gwH+YwCGIasIUwhT25BVBADtzYNYrHvv4gAAAABJRU5ErkJggg=="); | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog .ew-color-picker>.yj-pre-collect-color-container>.yj-pre-collect-color:nth-child(11n+1) { | ||||
|   margin: 0 0 8px 0; | ||||
| } | ||||
| @ -1132,14 +1151,16 @@ | ||||
| .YJ-custom-base-dialog .ew-color-picker>.yj-pre-collect-color-container>.yj-pre-collect-color.subtract { | ||||
|   border-color: rgba(var(--color-sdk-base-rgb), 0.2); | ||||
|   background: unset; | ||||
|   line-height: 22px; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog .ew-color-picker>.yj-pre-collect-color-container>.yj-pre-collect-color.add:hover, | ||||
| .YJ-custom-base-dialog .ew-color-picker>.yj-pre-collect-color-container>.yj-pre-collect-color.subtract:hover { | ||||
|   border-color: rgba(var(--color-sdk-base-rgb), 0.4); | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog .ew-color-picker>.yj-pre-collect-color-container svg, | ||||
| .YJ-custom-base-dialog .ew-color-picker>.yj-pre-collect-color-container> svg { | ||||
| .YJ-custom-base-dialog .ew-color-picker>.yj-pre-collect-color-container>svg { | ||||
|   margin: 0; | ||||
| } | ||||
|  | ||||
| @ -1156,10 +1177,12 @@ | ||||
|   border-radius: 3px; | ||||
|   cursor: pointer; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog .ew-color-picker>.yj-pre-collect-color-container>.yj-pre-collect-color>.yj-pre-define-color-item.subtract-btn { | ||||
|   position: absolute; | ||||
|   top: 0; | ||||
|   left: 0; | ||||
|   line-height: 20px; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog .ew-color-picker>.yj-pre-collect-color-container>.yj-pre-collect-color:hover { | ||||
| @ -1168,11 +1191,15 @@ | ||||
|  | ||||
| .YJ-custom-base-dialog .ew-color-picker .ew-color-dropbtngroup { | ||||
|   display: flex; | ||||
|   position: unset; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog .ew-color-picker .ew-color-dropbtngroup button { | ||||
|   padding: 5px 10px 4px 10px; | ||||
|   padding: 0 8px; | ||||
|   height: 28px; | ||||
|   line-height: 28px; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog .ew-color-picker .ew-color-dropbtngroup button.ew-color-clear { | ||||
|   margin-right: 8px; | ||||
| } | ||||
| @ -1180,6 +1207,7 @@ | ||||
| .YJ-custom-base-dialog .ew-color-picker-box { | ||||
|   border-width: 4px; | ||||
|   border-color: #ffffff; | ||||
|   display: block; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog .ew-color-picker-box>.ew-color-picker-no, | ||||
| @ -1209,12 +1237,12 @@ | ||||
|   transform: rotate(-45deg); | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog .ew-color-picker .ew-color-dropbtns{ | ||||
| .YJ-custom-base-dialog .ew-color-picker .ew-color-dropbtns { | ||||
|   display: flex; | ||||
|   align-items: center; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog .ew-color-picker svg{ | ||||
| .YJ-custom-base-dialog .ew-color-picker svg { | ||||
|   margin: 0; | ||||
| } | ||||
|  | ||||
| @ -1401,6 +1429,24 @@ | ||||
|   margin-bottom: 10px; | ||||
|   display: flex; | ||||
|   position: relative; | ||||
|   overflow-y: auto; | ||||
| } | ||||
|  | ||||
| .DIV-cy-tabs .DIV-cy-tab-top::-webkit-scrollbar { | ||||
|   width: 4px; | ||||
|   height: 4px; | ||||
| } | ||||
|  | ||||
| .DIV-cy-tabs .DIV-cy-tab-top::-webkit-scrollbar-thumb { | ||||
|   border-radius: 5px; | ||||
|   -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2); | ||||
|   background-color: rgba(var(--color-sdk-base-rgb)); | ||||
| } | ||||
|  | ||||
| .DIV-cy-tabs .DIV-cy-tab-top::-webkit-scrollbar-track { | ||||
|   -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2); | ||||
|   border-radius: 5px; | ||||
|   background-color: rgba(var(--color-sdk-base-rgb), 0.1); | ||||
| } | ||||
|  | ||||
| .DIV-cy-tabs .DIV-cy-tab-top::after { | ||||
| @ -1445,7 +1491,14 @@ | ||||
|   border-bottom: 2px solid #dddddd00; | ||||
|   position: relative; | ||||
|   z-index: 2; | ||||
|   white-space: nowrap; | ||||
|   user-select: none; | ||||
|   cursor: pointer; | ||||
|   -webkit-pointer-events: auto; | ||||
|   -moz-pointer-events: auto; | ||||
|   -ms-pointer-events: auto; | ||||
|   -o-pointer-events: auto; | ||||
|   pointer-events: auto; | ||||
| } | ||||
|  | ||||
| .DIV-cy-tabs .DIV-cy-tab-pane-title-p span { | ||||
| @ -1935,6 +1988,7 @@ | ||||
| .YJ-custom-base-dialog.water-surface>.content>div .row .label { | ||||
|   flex: 0 0 60px; | ||||
| } | ||||
|  | ||||
| /* 流光飞线 */ | ||||
| .YJ-custom-base-dialog.flow-line-surface>.content { | ||||
|   width: 586px; | ||||
| @ -2104,6 +2158,10 @@ | ||||
|   width: 200px; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog.particle-effects>.content .ew-color-picker .row>.col { | ||||
|   width: auto; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog.particle-effects>.content [type="range"] { | ||||
|   margin-top: 10px; | ||||
| } | ||||
| @ -2749,6 +2807,7 @@ | ||||
| .YJ-custom-base-dialog.polyline>.content { | ||||
|   width: 580px; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog.polyline>.content>div #dashTextureDom { | ||||
|   display: none; | ||||
| } | ||||
| @ -2800,6 +2859,7 @@ | ||||
| .YJ-custom-base-dialog.polyline>.content>div .spatial-info-table .table-body { | ||||
|   max-height: 185px; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog.polyline>.content>div .input-select-unit-box textarea { | ||||
|   border-radius: unset !important; | ||||
| } | ||||
| @ -2928,34 +2988,37 @@ | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog.polyline>.content>div .input-select-unit-box textarea { | ||||
|   border-radius: unset!important; | ||||
|   border-radius: unset !important; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog.polyline>.content>div .input-select-unit .datalist { | ||||
|    background-color:rgba(var(--color-sdk-base-rgb), 0.1)!important; | ||||
|   background-color: rgba(var(--color-sdk-base-rgb), 0.1) !important; | ||||
|   border-radius: 4px 0px 0px 4px !important; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog.polyline>.content>div .input-select-unit:nth-of-type(1) .datalist { | ||||
|    background-color:rgba(var(--color-sdk-base-rgb), 0.1)!important; | ||||
|    border-radius: 4px 0px, 0px, 4px!important; | ||||
|   background-color: rgba(var(--color-sdk-base-rgb), 0.1) !important; | ||||
|   border-radius: 4px 0px, 0px, 4px !important; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog.polyline>.content>div .input-select-unit:nth-of-type(2) .datalist { | ||||
|    background-color:rgba(var(--color-sdk-base-rgb), 0.1)!important; | ||||
|   border-radius: 0px 4px 4px 0px!important; | ||||
|   background-color: rgba(var(--color-sdk-base-rgb), 0.1) !important; | ||||
|   border-radius: 0px 4px 4px 0px !important; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog.polyline>.content>div .input-select-unit:nth-of-type(1) input { | ||||
|     border: 1px solid rgba(var(--color-sdk-base-rgb), 0.5)!important; | ||||
| } | ||||
| .YJ-custom-base-dialog.polyline>.content>div .input-select-unit:nth-of-type(2) input { | ||||
|   border: 1px solid rgba(var(--color-sdk-base-rgb), 0.5)!important; | ||||
|   border: 1px solid rgba(var(--color-sdk-base-rgb), 0.5) !important; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog.polyline>.content input.input-text{ | ||||
|     background-color: rgba(0, 0, 0, 0.5)!important; | ||||
|     border-radius: unset!important; | ||||
|     border-top: 1px solid rgba(var(--color-sdk-base-rgb), 0.5)!important; | ||||
|     border-bottom: 1px solid rgba(var(--color-sdk-base-rgb), 0.5) !important; | ||||
| .YJ-custom-base-dialog.polyline>.content>div .input-select-unit:nth-of-type(2) input { | ||||
|   border: 1px solid rgba(var(--color-sdk-base-rgb), 0.5) !important; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog.polyline>.content input.input-text { | ||||
|   background-color: rgba(0, 0, 0, 0.5) !important; | ||||
|   border-radius: unset !important; | ||||
|   border-top: 1px solid rgba(var(--color-sdk-base-rgb), 0.5) !important; | ||||
|   border-bottom: 1px solid rgba(var(--color-sdk-base-rgb), 0.5) !important; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog.polyline>.content>div .input-select-line-type-box .cy_datalist input { | ||||
| @ -2979,73 +3042,124 @@ | ||||
|   height: 13px; | ||||
|   margin-right: 7px; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog.polyline>.content>div .input-select-line-type-box .cy_datalist i.line { | ||||
|   border: 1px solid rgba(var(--color-sdk-base-rgb), 1); | ||||
|   height: 0px; | ||||
|   margin-top: 4px; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog.polyline>.content>div .input-select-line-type-box .cy_datalist i.dash-line { | ||||
|   border: 1px dashed rgba(var(--color-sdk-base-rgb), 1); | ||||
|   height: 0px; | ||||
|   margin-top: 4px; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog.polyline>.content>div .input-select-line-type-box .cy_datalist i.light-line { | ||||
|   border: 1px solid rgba(var(--color-sdk-base-rgb), 1); | ||||
|   height: 0px; | ||||
|   margin-top: 4px; | ||||
|   box-shadow: 0 0 3px #fff | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog.polyline>.content>div .input-select-line-type-box .cy_datalist i.tail-line { | ||||
|   background: url(../../img/arrow/tail.png) 100% 100% no-repeat; | ||||
|   background-size: 100% 100%; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog.polyline>.content>div .input-select-line-type-box .cy_datalist i.mult-tail-line { | ||||
|   background: url(../../img/arrow/tail.png) 100% 100% no-repeat; | ||||
|   background-size: 100% 100%; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog.polyline>.content>div .input-select-line-type-box .cy_datalist i.flow-dash-line1 { | ||||
|   border: 1px dashed rgba(var(--color-sdk-base-rgb), 1); | ||||
|   height: 0px; | ||||
|   margin-top: 4px; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog.polyline>.content>div .input-select-line-type-box .cy_datalist i.flow-dash-line2 { | ||||
|   border: 1px dashed rgba(var(--color-sdk-base-rgb), 1); | ||||
|   height: 0px; | ||||
|   margin-top: 4px; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog.polyline>.content>div .input-select-line-type-box .cy_datalist i.pic-line1 { | ||||
|   background: url(../../img/arrow/1.png); | ||||
|   background-size: cover; | ||||
|   background-position: center; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog.polyline>.content>div .input-select-line-type-box .cy_datalist i.pic-line2 { | ||||
|   background: url(../../img/arrow/2.png); | ||||
|   background-size: cover; | ||||
|   background-position: center; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog.polyline>.content>div .input-select-line-type-box .cy_datalist i.pic-line3 { | ||||
|   background: url(../../img/arrow/3.png); | ||||
|   background-size: cover; | ||||
|   background-position: center; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog.polyline>.content>div .input-select-line-type-box .cy_datalist i.pic-line4 { | ||||
|   background: url(../../img/arrow/4.png) ; | ||||
|   background: url(../../img/arrow/4.png); | ||||
|   background-size: cover; | ||||
|   background-position: center; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog.polyline>.content>div .input-select-line-type-box .cy_datalist i.pic-line5 { | ||||
|   background: url(../../img/arrow/5.png); | ||||
|   background-size: cover; | ||||
|   background-position: center; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog.polyline>.content>div .input-select-line-type-box .cy_datalist i.pic-line6 { | ||||
|   background: url(../../img/arrow/6.png) 100% 100% no-repeat; | ||||
|   background-size: 100% 100%; | ||||
| } | ||||
|  | ||||
| /* 文本框 */ | ||||
| .popup-textarea{ | ||||
|   /* width: 212px; */ | ||||
|   width: 161px; | ||||
|   /* height: 154px; */ | ||||
|   height: 119px; | ||||
|   display: block; | ||||
|   pointer-events: none; | ||||
|   position: absolute; | ||||
|   /* z-index: 99; */ | ||||
|   background: url(../../img/pop.png) 100% 100% no-repeat; | ||||
|   background-size: 100% 100%; | ||||
|   padding: 5px 5px 0px 5px; | ||||
| } | ||||
| .popup-textarea textarea{ | ||||
|   width: 158px; | ||||
|   height: 95px; | ||||
|   background-color: unset!important; | ||||
|   border: unset!important; | ||||
|   color: #fff; | ||||
| } | ||||
| .popup-textarea textarea::-webkit-scrollbar { | ||||
|   width: 8px!important; | ||||
|   /* height: 8px!important; */ | ||||
| } | ||||
|  | ||||
| .popup-textarea textarea::-webkit-scrollbar-thumb { | ||||
|   border-radius: 5px!important; | ||||
|   -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2)!important; | ||||
|   background-color: rgba(var(--color-sdk-base-rgb))!important; | ||||
| } | ||||
|  | ||||
| .popup-textarea textarea::-webkit-scrollbar-track { | ||||
|   -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2)!important; | ||||
|   border-radius: 5px!important; | ||||
|   background-color: rgba(var(--color-sdk-base-rgb), 0.1)!important; | ||||
| } | ||||
|  | ||||
| /* 贴地图片 */ | ||||
| .YJ-custom-base-dialog.ground-image>.content { | ||||
|   width: 500px; | ||||
|   width: 560px; | ||||
| } | ||||
|  | ||||
| /* 模型 */ | ||||
| @ -3379,6 +3493,7 @@ | ||||
|   cursor: e-resize; | ||||
|   background-color: #d3d3d3; | ||||
|   user-select: none; | ||||
|   z-index: 1; | ||||
| } | ||||
|  | ||||
| .cesium-performanceDisplay-defaultContainer { | ||||
| @ -3467,3 +3582,242 @@ | ||||
| .YJ-custom-base-dialog.contour>.content .label { | ||||
|   flex: unset; | ||||
| } | ||||
|  | ||||
| /* 锚点设置 */ | ||||
| .YJ-custom-base-dialog.anchor-point { | ||||
|   user-select: none; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog.anchor-point>.content { | ||||
|   padding: 14px 40px; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog.anchor-point>.content>div { | ||||
|   border: 1px solid #757575; | ||||
|   position: relative; | ||||
| } | ||||
|  | ||||
| .YJ-custom-base-dialog.anchor-point>.content>div>.point { | ||||
|   width: 10px; | ||||
|   height: 10px; | ||||
|   position: absolute; | ||||
|   background: #FFDF53; | ||||
|   border-radius: 50%; | ||||
|   border: 1px solid #ff7300; | ||||
|   cursor: pointer; | ||||
| } | ||||
|  | ||||
| .billboard-attribute-box { | ||||
|   position: absolute; | ||||
|   z-index: 1; | ||||
|   background: linear-gradient(0deg, var(--color-sdk-bg-gradual)), rgba(0, 0, 0, 0.6); | ||||
|   border: 1.5px solid; | ||||
|   border-image: linear-gradient(to bottom, var(--color-sdk-gradual)) 1; | ||||
|   color: #fff; | ||||
|   min-width: 200px; | ||||
|   min-height: 120px; | ||||
|   box-sizing: border-box; | ||||
|   /* -webkit-pointer-events: none; | ||||
|   -moz-pointer-events: none; | ||||
|   -ms-pointer-events: none; | ||||
|   -o-pointer-events: none; | ||||
|   pointer-events: none; */ | ||||
| } | ||||
|  | ||||
| .billboard-attribute-box .DIV-cy-tabs { | ||||
|   height: 100%; | ||||
|   display: flex; | ||||
|   flex-direction: column; | ||||
|   backdrop-filter: blur(2px); | ||||
| } | ||||
|  | ||||
| .billboard-attribute-box .DIV-cy-tabs .DIV-cy-tab-top .DIV-cy-tab-pane-title { | ||||
|   padding: 0 2px; | ||||
| } | ||||
|  | ||||
| .billboard-attribute-box .DIV-cy-tabs .DIV-cy-tab-top .DIV-cy-tab-pane-title:first-child { | ||||
|   padding-left: 0; | ||||
| } | ||||
|  | ||||
| .billboard-attribute-box .DIV-cy-tabs .DIV-cy-tab-top .DIV-cy-tab-pane-title:last-child { | ||||
|   padding-right: 0; | ||||
| } | ||||
|  | ||||
| .billboard-attribute-box .DIV-cy-tabs .DIV-cy-tab-top .DIV-cy-tab-pane-title span { | ||||
|   margin: 0 5px; | ||||
| } | ||||
|  | ||||
| .billboard-attribute-box .DIV-cy-tabs .DIV-cy-tab-content { | ||||
|   padding: 0 5px 5px 5px; | ||||
|   box-sizing: border-box; | ||||
|   flex: 1; | ||||
|   overflow: auto; | ||||
| } | ||||
|  | ||||
| .billboard-attribute-box .DIV-cy-tabs .DIV-cy-tab-content::-webkit-scrollbar { | ||||
|   width: 8px; | ||||
|   height: 8px; | ||||
| } | ||||
|  | ||||
| .billboard-attribute-box .DIV-cy-tabs .DIV-cy-tab-content::-webkit-scrollbar-thumb { | ||||
|   border-radius: 5px; | ||||
|   -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2); | ||||
|   background-color: rgba(var(--color-sdk-base-rgb)); | ||||
| } | ||||
|  | ||||
| .billboard-attribute-box .DIV-cy-tabs .DIV-cy-tab-content::-webkit-scrollbar-track { | ||||
|   -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2); | ||||
|   border-radius: 5px; | ||||
|   background-color: rgba(var(--color-sdk-base-rgb), 0.1); | ||||
| } | ||||
|  | ||||
| .billboard-attribute-box .DIV-cy-tabs .DIV-cy-tab-content-pane { | ||||
|   width: 100%; | ||||
|   height: 100%; | ||||
| } | ||||
|  | ||||
| .billboard-attribute-box .DIV-cy-tabs .DIV-cy-tab-content-pane iframe { | ||||
|   border: none; | ||||
| } | ||||
|  | ||||
| .billboard-attribute-box .billboard-attribute-box-line { | ||||
|   position: absolute; | ||||
|   width: 0px; | ||||
|   /* border-left: 1px solid rgba(var(--color-sdk-base-rgb), 0.5); */ | ||||
|   border-left: 1px solid rgba(var(--color-sdk-base-rgb), 1); | ||||
|   /* transform: rotate(45deg); */ | ||||
|   transform-origin: 0px 0px; | ||||
|   -webkit-pointer-events: none; | ||||
|   -moz-pointer-events: none; | ||||
|   -ms-pointer-events: none; | ||||
|   -o-pointer-events: none; | ||||
|   pointer-events: none; | ||||
| } | ||||
|  | ||||
| .billboard-attribute-box .drag-nook { | ||||
|   position: absolute; | ||||
|   width: 12px; | ||||
|   height: 12px; | ||||
|   display: block; | ||||
|   user-select: none; | ||||
|   -webkit-pointer-events: auto; | ||||
|   -moz-pointer-events: auto; | ||||
|   -ms-pointer-events: auto; | ||||
|   -o-pointer-events: auto; | ||||
|   pointer-events: auto; | ||||
|   z-index: 3; | ||||
|   clip-path: polygon(0% 100%, 100% 100%, 50% 50%); | ||||
|   background-image: linear-gradient(to top, #ffffff 1px, #00000000 1px); | ||||
|   background-size: 100% 3px; | ||||
|   /* background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAJRJREFUWEftltsJgFAMQ5NNdBJ1Eh3NTdRJdJPIBQXF50/p/WgHSNNDCSGch877EQbyIyCpBtAa/cZEsj9qXwhImgEURgZA8rTzzkAiYGVgITm+ErC6/Ek3vycMAkHAnYCkAUDKAosZSTaeSZiCqIwgCgJBIG8CWyXzKySSZBGBu+afStYBqIxMfJdSo8WPslHJgsAKWjkmIRBy/c8AAAAASUVORK5CYII='); */ | ||||
| } | ||||
|  | ||||
| .billboard-attribute-box .drag-nook.left-top { | ||||
|   top: -6px; | ||||
|   left: -6px; | ||||
|   cursor: se-resize; | ||||
|   transform: rotate(-45deg); | ||||
|   display: none; | ||||
| } | ||||
|  | ||||
| .billboard-attribute-box .drag-nook.right-top { | ||||
|   top: -6px; | ||||
|   right: -6px; | ||||
|   cursor: ne-resize; | ||||
|   transform: rotate(45deg); | ||||
|   display: none; | ||||
| } | ||||
|  | ||||
| .billboard-attribute-box .table { | ||||
|   background-color: #ffffff00; | ||||
|   color: #ffffff; | ||||
|   overflow: hidden; | ||||
|   border: 1px solid rgba(var(--color-sdk-base-rgb), 0.5); | ||||
| } | ||||
|  | ||||
| .billboard-attribute-box .table .table-head .tr { | ||||
|   border-top: none; | ||||
|   border-left: none; | ||||
|   border-right: none; | ||||
| } | ||||
|  | ||||
| .billboard-attribute-box .table .tr { | ||||
|   display: flex; | ||||
|   border: 1px solid rgba(var(--color-sdk-base-rgb), 0.5); | ||||
|   border-right: none; | ||||
| } | ||||
| .billboard-attribute-box .table .tr .th, .billboard-attribute-box .table .tr .td { | ||||
|   border-right: 1px solid rgba(var(--color-sdk-base-rgb), 0.5); | ||||
|   display: flex; | ||||
|   justify-content: center; | ||||
| } | ||||
| .billboard-attribute-box .table .tr .th:last-child, .billboard-attribute-box .table .tr .td:last-child { | ||||
|   border-right: none; | ||||
| } | ||||
|  | ||||
|  | ||||
| .billboard-attribute-box .table .table-body .tr { | ||||
|   border-bottom: none; | ||||
|   border-left: none; | ||||
| } | ||||
|  | ||||
| .billboard-attribute-box .table .table-body .tr:first-child { | ||||
|   border-top: none; | ||||
| } | ||||
|  | ||||
| /* 自定义提示 */ | ||||
| #YJ-custom-message { | ||||
|   /* 固定在顶部中央 */ | ||||
|   position: fixed; | ||||
|   top: 0; | ||||
|   left: 50%; | ||||
|   transform: translate(-50%, 0%); | ||||
|   /* 初始位置在屏幕顶部外 */ | ||||
|  | ||||
|   /* 样式美化 */ | ||||
|   display: flex; | ||||
|   border-radius: 4px; | ||||
|   font-size: 14px; | ||||
|   padding: 15px 20px; | ||||
|   width: 380px; | ||||
|   box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); | ||||
|   z-index: 9999999; | ||||
|  | ||||
|  | ||||
|   /* 动画定义 */ | ||||
|   animation: YJ-custom-message-slideDown 0.5s forwards, | ||||
|     YJ-custom-message-fadeOut 0.5s 1500ms forwards; | ||||
| } | ||||
|  | ||||
| #YJ-custom-message i { | ||||
|   margin: 2px 10px 0 0; | ||||
|   display: flex; | ||||
|   align-items: center; | ||||
|   width: 16px; | ||||
| } | ||||
|  | ||||
| #YJ-custom-message.success { | ||||
|   background-color: #f0f9eb; | ||||
|   color: rgb(82, 196, 26); | ||||
| } | ||||
| #YJ-custom-message.warning { | ||||
|   background-color: #fdf6ec; | ||||
|   color: #e6a23c; | ||||
| } | ||||
|  | ||||
| /* 滑入动画 */ | ||||
| @keyframes YJ-custom-message-slideDown { | ||||
|   to { | ||||
|     top: 20px; | ||||
|     /* 移动到屏幕顶部 */ | ||||
|   } | ||||
| } | ||||
|  | ||||
| /* 淡出动画 - 1500ms后执行 */ | ||||
| @keyframes YJ-custom-message-fadeOut { | ||||
|   to { | ||||
|     opacity: 0; | ||||
|     top: -200px | ||||
|       /* 移回顶部外 */ | ||||
|   } | ||||
| } | ||||
|  | ||||
										
											Binary file not shown.
										
									
								
							Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user