Skip to content

Instantly share code, notes, and snippets.

// both the 'Player' component and this component exist as scripts on the player instance in the scene
// My guess is that start() is called on this component before on Player()
// (even though this script is listed last)
// Is this a bad pattern? It seems like running GetComponent() on each FixedUpdate() and checking for null would be a huge waste
// How do unity developers do this instead?
void start() {
player = GetComponent<Player>();
}
~ $ npm install --save [email protected] --verbose
npm info it worked if it ends with ok
npm verb cli [ '/app/.heroku/node/bin/node',
npm verb cli '/app/.heroku/node/bin/npm',
npm verb cli 'install',
npm verb cli '--save',
npm verb cli '[email protected]',
npm verb cli '--verbose' ]
npm info using [email protected]
npm info using [email protected]
https://29a.ch/2010/5/17/path-tracing-a-cornell-box-in-javascript
https://29a.ch/sandbox/2010/cornellbox/worker.js
https://github.com/mateuszroth/raytracejs/blob/master/src/js/partials/raytrace.js
http://www.gabrielgambetta.com/tiny_raytracer_full.js
http://jupiter909.com/mark/jsrt.html
https://mzucker.github.io/2016/08/03/miniray.html
http://lousodrome.net/blog/light/tag/path-tracing/
http://create.stephan-brumme.com/smallpt-js/
http://blog.tojicode.com/2010/09/raytracing-in-javascript.html
https://benedikt-bitterli.me/tantalum/
async function makePizza(sauceType = 'red') {
let [ dough, [ sauce, cheese ]] = await Promise.all([ makeDough(), makeToppings(sauceType) ])
return dough.add(sauce).add(cheese)
}
async function makeToppings(sauceType) {
return [ await makeSauce(sauceType), await makeCheese() ]
}
<!doctype html>
<html>
<head>
<title>JS Paint</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; font-family: arial, sans-serif; }
body { background: #eee; }
#wrap { position: relative; margin: 50px auto 0 auto; width: 800px; }
#canvas { width: 800px; height: 600px; background: #fff; box-shadow: 1px 1px 32px #ddd; cursor: crosshair; }
#tools { position: absolute; width: 150px; top: 0; left: -150px; font-size: 18px; }
package main
import "fmt"
// fibonacci is a function that returns
// a function that returns an int.
func fibonacci() func() int {
prev := [2]int{0, 1}
return func() int {
n := prev[0]
func main() {
scene := trace.Scene{}
camera := trace.Camera{Width: 960, Height: 540}
sampler := trace.NewSampler(&camera, &scene, 10)
renderer := trace.NewRenderer(&camera)
light := trace.NewLight(1000, 1000, 1000)
redPlastic := trace.NewPlastic(1, 0, 0, 1)
bluePlastic := trace.NewPlastic(0, 0, 1, 1)
whitePlastic := trace.NewPlastic(1, 1, 1, 0)
silver := trace.NewMetal(0.972, 0.960, 0.915, 1)
// Start starts rendering based on CLI parameters
func (c Cli) Start() {
out := flag.String("out", "render.png", "Output png filename.")
concurrency := flag.Int("frames", runtime.NumCPU(), "Number of frames to combine.")
samples := flag.Float64("samples", math.Inf(1), "Average per pixel samples to take.")
heat := flag.String("heat", "", "Heatmap png filename.")
flag.Parse()
running := make(chan struct{})
ch := make(chan os.Signal, 2)
for (let i = 1; i <= 100; i++) {
const match = []
if (i % 3 === 0) match.push('fizz')
if (i % 5 === 0) match.push('buzz')
if (match.length === 0) match.push(i)
console.log(match.join(''))
}

3 Ways to design the lightmap API

The purpose of the module is to create and update path-traced 2D lightmaps. For example, to create interesting dynamic top-down lighting in a 2D game.

Option 1: Trace on lightmap

lm := lightmap.New(image.Rect(0, 0, 100, 100))
light := lightmap.Light{