stage.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. The MIT License (MIT)
  3. Copyright (c) 2014-2020 Nikolai Suslov and the Krestianstvo.org project contributors. (https://github.com/NikolaySuslov/livecodingspace/blob/master/LICENSE.md)
  4. Virtual World Framework Apache 2.0 license (https://github.com/NikolaySuslov/livecodingspace/blob/master/licenses/LICENSE_VWF.md)
  5. */
  6. /// @module vwf/model/stage
  7. /// @requires vwf/model
  8. import { Fabric } from '/core/vwf/fabric.js';
  9. class Stage extends Fabric {
  10. constructor(module) {
  11. //console.log("Stage constructor");
  12. super(module, "Model")
  13. }
  14. factory(){
  15. return this.load( this.module,
  16. {
  17. fabricize: function ( model, model_api ) {
  18. this.model = model;
  19. // Suppress functions that aren't implemented in the stage to the right.
  20. Object.keys( model_api ).forEach( function( modelFunctionName ) {
  21. if ( ! model[modelFunctionName] ) {
  22. this[modelFunctionName] = undefined;
  23. }
  24. }, this );
  25. }
  26. },
  27. function( modelFunctionName ) {
  28. // == Model API ============================================================================
  29. return function() {
  30. return this.model[modelFunctionName] && this.model[modelFunctionName].apply( this.model, arguments );
  31. };
  32. }, function( kernelFunctionName ) {
  33. // == Kernel API ===========================================================================
  34. return function() {
  35. return this.kernel[kernelFunctionName].apply( this.kernel, arguments );
  36. };
  37. } );
  38. }
  39. }
  40. export {
  41. Stage
  42. }