Coder Social home page Coder Social logo

olagjo / nin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ninjadev/nin

0.0 1.0 0.0 37.42 MB

nin is ninjatool

Home Page: https://www.npmjs.com/package/ninjadev-nin

License: Apache License 2.0

Makefile 0.03% JavaScript 98.12% HTML 0.61% GLSL 0.02% CSS 1.22%

nin's Introduction

nin

DISCLAIMER: This is a tool created for internal use by Ninjadev, and is open sourced to share ideas with and get feedback from the community. You are free to use it, according to the License, but we will not necessarily provide support and may at any time add, change or remove features as we require for our productions.

nin is ninjatool

nin is Ninjadev's internal demo tool. It is a tool for easing development of browser-based WebGL demos. Core features include:

  • Node-based demotool, effortlessly reuse your effects, scenes, and create crazy transitions.
  • Livereloading of shaders and scenes in the browser. No more manual recompilation!
  • Tight THREE.js integration for all your WebGL needs.
  • Compile and pack your WebGL demo to a .png.html file for easy compo delivery

The backend component is written in node.js, and keeps track of and recompiles changed files. The frontend is created using React, and communicates with the backend over websockets.

User manual

Installing nin

To install nin simply run the command npm install -g ninjadev-nin. This projects requires node version 7.9.0 or newer. You can install node from packaging here or download zipped source from this page and verify signatures with the guide here;

You will also need git installed for project generation to work. New project created with nin get a default .eslintrc suitable for WebGL demos with THREE.js.

Getting started

Running nin new <dirname> will create the specified directory and initialize a new nin project inside. Running nin run inside the newly created project will make it accessible on http://localhost:8000.

nin creates a manifest file called nin.json. You should fill out this file with the title of your demo, the authors, a description, song metadata, and even a google analytics tracking code to collect statistics. The metadata is then used to generate html meta-tags in the head of the demo, as well as in the metadata segment of the .png.html file. The png metadata can be viewed with a command such as pngcheck -c -t -7 bin/demo.png.html on linux.

My First Node

Create a new node by clicking Generate -> THREE NODE in the frontend menu. The node will be placed in src/nodeName.js and added to the graph in res/graph.json. You must connect the node yourself to the output node. This is done by setting connected.screen to nodeName.render as in the example below, where nodeName is the id of the node you want to connect to the display.

{
    "id": "root",
        "type": "NIN.RootNode",
        "connected": {
            "screen": "nodeName.render"
        }
    }
}

Shaders

Create a shader by clicking Generate -> Shader Node in the frontend menu. It will be placed in the folder src/shaders/nameOfTheShader/. To get livereload on shader change, you shader must be specified in the options object of your node in res/graph.json, the shader generator will do this for you. If needed, you can access the shader through the global SHADERS object, by writing SHADERS.nameOfTheShader.

Compiling

The nin compile command will create a single file bin/demo.png.html that contains all the code and resources of your demo. Base64 and PNG compression magic is used to achieve this. It will at the same time output a file without PNG compression, bin/demo.html, which will be slightly larger, but compatible with a wider range of devices (especially smartphones). For faster compiles, pass the flag --no-closure-compiler. This will only concatenate js files, without any minifying.

.ninrc

Many of nin's settings can be overriden by placing a .ninrc file in your home directory. Currently, keyboard shortcuts is the only behavior which can be changed in the .ninrc. The list of canonical names for keybindings can be found in nin/frontend/app/scripts/directives/menubar.js.

An example .ninrc looks like the following:

[keybinds]
startRendering=left
stopRendering=right

Rendering to video

  1. nin run.
  2. Open nin in your browser, navigate to the frame you want to render from, and press R. This will start dumping single frames as numbered .PNGs in bin/render/ in your project folder.
  3. Refresh etc every time WebGL crashes.
  4. When you have rendered all the frames: nin render. You need ffmpeg (ffmpeg.org) installed for this.
  5. The demo is now available at bin/render/render.mp4.

Each frame will take up to around 4MB on disk, and the finished .mp4 will be on the order of 1GB when rendered, so make sure you have enough disk space. Expect to render maybe a frame or two per second.

Developer manual

Setup

You will need to have node, yarn and webpack installed. Yarn installation guide is available here. If you already have npm installed you can bootstrap to yarn by running npm install -g yarn. Install webpack by running npm install -g webpack.

Running make in the nin folder will build and compile the entire project. Running npm link will add nin to your node binaries path, making it available globally.

Developing

First, run nin run inside your project. If you wish to develop on the frontend, running make run inside nin/frontend/ makes webpack rebuild the frontend on file change. You only need to rerun nin run if you change files in either nin/dasBoot or nin/backend.

Linting

The frontend part of this project uses ESLint for linting. See the .eslintrc.js file in the frontend part of this project.

The demo itself and our own dasBoot uses the Google Closure Linter, please see this link for installation information. https://developers.google.com/closure/utilities/docs/linter_howto Use the --nojsdoc flag.

Testimonials / Reviews

nice! - mrdoob

Oh man, I didn't know you guys released your tools. I'm a big fan of your stuff -- awesome to see such polished prods on the web. Happy to have helped enable some amazing work! - daeken

Publishing nin

To publish nin type the command make publish. To be able to publish you need access to the ninjadev user on npm whose password will be given through secure channels.

List of known nin projects

nin's People

Contributors

sigvef avatar stianjensen avatar aleksanb avatar cristeahub avatar iver56 avatar peterhgombos avatar joms avatar lionleaf avatar

Watchers

Ola Gjønnes 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.