Commit f2c64205 by wanghao

同步代码

parent 645dd9f1
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Mars3D三维可视化平台 mars3d * Mars3D三维可视化平台 mars3d
* *
* 版本信息:v3.6.5 * 版本信息:v3.6.5
* 编译日期:2023-09-08 17:15:08 * 编译日期:2023-09-12 12:41:31
* 版权所有:Copyright by 火星科技 http://mars3d.cn * 版权所有:Copyright by 火星科技 http://mars3d.cn
* 使用单位:免费公开版 ,2023-03-17 * 使用单位:免费公开版 ,2023-03-17
*/ */
...@@ -1016,15 +1016,3 @@ ...@@ -1016,15 +1016,3 @@
margin-left: -6px; margin-left: -6px;
border-right-color: rgba(63, 72, 84, 0.9); border-right-color: rgba(63, 72, 84, 0.9);
} }
.mars3d-widgetbar {
margin: 0 auto;
position: absolute;
bottom: 30px;
left: 20%;
width: 60%;
height: auto;
z-index: 1987;
}
.mars3d-widgetbar .fa {
margin-right: 5px;
}
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
// 移动位置、旋转 3dtiles
class TilesEditor extends mars3d.BaseClass {
//= ========= 构造方法 ==========
constructor(options) {
super(options)
this.options = options
this.map = options.map
this.scene = this.map.scene
this._position = options.position
this._heading = options.heading || 0
this._range = options.range || 100
this.dragging = false
this.rotating = false
this._enabled = false
this.billboards = this.map.scene.primitives.add(new Cesium.BillboardCollection())
this.handler = new Cesium.ScreenSpaceEventHandler(this.map.canvas)
// 用来平移位置的指示器
this.movep = this.billboards.add({
position: this.position,
color: Cesium.Color.fromCssColorString("#FFFF00"),
image: options.moveImg,
show: false,
disableDepthTestDistance: Number.POSITIVE_INFINITY
})
// 用来旋转的指示器
this.rotatep = this.billboards.add({
position: this.rotationPosition,
color: Cesium.Color.fromCssColorString("#FFFF00"),
image: options.rotateImg,
show: false,
disableDepthTestDistance: Number.POSITIVE_INFINITY
})
}
//= ========= 对外属性 ==========
// 启用状态
get enabled() {
return this._enabled
}
set enabled(val) {
this._enabled = val
if (val) {
this.handler.setInputAction((p) => {
this.handlerOnLeafDown(p)
}, Cesium.ScreenSpaceEventType.LEFT_DOWN)
this.handler.setInputAction((p) => {
this.handlerOnMouseMove(p)
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE)
this.handler.setInputAction((p) => {
this.handlerOnLeftUp(p)
}, Cesium.ScreenSpaceEventType.LEFT_UP)
this.rotatep.show = true
this.movep.show = true
} else {
this.handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_DOWN)
this.handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE)
this.handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_UP)
this.rotatep.show = false
this.movep.show = false
}
}
// 移动位置的图标位置
get position() {
return this._position
}
set position(value) {
this._position = value
this.movep.position = this.position
this.rotatep.position = this.rotationPosition
}
// 旋转方向的图标位置(依据位置和朝向计算)
get rotationPosition() {
if (this._position) {
return mars3d.PointUtil.getPositionByDirectionAndLen(this._position, this._heading, this._range)
} else {
return null
}
}
get heading() {
return this._heading
}
set heading(value) {
this._heading = value
if (this._position) {
this.rotatep.position = this.rotationPosition
}
}
get range() {
return this._range
}
set range(value) {
this._range = value
if (this._position) {
this.rotatep.position = this.rotationPosition
}
}
//= ========= 方法 ==========
handlerOnLeafDown(event) {
const pickedObjects = this.scene.drillPick(event.position, 2)
for (let i = 0; i < pickedObjects.length; i++) {
const pickedObject = pickedObjects[i]
if (Cesium.defined(pickedObject) && pickedObject.primitive === this.movep) {
this.dragging = true
this.scene.screenSpaceCameraController.enableRotate = false
break
} else if (Cesium.defined(pickedObject) && pickedObject.primitive === this.rotatep) {
this.rotating = true
this.scene.screenSpaceCameraController.enableRotate = false
break
}
}
}
handlerOnMouseMove(event) {
const position = this.pickTerrain(event.endPosition)
if (!position) {
return
}
if (this.dragging) {
this.position = position
this.movep.position = this.position
this.rotatep.position = this.rotationPosition
this.fire(mars3d.EventType.change, {
position: this._position
})
} else if (this.rotating) {
this.rotatep.position = position
this._range = Cesium.Cartesian3.distance(this._position, position)
this._heading = mars3d.MeasureUtil.getAngle(this._position, position) // 模型是正东为0
this.fire(mars3d.EventType.change, {
heading: this._heading
})
}
}
handlerOnLeftUp(event) {
if (this.dragging || this.rotating) {
this.rotating = this.dragging = false
this.scene.screenSpaceCameraController.enableRotate = true
// 如果没有这句话 会导致billboards的某些没有刷新,无法再次点击
this.billboards._createVertexArray = true
}
}
pickTerrain(wndpos) {
const ray = this.map.camera.getPickRay(wndpos)
const pos = this.map.scene.globe.pick(ray, this.map.scene)
return pos
}
remove() {
// 从场景中移除
if (this.billboards) {
this.scene.primitives.remove(this.billboards)
this.billboards = undefined
}
this.rotatep.show = false
this.movep.show = false
}
destroy() {
this.remove()
this.handler.destroy()
// 删除所有绑定的数据
for (const i in this) {
delete this[i]
}
}
}
...@@ -228,9 +228,9 @@ function UIComponent() { ...@@ -228,9 +228,9 @@ function UIComponent() {
) )
useEffect(() => { useEffect(() => {
setTimeout(() => { // setTimeout(() => {
mapWork.showModel(inputUrl) // mapWork.showModel(inputUrl)
}, 1000) // }, 1000)
}, [inputUrl]) }, [inputUrl])
const checkedChange = useCallback((keys: any, item: any) => { const checkedChange = useCallback((keys: any, item: any) => {
...@@ -300,6 +300,10 @@ function UIComponent() { ...@@ -300,6 +300,10 @@ function UIComponent() {
mapWork.eventTarget.on("changeHeight", function (event: any) { mapWork.eventTarget.on("changeHeight", function (event: any) {
marsGuiRef.current.updateField("txtZ", event.alt) marsGuiRef.current.updateField("txtZ", event.alt)
}) })
mapWork.eventTarget.on("historyUrl", function (event: any) {
setInputUrl(event.url)
mapWork.showModel(inputUrl)
})
}, []) }, [])
return ( return (
...@@ -326,7 +330,7 @@ function UIComponent() { ...@@ -326,7 +330,7 @@ function UIComponent() {
style={{ width: "280px" }} style={{ width: "280px" }}
defaultValue={inputUrl} defaultValue={inputUrl}
onChange={(e) => { onChange={(e) => {
setInputUrl(e + "") setInputUrl(e.target.value + "")
}} }}
></MarsInput> ></MarsInput>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论