FloatNode.js 905 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { InputNode } from '../core/InputNode.js';
  2. function FloatNode( value ) {
  3. InputNode.call( this, 'f' );
  4. this.value = value || 0;
  5. }
  6. FloatNode.prototype = Object.create( InputNode.prototype );
  7. FloatNode.prototype.constructor = FloatNode;
  8. FloatNode.prototype.nodeType = 'Float';
  9. FloatNode.prototype.generateReadonly = function ( builder, output, uuid, type/*, ns, needsUpdate */ ) {
  10. return builder.format( this.value + ( this.value % 1 ? '' : '.0' ), type, output );
  11. };
  12. FloatNode.prototype.copy = function ( source ) {
  13. InputNode.prototype.copy.call( this, source );
  14. this.value = source.value;
  15. return this;
  16. };
  17. FloatNode.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 { FloatNode };