Skip to content

Instantly share code, notes, and snippets.

@vorg
vorg / index.js
Created January 12, 2018 12:26
pex-context example
const createContext = require('pex-context')
const createCube = require('primitive-cube')
const mat4 = require('pex-math/mat4')
const ctx = createContext({ width: 640, height: 480 })
const cube = createCube()
const clearCmd = {
pass: ctx.pass({
clearColor: [0, 0, 0, 1],
package pl.vorg.carrot {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.*;
import mx.utils.*;
import pl.vorg.geom.*;
import pl.vorg.text.*;
import pl.vorg.utils.*;
@vorg
vorg / command.js
Last active March 27, 2017 12:23
pex-context command
const createContext = require('pex-context')
const ctx = createContext({ width: 1280, height: 720})
const drawCmd = {
pass: ctx.pass({
clearColor: [0.5, 0.5, 0.5, 1],
clearDepth: 1
}),
pipeline: ctx.pipeline({
vert: vertSrc,
const depthPassCmd = ctx.command({
name: 'depthPass',
framebuffer: shadowFramebuffer,
viewport: [0, 0, depthMapSize, depthMapSize],
clearColor: [1, 1, 0, 1],
clearDepth: 1
})
...
// 1 curent, plain prop
var tree = {
height: 1
}
console.log(tree.height)
gui.addParam('Height', tree, 'height', { min: 0, max: 10 })
// 2 prop with metadata
var tree = {
@vorg
vorg / index.js
Last active November 9, 2016 12:02
pull stream drag mouse test
const pull = require('pull-stream')
const log = require('pull-stream/sinks/log')
const filter = require('pull-stream/throughs/filter')
const take = require('pull-stream/throughs/take')
const containsPoint = require('pex-geom/Rect').containsPoint
const pushableStream = require('pull-pushable')
// Draw a red canvas with yellow "button" on the left
const btnRect = [[10, 10], [100, 100]]
@vorg
vorg / index.js
Last active November 9, 2016 15:49
requirebin sketch
// Streams implementation for mouse events.
// Started based thinking in https://github.com/pex-gl/pex-gui/issues/8
// IMPORT DEPENDENCIES
// Flyd is "The less is more, modular, functional reactive programming library"
const flyd = require('flyd')
// emit events from one stream until another stream fires
const takeUntil = require('flyd/module/takeuntil')
@vorg
vorg / index.js
Created November 7, 2016 15:24
requirebin sketch
var regl = require('regl')()
var setupViewWorking = regl({
scissor: {
enable: true,
box: {x: 0, y: 0, width: 100, height: 100}
}
})
var setupViewNotWorking = regl({
@vorg
vorg / index.js
Last active November 2, 2016 11:35
requirebin sketch
// Welcome! require() some modules from npm (like you were using browserify)
// and then hit Run Code to run your code on the right side.
// Modules get downloaded from browserify-cdn and bundled in your browser.
var gl = require('pex-gl')(600, 300)
var io = require('pex-io')
var regl = require('regl')(gl)
function loadImageBrowser (url, callback) {
console.log('hacking image loader')
var img = new window.Image()
@vorg
vorg / index.js
Created September 22, 2016 16:39
regl vertex attribute size dependency
var regl = require('regl')()
regl.clear({
color: [0, 0, 0, 1],
depth: 1
})
// In regl, draw operations are specified declaratively using. Each JSON
// command is a complete description of all state. This removes the need to
// .bind() things like buffers or shaders. All the boilerplate of setting up