osc.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /*
  2. The MIT License (MIT)
  3. Copyright (c) 2014-2018 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. // VWF & OSC model driver
  7. import { Fabric } from '/core/vwf/fabric.js';
  8. class OSCModel extends Fabric {
  9. constructor(module) {
  10. console.log("OSCModel constructor");
  11. super(module, "Model");
  12. }
  13. factory() {
  14. let _self_ = this;
  15. return this.load( this.module,
  16. {
  17. // == Module Definition ====================================================================
  18. // -- pipeline -----------------------------------------------------------------------------
  19. // pipeline: [ log ], // vwf <=> log <=> scene
  20. // -- initialize ---------------------------------------------------------------------------
  21. initialize: function() {
  22. this.objects = {}; // maps id => { property: value, ... }
  23. self = this;
  24. this.osc = null;
  25. //window._OSCModel = this;
  26. },
  27. // == Model API ============================================================================
  28. // -- creatingNode -------------------------------------------------------------------------
  29. creatingNode: function( nodeID, childID, childExtendsID, childImplementsIDs,
  30. childSource, childType, childURI, childName, callback /* ( ready ) */ ) {
  31. },
  32. // -- deletingNode -------------------------------------------------------------------------
  33. deletingNode: function( nodeID ) {
  34. },
  35. // -- addingChild --------------------------------------------------------------------------
  36. addingChild: function( nodeID, childID, childName ) {
  37. },
  38. // -- removingChild ------------------------------------------------------------------------
  39. removingChild: function( nodeID, childID ) {
  40. },
  41. // -- parenting ----------------------------------------------------------------------------
  42. parenting: function( nodeID ) {
  43. },
  44. // -- childrening --------------------------------------------------------------------------
  45. childrening: function( nodeID ) {
  46. },
  47. // -- naming -------------------------------------------------------------------------------
  48. naming: function( nodeID ) {
  49. },
  50. // -- creatingProperty ---------------------------------------------------------------------
  51. creatingProperty: function( nodeID, propertyName, propertyValue ) {
  52. // var object = this.objects[nodeID] || ( this.objects[nodeID] = {} );
  53. // return object[propertyName] = propertyValue;
  54. },
  55. // -- initializingProperty -----------------------------------------------------------------
  56. initializingProperty: function( nodeID, propertyName, propertyValue ) {
  57. // var object = this.objects[nodeID] || ( this.objects[nodeID] = {} );
  58. // return object[propertyName] = propertyValue;
  59. },
  60. // TODO: deletingProperty
  61. // -- settingProperty ----------------------------------------------------------------------
  62. settingProperty: function( nodeID, propertyName, propertyValue ) {
  63. // var object = this.objects[nodeID] || ( this.objects[nodeID] = {} );
  64. // return object[propertyName] = propertyValue;
  65. },
  66. // -- gettingProperty ----------------------------------------------------------------------
  67. gettingProperty: function( nodeID, propertyName, propertyValue ) {
  68. // var object = this.objects[nodeID];
  69. // return object && object[propertyName];
  70. },
  71. // -- creatingMethod -----------------------------------------------------------------------
  72. creatingMethod: function( nodeID, methodName, methodParameters, methodBody ) {
  73. },
  74. // TODO: deletingMethod
  75. // -- callingMethod ------------------------------------------------------------------------
  76. callingMethod: function( nodeID, methodName, methodParameters ) {
  77. // if (methodName == 'sendOSC') {
  78. // if (this.osc == null) {
  79. // this.osc = _OSCManager;
  80. // }
  81. // // var msg = {
  82. // // address: "/hello/from/oscjs",
  83. // // args: [Math.random()]
  84. // // };
  85. // this.osc.port.send(methodParameters);
  86. // console.log('send: ' + methodParameters);
  87. // }
  88. },
  89. // -- creatingEvent ------------------------------------------------------------------------
  90. creatingEvent: function( nodeID, eventName, eventParameters ) {
  91. },
  92. // TODO: deletingEvent
  93. // -- firingEvent --------------------------------------------------------------------------
  94. firingEvent: function( nodeID, eventName, eventParameters ) {
  95. },
  96. // -- executing ----------------------------------------------------------------------------
  97. executing: function( nodeID, scriptText, scriptType ) {
  98. }
  99. } );
  100. }
  101. }
  102. export {
  103. OSCModel as default
  104. }