I'm using video.js https://videojs.com/ and https://videojs-vr.netlify.app/ to play a VR video. Video.js with the help of videojsvr can do this. Videojs-vr supports Three.js and can access three.js objects using this
var player = videojs('my-video');
player.vr().camera;
player.vr().scene;
player.vr().renderer;
I want to add a crosshair or any dot/circle in the middle of the video/scene that stay fixed even moving the screen within the 360 video. How can I achieve that?
I have the following code
// Add crosshair
addCrosshair() {
var self = this;
var player = self.get('player');
const cursor = new THREE.Mesh(
new THREE.RingBufferGeometry(0.2, 0.08, 30),
new THREE.MeshBasicMaterial({ color: "#FFFFFF", side: THREE.DoubleSide })
);
cursor.position.x = 0;
cursor.position.y = 0;
cursor.position.z = -8;
player.vr().scene.add(player.vr().camera)
player.vr().camera.add(cursor);
}
It seems to be doing what I need and the dot/small circle stays fixed in the center of the video/scene. However, it affects other three.js object I've placed in the video. It messes up with the rendering of other objects. I've got a theory that it happens because I'm adding the cursor/dot in another camera and then add it to the scene.
I've tried to do add it as another child of my other three.js objects. Although that seem to work too at first, if I move around the view within the 360 video, the cursor/dot doesn't stay fixed in the scene.
Hopefully my question make sense. If you don't have experience using videojs and video-vr.js, can you just help me to position a three.js object/crosshair at the center of the scene no matter where you move the camera view within the scene? Thank you so much in advance! Would be a big help to me.
Via Active questions tagged javascript - Stack Overflow https://ift.tt/nRNZYxk
Comments
Post a Comment