FloatNode.js 715 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { InputNode } from '../core/InputNode.js';
  2. class FloatNode extends InputNode {
  3. constructor( value ) {
  4. super( 'f' );
  5. this.value = value || 0;
  6. }
  7. generateReadonly( builder, output, uuid, type/*, ns, needsUpdate */ ) {
  8. return builder.format( this.value + ( this.value % 1 ? '' : '.0' ), 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. FloatNode.prototype.nodeType = 'Float';
  26. export { FloatNode };