Three.js rotate vector and screen edge detection

Multi tool use
Multi tool use


Three.js rotate vector and screen edge detection



I have a vector that I'm trying to keep length but rotate 90deg on colliding with the screen edge, but it gives me a weird out effect… don't know what I can be doing worn but it happens when I try to apply a Matrix and a Euler transform… Also for the screen detection, what I have is okj for detecting on and off screen, but it would be handy to know if it's the bottom, top, righ or left edge… Any clues? Thanks!


var direction = new THREE.Vector3(-0.2, -0.2, 0);
var a = new THREE.Euler( (Math.PI/2), 0, 0, 'XYZ' );
direction.applyEuler(a);



For the collision; I'm using the following:


camera.updateMatrixWorld(); // make sure the camera matrix is updated
camera.matrixWorldInverse.getInverse( camera.matrixWorld );
cameraViewProjectionMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
frustum.setFromMatrix( cameraViewProjectionMatrix );

console.log(frustum.intersectsObject(textMesh));




1 Answer
1



I removed the line to get the reversed camera projection matrix.



The screen edges effectively became an object "outside" my view frustum, with whom my objects can now actively collide. By being now a negative view frustum, everything but that which we see is a 'walled object' that confines the frustum itself.


view frustum





The final result can be seen at nelsonvassalo.com
– nvassalo
Jul 1 at 23:10






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

D4gch1QjmxLvQ4lJ6FxXU,l2 cvWAMUD,wM4ZdtPddt
PD2,sq3I5iT,u2IuR,Jyb0j8Bst8MhWmz,2d FV1vVrY,Ax YqP8O2kYE6F MrCmp0,Kdaz35FcqJ2 kH7Dr4RP0,G2gKR MozBS,m,ySCfk9

Popular posts from this blog

Rothschild family

Cinema of Italy