IntNode.js 905 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /**
  2. * @author sunag / http://www.sunag.com.br/
  3. */
  4. import { InputNode } from '../core/InputNode.js';
  5. function IntNode( value ) {
  6. InputNode.call( this, 'i' );
  7. this.value = Math.floor( value || 0 );
  8. };
  9. IntNode.prototype = Object.create( InputNode.prototype );
  10. IntNode.prototype.constructor = IntNode;
  11. IntNode.prototype.nodeType = "Int";
  12. IntNode.prototype.generateReadonly = function ( builder, output, uuid, type, ns, needsUpdate ) {
  13. return builder.format( this.value, type, output );
  14. };
  15. IntNode.prototype.copy = function ( source ) {
  16. InputNode.prototype.copy.call( this, source );
  17. this.value = source.value;
  18. };
  19. IntNode.prototype.toJSON = function ( meta ) {
  20. var data = this.getJSONNode( meta );
  21. if ( ! data ) {
  22. data = this.createJSONNode( meta );
  23. data.value = this.value;
  24. if ( this.readonly === true ) data.readonly = true;
  25. }
  26. return data;
  27. };
  28. export { IntNode };