aframe-ar-driver.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. */
  5. import {Fabric} from '/core/vwf/fabric.js';
  6. class AFrameARView extends Fabric {
  7. constructor(module) {
  8. console.log("AFrameARView constructor");
  9. super(module, 'View');
  10. }
  11. factory() {
  12. let _self_ = this;
  13. return this.load(this.module,
  14. {
  15. initialize: function() {
  16. let self = this;
  17. this.fabric = _self_;
  18. },
  19. createdNode: function (nodeID, childID, childExtendsID, childImplementsIDs,
  20. childSource, childType, childIndex, childName, callback /* ( ready ) */) {
  21. // var node = this.state.nodes[childID];
  22. // // If the "nodes" object does not have this object in it, it must not be one that
  23. // // this driver cares about
  24. // if (!node) {
  25. // return;
  26. // }
  27. },
  28. initializedNode: function (nodeID, childID) {
  29. let self = this;
  30. //let viewDriver = vwf.views["vwf/view/aframe"];
  31. let viewDriver = vwf.views["/drivers/view/aframe"];
  32. if (!viewDriver) {
  33. return;
  34. }
  35. let node = viewDriver.state.nodes[childID];
  36. if (!node) {
  37. return;
  38. }
  39. if (viewDriver.state.scenes[childID]) {
  40. let scene = viewDriver.state.scenes[childID];
  41. scene.setAttribute('embedded', {});
  42. scene.setAttribute('arjs', {trackingMethod: "best", sourceType: "webcam", debugUIEnabled: "false"});
  43. }
  44. if (viewDriver.state.nodes[childID].extendsID == "proxy/aframe/acamera.vwf") {
  45. //if(!childID.includes('avatar')){
  46. if(node.type == 'ar'){
  47. console.log(childID);
  48. vwf_view.kernel.callMethod(childID, "setCameraToActive", [vwf.moniker_]);
  49. }
  50. }
  51. },
  52. firedEvent: function (nodeID, eventName, eventParameters) {
  53. // var node = self.viewDriver.state.nodes[nodeID];
  54. // if (!node) {
  55. // return;
  56. // }
  57. // if (eventName == "createAvatar") {
  58. // let avatarName = 'avatar-' + self.kernel.moniker();
  59. // vwf_view.kernel.callMethod(avatarName, "showHideAvatar", false);
  60. // }
  61. },
  62. /*
  63. * Receives incoming messages
  64. */
  65. calledMethod: function( nodeID, methodName, methodParameters, methodValue ) {
  66. let self = this;
  67. let viewDriver = vwf.views["/drivers/view/aframe"];
  68. if (!viewDriver) {
  69. return;
  70. }
  71. var node = viewDriver.state.nodes[nodeID];
  72. if (!node) {
  73. return;
  74. }
  75. if (methodName == "createAvatarBody") {
  76. let avatarName = 'avatar-' + self.kernel.moniker();
  77. if (nodeID == avatarName) {
  78. vwf_view.kernel.callMethod(nodeID, "showHideAvatar", [false]);
  79. }
  80. }
  81. }
  82. })
  83. }
  84. }
  85. export { AFrameARView as default }