Giter VIP home page Giter VIP logo

ts-raycasting's Introduction

TS RayCasting

Travis

Raycast Example

Tutorial

Overview

TS RayCasting is tiny and fast raycast library written in Typescript.

API

castray-example

castRay(map, x, y, intersection, rayRot)

castRay(map: number[][], x: number, y: number, intersection: testintersection, rayRot: number): IRay

Will cast ray from position in map, which is two-dimensional world of numbers, where every number means a specific wall. To check if ray already hit a wall, there's intersection callback. If testfunction returns false, then it'll stop casting ray further and it means that wall was hit.

castRays(map, x, y, rot, intersection, config)

castRays(map: number[][], x: number, y: number, rot: number, intersection: testintersection, config: IRayConf = defaultConfig): IRay[]

Will cast several rays from position in map, which is two-dimensional world of numbers, where every number means a specific wall. rot is direction of camera or caster. To check if ray already hit a wall, there's intersection callback. If testfunction returns false, then it'll stop casting ray further and it means that wall was hit.

intersection(row, column, dist, index)

type testintersection = (row: number, column: number, dist: number, index: number) => boolean;

It's same callback in both castRay and castRays function, where is put a logic of hitting a wall. If testFunctions returns false, it'll stop casting ray further (specific ray, not all rays in castRays function).

Devs

  • npm run build build library, everything will be in dist/ folder
  • npm run build:web build minified raycast library for browser
  • npm run build:node build library with all declaration files
  • npm run build:example build examples
  • npm run lint lint all .ts files

ts-raycasting's People

Contributors

dderevjanik avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.