Skip to content

Instantly share code, notes, and snippets.

View Makio64's full-sized avatar

Makio64 Makio64

View GitHub Profile
@Makio64
Makio64 / gist:3a684306445dc96aa048
Last active August 29, 2015 14:05
JS Class template / best practice
'use strict';
/**
* MyClass
*
* @class MyClass
* @author David Ronai http://makiopolis.com/ @Makio64
*/
@Makio64
Makio64 / gist:9a921ec6342cca1438f4
Last active August 29, 2015 14:05
JS Singleton template / best practice
'use strict';
/**
* MySingleton
*
* @class MySingleton
* @author David Ronai http://makiopolis.com/ @Makio64
*/
@Makio64
Makio64 / ObjectPool.coffee
Created December 21, 2015 13:49
Utility class to manage pool of objects
# Utility class to manage pool of objects
class ObjectPool
constructor: (@create, @minSize, @maxSize) ->
@list = []
for [0...@minSize]
@add()
return
Stage3d = require('makio/core/Stage3d')
class FBO
constructor:( width, height, @renderer, @simulation )->
#---------------------------------------------------------------------------------------- Create Render
options = {
wrapS: THREE.RepeatWrapping
@Makio64
Makio64 / optimizedSnoise2d.glsl
Last active May 15, 2016 13:08
Optimized version of the Ashima simplex noise 2D
// Optimized by @makio64 - FabriceNeyret2
// Original post on shadertoy: https://www.shadertoy.com/view/4sdGD8
// Original : https://github.com/ashima/webgl-noise/blob/master/src/noise2D.glsl
vec3 permute(vec3 x) { return mod( x*x*34.+x, 289.); }
float snoise(vec2 v) {
vec2 i = floor(v + (v.x+v.y)*.36602540378443),
x0 = v - i + (i.x+i.y)*.211324865405187,
j = step(x0.yx,x0),
x1 = x0-j+.211324865405187,
@Makio64
Makio64 / optimizedSnoise3d.glsl
Created May 15, 2016 13:06
Optimized version of the Ashima simplex noise 3d
// Optimized AshimaSimplexNoise by @makio64
// Original post on shadertoy : https://www.shadertoy.com/view/Xd3GRf
// Original : https://github.com/ashima/webgl-noise/blob/master/src/noise3D.glsl
vec4 permute(vec4 x){return mod(x*x*34.+x,289.);}
float snoise(vec3 v){
const vec2 C = 1./vec2(6,3);
const vec4 D = vec4(0,.5,1,2);
vec3 i = floor(v + dot(v, C.yyy));
vec3 x0 = v - i + dot(i, C.xxx);
@Makio64
Makio64 / regex require => import
Last active January 12, 2017 01:34
regex to find the old way to require files & import it in the new way
\S*\s+(\S*)\s*=[ ]*require\(\s*["'](.*)["']\s*\)\s*;?
import $1 from '$2'
before:
const bouboup = require( 'blabla/bouboup' )
after:
import bouboup from 'blabla/bouboup'
# Git Worklow
### branches
- **develop** : *remote* branch with all versions
- **local** : *local* branch with local version
### workflow
1. After cloning the project, create a **local** branch
@Makio64
Makio64 / gist:d8b2a8350d936681b8ccb6886f4cdd22
Last active April 25, 2017 17:15
PIXI 4.4.x Tips performance
Global :
- Dont use PIXI.Graphics
- render elements in the order of atlas/textures used : for 2 atlas or texture A & B, then render elements using AAAABBB instead of ABABABA
- On branch next from Pixi there is PIXI.mesh.Geometry & shaders very good for perf
http://dev.goodboydigital.com/client/goodboy/geometry/examples/index.html#/mesh/uniforms.js
- prefer generateSprite to cacheasbitmap to cache container/no animated element
Spritesheets:
- Use spritesheets whenever its possible
- Scales them down to 50% on mobile/tablet
@Makio64
Makio64 / MeshCustomMaterial
Last active July 17, 2017 13:18
MeshCustomMaterial, use to your own risk ;)
export default class MeshCustomMaterial extends THREE.MeshStandardMaterial {
constructor(parameters, uniforms={}, fs=null , vs=null ){
fs = fs || `
#define PHYSICAL
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float roughness;
uniform float metalness;
uniform float opacity;