SubSlotNode.js 956 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import { TempNode } from '../core/TempNode.js';
  2. class SubSlotNode extends TempNode {
  3. constructor( slots ) {
  4. super();
  5. this.slots = slots || {};
  6. }
  7. getType( builder, output ) {
  8. return output;
  9. }
  10. generate( builder, output ) {
  11. if ( this.slots[ builder.slot ] ) {
  12. return this.slots[ builder.slot ].build( builder, output );
  13. }
  14. return builder.format( '0.0', 'f', output );
  15. }
  16. copy( source ) {
  17. super.copy( source );
  18. for ( const prop in source.slots ) {
  19. this.slots[ prop ] = source.slots[ prop ];
  20. }
  21. return this;
  22. }
  23. toJSON( meta ) {
  24. let data = this.getJSONNode( meta );
  25. if ( ! data ) {
  26. data = this.createJSONNode( meta );
  27. data.slots = {};
  28. for ( const prop in this.slots ) {
  29. const slot = this.slots[ prop ];
  30. if ( slot ) {
  31. data.slots[ prop ] = slot.toJSON( meta ).uuid;
  32. }
  33. }
  34. }
  35. return data;
  36. }
  37. }
  38. SubSlotNode.prototype.nodeType = 'SubSlot';
  39. export { SubSlotNode };