我正在尝试使用 argon.js 将 lla 坐标从预定义的参考系转换为本地坐标。向我推荐的方法(据我所知)要求我从一组 lla 中创建一个 cesium 实体,然后在使用其他 lla 创建后续 cesium 实体时使用该 ceisum 实体作为参考。
我尝试使用两种方法来做到这一点:第一种方法是在 argon.js 中创建参考 cesium 实体,第二种方法是创建一个带有 geopose 的 a-frame 实体,然后从 a-frame 实体的列表中获取 cesium 实体成分。我使用 argon.js 进行所有后续转换。
在这两种方法中,我都成功地创建了参考铯实体,并且(至少在我看来)转换后的铯实体包括参考实体作为它们的参考框架。但是,转换后的实体的 entityPose 仍然是 0,0,0。我的期望是参考实体将是 0,0,0,并且转换后的实体将具有相对于它的局部坐标(例如 4,8,10) . 此外,在每种情况下,实体的poseStatus 为0,但argon.js 文档仅列出了KNOWN = 1、FOUND = 2 和LOST = 4 的可能性。
我在下面包含了我的代码,以及检查员的一些反馈。返回的对象非常大,所以我只包含了我认为相关的内容,但如果我应该包含其他属性,请告诉我。另请注意,代码包含我上面列出的两个选项,第二个选项被注释掉了。
有关一些历史,请参见:
使用地理坐标而不是笛卡尔在 Argon 和 A-Frame 中绘制
<!DOCTYPE html>
<html>
<head>
<title>Hello world</title>
<script src="/socket.io/socket.io.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/geolocator/2.1.0/geolocator.js"></script>
<script src="arframe/main/resources/js/aframe.js"></script>
<script src="arframe/main/resources/js/argon.min.js"></script>
<script src="arframe/main/build.js"></script>
<script src="arframe/main/resources/js/CSS3DArgonRenderer.js"></script>
<script src="arframe/main/resources/js/CSS3DArgonHUD.js"></script>
<script src="arframe/main/resources/js/aframe-look-at-component.js"></script>
</head>
<body>
<h1>Hello world</h1>
<ar-scene>
<!--OPTION 2-->
<!-- <a-entity id='madRefFrame' referenceframe='lla: -84.31169 33.756128'></a-entity> -->
</ar-scene>
<script>
// OPTION 1
var app = Argon.init();
// OPTION 2
//var scene = document.querySelector('ar-scene');
//var app = scene.argonApp;
var Cesium = Argon.Cesium;
var Cartesian3 = Cesium.Cartesian3;
var ConstantPositionProperty = Cesium.ConstantPositionProperty;
var ReferenceFrame = Cesium.ReferenceFrame;
var ReferenceEntity = Cesium.ReferenceEntity;
app.context.setDefaultReferenceFrame(app.context.localOriginEastUpSouth);
app.updateEvent.addEventListener(function (frame) {
if (Argon.PoseStatus.KNOWN) {
// OPTION 1
var madRefData = { lla : { x : -84.31169, y : 33.756128, z : 299 }};
var madRef = Cartesian3.fromDegrees(madRefData.lla.x, madRefData.lla.y, madRefData.lla.z);
var options = { position: new ConstantPositionProperty(madRef, ReferenceFrame.FIXED),
orientation: Cesium.Quaternion.IDENTITY
};
var madRefEntity = new Cesium.Entity(options);
console.log('madRefEntity');
console.log(madRefEntity);
var madRefEntityPose = app.context.getEntityPose(madRefEntity);
console.log('madRefEntityPose');
console.log(madRefEntityPose);
// OPTION 2
// var madRefEL = document.querySelector('#madRefFrame');
// var madRefFrame = madRefEL.components['referenceframe'];
// var madRefEntity = madRefFrame.cesiumEntity;
//
// console.log('madRefEntity');
// console.log(madRefEntity);
//
// var madRefEntityPose = app.context.getEntityPose(madP1Entity);
//
// console.log('madRefEntityPose');
// console.log(madRefEntityPose);
// USED IN OPTIONS 1 AND 2
var madP1Data = { lla : { x : -84.31169, y : 33.755602, z : 297 }};
var madP1Ref = Cartesian3.fromDegrees(madP1Data.lla.x, madP1Data.lla.y, madP1Data.lla.z);
var options = { position: new ConstantPositionProperty(madP1Ref, madRefEntity),
orientation: Cesium.Quaternion.IDENTITY
};
var madP1Entity = new Cesium.Entity(options);
console.log('madP1Entity');
console.log(madP1Entity);
var madP1EntityPose = app.context.getEntityPose(madP1Entity);
console.log('madP1EntityPose');
console.log(madP1EntityPose);
} else {
// if we don't know the user pose we can't do anything
console.log("we don't know.");
return;
};
});
</script>
</body>
</html>
督察反馈:
A-Frame Version: 0.3.2
three Version: ^0.76.1
WebVR Polyfill Version: 0.9.15
Reality changed to: {"uri":"reality:empty","title":"Reality","providedReferenceFrames":["FIXED"]}
THREE.CSS3DArgonRenderer 76CSS3D
THREE.CSS3DArgonHUD 76CSS3D
THREE.WebGLRenderer 76
Reality changed to: {"uri":"reality:empty","title":"Reality","providedReferenceFrames":["FIXED"]}
reference frame changed to FOUND
madRefEntity
Object { _availability: undefined,
_id: "ae5fe824-12ea-4d7f-87e8-0eee0ca31008",
// METHOD 2
// _id: "madRefFrame"
_parent: undefined,
_propertyNames: Array[19],
...
_position:Object
_definitionChanged:Object
_referenceFrame:0
_value:Object
x:526169.6230387943
y:-5282445.040716821
z:3524154.8442182266
// METHOD 2
//x:526144.9834483624
//y:-5282197.673182507
//z:3523988.702129788
...
}
madRefEntityPose
Object { position : { x: 0, y: 0, z: 0 },
orientation: { w: 1, x: 0, y: 0, z: 0 },
time: {dayNumber: 2457689, secondsOfDay : 81280.139927485},
poseStatus: 0 }
madRefP1Entity
Object { _availability: undefined,
_id: "9ded96ab-961c-4ba3-b766-8c37e919877f",
...
_parent: undefined,
_position: object
_referenceFrame: object
_id: "ae5fe824-12ea-4d7f-87e8-0eee0ca31008",
// METHOD 2
// _id: "madRefFrame"
_orientation: object
_value: Object
_w: 1,
_x: 0,
_y: 0
_z: 0
...
_position: Object
_value:Object
x:526169.6230387943
y:-5282445.040716821
z:3524154.8442182266
// METHOD 2
//x:526144.9834483624
//y:-5282197.673182507
//z:3523988.702129788
...
...
...
_value:Object
x:526172.6715934229
y:-5282475.646478866
z:3524105.2236363157
...
}
madRefEntityPose
madRefEntityPose = { position : { x: 0, y: 0, z: 0 },
orientation: { w: 1, x: 0, y: 0, z: 0 },
time: {dayNumber: 2457689, secondsOfDay : 81281.12722016001},
poseStatus: 0 }