Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

路径-室内漫游的2个路径数据? #96

Open
liyihongcug opened this issue Jan 18, 2021 · 4 comments
Open

路径-室内漫游的2个路径数据? #96

liyihongcug opened this issue Jan 18, 2021 · 4 comments

Comments

@liyihongcug
Copy link

pathPositions
pathRotations

"ref": "path",
"czmObject": {
"xbsjType": "Path",
"xbsjGuid": "8e547cc4-1a3f-4a9c-b569-a62c92290851",
"name": "Path路径属性窗口",
"positions": pathPositions,
"rotations": pathRotations,

能否解释下 rotations干啥用的? 是否相机使用的?
如果能解释path是如何实现的吗 ,感觉不是czml

@vtxf
Copy link
Collaborator

vtxf commented Jan 26, 2021

rotations是每个关键点上的朝向,默认[0, 0, 0], 朝东平视,是绑定的相机或者物体使用的;
和czml没有关系。

@liyihongcug
Copy link
Author

早上也刚弄明白这个知识点
代码 XbsjEarthv1.4.27/Apps/Examples/?menu=true&url=./earth-path-fly.html
"positions": [
[
1.9016746584889261,
0.5972140444354529,
540.3422462577171
],
[
1.9017267341518718,
0.5972133503414322,
520.1137699152557
],
[
1.9017257997179968,
0.5972736030398242,
528.3876170108886
],
[
1.9016747349263112,
0.5972754003153069,
521.087861389408
]
],
"rotations": [
[
6.868275118748086,
-0.2742692911775144,
0.0016584301080495578
],
[
5.703866308921896,
-0.19385405041989068,
6.281509509407803
],
[
3.8005195675504133,
-0.2597408290639396,
6.281339310424716
],
[
2.501667530825695,
-0.2173829253288364,
0.001819016773946025
]
],
这里很困惑,官方cesium例子里 是不用管相机的rotations的(参考最后的官方的代码)
能大致解释下你做的飞行 Position 和 rotation如何关联使用的吗, 如果能贴代码解释可能更好?
(另外确认一下,你用的是一个相机还是 用了主副两个相机)

我找出的官方飞行代码如下:
function computeCirclularFlight(lon, lat, radius) {
var property = new Cesium.SampledPositionProperty();
for (var i = 0; i <= 360; i += 45) {
var radians = Cesium.Math.toRadians(i);
var time = Cesium.JulianDate.addSeconds(
start,
i,
new Cesium.JulianDate()
);
var position = Cesium.Cartesian3.fromDegrees(
lon + radius * 1.5 * Math.cos(radians),
lat + radius * Math.sin(radians),
Cesium.Math.nextRandomNumber() * 500 + 1750
);
property.addSample(time, position);
//Also create a point for each sample we generate.
viewer.entities.add({
position: position,
point: {
pixelSize: 8,
color: Cesium.Color.TRANSPARENT,
outlineColor: Cesium.Color.YELLOW,
outlineWidth: 3,
},
});
}
return property;
}
//Compute the entity position property.
var position = computeCirclularFlight(-112.110693, 36.0994841, 0.03);
//Actually create the entity
var entity = viewer.entities.add({
//Set the entity availability to the same interval as the simulation time.
availability: new Cesium.TimeIntervalCollection([
new Cesium.TimeInterval({
start: start,
stop: stop,
}),
]),
//Use our computed positions
position: position,
//Automatically compute orientation based on position movement.
orientation: new Cesium.VelocityOrientationProperty(position),
//Load the Cesium plane model to represent the entity
model: {
uri: "Cesium_Air.glb",
minimumPixelSize: 64,
},
//Show the path as a pink line sampled in 1 second increments.
path: {
resolution: 1,
material: new Cesium.PolylineGlowMaterialProperty({
glowPower: 0.1,
color: Cesium.Color.YELLOW,
}),
width: 10,
},
});

@liyihongcug
Copy link
Author

function setRoamView() {
if (flyEntity) {
const center = flyEntity.position.getValue(viewer.clock.currentTime)
if (center) {
const vector = new Cesium.Cartesian3(target.x - center.x, target.y - center.y, 500)
viewer.camera.lookAt(center, vector)
}
}
}
viewer.scene.preUpdate.addEventListener(setRoamView) // 我使用preUpdate.addEventListener(setRoamView)
实现相同的功能但发现镜头无法鼠标切换,相机镜头能始终朝向大雁塔,但还是应该如例子一样鼠标能改变镜头

@liyihongcug
Copy link
Author

liyihongcug commented Feb 4, 2021

假期的努力没有白费,搞定了. viewer.scene.camera.setView({
destination: endPosition,
orientation: {
heading: heading,
pitch: pitch,
}
}); 可以解决这个问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants