Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CameraNode: Fix missing variable declaration #12951

Merged
merged 4 commits into from Dec 22, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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