videojs / videojs-vr

A plugin to add 360 and VR video support to video.js.
https://videojs-vr.netlify.com/
MIT License
542 stars 144 forks source link

Add a spot point to point to change to another video #213

Open magix opened 4 years ago

magix commented 4 years ago

Description

  window.addEventListener('click', function (event) {
      // console.log("click---- " + event);
      // var intersects = getIntersects(event.layerX, event.layerY);
      // if (intersects.length > 0) {
      //   console.log("---- " + selectedObject);
      // }
    var mousex = (event.clientX / window.innerWidth) * 2 - 1;
    var mousey = -(event.clientY / window.innerHeight) * 2 + 1;

    var vector = new THREE.Vector3(mousex, mousey, 0.5).unproject(camera);

    var raycaster = new THREE.Raycaster(camera.position, vector.sub(camera.position).normalize());

    var intersects = raycaster.intersectObjects(objects);
    console.log('imtersrcts=' + intersects)

    if (intersects.length > 0) {

      SELECTED = intersects[0].object;
      var intersected = intersects[0].object;
      console.log(intersects[0].object)
    }

  });

}

Results

three.js:3556 Uncaught TypeError: Cannot read property 'elements' of undefined at Vector3.applyMatrix4 (three.js:3556) at Vector3.unproject (three.js:3598)

Expected

only i want to do is to raycast a object .to make change

Actual

unproject: function ( camera ) { return this.applyMatrix4( camera.projectionMatrixInverse ).applyMatrix4( camera.matrixWorld );

//debug this camera.projectionMatrixInverse is null? },

Error output

If there are any errors at all, please include them here.

Additional Information

versions

videojs

last version ;

three.js is lastest version

browsers

chrome

OSes

mac

plugins

import new three.js

magix commented 4 years ago

i found thereis a three.js in videojs-vr . i import a new three.js,

Luxcy commented 2 years ago

I got the same error as you. How do I fix it? Thanks. @magix

Luxcy commented 2 years ago

Thanks. I import * as THREE from 'videojs-vr/node_modules/three/build/three.js'. fix it.