Skip to content

Instantly share code, notes, and snippets.

View gonnavis's full-sized avatar

Vis gonnavis

View GitHub Profile
@gonnavis
gonnavis / IndexedDB101.js
Created November 23, 2020 17:48 — forked from JamesMessinger/IndexedDB101.js
Very Simple IndexedDB Example
// This works on all devices/browsers, and uses IndexedDBShim as a final fallback
var indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB || window.shimIndexedDB;
// Open (or create) the database
var open = indexedDB.open("MyDatabase", 1);
// Create the schema
open.onupgradeneeded = function() {
var db = open.result;
var store = db.createObjectStore("MyObjectStore", {keyPath: "id"});
<script src="https://cdnjs.cloudflare.com/ajax/libs/vConsole/3.3.4/vconsole.min.js"></script>
<script>
var vConsole = new VConsole();
</script>
@gonnavis
gonnavis / object-watch.js
Created November 27, 2020 06:37 — forked from eligrey/object-watch.js
object.watch polyfill in ES5
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
ffmpeg -i data/video.mp4 -vcodec h264 -b:v 1000k -acodec mp2 data/output.mp4
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Cheatsheet
.\[]{}^$()?=!<>|:*+
- if in [a-z]
, if in {,}
// http://glslsandbox.com/e#61476.1
float hash( float n ){
return fract(sin(n)*1751.5453);
}
float hash1( vec2 p ){
return fract(sin(p.x+131.1*p.y)*1751.5453);
}
vec3 hash3( float n ){
Object.keys(THREE)[Object.values(THREE).findIndex(n=>n===1001)]
@gonnavis
gonnavis / disney_brdf.glsl
Created May 1, 2021 23:43 — forked from mateuszwojt/disney_brdf.glsl
Disney Principled BRDF GLSL shader implementation
// Principled PBR Path tracer. Except where otherwise noted:
// Copyright © 2019 Markus Moenig Distributed under The MIT License.
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
@gonnavis
gonnavis / bonus.html
Created October 16, 2021 04:47 — forked from BlueMagnificent/bonus.html
Javascript 3D Physics Tut 2 Bonus
<html>
<head>
<meta charset="utf-8">
<title>Move JS 3D Physics</title>
<style>
body { margin: 0; }
</style>
</head>
<body>
@gonnavis
gonnavis / contact_pair_test.html
Created October 17, 2021 01:13 — forked from BlueMagnificent/contact_pair_test.html
Javascript 3D Physics Tut 3 Contact Pair Test
<html>
<head>
<meta charset="utf-8">
<title>Collision JS 3D Physics</title>
<style>
body { margin: 0; }
</style>
</head>
<body>