Skip to content

Instantly share code, notes, and snippets.

View zz85's full-sized avatar

Joshua Koo zz85

View GitHub Profile
THREE.LetterZ = function () {
THREE.Geometry.call( this );
var scope = this;
vertices = [{"x":90.3,"y":0},{"x":0,"y":0},{"x":0,"y":-14.85},{"x":63.599999999999994,"y":-94.35},{"x":3,"y":-94.35},{"x":3,"y":-110.55},{"x":87.3,"y":-110.55},{"x":87.3,"y":-95.25},{"x":24,"y":-16.349999999999998},{"x":90.3,"y":-16.349999999999998}];
faces = [[9,0,1],[1,2,3],[3,4,5],[5,6,7],[8,9,1],[3,5,7],[7,8,1],[1,3,7]];
for (var i in vertices) {
@zz85
zz85 / THREE.FontText.js
Created May 24, 2011 11:46
THREE.FontText
/**
* @author mr.doob / http://mrdoob.com/
* @author philogb / http://blog.thejit.org/
* @author zz85 / http://www.lab4games.net/zz85/blog
*/
THREE.Vector2 = function ( x, y ) {
this.set(
@zz85
zz85 / THREE.Path.js & THREE.Shape.js
Created July 5, 2011 16:26
Prototype Path & Shape & Extrude Geometry Class
/**
* @author zz85 / http://www.lab4games.net/zz85/blog
* Creates free form path.
**/
THREE.Path = function (path) {
this.path = path || [];
};
var ACTIONS = {
@zz85
zz85 / THREE.Path.js & THREE.Shape.js & THREE.ExtrudeGeometry.js
Created July 10, 2011 18:16
Prototype Path & Shape & Extrude Geometry Class
/**
* @author zz85 / http://www.lab4games.net/zz85/blog
* Creates free form path.
**/
THREE.Path = function (points) {
this.path = [];
if (points) {
this.fromPoints(points);
}
@zz85
zz85 / ExtrudeGeometry.js
Created July 26, 2011 08:11
Bevel Problems
/**
* @author zz85 / http://www.lab4games.net/zz85/blog
* Creates extruded geometry from a path shape.
**/
THREE.ExtrudeGeometry = function( shapes, options ) {
THREE.Geometry.call( this );
shapes = shapes instanceof Array ? shapes : [ shapes ];
@zz85
zz85 / gist:1193068
Created September 4, 2011 16:02
Triangle Blur - ShaderUtils
/**
* @author alteredq / http://alteredqualia.com/
*
* ShaderExtras currently contains:
*
* screen
* convolution
* film
* bokeh
* sepia
@zz85
zz85 / perlin-noise-classical.js
Created September 13, 2011 15:37 — forked from banksean/perlin-noise-classical.js
two Perlin noise generators in javascript. The simplex version is about 10% faster (in Chrome at least, haven't tried other browsers)
// Ported from Stefan Gustavson's java implementation
// http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
// Read Stefan's excellent paper for details on how this code works.
//
// Sean McCullough banksean@gmail.com
/**
* You can pass in a random number generator object if you like.
* It is assumed to have a random() method.
*/
@zz85
zz85 / TurbulenceEffect.js
Created September 20, 2011 13:43
Turbulence Effect for Sparks.js
var perlin = new SimplexNoise();
var Turbulence = function() {
this.frequency = 1;
this.octaves = 1;
this.amplitude = 1000;
this.evolution = 0;
Turbulence._turbulenceVel = new THREE.Vector3();
};
@zz85
zz85 / pointInPolygon.js
Created October 3, 2011 00:16
Point in Polgon
// https://github.com/zz85/
// implements Point - in - Polygon
// described in "A Winding Number and Point-in-Polygon Algorithm"
// returns 0 if point is not in polygon
// returns n > 0 if contour winds around point in counter-clockwise manner n times
// returns n < 0 if contour winds around point in clockwise manner -n times
function pointInPolygon(point, contour) {
// Creates a copy of contour
var adjustedContour = [];
var i,il;
@zz85
zz85 / CombineCamera.js
Created October 5, 2011 09:14
A general purpose camera for Three.js
THREE.CombinedCamera = function ( width, height, fov, near, far, orthonear, orthofar ) {
THREE.Camera.call( this );
this.cameraO = new THREE.OrthographicCamera( width / - 2, width / 2, height / 2, height / - 2, orthonear, orthofar );
this.cameraP = new THREE.PerspectiveCamera( fov, width/height, near, far );
this.toPerspective();
};