Git Product home page Git Product logo

geom-normals's Introduction

geom-normals

Compute normals for a simplicial complex geometry based on faces/cells information.

Installation

npm install geom-normals

Usage

import normals from "geom-normals";
import { plane } from "primitive-geometry";

const geometry = plane();

// Modify geometry.positions
// ...

// Recompute normals
normals(geometry.positions, geometry.cells, geometry.normals);

API

normals(positions, cells, [out]): normals

Parameters

  • positions: TypedArray | Array | Array<[x, y, z]> – simplicial complex geometry positions (eg. new Float32Array([x, y, z, x, y, z, ...])/new Array(x, y, z, x, y, z, ...) or new Array([x, y, z], [x, y, z], ...))
  • cells: TypedArray | Array | Array<[x, y, z]> – simplicial complex geometry cells (eg. new Uint32Array([a, b, c, a, b, c, ...])/new Array(a, b, c, a, b, c, ...) or new Array([a, b, c], [a, b, c], ...))
  • out (optional): TypedArray | Array | Array<[x, y, z]> – simplicial complex geometry normals to write to (eg. new Float32Array([x, y, z, x, y, z, ...])/new Array(x, y, z, x, y, z, ...) or new Array([x, y, z], [x, y, z], ...))

Returns

  • normals: TypedArray | Array | Array<[x, y, z]> – The normals parameter array updated (or created) with per vertex computed normals.

Note: If there are two vertices with the same position but different index there will be discontinuity (hard edge)

License

MIT. See license file.

geom-normals's People

Contributors

vorg avatar dmnsgn avatar

Stargazers

 avatar Roman avatar

Watchers

 avatar

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.