Code Monkey home page Code Monkey logo

Comments (6)

bnolan avatar bnolan commented on May 5, 2024

I'm using this. I want to put in a face -> ray intersection test, I'll probably appropriate the one from sylvester. I currently have a heightfield -> ray intersection function, but it only works for rays that are parallel to the y axis. ;D

  THREE.Ray = function ( origin, direction ) {
    this.origin = origin;
    this.direction = direction;
  }

  THREE.Ray.prototype = {
  };

  THREE.Ray.prototype.constructor = THREE.Ray;

from three.js.

bnolan avatar bnolan commented on May 5, 2024

I think this will work if I add getCenter() to the face class. It doesn't do a bounds test though.

intersection : function(face){
  var A = this.origin,
    D = this.direction,
    P = face.getCenter(),
    N = face.normal,

  multiplier = (N.x*(P.x-A.x) + N.y*(P.y-A.y) + N.z*(P.z-A.z)) / (N.x*D.x + N.y*D.y + N.z*D.z);
  return new THREE.Vector3([A.x + D.x*multiplier, A.y + D.y*multiplier, A.z + D.z*multiplier]);
}

from three.js.

mindlapse avatar mindlapse commented on May 5, 2024

i do face intersection tests in my new fork, the face center is not needed. Ideally I'd like to make the intersection check reusable, but everything is stowed away in ClickResolver.js right now.

from three.js.

mindlapse avatar mindlapse commented on May 5, 2024

Here is the commit for the 3d onclick detection / event handling:
http://github.com/mindlapse/three.js/commit/64e23a7204628998791bbd4db5d6d9355ccc1131

The code is still pretty new

from three.js.

mrdoob avatar mrdoob commented on May 5, 2024

Yeah. I'm struggling on what should be the right naming for all this...

Having a Ray.js as a base with the intersection methods there sounds like a good idea. Then maybe a Unproject to convert 2D coords to a 3D ray?

from three.js.

mrdoob avatar mrdoob commented on May 5, 2024

This is how it turned up:
https://github.com/mrdoob/three.js/blob/master/src/core/Ray.js

from three.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.