Skip to content

Instantly share code, notes, and snippets.

@automat
automat / obj2json.js
Created July 14, 2015 15:41
obj2JSON
//Parses .obj file, returns .json
var colors = require('colors'),
argv = require('minimist')(process.argv.slice(2),{string:['o','m','p']}),
fs = require('fs'),
path = require('path');
function logUsageAndExit(){
console.log(('Usage: [pathToObjFile] -o [pathToOutJson] [-m] [-p]').yellow);

###pex-gl

  • all gl related obj wrappers

  • class namespace vs method namepspace

    var gl = require('pex-gl');
    
    var Mesh = gl.Mesh;
    

var Program = gl.Program;

#General

###Private/Public/Explicitness

  • private vs public members vs user trust vs clarity

###Documentation

  • proper documentation for every single core module, should develop into habit, i like jsdoc ;), can do:
@automat
automat / v8_related
Created August 29, 2014 10:58
v8_related
@automat
automat / README.md
Last active August 29, 2015 14:05
Canvas - Flush fill vs. direct fill

Canvas - Flush fill vs. direct fill

A quick test to see if filling group of shapes is more performant than filling each shape separately. FillStyle is wrapped to imitate the processing api, in 'normal' mode 'fill' just sets the current fillStyle, ellipse() constructs a new path via 'beginPath' and immediately closes it by applying the fillStyle with 'fill'. In 'flush' mode 'fill' already begins to construct a new path via 'beginPath' right after setting the fillStyle. All subsequent calls to ellipse only append new path segments to the same path. The current path gets closed by calling 'fill' again or automatically right after draw().

@automat
automat / README.md
Last active August 29, 2015 14:05
Canvas - Drawing command stack - write pixels

Canvas - Drawing command stack - write pixels

Drawing thousands of instances via direct pixel manipulation. Slow.

@automat
automat / README.md
Created August 16, 2014 20:42
Canvas - Drawing command stack - cached image

Canvas - Drawing command stack - cached image

Draw-calls are stacked and processed at the end of the draw loop. The shape to be drawn is rendered on an off-screen canvas, if the required shape is larger than the buffered one, the off-screen version gets updated otherwise a scaled down version will be drawn on the target canvas. Colored versions of the off-screen shape are stored into a lookup-table and updated if the base shape changes.

Obviously this works best if the color palette is limited.

@automat
automat / README.md
Created August 16, 2014 20:42
Canvas - Drawing command stack

Canvas - Drawing command stack

A quick test to check if merging immediate mode draw method calls on the fly and batch executing them at the end of each draw loop (to reduce the number of fill / beginPath / endPath calls to a minimum ) does yield to performance benefits.

Unfortunately processing the stack is really slow.

@automat
automat / app.js
Last active January 4, 2016 04:09
Queued worker test
function App(){
this._queue = [];
this._queueProcessing = false;
this._worker = new Worker('worker.js');
var self = this;
this._worker.addEventListener('message', function(e){
var returnObj;
var dataObj = e.data;