Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
JINRUN-DP
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xinzhedeai
JINRUN-DP
Commits
4581e2b7
Commit
4581e2b7
authored
Nov 17, 2025
by
xinzhedeai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add:tileset加载,setview
parent
249f3edb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
100 additions
and
2 deletions
+100
-2
index.vue
src/views/index.vue
+100
-2
No files found.
src/views/index.vue
View file @
4581e2b7
...
...
@@ -14,6 +14,7 @@ export default {
version
:
"
3.8.9
"
,
// Cesium查看器实例
viewer
:
null
,
tileset
:
null
,
};
},
mounted
()
{
...
...
@@ -102,9 +103,31 @@ export default {
);
this
.
viewer
.
scene
.
primitives
.
add
(
tileset
);
console
.
log
(
"
tileset
"
,
tileset
);
console
.
log
(
"
倾斜摄影模型加载成功
"
,
tileset
);
if
(
tileset
)
{
this
.
tileset
=
tileset
;
this
.
locateToTileset
();
}
// tileset.allTilesLoaded.addEventListener(() => {
// this.tileset = tileset;
// console.log("All tiles are loaded");
// this.locateToTileset();
// });
// // // 监听模型加载完成事件
// tileset.readyPromise
// .then(() => {
// this.locateToTileset();
// })
// .catch((error) => {
// console.error("定位到模型失败:", error);
// });
console
.
log
(
"
tileset
"
,
this
.
tileset
);
}
catch
(
error
)
{
console
.
error
(
`
Error creating tileset
:
${
error
}
`
);
console
.
error
(
`
加载倾斜摄影模型失败
:
${
error
}
`
);
}
console
.
log
(
"
Cesium地图初始化成功
"
);
...
...
@@ -112,6 +135,81 @@ export default {
console
.
error
(
"
Cesium地图初始化失败:
"
,
error
);
}
},
/**
* 获取倾斜摄影模型的经纬度并将摄像机视角转向模型上方
*/
locateToTileset
()
{
if
(
!
this
.
tileset
||
!
this
.
viewer
)
{
console
.
error
(
"
模型或视图未准备就绪
"
);
return
;
}
try
{
// 获取模型的边界球
const
boundingSphere
=
this
.
tileset
.
boundingSphere
;
if
(
!
boundingSphere
)
{
console
.
error
(
"
无法获取模型边界
"
);
return
;
}
// 获取模型中心点的笛卡尔坐标
const
center
=
boundingSphere
.
center
;
// 将笛卡尔坐标转换为经纬度坐标
const
cartographic
=
Cesium
.
Cartographic
.
fromCartesian
(
center
);
const
longitude
=
Cesium
.
Math
.
toDegrees
(
cartographic
.
longitude
);
const
latitude
=
Cesium
.
Math
.
toDegrees
(
cartographic
.
latitude
);
const
height
=
cartographic
.
height
;
console
.
log
(
"
倾斜摄影模型中心点经纬度:
"
,
{
longitude
:
longitude
,
latitude
:
latitude
,
height
:
height
,
});
// 计算合适的观察距离 - 基于模型半径的倍数
const
distance
=
boundingSphere
.
radius
*
2.5
;
// 可以根据需要调整倍数
// 设置相机位置在模型上方
const
cameraPosition
=
Cesium
.
Cartesian3
.
fromRadians
(
cartographic
.
longitude
,
cartographic
.
latitude
,
height
+
distance
// 相机高度为模型最高点加上观察距离
);
// 计算相机看向模型中心的方向
const
heading
=
Cesium
.
Math
.
toRadians
(
0
);
// 方向角
const
pitch
=
Cesium
.
Math
.
toRadians
(
-
60
);
// 俯仰角 - 负数表示向下看
const
roll
=
Cesium
.
Math
.
toRadians
(
0
);
// 翻滚角
// 使用flyTo方法平滑过渡到目标位置
this
.
viewer
.
camera
.
flyTo
({
destination
:
cameraPosition
,
orientation
:
{
heading
:
heading
,
pitch
:
pitch
,
roll
:
roll
,
},
duration
:
2
,
// 过渡时间2秒
complete
:
()
=>
{
console
.
log
(
"
相机已成功定位到模型上方
"
);
},
});
// 或者使用lookAt方法直接看向模型中心
// this.viewer.camera.lookAt(
// center,
// new Cesium.HeadingPitchRange(
// heading,
// pitch,
// distance
// )
// );
}
catch
(
error
)
{
console
.
error
(
"
定位到模型上方失败:
"
,
error
);
}
},
},
};
</
script
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment