Git Product home page Git Product logo

four-points-controls's Introduction

four-points-controls

Allows you to orient an object in 3D using positions of four points of its local XY plane in the camera plane. Get it from NPM or CDN and then just:

const controls = FourPointsControls( camera, renderer.domElement );
controls.add( mesh ); // your 3D object to orient
scene.add( controls );

Demo

https://makc.github.io/four-points-controls/

API

// camera: an active instance of PerspectiveCamera
// element: optional HTMLElement to add pointer listeners to; if
// not specified, no handles are created and you are responsible
// for updating controls.points values
const controls = FourPointsControls( camera, element );

// four points in the camera plane, set by controls UI if element
// was specified, or by you (both x and y should be normalized to
// -1...1 range
controls.points = [...];

// currently active corner, 0...3 (see exact3 comment below)
const index = controls.currentPoint;

// a method of pose calculation (see below for supported values)
controls.method = ...;

Methods

  • FourPointsControls.exact3
    calculates exact fit of three points and minimizes fourth point reprojection error (this is similar to opencv SOLVEPNP_P3P method); three points used are those around the active corner

  • FourPointsControls.exact3.average
    experimental; calculates approximate fit of four points by averaging the results of FourPointsControls.exact3 for every point

  • FourPointsControls.exact4
    default; calculates exact fit of four points, but sacrifices the transformation orthonormality (this works best with flat or near-flat objects)

  • FourPointsControls.exact4.diamond
    experimental; tweaks the results of FourPointsControls.exact4 to equalize the lengths of X and Y axes

  • FourPointsControls.opencv
    calculates approximate fit of four points using opencv SOLVEPNP_IPPE_SQUARE method (you will need to preload ~9 MB opencv.js build to use this option)

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.