[
  {
    "path": ".gitignore",
    "content": ".DS_Store\n*~\nstuff\nexperiments\nnode_modules\n"
  },
  {
    "path": ".npmignore",
    "content": "/assets\nstuff\nexperiments"
  },
  {
    "path": "LICENSE.md",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2014 Marcin Ignac\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE."
  },
  {
    "path": "README.md",
    "content": "# Pex\n\nPEX is a collection of JavaScript modules the combination of which becomes a powerful 3D graphics library for the desktop and the web. This repository is currently **DEPRECATED**. \n\nPlease use [pex-context](https://github.com/pex-gl/pex-context) (stable) or [pex-renderer](https://github.com/pex-gl/pex-renderer) (beta).\n\n![Pex](assets/pex.jpg)\n\n\n"
  },
  {
    "path": "index.js",
    "content": "#!/usr/bin/env node\n\nvar program = require('commander');\nvar pkg = require(__dirname + '/package.json');\nvar version = pkg.version;\nvar init = require('./lib/init/init.js');\n\nvar args = process.argv.slice(2);\n\nprogram\n  .usage('[command] [options]')\n  .version(version)\n  .option('-f, --force', 'force on non-empty directory')\n\nprogram\n  .command('init [projectName]')\n  .description('generate example project')\n  .action(function(name) {\n    init.generate(name);\n  });\n\nprogram.on('--help', function(){\n  console.log('  Examples:');\n  console.log('');\n  console.log('    $ pex init projectName');\n  console.log('');\n});\n\nprogram.parse(process.argv);\n\nif (process.argv.length == 2) {\n  program.help();\n}\n\nvar destPath = program.args.shift() || '.';\n"
  },
  {
    "path": "lib/init/init.js",
    "content": "var aasciArt = (\n        '            _               _        _      _       \\n'\n        +'           /\\\\ \\\\            /\\\\ \\\\    /_/\\\\    /\\\\ \\\\    \\n'\n        +'          /  \\\\ \\\\          /  \\\\ \\\\   \\\\ \\\\ \\\\   \\\\ \\\\_\\\\   \\n'\n        +'         / /\\\\ \\\\ \\\\        / /\\\\ \\\\ \\\\   \\\\ \\\\ \\\\__/ / /   \\n'\n        +'        / / /\\\\ \\\\_\\\\      / / /\\\\ \\\\_\\\\   \\\\ \\\\__ \\\\/_/    \\n'\n        +'       / / /_/ / /     / /_/_ \\\\/_/    \\\\/_/\\\\__/\\\\    \\n'\n        +'      / / /__\\\\/ /     / /____/\\\\        _/\\\\/__\\\\ \\\\   \\n'\n        +'     / / /_____/     / /\\\\____\\\\/       / _/_/\\\\ \\\\ \\\\  \\n'\n        +'    / / /           / / /______      / / /   \\\\ \\\\ \\\\  \\n'\n        +'   / / /           / / /_______\\\\    / / /    /_/ /  \\n'\n        +'   \\\\/_/            \\\\/__________/    \\\\/_/     \\\\_\\\\/  \\n'\n);\n\nvar mkdirp = require('mkdirp');\nvar os = require('os');\nvar fs = require('fs');\nvar path = require('path');\nvar inquirer = require('inquirer');\nvar async = require('async');\nvar exec = require('child_process').exec;\n\nvar appName = 'pexample';\nvar eol = os.EOL;\n\nfunction loadTemplate(name) {\n  return fs.readFileSync(path.join(__dirname, '.', 'templates', name), 'utf-8');\n}\n\nvar mainfile    = loadTemplate('main.js');\nvar indexHTML   = loadTemplate('index.html');\nvar showNormalsVert     = loadTemplate('assets/ShowNormals.vert');\nvar showNormalsFrag     = loadTemplate('assets/ShowNormals.frag');\n\n\nmodule.exports.generate = function(destPath, options) {\n    options = options || {};\n    options.force = options.force || false;\n\n    appName = path.basename(path.resolve(destPath));\n    emptyDirectory(destPath, function(empty){\n        if (empty || options.force) {\n            createApplicationAt(destPath, options);\n        } else {\n            inquirer.prompt([\n                {\n                    type: 'confirm',\n                    name: 'deleteDestPath',\n                    message: 'destination path is not empty. continue?',\n                    default: false\n            }],\n\n            function(response){\n                if (response.deleteDestPath) {\n                    createApplicationAt(destPath, options);\n                } else {\n                    abort('aborting');\n                }\n            });\n        }\n    });\n};\n\nfunction isOnline(callback) {\n    require('dns').resolve('www.google.com', function(err) {\n        if (err) { callback(err, false); }\n        else callback(null, true);\n    });\n}\n\nfunction getPackageVersion(pkg, callback) {\n    var version = execSync('npm show ' + pkg.name + ' version');\n    version = version.trim();\n    return version;\n}\n\nvar pexPackages = require('../pkg/pex-packages-core');\n\nfunction getPackageVersion(packageInfo, callback) {\n    exec('npm show ' + packageInfo.name + ' version', function(err, stdout, stderr) {\n        var version = stdout.trim();\n        console.log('   \\x1b[36mmodule\\x1b[0m : ' +packageInfo.name + ' @ ' + version);\n        callback(null, version);\n    })\n}\n\nfunction generatePackageInfo(callback) {\n    isOnline(function(err, online) {\n        var pkg = {\n            name: appName,\n            version: '0.0.1',\n            private: true,\n            dependencies: {\n                'beefy':            '^2.1.5',\n                'browserify':       '^12.0.1',\n                'glslify-promise':  '^1.0.1',\n                'is-browser':       '^2.0.1',\n                'primitive-cube':   '^1.0.2'\n            }\n        }\n        function dummy(packageName, callback) {\n            callback(null, '*');\n        }\n        async.map(pexPackages, online ? getPackageVersion : dummy, function(err, results) {\n            pexPackages.forEach(function(packageInfo, packageIndex) {\n                pkg.dependencies[packageInfo.name] = '^' + results[packageIndex];\n            })\n            callback(null, pkg);\n        })\n    })\n}\n\nfunction createApplicationAt(path, options) {\n    var buildCommand = '';\n    console.log();\n    process.on('exit', function(){\n        console.log();\n        console.log(aasciArt);\n        console.log();\n        console.log(' don\\'t forget to install dependencies:');\n        console.log();\n        console.log('     $ cd %s', path);\n        console.log('     $ npm install');\n        console.log('     $ ' + buildCommand);\n        console.log();\n    });\n\n    mkdir(path, function() {\n        generatePackageInfo(function(err, pkg) {\n            pkg.scripts = {};\n            pkg.scripts.start = 'beefy main.js:main.web.js --open -- -i plask -g glslify-promise/transform';\n            pkg.scripts.build = 'browserify main.js -i plask -g glslify-promise/transform -o main.web.js';\n            buildCommand = 'npm start';\n            write(path + '/package.json', JSON.stringify(pkg, null, 2));\n            write(path + '/main.js', mainfile);\n            write(path + '/index.html', indexHTML);\n            mkdir(path + '/assets', function() {\n                write(path + '/assets/ShowNormals.vert', showNormalsVert);\n                write(path + '/assets/ShowNormals.frag', showNormalsFrag);\n            });\n        })\n    });\n}\n\nfunction copyTemplate(from, to) {\n  from = path.join(__dirname, '..', 'templates', from);\n  write(to, fs.readFileSync(from, 'utf-8'));\n}\n\nfunction emptyDirectory(path, fn) {\n    fs.readdir(path, function(err, files){\n        if (err && 'ENOENT' != err.code) throw err;\n        fn(!files || !files.length);\n    });\n}\n\n\nfunction write(path, str, mode) {\n    fs.writeFile(path, str, { mode: mode || 0666 });\n    console.log('   \\x1b[36mcreate\\x1b[0m : ' + path);\n}\n\n\nfunction mkdir(path, fn) {\n    mkdirp(path, 0755, function(err){\n        if (err) throw err;\n        console.log('   \\033[36mcreate\\033[0m : ' + path);\n        fn && fn();\n    });\n}\n\nfunction abort(str) {\n    console.error(str);\n    process.exit(1);\n}\n"
  },
  {
    "path": "lib/init/templates/assets/ShowNormals.frag",
    "content": "#ifdef GL_ES\nprecision highp float;\n#endif\n\nvarying vec3 ecNormal;\n\nvoid main() {\n    gl_FragColor = vec4(normalize(ecNormal) * 0.5 + 0.5, 1.0);\n}\n"
  },
  {
    "path": "lib/init/templates/assets/ShowNormals.vert",
    "content": "attribute vec4 aPosition;\nattribute vec3 aNormal;\n\nuniform mat4 uProjectionMatrix;\nuniform mat4 uViewMatrix;\nuniform mat4 uModelMatrix;\nuniform mat3 uNormalMatrix;\n\nvarying vec3 ecNormal;\n\nvoid main() {\n    gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * aPosition;\n    ecNormal = uNormalMatrix * aNormal;\n}\n"
  },
  {
    "path": "lib/init/templates/index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n    <head>\n        <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no\">\n        <meta charset=\"UTF-8\">\n        <title>PEX</title>\n        <script src=\"main.web.js\"></script>\n        <style type=\"text/css\">\n        body { padding: 0; margin: 0; overflow: hidden; }\n        </style>\n    </head>\n    <body>\n    </body>\n</html>\n"
  },
  {
    "path": "lib/init/templates/main.js",
    "content": "var Window          = require('pex-sys/Window');\nvar PerspCamera     = require('pex-cam/PerspCamera');\nvar Arcball         = require('pex-cam/Arcball');\nvar createCube      = require('primitive-cube');\nvar glslify         = require('glslify-promise');\nvar isBrowser       = require('is-browser');\n\nWindow.create({\n    settings: {\n        width:  1280,\n        height: 720,\n        fullScreen: isBrowser ? true : true\n    },\n    resources: {\n        showNormalsVert: { glsl: glslify(__dirname + '/assets/ShowNormals.vert') },\n        showNormalsFrag: { glsl: glslify(__dirname + '/assets/ShowNormals.frag') },\n    },\n    init: function() {\n        var ctx = this.getContext();\n        var res = this.getResources();\n\n        this.camera  = new PerspCamera(45,this.getAspectRatio(),0.001,20.0);\n        this.camera.lookAt([0, 1, 3], [0, 0, 0]);\n        ctx.setProjectionMatrix(this.camera.getProjectionMatrix());\n\n        this.arcball = new Arcball(this.camera, this.getWidth(), this.getHeight());\n        this.arcball.setDistance(3.0);\n        this.addEventListener(this.arcball);\n\n        this.showNormalsProgram = ctx.createProgram(res.showNormalsVert, res.showNormalsFrag);\n        ctx.bindProgram(this.showNormalsProgram);\n\n        var cube = createCube();\n        var cubeAttributes = [\n            { data: cube.positions, location: ctx.ATTRIB_POSITION },\n            { data: cube.normals, location: ctx.ATTRIB_NORMAL }\n        ];\n        var cubeIndices = { data: cube.cells };\n        this.cubeMesh = ctx.createMesh(cubeAttributes, cubeIndices, ctx.TRIANGLES);\n    },\n    draw: function() {\n        var ctx = this.getContext();\n\n        this.arcball.apply();\n        ctx.setViewMatrix(this.camera.getViewMatrix());\n\n        ctx.setClearColor(1, 0.2, 0.2, 1);\n        ctx.clear(ctx.COLOR_BIT | ctx.DEPTH_BIT);\n        ctx.setDepthTest(true);\n\n        ctx.bindProgram(this.showNormalsProgram);\n        ctx.bindMesh(this.cubeMesh);\n        ctx.drawMesh();\n    }\n})\n"
  },
  {
    "path": "lib/pkg/pex-packages-core.json",
    "content": "[\n  { \"name\" : \"pex-cam\" },\n  { \"name\" : \"pex-color\" },\n  { \"name\" : \"pex-context\" },\n  { \"name\" : \"pex-draw\" },\n  { \"name\" : \"pex-geom\" },\n  { \"name\" : \"pex-io\" },\n  { \"name\" : \"pex-math\" },\n  { \"name\" : \"pex-sys\" }\n]\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"pex\",\n  \"version\": \"1.0.2\",\n  \"description\": \"Pex is a javascript 3d library / engine allowing for seamless development between Plask and WebGL in the browser.\",\n  \"keywords\": [\n    \"pex\",\n    \"plask\",\n    \"cli\"\n  ],\n  \"main\": \"index.js\",\n  \"preferGlobal\": \"true\",\n  \"bin\": {\n    \"pex\": \"./index.js\"\n  },\n  \"author\": {\n    \"name\": \"Marcin Ignac\",\n    \"email\": \"marcin.ignac@gmail.com\",\n    \"url\": \"http://marcinignac.com\"\n  },\n  \"contributors\": [\n    {\n      \"name\": \"Nick Nikolov\"\n    },\n    {\n      \"name\": \"Marcin Ignac\"\n    }\n  ],\n  \"dependencies\": {\n    \"async\": \"^0.9.0\",\n    \"commander\": \"^2.3.0\",\n    \"inquirer\": \"^0.5.1\",\n    \"mkdirp\": \"^0.5.0\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"https://github.com/pex-gl/pex.git\"\n  },\n  \"homepage\": \"https://github.com/pex-gl/pex\",\n  \"bugs\": \"https://github.com/pex-gl/pex/issues\",\n  \"license\": \"MIT\"\n}\n"
  }
]