aframe-ar-driver.js 2.6 KB

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