Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cesium-frame
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
jlc
cesium-frame
Commits
be9b10a4
Commit
be9b10a4
authored
Aug 05, 2024
by
jlc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:动目标船案例的修改
parent
23e89783
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
60 deletions
+66
-60
Ship.png
src/assets/Ship.png
+0
-0
ship-function.js
src/examples/movingTarget/ship/ship-function.js
+53
-58
ship.vue
src/examples/movingTarget/ship/ship.vue
+13
-2
No files found.
src/assets/Ship.png
View replaced file @
23e89783
View file @
be9b10a4
54.2 KB
|
W:
|
H:
531 KB
|
W:
|
H:
2-up
Swipe
Onion skin
src/examples/movingTarget/ship/ship-function.js
View file @
be9b10a4
export
function
addShip
(
viewer
)
{
export
function
addShip
(
viewer
)
{
const
czml
=
[
let
start
=
Cesium
.
JulianDate
.
fromDate
(
new
Date
());
// 设置时间轴当前时间为开始时间
{
start
=
Cesium
.
JulianDate
.
addHours
(
start
,
8
,
new
Cesium
.
JulianDate
());
// 开始时间加8小时改为北京时间
id
:
"document"
,
let
stop
=
Cesium
.
JulianDate
.
addSeconds
(
start
,
400
,
new
Cesium
.
JulianDate
());
// 设置结束时间为开始时间加400秒
name
:
"Ship"
,
version
:
"1.0"
,
viewer
.
clock
.
startTime
=
start
.
clone
();
// 设置时钟开始时间
clock
:
{
viewer
.
clock
.
currentTime
=
start
.
clone
();
// 设置时钟当前时间
interval
:
"2019-08-28T04:00:00Z/2019-08-28T04:20:00Z"
,
viewer
.
clock
.
stopTime
=
stop
.
clone
();
// 设置时钟结束时间
currentTime
:
"2019-08-28T04:00:00.00Z"
,
viewer
.
clock
.
multiplier
=
1
;
// 设置时间倍数
multiplier
:
1
,
viewer
.
timeline
.
zoomTo
(
start
,
stop
);
// 时间轴绑定到viewer上去
range
:
"LOOP_STOP"
,
viewer
.
clock
.
clockRange
=
Cesium
.
ClockRange
.
LOOP_STOP
;
// 循环执行,到达终止时间,重新从起点时间开始
step
:
"SYSTEM_CLOCK_MULTIPLIER"
}
},
{
id
:
"path"
,
name
:
"path for Ship"
,
description
:
"<p>this is a ship</p>"
,
availability
:
"2019-08-28T04:00:00Z/2019-08-28T04:20:00Z"
,
path
:
{
material
:
{
polylineOutline
:
{
color
:
{
rgba
:
[
255
,
0
,
255
,
255
],
},
outlineColor
:
{
rgba
:
[
0
,
255
,
255
,
255
],
},
outlineWidth
:
5
},
},
width
:
8
,
// 折线宽度
leadTime
:
5
,
trailTime
:
50000
,
resolution
:
5
,
},
orientation
:
{
"velocityReference"
:
"#position"
},
model
:
{
gltf
:
'https://raw.githubusercontent.com/jinlinchao123/Cesium-assets/main/3Dmodel/ship.glb'
,
minimumPixelSize
:
128
,
},
position
:
{
epoch
:
"2019-08-28T04:00:00.00Z"
,
cartographicDegrees
:
[
0
,
140
,
30
,
0
,
1200
,
143
,
30
,
0
]
}
},
];
var
dataSourcePromise
=
viewer
.
dataSources
.
add
(
Cesium
.
CzmlDataSource
.
load
(
czml
));
// 生成路径
dataSourcePromise
.
then
(
function
(
dataSource
)
{
function
computeFlight
(
source
)
{
// 根据模型所在的实体去进行加载
let
property
=
new
Cesium
.
SampledPositionProperty
();
viewer
.
trackedEntity
=
dataSource
.
entities
.
getById
(
'path'
);
for
(
let
i
=
0
;
i
<
source
.
length
;
i
++
)
{
}).
catch
(
function
(
error
)
{
let
time
=
Cesium
.
JulianDate
.
addSeconds
(
start
,
source
[
i
].
time
,
new
Cesium
.
JulianDate
);
console
.
error
(
error
);
let
position
=
Cesium
.
Cartesian3
.
fromDegrees
(
source
[
i
].
longitude
,
source
[
i
].
latitude
,
source
[
i
].
height
);
// 添加位置,和时间对应
property
.
addSample
(
time
,
position
);
}
return
property
;
}
let
data
=
[
{
longitude
:
121
,
latitude
:
33
,
height
:
0
,
time
:
0
},
{
longitude
:
123
,
latitude
:
32
,
height
:
0
,
time
:
180
},
{
longitude
:
122
,
latitude
:
31
,
height
:
0
,
time
:
400
}
]
let
property
=
computeFlight
(
data
);
let
entity
=
viewer
.
entities
.
add
({
availability
:
new
Cesium
.
TimeIntervalCollection
([
new
Cesium
.
TimeInterval
({
start
:
start
,
stop
:
stop
})]),
position
:
property
,
orientation
:
new
Cesium
.
VelocityOrientationProperty
(
property
),
// 根据速度计算方向角
model
:
{
uri
:
'https://raw.githubusercontent.com/jinlinchao123/Cesium-assets/main/3Dmodel/ship.glb'
,
//gltf文件的URL
scale
:
0.05
,
// 放大倍数
silhouetteColor
:
Cesium
.
Color
.
fromCssColorString
(
'rgba(0, 255, 0, 1)'
),
// 船模型边框颜色
silhouetteSize
:
1
,
// 船模型边框宽度
minimumPixelSize
:
128
},
path
:
{
// 船路径
resolution
:
1
,
material
:
new
Cesium
.
PolylineGlowMaterialProperty
({
glowPower
:
0.1
,
// 颜色透明度
color
:
Cesium
.
Color
.
fromCssColorString
(
'rgba(0, 253, 239, 0.5)'
)
// 路线颜色
}),
width
:
2
// 路线的显示宽度
}
});
});
}
viewer
.
trackedEntity
=
entity
;
// 视角跟随模型
}
\ No newline at end of file
src/examples/movingTarget/ship/ship.vue
View file @
be9b10a4
...
@@ -15,8 +15,19 @@ onMounted(() => {
...
@@ -15,8 +15,19 @@ onMounted(() => {
window
.
Cesium
.
Ion
.
defaultAccessToken
=
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI3Njg4ZWU5Yi1iZDhiLTRhYmUtOTRiYS04YjM5NmUwNjVmMDMiLCJpZCI6MjI3MzQ3LCJpYXQiOjE3MjA1MjA4Mjh9.E5XW4LnwgfVAaBC-znaYr61m4yK0-j2qEQhi9qwFFPE'
window
.
Cesium
.
Ion
.
defaultAccessToken
=
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI3Njg4ZWU5Yi1iZDhiLTRhYmUtOTRiYS04YjM5NmUwNjVmMDMiLCJpZCI6MjI3MzQ3LCJpYXQiOjE3MjA1MjA4Mjh9.E5XW4LnwgfVAaBC-znaYr61m4yK0-j2qEQhi9qwFFPE'
viewer
=
new
window
.
Cesium
.
Viewer
(
'cesiumContainer'
,
{
viewer
=
new
window
.
Cesium
.
Viewer
(
'cesiumContainer'
,
{
infoBox
:
false
,
baseLayerPicker
:
false
,
// 影像切换
shouldAnimate
:
true
animation
:
true
,
//是否显示动画控件
timeline
:
false
,
//是否显示时间线控件
infoBox
:
false
,
//是否显示点击要素之后显示的信息
geocoder
:
false
,
//是否显示地名查找控件
timeline
:
true
,
//是否启用时间线控件
fullscreenButton
:
false
,
shouldAnimate
:
true
,
navigationHelpButton
:
false
,
//是否显示帮助信息控件
terrainProvider
:
Cesium
.
createWorldTerrain
({
requestWaterMask
:
true
,
// required for water effects
requestVertexNormals
:
true
// required for terrain lighting
})
});
});
addShip
(
viewer
)
addShip
(
viewer
)
...
...
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