IntNode.js 866 B

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