ohm.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. import {Fabric} from '/core/vwf/fabric.js';
  9. class OhmViewDriver extends Fabric {
  10. constructor(module) {
  11. console.log("OhmViewDriver constructor");
  12. super(module, 'View');
  13. }
  14. factory() {
  15. let _self_ = this;
  16. return this.load(this.module,
  17. {
  18. // == Module Definition ====================================================================
  19. initialize: function (options) {
  20. let self = this;
  21. this.fabric = _self_;
  22. this.nodes = {};
  23. },
  24. // initializedNode: function( nodeID, childID ) {
  25. // },
  26. createdProperty: function (nodeId, propertyName, propertyValue) {
  27. return this.satProperty(nodeId, propertyName, propertyValue);
  28. },
  29. initializedProperty: function (nodeId, propertyName, propertyValue) {
  30. return this.satProperty(nodeId, propertyName, propertyValue);
  31. },
  32. satMethod: function (nodeId, methodName) {
  33. let self = this;
  34. var node = this.state.nodes[ nodeId ];
  35. if ( !( node && node.lang) ) {
  36. return;
  37. }
  38. if (methodName.indexOf("Operation") > -1) {
  39. //self.kernel.callMethod (nodeId, methodName);
  40. self.kernel.setProperty(nodeId, 'ohmLang', node.lang.source);
  41. console.log("set new lang properties");
  42. }
  43. },
  44. // createdMethod: function( nodeId, methodName, methodParameters, methodBody) {
  45. // var self = this;
  46. // var node = this.state.nodes[ nodeId ];
  47. // if ( !( node && node.lang) ) {
  48. // return;
  49. // }
  50. // if (methodName.indexOf("Operation") > -1) {
  51. // console.log("add semantic operations");
  52. // self.kernel.callMethod (nodeId, methodName);
  53. // }
  54. // },
  55. satProperty: function (nodeId, propertyName, propertyValue) {
  56. let self = this;
  57. var node = this.state.nodes[ nodeId ];
  58. if ( !( node && node.lang) ) {
  59. return;
  60. }
  61. var lang = node.lang;
  62. switch (propertyName) {
  63. case "ohmLang":
  64. if (propertyValue) {
  65. self.kernel.callMethod (nodeId, 'initLang');
  66. }
  67. break;
  68. }
  69. },
  70. // firedEvent: function (nodeID, eventName, eventParameters) {
  71. // },
  72. // ticked: function (vwfTime) {
  73. // }
  74. });
  75. }
  76. }
  77. export { OhmViewDriver as default }