IntNode.js 688 B

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