Guest User

wikitude

a guest
Jan 12th, 2016
101
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var World = {
  2. loaded: false,
  3.  
  4. init: function initFn() {
  5. /*
  6. Disable all sensors in "IR-only" Worlds to save performance. If the property is set to true, any geo-related components (such as GeoObjects and ActionRanges) are active. If the property is set to false, any geo-related components will not be visible on the screen, and triggers will not fire.
  7. */
  8. AR.context.services.sensors = false;
  9. this.createOverlays();
  10. },
  11.  
  12. createOverlays: function createOverlaysFn() {
  13. /*
  14. First an AR.Tracker needs to be created in order to start the recognition engine. It is initialized with a URL specific to the target collection. Optional parameters are passed as object in the last argument. In this case a callback function for the onLoaded trigger is set. Once the tracker is fully loaded the function worldLoaded() is called.
  15.  
  16. Important: If you replace the tracker file with your own, make sure to change the target name accordingly.
  17. Use a specific target name to respond only to a certain target or use a wildcard to respond to any or a certain group of targets.
  18. */
  19. this.tracker = new AR.ClientTracker("assets/tracker.wtc", {
  20. onLoaded: this.worldLoaded
  21. });
  22.  
  23. /*
  24. The next step is to create the augmentation. In this example an image resource is created and passed to the AR.ImageDrawable. A drawable is a visual component that can be connected to an IR target (AR.Trackable2DObject) or a geolocated object (AR.GeoObject). The AR.ImageDrawable is initialized by the image and its size. Optional parameters allow for position it relative to the recognized target.
  25. */
  26.  
  27. /* Create overlay for page one */
  28. var imgOne = new AR.ImageResource("assets/FG7809.png");
  29. var overlayOne = new AR.ImageDrawable(imgOne, 1, {
  30. offsetX: 0.15,
  31. offsetY: 0
  32. });
  33.  
  34. var video = new AR.VideoDrawable("assets/textvid2.mp4", .5, {
  35. offsetX: 0,
  36. offsetY: 0,
  37. onLoaded: function videoLoaded() {
  38. video.enabled = true;
  39. },
  40. onPlaybackStarted: function videoPlaying () {
  41. video.playing = true;
  42. video.enabled = true;
  43. },
  44. onFinishedPlaying: function videoFinished () {
  45. video.playing = false;
  46. video.enabled = false;
  47. },
  48. onClick: function videoClicked () {
  49. if (video.playing) {
  50. video.pause();
  51. video.playing = false;
  52. } else {
  53. video.resume();
  54. video.playing = true;
  55. }
  56. }
  57. });
  58.  
  59. var imgTwo = new AR.ImageResource("assets/FG7814.png");
  60. var overlayTwo = new AR.ImageDrawable(imgTwo, 1, {
  61. offsetX: -0.15,
  62. offsetY: 0
  63. });
  64.  
  65. var video2 = new AR.VideoDrawable("assets/Jeanny.mp4", .5, {
  66. offsetX: 0,
  67. offsetY: 0,
  68. onLoaded: function videoLoaded() {
  69. video2.enabled = true;
  70. },
  71. onPlaybackStarted: function videoPlaying () {
  72. video2.playing = true;
  73. video2.enabled = true;
  74. },
  75. onFinishedPlaying: function videoFinished () {
  76. video2.playing = false;
  77. video2.enabled = false;
  78. },
  79. onClick: function videoClicked () {
  80. if (video2.playing) {
  81. video2.pause();
  82. video2.playing = false;
  83. } else {
  84. video2.resume();
  85. video2.playing = true;
  86. }
  87. }
  88. });
  89.  
  90. var imgThree = new AR.ImageResource("assets/FG7815.png");
  91. var overlayThree = new AR.ImageDrawable(imgThree, 1, {
  92. offsetX: 0,
  93. offsetY: 0
  94. });
  95.  
  96. var video3 = new AR.VideoDrawable("assets/textvid.mp4", 2, {
  97. offsetX: 0,
  98. offsetY: 0,
  99. onLoaded: function videoLoaded() {
  100. video3.enabled = true;
  101. },
  102. onPlaybackStarted: function videoPlaying () {
  103. video3.playing = true;
  104. video3.enabled = true;
  105. },
  106. onFinishedPlaying: function videoFinished () {
  107. video3.playing = false;
  108. video3.enabled = false;
  109. },
  110. onClick: function videoClicked () {
  111. if (video3.playing) {
  112. video3.pause();
  113. video3.playing = false;
  114. } else {
  115. video3.resume();
  116. video3.playing = true;
  117. }
  118. }
  119. });
  120.  
  121. var pageOne = new AR.Trackable2DObject(this.tracker, "imgOne", {
  122. drawables: {
  123. cam: overlayOne
  124. },
  125. onEnterFieldOfVision: function onEnterFieldOfVisionFn () {
  126. if (video.playing) {
  127. video.pause();
  128. }
  129. },
  130. onExitFieldOfVision: function onExitFieldOfVisionFn () {
  131. if (video.playing) {
  132. video.pause();
  133. }
  134. }
  135. });
  136.  
  137. var pageTwo = new AR.Trackable2DObject(this.tracker, "imgTwo", {
  138. drawables: {
  139. cam: overlayTwo
  140. },
  141. onEnterFieldOfVision: function onEnterFieldOfVisionFn () {
  142. if (video2.playing) {
  143. video2.pause();
  144. }
  145. },
  146. onExitFieldOfVision: function onExitFieldOfVisionFn () {
  147. if (video2.playing) {
  148. video2.pause();
  149. }
  150. }
  151. });
  152.  
  153. var pageThree = new AR.Trackable2DObject(this.tracker, "*", {
  154. drawables: {
  155. cam: video3
  156. },
  157. onEnterFieldOfVision: function onEnterFieldOfVisionFn () {
  158.  
  159. if (video3.playing) {
  160. video3.pause();
  161. }
  162. },
  163. onExitFieldOfVision: function onExitFieldOfVisionFn () {
  164. if (video3.playing) {
  165. video3.pause();
  166. }
  167. }
  168. });
  169. },
  170.  
  171. worldLoaded: function worldLoadedFn() {
  172. var cssDivInstructions = " style='display: table-cell;vertical-align: middle; text-align: right; width: 50%; padding-right: 15px;'";
  173. var cssDivSurfer = " style='display: table-cell;vertical-align: middle; text-align: left; padding-right: 15px; width: 38px'";
  174. var cssDivBiker = " style='display: table-cell;vertical-align: middle; text-align: left; padding-right: 15px;'";
  175. document.getElementById('loadingMessage').innerHTML =
  176. "<div" + cssDivInstructions + ">Scan Target &#35;1 (iphone) or &#35;2 (mug):</div>" +
  177. "<div" + cssDivSurfer + "><img src='assets/FG7809.png' height='64px' width='64px'></img></div>" +
  178. "<div" + cssDivBiker + "><img src='assets/FG7814.png' height='64px' width='64px'></img></div>";
  179.  
  180. // Remove Scan target message after 10 sec.
  181. setTimeout(function() {
  182. var e = document.getElementById('loadingMessage');
  183. e.parentElement.removeChild(e);
  184. }, 10000);
  185. }
  186. };
  187. World.init();
RAW Paste Data