Note that there are some explanatory texts on larger screens.

plurals
  1. POThree.js - troubles with the size of texture
    primarykey
    data
    text
    <p>Less words, more code =)</p> <pre><code>var objects = []; var camera, scene, renderer; document.addEventListener( 'mousedown', onDocumentMouseDown, false ); init(); render(); function onDocumentMouseDown( event ) { event.preventDefault(); var vector = new THREE.Vector3( ( event.clientX / window.innerWidth ) * 2 - 1, - ( event.clientY / window.innerHeight ) * 2 + 1, 0.5 ); projector.unprojectVector( vector, camera ); var ray = new THREE.Ray( camera.position, vector.subSelf( camera.position ).normalize() ); var intersects = ray.intersectObjects( objects ); if ( intersects.length &gt; 0 ) { console.log(intersects[ 0 ].object); } } function init() { container = document.getElementById( 'container' ); scene = new THREE.Scene(); camera = new THREE.PerspectiveCamera( 90, window.innerWidth / window.innerHeight, 1, 1100 ); camera.position.z = 50; scene.add( camera ); var particle = new THREE.Particle( new THREE.ParticleBasicMaterial( { map: THREE.ImageUtils.loadTexture( "img/satellite.png" ) } ) ); objects.push( particle ); //particle.scale.x = particle.scale.y = 0.25 scene.add( particle ); projector = new THREE.Projector(); renderer = new THREE.CanvasRenderer(); renderer.setSize( window.innerWidth, window.innerHeight ); container.appendChild( renderer.domElement ); } function render() { camera.lookAt( scene.position ); renderer.render( scene, camera ); } </code></pre> <p>As a result, we get clickable particle with a texture. But I don't understand several things:</p> <ol> <li><p>Why the "clickable" area of particle is so small? It works only if I click in the middle of a particle.</p></li> <li><p>Why is that particle so huge? The texture is this <img src="https://habrastorage.org/storage2/932/6cd/613/9326cd613aa9b4afe2f048ad67004aab.png" alt="16×16"> .png file and the particle is way more bigger than 16×16. How can I fix that? Yes, I know about particle.scale, that will make particle look smaller. But, the "clickable" area of particle woukd also become smaller.</p></li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload