BoolNode.js 901 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. };
  19. BoolNode.prototype.toJSON = function ( meta ) {
  20. var data = this.getJSONNode( meta );
  21. if ( ! data ) {
  22. data = this.createJSONNode( meta );
  23. data.value = this.value;
  24. if ( this.readonly === true ) data.readonly = true;
  25. }
  26. return data;
  27. };
  28. export { BoolNode };