I’ve posted a similar question in another forum, but I wanted to provide more clarity on the issue I'm facing.
What's my objective? I am currently using three.js within a WebView on my android device to create a scene that consists of a simple box (intended for use as a bounding box) and a camera. The camera needs to be interactive with the android device, allowing me to dynamically set its position by moving the device. These position vectors are generated by a SLAM algorithm called Direct Sparse Odometry, which calculates the camera's position. I can access these values through JavaScript using the provided WebViewInterface from Android. My goal is to move around the box without having to manually adjust the camera's orientation every time I change the values. The view should dynamically adjust based on the camera's position and rotation relative to the object, akin to an Augmented Reality application. Ultimately, I aim to overlay virtual objects onto real-world objects using three.js for later scanning with DSO by circling the box to detect feature points.
What is DSO? DSO is a library used to track the real environment by identifying points from camera frames captured by Android's Camera 2 API. It provides a 4x4 transformation matrix representing the current pose, which I attempt to apply to the camera's position in three.js. Despite various attempts, including scaling the values, I continue to encounter a problem where the box lacks a fixed absolute position and seems to move in the opposite direction each time it's placed.
What's the issue? Despite my efforts to resolve discrepancies by adjusting the DSO values, I have determined that the problem lies within the implementation of three.js itself. I've experimented with applying matrices to the scene/camera and making the box a child object, yet the box still fails to maintain an absolute position within the scene. Additionally, I've struggled to achieve realistic rotations of the object.
You'll find my code below, though please note that I've substituted dynamic dummy values for the actual DSO data:
<body>
<canvas id="mCanvas">
</canvas>
</body>
<script>
// Code snippet included here
</script>
Any suggestions or insights would be greatly appreciated. Thank you!
Best regards,