FloatNode.js 941 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /**
  2. * @author sunag / http://www.sunag.com.br/
  3. */
  4. THREE.FloatNode = function ( value ) {
  5. THREE.InputNode.call( this, 'fv1' );
  6. this.value = value || 0;
  7. };
  8. THREE.FloatNode.prototype = Object.create( THREE.InputNode.prototype );
  9. THREE.FloatNode.prototype.constructor = THREE.FloatNode;
  10. THREE.FloatNode.prototype.nodeType = "Float";
  11. THREE.FloatNode.prototype.generateReadonly = function ( builder, output, uuid, type, ns, needsUpdate ) {
  12. return builder.format( this.value + ( this.value % 1 ? '' : '.0' ), type, output );
  13. };
  14. THREE.FloatNode.prototype.copy = function ( source ) {
  15. THREE.InputNode.prototype.copy.call( this, source );
  16. this.value = source.value;
  17. };
  18. THREE.FloatNode.prototype.toJSON = function ( meta ) {
  19. var data = this.getJSONNode( meta );
  20. if ( ! data ) {
  21. data = this.createJSONNode( meta );
  22. data.value = this.value;
  23. if ( this.readonly === true ) data.readonly = true;
  24. }
  25. return data;
  26. };