wmrvrcontroller.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. this.simpleDef = {
  2. "extends": "http://vwf.example.com/aframe/abox.vwf",
  3. "properties": {
  4. "color": "white",
  5. "position": "0 0 0",
  6. "height": 0.01,
  7. "width": 0.01,
  8. "depth": 1,
  9. },
  10. children: {
  11. "pointer": {
  12. "extends": "http://vwf.example.com/aframe/abox.vwf",
  13. "properties": {
  14. "color": "green",
  15. "position": "0 0 -0.8",
  16. "height": 0.1,
  17. "width": 0.1,
  18. "depth": 0.1
  19. }
  20. },
  21. "interpolation":
  22. {
  23. "extends": "http://vwf.example.com/aframe/interpolation-component.vwf",
  24. "type": "component",
  25. "properties": {
  26. "enabled": true
  27. }
  28. }
  29. }
  30. }
  31. this.modelDef = {
  32. "extends": "http://vwf.example.com/aframe/agltfmodel.vwf",
  33. "properties": {
  34. "src": "#wmrvr",
  35. "position": "0 0 0",
  36. "rotation": "0 180 0"
  37. },
  38. "children": {
  39. "animation-mixer": {
  40. "extends": "http://vwf.example.com/aframe/anim-mixer-component.vwf",
  41. "properties": {
  42. "clip": "*",
  43. "duration": 1
  44. }
  45. }
  46. }
  47. }
  48. this.createController = function (modelSrc) {
  49. let controllerDef = this.simpleDef;
  50. var newNode = {
  51. "extends": "http://vwf.example.com/aframe/aentity.vwf",
  52. "properties": {
  53. "position": [0, 0, 0]
  54. },
  55. children: {
  56. "controller": controllerDef
  57. }
  58. }
  59. if (modelSrc) {
  60. let controllerDef = this.modelDef;
  61. controllerDef.properties.src = modelSrc;
  62. newNode.children.controller = controllerDef;
  63. }
  64. let interpolation = {
  65. "extends": "http://vwf.example.com/aframe/interpolation-component.vwf",
  66. "type": "component",
  67. "properties": {
  68. "enabled": true
  69. }
  70. }
  71. this.children.create( "interpolation", interpolation );
  72. this.children.create("handVRNode", newNode);
  73. }
  74. this.updateVRControl = function(position, rotation){
  75. this.rotation = rotation;
  76. this.position = position;
  77. }
  78. this.createSimpleController = function(){
  79. if (this.handVRNode.controller) {
  80. this.handVRNode.children.delete(this.handVRNode.controller);
  81. let controllerDef = this.simpleDef;
  82. this.handVRNode.children.create("controller", controllerDef);
  83. }
  84. }
  85. this.createAvatarFromGLTF = function(modelSrc){
  86. if (this.handVRNode.controller) {
  87. this.handVRNode.children.delete(this.handVRNode.controller);
  88. let controllerDef = this.modelDef;
  89. controllerDef.properties.src = modelSrc;
  90. this.handVRNode.children.create("controller", controllerDef);
  91. }
  92. }
  93. this.initialize = function() {
  94. // this.future(0).update();
  95. }
  96. this.triggerdown = function() {
  97. this.handVRNode.controller.pointer.color = 'red'
  98. }
  99. this.triggerup = function() {
  100. this.handVRNode.controller.pointer.color = 'green'
  101. }