Right now, I put my object in my 3D environment using
object.position.y = 5;
object.position.x = getRandomInt(-90,100);
object.position.z = getRandomInt(-50,150);
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
I want to place this object not just randomly, but randomly inside the viewport of the user. Anyone who knows how to do this? I'm using Pointer Lock Controls.
Update: I've managed to place the object in the center of the viewing port, using
object.position.x = 0;
object.position.y = 0;
object.position.z = -50;
object.position.applyMatrix4( camera.matrixWorld );
But I want it to appear on a random position in the camera view, so... not there yet...