Nitrate Processed Mincemeat


    2.0.0 • Public • Published


    Build Status Dependency Status

    simple-raytracer works as a standalone version of the JS raytracer found in, which was inspired by jsRayTracer. It's presents a very simple interface to break a Ray Tracing job into multiple tasks that can be run sequentially or in parallel.

    What is Ray Tracing?

    tl;dr; In computer graphics, ray tracing is a technique for generating an image by tracing the path of light through pixels in an image plane and simulating the effects of its encounters with virtual objects.

    The original authors of jsRayTracer offer a great in depth explanation of how Ray Tracing works and how the core of this module performs it. Worth checking it out.

    If you would like to know more, wikipedia has your back

    What does this module offer

    A simple interface to execute a ray tracing job over a 'world' or 'scene' described in CSS, from scene parser, to job task partition, to the actual individual ray trace task and finally how to glue the results together so you can get your rendered image.

    A great place to start is by checking the examples folder to see how to run it using Node.js or using the browser only.


    /* require the module */
    const srt = require('simple-raytracer');
    /* load a scene */
    const scene = srt.prepareScene.byPath(<path/to/scene/file>);
    /* create individual tasks, each one is a work unit */
    const tasks = srt.prepareTasks({
      split: 20,
    /* use srt.runTask to execute each of them */
    const rayTraceResult = srt.runTask(scene, tasks[0]);

    Example of running it with Node

    You can find the example here, it is using pngjs to export the image to a .png to export the render to png. To run it simply do:

    git clone
    cd simple-raytracer
    npm i
    cd examples/node
    node index.js

    Example of running it in the browser with browserify

    You can find the example here. To run it simply do:

    git clone
    cd simple-raytracer
    npm i
    cd examples/browser
    node serve.js
    open your browser in http://localhost:9000


    This module was initialy developed as part of David Dias' M.Sc Thesis project, browserCloudjs, under supervision by Luís Veiga, Distributed Systems Group @ INESC-ID Lisboa , Instituto Superior Técnico, Universidade de Lisboa, with the support of Fundação para a Ciência e Tecnologia.

    More info on the team's work at:

    Additionall thanks to Diogo Cunha and Pierre Ozoux for creating and Igor Soarez for reviewing and helping me solve a gnarly bug :)


    npm i simple-raytracer

    DownloadsWeekly Downloads






    Unpacked Size

    201 kB

    Total Files


    Last publish


    • daviddias