/usr/share/javascript/three/examples/js/nodes/accessors/CameraNode.js is in libjs-three 80+dfsg2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | /**
* @author sunag / http://www.sunag.com.br/
*/
THREE.CameraNode = function( scope, camera ) {
THREE.TempNode.call( this, 'v3' );
this.setScope( scope || THREE.CameraNode.POSITION );
this.setCamera( camera );
};
THREE.CameraNode.POSITION = 'position';
THREE.CameraNode.DEPTH = 'depth';
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 ) {
this.camera = camera;
this.requestUpdate = camera !== undefined;
};
THREE.CameraNode.prototype.setScope = function( scope ) {
switch ( this.scope ) {
case THREE.CameraNode.DEPTH:
delete this.near;
delete this.far;
break;
}
this.scope = scope;
switch ( scope ) {
case THREE.CameraNode.DEPTH:
this.near = new THREE.FloatNode( camera ? camera.near : 1 );
this.far = new THREE.FloatNode( camera ? camera.far : 1200 );
break;
}
};
THREE.CameraNode.prototype.getType = function( builder ) {
switch ( this.scope ) {
case THREE.CameraNode.DEPTH:
return 'fv1';
}
return this.type;
};
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 ) {
switch ( this.scope ) {
case THREE.CameraNode.POSITION:
return false;
}
return true;
};
THREE.CameraNode.prototype.generate = function( builder, output ) {
var material = builder.material;
var result;
switch ( this.scope ) {
case THREE.CameraNode.POSITION:
result = 'cameraPosition';
break;
case THREE.CameraNode.DEPTH:
builder.include( 'depthcolor' );
result = 'depthcolor(' + this.near.build( builder, 'fv1' ) + ',' + this.far.build( builder, 'fv1' ) + ')';
break;
case THREE.CameraNode.TO_VERTEX:
result = 'normalize( ' + new THREE.PositionNode( THREE.PositionNode.WORLD ).build( builder, 'v3' ) + ' - cameraPosition )';
break;
}
return builder.format( result, this.getType( builder ), output );
};
THREE.CameraNode.prototype.updateAnimation = function( delta ) {
switch ( this.scope ) {
case THREE.CameraNode.DEPTH:
this.near.number = camera.near;
this.far.number = camera.far;
break;
}
};
|