Skip to content

Commit

Permalink
Merge pull request #12951 from Itee/patch-1
Browse files Browse the repository at this point in the history
CameraNode: Fix missing variable declaration
  • Loading branch information
mrdoob committed Dec 22, 2017
2 parents dae2967 + 1ea94ad commit 8fc3a43
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions examples/js/nodes/accessors/CameraNode.js
Expand Up @@ -2,7 +2,7 @@
* @author sunag / http://www.sunag.com.br/
*/

THREE.CameraNode = function( scope, camera ) {
THREE.CameraNode = function ( scope, camera ) {

THREE.TempNode.call( this, 'v3' );

Expand All @@ -12,14 +12,14 @@ THREE.CameraNode = function( scope, camera ) {
};

THREE.CameraNode.fDepthColor = new THREE.FunctionNode( [
"float depthColor( float mNear, float mFar ) {",
" #ifdef USE_LOGDEPTHBUF_EXT",
" float depth = gl_FragDepthEXT / gl_FragCoord.w;",
" #else",
" float depth = gl_FragCoord.z / gl_FragCoord.w;",
" #endif",
" return 1.0 - smoothstep( mNear, mFar, depth );",
"}"
"float depthColor( float mNear, float mFar ) {",
" #ifdef USE_LOGDEPTHBUF_EXT",
" float depth = gl_FragDepthEXT / gl_FragCoord.w;",
" #else",
" float depth = gl_FragCoord.z / gl_FragCoord.w;",
" #endif",
" return 1.0 - smoothstep( mNear, mFar, depth );",
"}"
].join( "\n" ) );

THREE.CameraNode.POSITION = 'position';
Expand All @@ -29,14 +29,14 @@ THREE.CameraNode.TO_VERTEX = 'toVertex';
THREE.CameraNode.prototype = Object.create( THREE.TempNode.prototype );
THREE.CameraNode.prototype.constructor = THREE.CameraNode;

THREE.CameraNode.prototype.setCamera = function( camera ) {
THREE.CameraNode.prototype.setCamera = function ( camera ) {

this.camera = camera;
this.requestUpdate = camera !== undefined;

};

THREE.CameraNode.prototype.setScope = function( scope ) {
THREE.CameraNode.prototype.setScope = function ( scope ) {

switch ( this.scope ) {

Expand All @@ -55,6 +55,7 @@ THREE.CameraNode.prototype.setScope = function( scope ) {

case THREE.CameraNode.DEPTH:

var camera = this.camera;
this.near = new THREE.FloatNode( camera ? camera.near : 1 );
this.far = new THREE.FloatNode( camera ? camera.far : 1200 );

Expand All @@ -64,41 +65,47 @@ THREE.CameraNode.prototype.setScope = function( scope ) {

};

THREE.CameraNode.prototype.getType = function( builder ) {
THREE.CameraNode.prototype.getType = function ( builder ) {

switch ( this.scope ) {

case THREE.CameraNode.DEPTH:
return 'fv1';

}

return this.type;

};

THREE.CameraNode.prototype.isUnique = function( builder ) {
THREE.CameraNode.prototype.isUnique = function ( builder ) {

switch ( this.scope ) {

case THREE.CameraNode.DEPTH:
case THREE.CameraNode.TO_VERTEX:
return true;

}

return false;

};

THREE.CameraNode.prototype.isShared = function( builder ) {
THREE.CameraNode.prototype.isShared = function ( builder ) {

switch ( this.scope ) {

case THREE.CameraNode.POSITION:
return false;

}

return true;

};

THREE.CameraNode.prototype.generate = function( builder, output ) {
THREE.CameraNode.prototype.generate = function ( builder, output ) {

var material = builder.material;
var result;
Expand Down Expand Up @@ -133,12 +140,13 @@ THREE.CameraNode.prototype.generate = function( builder, output ) {

};

THREE.CameraNode.prototype.updateFrame = function( delta ) {
THREE.CameraNode.prototype.updateFrame = function ( delta ) {

switch ( this.scope ) {

case THREE.CameraNode.DEPTH:

var camera = this.camera;
this.near.number = camera.near;
this.far.number = camera.far;

Expand Down

0 comments on commit 8fc3a43

Please sign in to comment.