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 9020767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:06:05+00:00 2026-06-16T05:06:05+00:00

Hi i’m starting to work with webGL using Three.js and I need to detect

  • 0

Hi i’m starting to work with webGL using Three.js and I need to detect if a click on a sphere is within a certain section of it’s surface.

Currently i can detect if the sphere was clicked and get the coords of the point clicked. Now what i need is to detect if that click was in a certain region of that sphere, based on a array of 3D points from that sphere (another suggestion is ok).

The sphere is in the center point, and the point is garrantied to be on the surface of the sphere. Now i need to calculate if it’s just within a section section. Any suggestions? My problem seams to be more mathematical.
Also i prefere a generic way to do this because the sections may be just a triangle or may be more complex figures.

  • 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-16T05:06:06+00:00Added an answer on June 16, 2026 at 5:06 am

    I’ve ended using a different method then the suggestions.

    I’m using matrix determinants where: (T1, T2, T3) are points that form a triangle and X is the point i want to know if it’s inside this triangle, then i simple calculate 3 determinants where:

    d1 = det([T1 T2 X])
    d2 = det([T1 X T3])
    d3 = det([T1 T2 X])
    

    If all determinants are the same sign, then the point is inside the triangle.
    Now i form a list of triangles based on the selection area and check if the point is inside one of those triangles.

    this.Detector.triangleDetector = function(position, triangleArray){
        for(var idxString in triangleArray){
            var index = parseInt(idxString);
            if(this.pointInTriangle(position, triangleArray[index].coords1, triangleArray[index].coords2, triangleArray[index].coords3))
                return true;
        }
        return false;
    }
    

    The function pointInTriangle(x,t1,t2,t3) does the determinant verification.

    this.Detector.pointInTriangle = function(x,T1,T2,T3){
        var array1 = [coord1.x ,coord1.y ,coord1.z];
        var array2 = [coord2.x ,coord2.y ,coord2.z];
        var array3 = [coord3.x ,coord3.y ,coord3.z];
        var zero = 0;
        var A = [[zero,zero,zero],[zero,zero,zero],[zero,zero,zero]];
        var d1,d2,d3;
        A[0][0] = position.x;
        A[0][1] = position.y;
        A[0][2] = position.z;
        A[1][0] = array2[0];
        A[1][1] = array2[1];
        A[1][2] = array2[2];
        A[2][0] = array3[0];
        A[2][1] = array3[1];
        A[2][2] = array3[2];
        d1 = MyMath.determinant(A,3);
    
        A[0][0] = array1[0];
        A[0][1] = array1[1];
        A[0][2] = array1[2];
        A[1][0] = position.x;
        A[1][1] = position.y;
        A[1][2] = position.z;
        d2 = MyMath.determinant(A,3);
    
        A[1][0] = array2[0];
        A[1][1] = array2[1];
        A[1][2] = array2[2];
        A[2][0] = position.x;
        A[2][1] = position.y;
        A[2][2] = position.z;
        d3 = MyMath.determinant(A,3);
    
        if((d1>=0 && d2 >=0 && d3>=0) || (d1<=0 && d2 <=0 && d3<=0)){
            return true;
        }
        return false;
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have thousands of HTML files to process using Groovy/Java and I need to
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
In my XML file chapters tag has more chapter tag.i need to display chapters
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.