123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- /**
- * @author sunag / http://www.sunag.com.br/
- */
- THREE.NodeCamera = function( scope, camera ) {
-
- THREE.NodeTemp.call( this, 'v3' );
-
- this.scope = scope || THREE.NodeCamera.POSITION;
- this.camera = camera;
-
- switch(scope) {
-
- case THREE.NodeCamera.DEPTH:
-
- this.near = new THREE.NodeFloat( camera ? camera.near : 1);
- this.far = new THREE.NodeFloat(camera ? camera.far : 1200);
-
- break;
-
- }
-
- this.requestUpdate = this.camera !== undefined;
-
- };
- THREE.NodeCamera.prototype = Object.create( THREE.NodeTemp.prototype );
- THREE.NodeCamera.prototype.constructor = THREE.NodeCamera;
- THREE.NodeCamera.POSITION = 'position';
- THREE.NodeCamera.DEPTH = 'depth';
- THREE.NodeCamera.prototype.getType = function( builder ) {
-
- switch(this.scope) {
- case THREE.NodeCamera.DEPTH:
- return 'fv1';
- }
-
- return this.type;
-
- };
- THREE.NodeCamera.prototype.isUnique = function( builder ) {
-
- switch(this.scope) {
- case THREE.NodeCamera.DEPTH:
- return true;
- }
-
- return false;
-
- };
- THREE.NodeCamera.prototype.isShared = function( builder ) {
-
- switch(this.scope) {
- case THREE.NodeCamera.POSITION:
- return false;
- }
-
- return true;
-
- };
- THREE.NodeCamera.prototype.generate = function( builder, output ) {
-
- var material = builder.material;
- var result;
-
- switch (this.scope) {
-
- case THREE.NodeCamera.POSITION:
-
- result = 'cameraPosition';
-
- break;
-
- case THREE.NodeCamera.DEPTH:
-
- builder.include('depthcolor');
-
- result = 'depthcolor(' + this.near.build( builder, 'fv1' ) + ',' + this.far.build( builder, 'fv1' ) + ')';
-
- break;
-
- }
-
- return builder.format( result, this.getType( builder ), output );
- };
- THREE.NodeCamera.prototype.updateAnimation = function( delta ) {
-
- switch(this.scope) {
-
- case THREE.NodeCamera.DEPTH:
-
- this.near.number = camera.near;
- this.far.number = camera.far;
-
- break;
-
- }
-
- };
|