Skip to content

Instantly share code, notes, and snippets.

http://www.shaderific.com/glsl-functions/
@floz
floz / Main.js
Created July 17, 2017 12:48
Loading texture (js,vertex,fragment)
let customMaterial = new THREE.RawShaderMaterial( {
uniforms: {
color: { type: "c", value: new THREE.Color( 0x00ff00 ) },
tex: { type: "t", value: new THREE.TextureLoader().load( "./imgs/toto.jpg" ) }
},
vertexShader: vsBasic,
fragmentShader: fsBasic
} )
this.meshSmall = new THREE.Mesh( geometry, customMaterial )
this.meshSmall.scale.set( 1, 1, 1 )
<!DOCTYPE html>
<html>
<head>
<title>accueil</title>
<link href="style.css" rel="nofollow" type="text/css">
<style type="text/css">
#container {
position: relative;
margin: 0 auto;
width: 1024px;
const interactions = require( "fz/events/interactions" )
const stage = require( "fz/core/stage" )
const dgui = require( "fz/utils/dgui" )
const timeout = require( "fz/utils/timeout" )
class OrbitControls {
// camera = THREE.Camera
// target = THREE.Vector3
constructor( camera, target, radius ) {
@floz
floz / scripts.js
Created May 26, 2015 19:01
browserify js
var gulp = require( "gulp" );
var gutil = require( "gulp-util" );
var plumber = require( "gulp-plumber" );
var browserify = require( "browserify" );
var source = require( "vinyl-source-stream" );
var watchify = require( "watchify" );
gulp.task( "scripts", function() {
watchify.args.paths = [ "./site/scripts/" ];
var b = browserify( "./site/scripts/main.js", watchify.args );
@floz
floz / gist:52fdf6c805dd96f4553a
Last active August 29, 2015 14:20
AlphaMaskFilter2.js
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
/**
* The AlphaMaskFilter2 class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object.
* You can use this filter to apply all manor of crazy warping effects
* Currently the r property of the texture is used to offset the x and the g property of the texture is used to offset the y.
*
* @class AlphaMaskFilter2
@floz
floz / gist:53ad2765cc846187cdd3
Created December 18, 2014 18:47
PhotoshopMath.glsl
/*
** Copyright (c) 2012, Romain Dura [email protected]
**
** Permission to use, copy, modify, and/or distribute this software for any
** purpose with or without fee is hereby granted, provided that the above
** copyright notice and this permission notice appear in all copies.
**
** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
** WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
** MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
@floz
floz / gist:b573787ec9ab36aa8911
Created October 2, 2014 00:31
Update pixi texture from canvas
# if engine.isWebGL()
# PIXI.updateWebGLTexture @_texture.baseTexture, engine.getRenderer().gl
/*
* Natural Sort algorithm for Javascript - Version 0.6 - Released under MIT license
* Author: Jim Palmer (based on chunking idea from Dave Koelle)
* Contributors: Mike Grier (mgrier.com), Clint Priest, Kyle Adams, guillermo
*/
function naturalSort(a, b) {
var re = /(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?$|^0x[0-9a-f]+$|[0-9]+)/gi,
sre = /(^[ ]*|[ ]*$)/g,
dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,
hre = /^0x[0-9a-f]+$/i,
@floz
floz / _mobile_mixins.styl
Created April 29, 2014 15:26
Mobiles mixins for stylus
baseImg = "../img/"
img( url )
background transparent url( baseImg + url ) no-repeat
imgImportant( url )
background transparent url( baseImg + url ) !important
imgRepeat( url )
background transparent url( baseImg + url )