webvr js meetup initial commit

This commit is contained in:
Senad Uka
2017-03-11 15:22:17 +01:00
commit 3f640b55db
761 changed files with 264174 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
/**
* @author sunag / http://www.sunag.com.br/
*/
THREE.ColorNode = function( color ) {
THREE.InputNode.call( this, 'c' );
this.value = new THREE.Color( color || 0 );
};
THREE.ColorNode.prototype = Object.create( THREE.InputNode.prototype );
THREE.ColorNode.prototype.constructor = THREE.ColorNode;
THREE.NodeMaterial.addShortcuts( THREE.ColorNode.prototype, 'value', [ 'r', 'g', 'b' ] );

View File

@@ -0,0 +1,63 @@
/**
* @author sunag / http://www.sunag.com.br/
*/
THREE.CubeTextureNode = function( value, coord, bias ) {
THREE.InputNode.call( this, 'v4', { shared : true } );
this.value = value;
this.coord = coord || new THREE.ReflectNode();
this.bias = bias;
};
THREE.CubeTextureNode.prototype = Object.create( THREE.InputNode.prototype );
THREE.CubeTextureNode.prototype.constructor = THREE.CubeTextureNode;
THREE.CubeTextureNode.prototype.getTexture = function( builder, output ) {
return THREE.InputNode.prototype.generate.call( this, builder, output, this.value.uuid, 't' );
};
THREE.CubeTextureNode.prototype.generate = function( builder, output ) {
if ( output === 'samplerCube' ) {
return this.getTexture( builder, output );
}
var cubetex = this.getTexture( builder, output );
var coord = this.coord.build( builder, 'v3' );
var bias = this.bias ? this.bias.build( builder, 'fv1' ) : undefined;
if ( bias == undefined && builder.requires.bias ) {
bias = builder.requires.bias.build( builder, 'fv1' );
}
var code;
if ( bias ) code = 'texCubeBias(' + cubetex + ',' + coord + ',' + bias + ')';
else code = 'texCube(' + cubetex + ',' + coord + ')';
if ( builder.isSlot( 'color' ) ) {
code = 'mapTexelToLinear(' + code + ')';
} else if ( builder.isSlot( 'emissive' ) ) {
code = 'emissiveMapTexelToLinear(' + code + ')';
} else if ( builder.isSlot( 'environment' ) ) {
code = 'envMapTexelToLinear(' + code + ')';
}
return builder.format( code, this.type, output );
};

View File

@@ -0,0 +1,29 @@
/**
* @author sunag / http://www.sunag.com.br/
*/
THREE.FloatNode = function( value ) {
THREE.InputNode.call( this, 'fv1' );
this.value = [ value || 0 ];
};
THREE.FloatNode.prototype = Object.create( THREE.InputNode.prototype );
THREE.FloatNode.prototype.constructor = THREE.FloatNode;
Object.defineProperties( THREE.FloatNode.prototype, {
number: {
get: function() {
return this.value[ 0 ];
},
set: function( val ) {
this.value[ 0 ] = val;
}
}
} );

29
node_modules/three/examples/js/nodes/inputs/IntNode.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
/**
* @author sunag / http://www.sunag.com.br/
*/
THREE.IntNode = function( value ) {
THREE.InputNode.call( this, 'iv1' );
this.value = [ Math.floor( value || 0 ) ];
};
THREE.IntNode.prototype = Object.create( THREE.InputNode.prototype );
THREE.IntNode.prototype.constructor = THREE.IntNode;
Object.defineProperties( THREE.IntNode.prototype, {
number: {
get: function() {
return this.value[ 0 ];
},
set: function( val ) {
this.value[ 0 ] = Math.floor( val );
}
}
} );

View File

@@ -0,0 +1,14 @@
/**
* @author sunag / http://www.sunag.com.br/
*/
THREE.Matrix4Node = function( matrix ) {
THREE.InputNode.call( this, 'm4' );
this.value = matrix || new THREE.Matrix4();
};
THREE.Matrix4Node.prototype = Object.create( THREE.InputNode.prototype );
THREE.Matrix4Node.prototype.constructor = THREE.Matrix4Node;

View File

@@ -0,0 +1,46 @@
THREE.MirrorNode = function( renderer, camera, options ) {
THREE.TempNode.call( this, 'v4' );
this.mirror = renderer instanceof THREE.Mirror ? renderer : new THREE.Mirror( renderer, camera, options );
this.textureMatrix = new THREE.Matrix4Node( this.mirror.textureMatrix );
this.worldPosition = new THREE.PositionNode( THREE.PositionNode.WORLD );
this.coord = new THREE.OperatorNode( this.textureMatrix, this.worldPosition, THREE.OperatorNode.MUL );
this.coordResult = new THREE.OperatorNode( null, this.coord, THREE.OperatorNode.ADD );
this.texture = new THREE.TextureNode( this.mirror.renderTarget.texture, this.coord, null, true );
};
THREE.MirrorNode.prototype = Object.create( THREE.TempNode.prototype );
THREE.MirrorNode.prototype.constructor = THREE.MirrorNode;
THREE.MirrorNode.prototype.generate = function( builder, output ) {
var material = builder.material;
if ( builder.isShader( 'fragment' ) ) {
this.coordResult.a = this.offset;
this.texture.coord = this.offset ? this.coordResult : this.coord;
if ( output === 'sampler2D' ) {
return this.texture.build( builder, output );
}
return builder.format( this.texture.build( builder, this.type ), this.type, output );
} else {
console.warn( "THREE.MirrorNode is not compatible with " + builder.shader + " shader." );
return builder.format( 'vec4(0.0)', this.type, output );
}
};

