Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8734127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:46:49+00:00 2026-06-13T09:46:49+00:00

I have building project with three.js… canvas where you can drag object and play

  • 0

I have building project with three.js… canvas where you can drag object
and play with the camera view as well… there is a famous example- "Draggable Cubes",
well my project is pretty similar.

On my project there are 3 main events: mouseup /mousedown/ mousemove…

Well everything was ok….but now I’m trying to run this code on iPhone,changing my events
with touchstart / touchmove / touchend…

The moving object function seems to work fine, but when I’m trying to select the object by clicking him,
it’s always the same object that been selected… and not the one I’m pointing on….

I guess the problem is with this function:

function onDocumentMouseDown( event ) {

            event.preventDefault();

            var vector = new THREE.Vector3( mouse.x, mouse.y, 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 > 0 ) {

                SELECTED = intersects[ 0 ].object;

                var intersects = ray.intersectObject( plane );
                offset.copy( intersects[ 0 ].point ).subSelf( plane.position );

            }
}

Is anybody have an idea what is the problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T09:46:50+00:00Added an answer on June 13, 2026 at 9:46 am

    in this line :

    var vector = new THREE.Vector3( mouse.x, mouse.y, 0.5 );
    

    You use the mouse Vector2 object but you don’t initialize it.

    Something like this should work :

    mouse.x = +(event.targetTouches[0].pageX / window.innerwidth) * 2 +-1;
    
    mouse.y = -(event.targetTouches[0].pageY / window.innerHeight) * 2 + 1;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a game project where there are simple container objects that can have
In my VB.NET project I have three configurations DEBUG|TEST|RELEASE. Currently when I am building
Let's imagine I already have a project building .NET 3.5 assembly. Now I want
I have a bit of a problem building my project. I'm getting the bellow
I seem to have hit a snag while building my project using Ant. The
I'm using qmake for building a project of mine. I have been trying to
I have an ARM project that I'm building with make. I'm creating the list
I have a C++ project I am building in VS2008. This project also links
I have an old C++ project and I'm having problem building it. For a
Currently I have a simple maven project that is building a jar file and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.