ohm.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. "use strict";
  2. /*
  3. The MIT License (MIT)
  4. Copyright (c) 2014-2018 Nikolai Suslov and the Krestianstvo.org project contributors. (https://github.com/NikolaySuslov/livecodingspace/blob/master/LICENSE.md)
  5. Virtual World Framework Apache 2.0 license (https://github.com/NikolaySuslov/livecodingspace/blob/master/licenses/LICENSE_VWF.md)
  6. */
  7. // VWF & Ohm view driver
  8. define(["module", "vwf/view"], function (module, view) {
  9. return view.load(module, {
  10. // == Module Definition ====================================================================
  11. initialize: function (options) {
  12. var self = this;
  13. this.nodes = {};
  14. },
  15. // initializedNode: function( nodeID, childID ) {
  16. // },
  17. createdProperty: function (nodeId, propertyName, propertyValue) {
  18. return this.satProperty(nodeId, propertyName, propertyValue);
  19. },
  20. initializedProperty: function (nodeId, propertyName, propertyValue) {
  21. return this.satProperty(nodeId, propertyName, propertyValue);
  22. },
  23. satMethod: function (nodeId, methodName) {
  24. var self = this;
  25. var node = this.state.nodes[ nodeId ];
  26. if ( !( node && node.lang) ) {
  27. return;
  28. }
  29. if (methodName.indexOf("Operation") > -1) {
  30. //self.kernel.callMethod (nodeId, methodName);
  31. self.kernel.setProperty(nodeId, 'ohmLang', node.lang.source);
  32. console.log("set new lang properties");
  33. }
  34. },
  35. // createdMethod: function( nodeId, methodName, methodParameters, methodBody) {
  36. // var self = this;
  37. // var node = this.state.nodes[ nodeId ];
  38. // if ( !( node && node.lang) ) {
  39. // return;
  40. // }
  41. // if (methodName.indexOf("Operation") > -1) {
  42. // console.log("add semantic operations");
  43. // self.kernel.callMethod (nodeId, methodName);
  44. // }
  45. // },
  46. satProperty: function (nodeId, propertyName, propertyValue) {
  47. var self = this;
  48. var node = this.state.nodes[ nodeId ];
  49. if ( !( node && node.lang) ) {
  50. return;
  51. }
  52. var lang = node.lang;
  53. switch (propertyName) {
  54. case "ohmLang":
  55. if (propertyValue) {
  56. self.kernel.callMethod (nodeId, 'initLang');
  57. }
  58. break;
  59. }
  60. },
  61. // firedEvent: function (nodeID, eventName, eventParameters) {
  62. // },
  63. // ticked: function (vwfTime) {
  64. // }
  65. });
  66. });