【发布时间】:2020-05-01 03:50:28
【问题描述】:
我想使用基于位置的标记来增强固定网络摄像头的图像。这将被添加到已经在其他部分使用three.js(通过react-three-fiber)的现有React 应用程序中,因此这些技术将被重用。
虽然计算标记(已知位置)相对于相机(已知位置)的位置很容易,我正在努力配置相机以获得“真实”对象和 AR 标记之间的良好视觉匹配。
我创建了一个 codesandbox with an artificial example 来说明挑战。
这是我配置相机的尝试:
const camera = {
position: [0, 1.5, 0],
fov: 85,
near: 0.005,
far: 1000
};
const bearing = 109; // degrees
<Canvas camera={camera}>
<Scene bearing={bearing}/>
</Canvas>
在场景组件的更下方,我正在根据网络摄像头的方位旋转相机,如下所示:
...
const rotation = { x: 0, y: bearing * -1, z: 0 };
camera.rotation.x = (rotation.x * Math.PI) / 180;
camera.rotation.y = (rotation.y * Math.PI) / 180;
camera.rotation.z = (rotation.z * Math.PI) / 180;
...
关于如何将相机配置为很好地匹配 three.js 框和现实生活对象的任何提示/想法?
【问题讨论】:
-
您考虑过 AR.js 及其 geoAR 功能吗?
-
我有。但首先它不完全是用例,其次我想使用 React 和 three.js。 AR.js 中基于位置的 AR 是基于
a-frame。
标签: three.js geolocation augmented-reality react-three-fiber