PropertyNode.js 613 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { InputNode } from '../core/InputNode.js';
  2. class PropertyNode extends InputNode {
  3. constructor( object, property, type ) {
  4. super( type );
  5. this.object = object;
  6. this.property = property;
  7. }
  8. get value() {
  9. return this.object[ this.property ];
  10. }
  11. set value( val ) {
  12. this.object[ this.property ] = val;
  13. }
  14. toJSON( meta ) {
  15. let data = this.getJSONNode( meta );
  16. if ( ! data ) {
  17. data = this.createJSONNode( meta );
  18. data.value = this.value;
  19. data.property = this.property;
  20. }
  21. return data;
  22. }
  23. }
  24. PropertyNode.prototype.nodeType = 'Property';
  25. export { PropertyNode };