Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

97
Views
XRController raycast distance issue

I've got a problem in THREEJS with the XR controller when I try to raycast object which are further thant 40 in distance. Under 40, the raycast works fine.

I relied on this example in threeJS : https://threejs.org/examples/webxr_vr_dragging.html

Someone know of a way to increase the distance of test for raycasting in WebXR?

Below is the code I'm using to instanciate the controller.

setControllerVR(groupCamera, renderer) {
        let context = this;
        let controller1 = renderer.xr.getController(0);
        controller1.addEventListener('selectstart', this.onSelectStart.bind(this));
        controller1.addEventListener('selectend', this.onSelectEnd.bind(this));
        controller1.addEventListener('connected', function (event) {

            this.add(context.buildController(event.data));

        });
        controller1.addEventListener('disconnected', function () {

            this.remove(this.children[0]);

        });
        groupCamera.add(controller1);
        this.controller1 = controller1;
    }

    buildController( data ) {

        let geometry, material;

        switch ( data.targetRayMode ) {

            case 'tracked-pointer':

                geometry = new THREE.BufferGeometry();
                geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( [ 0, 0, 0, 0, 0, - 1 ], 3 ) );
                geometry.setAttribute( 'color', new THREE.Float32BufferAttribute( [ 0.5, 0.5, 0.5, 0, 0, 0 ], 3 ) );

                material = new THREE.LineBasicMaterial( { vertexColors: true, blending: THREE.AdditiveBlending } );

                return new THREE.Line( geometry, material );

            case 'gaze':

                geometry = new THREE.RingGeometry( 0.02, 0.04, 32 ).translate( 0, 0, - 1 );
                material = new THREE.MeshBasicMaterial( { opacity: 0.5, transparent: true } );
                return new THREE.Mesh( geometry, material );

        }

    }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

To increase the distance was simpler than I first thought.

You juste need to increase the scale of the line on the Z axis like :

geometry.scale(1,1, 100);

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!