View File

@@ -0,0 +1,24 @@
/**
* @author sunag / http://www.sunag.com.br/
*/
THREE.ScreenNode = function( coord ) {
THREE.TextureNode.call( this, undefined, coord );
};
THREE.ScreenNode.prototype = Object.create( THREE.TextureNode.prototype );
THREE.ScreenNode.prototype.constructor = THREE.ScreenNode;
THREE.ScreenNode.prototype.isUnique = function() {
return true;
};
THREE.ScreenNode.prototype.getTexture = function( builder, output ) {
return THREE.InputNode.prototype.generate.call( this, builder, output, this.getUuid(), 't', 'renderTexture' );
};

View File

@@ -0,0 +1,67 @@
/**
* @author sunag / http://www.sunag.com.br/
*/
THREE.TextureNode = function( value, coord, bias, project ) {
THREE.InputNode.call( this, 'v4', { shared : true } );
this.value = value;
this.coord = coord || new THREE.UVNode();
this.bias = bias;
this.project = project !== undefined ? project : false;
};
THREE.TextureNode.prototype = Object.create( THREE.InputNode.prototype );
THREE.TextureNode.prototype.constructor = THREE.TextureNode;
THREE.TextureNode.prototype.getTexture = function( builder, output ) {
return THREE.InputNode.prototype.generate.call( this, builder, output, this.value.uuid, 't' );
};
THREE.TextureNode.prototype.generate = function( builder, output ) {
if ( output === 'sampler2D' ) {
return this.getTexture( builder, output );
}
var tex = this.getTexture( builder, output );
var coord = this.coord.build( builder, this.project ? 'v4' : 'v2' );
var bias = this.bias ? this.bias.build( builder, 'fv1' ) : undefined;
if ( bias == undefined && builder.requires.bias ) {
bias = builder.requires.bias.build( builder, 'fv1' );
}
var method, code;
if ( this.project ) method = 'texture2DProj';
else method = bias ? 'tex2DBias' : 'tex2D';
if ( bias ) code = method + '(' + tex + ',' + coord + ',' + bias + ')';
else code = method + '(' + tex + ',' + coord + ')';
if ( builder.isSlot( 'color' ) ) {
code = 'mapTexelToLinear(' + code + ')';
} else if ( builder.isSlot( 'emissive' ) ) {
code = 'emissiveMapTexelToLinear(' + code + ')';
} else if ( builder.isSlot( 'environment' ) ) {
code = 'envMapTexelToLinear(' + code + ')';
}
return builder.format( code, this.type, output );
};

View File

@@ -0,0 +1,16 @@
/**
* @author sunag / http://www.sunag.com.br/
*/
THREE.Vector2Node = function( x, y ) {
THREE.InputNode.call( this, 'v2' );
this.value = new THREE.Vector2( x, y );
};
THREE.Vector2Node.prototype = Object.create( THREE.InputNode.prototype );
THREE.Vector2Node.prototype.constructor = THREE.Vector2Node;
THREE.NodeMaterial.addShortcuts( THREE.Vector2Node.prototype, 'value', [ 'x', 'y' ] );

View File

@@ -0,0 +1,17 @@
/**
* @author sunag / http://www.sunag.com.br/
*/
THREE.Vector3Node = function( x, y, z ) {
THREE.InputNode.call( this, 'v3' );
this.type = 'v3';
this.value = new THREE.Vector3( x, y, z );
};
THREE.Vector3Node.prototype = Object.create( THREE.InputNode.prototype );
THREE.Vector3Node.prototype.constructor = THREE.Vector3Node;
THREE.NodeMaterial.addShortcuts( THREE.Vector3Node.prototype, 'value', [ 'x', 'y', 'z' ] );

View File

@@ -0,0 +1,16 @@
/**
* @author sunag / http://www.sunag.com.br/
*/
THREE.Vector4Node = function( x, y, z, w ) {
THREE.InputNode.call( this, 'v4' );
this.value = new THREE.Vector4( x, y, z, w );
};
THREE.Vector4Node.prototype = Object.create( THREE.InputNode.prototype );
THREE.Vector4Node.prototype.constructor = THREE.Vector4Node;
THREE.NodeMaterial.addShortcuts( THREE.Vector4Node.prototype, 'value', [ 'x', 'y', 'z', 'w' ] );