Coder Social home page Coder Social logo

threejs-geometry-hittest's Introduction

threejs-geometry-hittest

This module provides a convenient method to check whether the given Geometry intersects with another object, in O(n) where n is the number of faces in the Geometry. This library could be useful for a project that don't need full-featured physics library but want to do some hit-test.

Following objects are supported:

  • Box3
  • Sphere

Please feel free to make pull requests, if you feel you can make this library better!

Example

const three = require('three');
const intersects = require('threejs-geometry-hittest').intersects;

// objects
const geometry = new three.BoxGeometry(1, 1, 1);
const box3 = new three.Box3(
	new three.Vector3(0.5, 0.5, 0.5),
	new three.Vector3(1.5, 1.5, 1.5)
);

// do hit-test. array returned.
const results = intersects(geometry, box3);

// indexes of faces intersecting with the box are printed to the console
for (const result of results) {
	console.log(`faceIndex = ${result.faceIndex}`);
}

threejs-geometry-hittest's People

Contributors

yvt avatar

Stargazers

hooke avatar Arif Hanif avatar Philippe Leefsma avatar

Watchers

James Cloos avatar Flávio Monteiro avatar  avatar  avatar

threejs-geometry-hittest's Issues

the inaccuracy in example

require('threejs-box-hittest'),
but your project is named "threejs-geometry-hittest".

Sorry for my English

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.