IntNode.js 919 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. return this;
  19. };
  20. IntNode.prototype.toJSON = function ( meta ) {
  21. var data = this.getJSONNode( meta );
  22. if ( ! data ) {
  23. data = this.createJSONNode( meta );
  24. data.value = this.value;
  25. if ( this.readonly === true ) data.readonly = true;
  26. }
  27. return data;
  28. };
  29. export { IntNode };