Put object inside viewing port in three.js
<p>Right now, I put my object in my 3D environment using</p>

<pre><code>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;
}
</code></pre>

<p>I want to place this object not just randomly, but randomly <em>inside the viewport of the user</em>. Anyone who knows how to do this? I'm using Pointer Lock Controls.</p>

<p>Update:
I've managed to place the object in the center of the viewing port, using</p>

<pre><code>object.position.x = 0;
object.position.y = 0;
object.position.z = -50;
object.position.applyMatrix4( camera.matrixWorld );
</code></pre>

<p>But I want it to appear on a random position in the camera view, so... not there yet...</p>