BoolNode.js 921 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * @author sunag / http://www.sunag.com.br/
  3. */
  4. import { InputNode } from '../core/InputNode.js';
  5. function BoolNode( value ) {
  6. InputNode.call( this, 'b' );
  7. this.value = Boolean( value );
  8. }
  9. BoolNode.prototype = Object.create( InputNode.prototype );
  10. BoolNode.prototype.constructor = BoolNode;
  11. BoolNode.prototype.nodeType = "Bool";
  12. BoolNode.prototype.generateReadonly = function ( builder, output, uuid, type/*, ns, needsUpdate */ ) {
  13. return builder.format( this.value, type, output );
  14. };
  15. BoolNode.prototype.copy = function ( source ) {
  16. InputNode.prototype.copy.call( this, source );
  17. this.value = source.value;
  18. return this;
  19. };
  20. BoolNode.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 { BoolNode };