Skip to content

Instantly share code, notes, and snippets.

@gero3
gero3 / issue
Created September 12, 2012 11:08
issue
## introduction
This is a suggestion on how we could make use of preprocessor definitions inside a shadermaterial.
## Why
I needed a shadermaterial that had more then 16 texture uniforms defined but depending on the configuration of my application only used 16 or less texture uniforms. So I needed the rebuild my shader sourcecode programmatically or I could make a definition system which used preprocessor definitions.
## definition
@gero3
gero3 / definition.js
Created September 12, 2012 09:31
description of shadermaterial
/*global THREE:true requestAnimationFrame:true shaders:true*/
var shaders = {
splat:{
defines : {"USE_DIFFUSE2" : true},
uniforms:{
"alpha1" : { type: "t", value: null },
"diffuse1" : { type: "t", value: null },
"multiplier1" : {type: "f", value: 16.0 },
@gero3
gero3 / ray.js
Created August 17, 2012 07:23
test for ray.js
THREE.Ray=function(L,M,N,O){this.origin=L||new THREE.Vector3;this.direction=M||new THREE.Vector3;this.near=N||0;this.far=O||Infinity;var q=new THREE.Vector3,p=new THREE.Vector3,r=new THREE.Vector3,v=new THREE.Vector3,s=new THREE.Vector3,D=new THREE.Vector3,t=new THREE.Vector3,u=new THREE.Vector3,E=new THREE.Vector3,w=new THREE.Vector3,m=new THREE.Vector3,x=new THREE.Matrix4,G=function(a,c){return a.distance-c.distance},g=new THREE.Vector3,h=new THREE.Vector3,j=new THREE.Vector3,H,I,c,J=function(a,
F,b){g.sub(b,a);H=g.dot(F);I=h.add(a,j.copy(F).multiplyScalar(H));return c=b.distanceTo(I)},n,i,o,k,y,z,A,B,C=function(a,c,b,f){g.sub(f,c);h.sub(b,c);j.sub(a,c);n=g.dot(g);i=g.dot(h);o=g.dot(j);k=h.dot(h);y=h.dot(j);z=1/(n*k-i*i);A=(k*o-i*y)*z;B=(n*y-i*o)*z;return 0<=A&&0<=B&&1>A+B},K=1E-4;this.setPrecision=function(a){K=a};this.intersectObject=function(a,g){var b,f=[];if(!0===g)for(var d=0,h=a.children.length;d<h;d++)Array.prototype.push.apply(f,this.intersectObject(a.children[d],g));if(a instanceof
THREE.Particle)
@gero3
gero3 / ray.js
Created August 17, 2012 07:23
test for ray.js
THREE.Ray=function(L,M,N,O){this.origin=L||new THREE.Vector3;this.direction=M||new THREE.Vector3;this.near=N||0;this.far=O||Infinity;var q=new THREE.Vector3,p=new THREE.Vector3,r=new THREE.Vector3,v=new THREE.Vector3,s=new THREE.Vector3,D=new THREE.Vector3,t=new THREE.Vector3,u=new THREE.Vector3,E=new THREE.Vector3,w=new THREE.Vector3,m=new THREE.Vector3,x=new THREE.Matrix4,G=function(a,c){return a.distance-c.distance},g=new THREE.Vector3,h=new THREE.Vector3,j=new THREE.Vector3,H,I,c,J=function(a,
F,b){g.sub(b,a);H=g.dot(F);I=h.add(a,j.copy(F).multiplyScalar(H));return c=b.distanceTo(I)},n,i,o,k,y,z,A,B,C=function(a,c,b,f){g.sub(f,c);h.sub(b,c);j.sub(a,c);n=g.dot(g);i=g.dot(h);o=g.dot(j);k=h.dot(h);y=h.dot(j);z=1/(n*k-i*i);A=(k*o-i*y)*z;B=(n*y-i*o)*z;return 0<=A&&0<=B&&1>A+B},K=1E-4;this.setPrecision=function(a){K=a};this.intersectObject=function(a,g){var b,f=[];if(!0===g)for(var d=0,h=a.children.length;d<h;d++)Array.prototype.push.apply(f,this.intersectObject(a.children[d],g));if(a instanceof
THREE.Particle)
{
"metadata": {
"formatVersion": 3,
"generatedBy": "Blender 2.60 Exporter",
"vertices": 224,
"faces": 200,
"normals": 86,
"colors": 0,
"uvs": 0,
"materials": 1,
@gero3
gero3 / gist:1764377
Created February 8, 2012 02:06
errors in o3 binding
info it worked if it ends with ok
verb command 'build' []
verb build args []
verb `which` succeededmake '/usr/bin/make'
spawn make [ 'V=1', 'BUILDTYPE=Debug', '-f', 'Makefile.gyp' ]
g++ '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DDEBUG' '-D_DEBUG' -I../../.node-gyp/0.7/src -I../../.node-gyp/0.7/deps/uv/include -I../../.node-gyp/0.7/deps/v8/include -Iinclude -Ihosts -Imodules -Ideps -Wall -pthread -m32 -ansi -O3 -msse2 -ffast-math -g -fPIC -DPIC -g -O0 -fno-rtti -fno-exceptions -O3 -msse2 -ffast-math -g -fPIC -DPIC -MMD -MF out/Debug/.deps/out/Debug/obj.target/o3/hosts/node-o3/sh_node.o.d.raw -c -o out/Debug/obj.target/o3/hosts/node-o3/sh_node.o hosts/node-o3/sh_node.cc
In file included from include/o3.h:41:0,
from hosts/node-o3/sh_node.cc:22:
include/cUnk.h:224:0: let op: ignoring #pragma warning [-Wunknown-pragmas]
include/cUnk.h:225:0: let op: ignoring #pragma warning [-Wunknown-pragmas]