You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

video.html 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1, maximum-scale=1">
  6. <title>encantar.js WebAR demo with A-Frame</title>
  7. <link href="../assets/demo.css" rel="stylesheet">
  8. <script src="../../dist/encantar.min.js"></script>
  9. <script src="https://cdn.jsdelivr.net/npm/aframe@1.6.0/dist/aframe-v1.6.0.min.js"></script>
  10. <script src="../../plugins/aframe-with-encantar.js"></script>
  11. <script src="../../addons/aframe/ar-scan-gimmick.js"></script>
  12. <script src="../../addons/aframe/gltf-anim.js"></script>
  13. </head>
  14. <body>
  15. <!-- The AR scene -->
  16. <a-scene encantar="stats: true; gizmos: true" loading-screen="enabled: false">
  17. <!--
  18. +============================+
  19. | Let's set up an AR session |
  20. +============================+
  21. -->
  22. <!-- The inputs that will feed the AR engine -->
  23. <ar-sources>
  24. <!-- Use a webcam -->
  25. <!--
  26. <ar-camera-source></ar-camera-source>
  27. -->
  28. <!-- Use a video element -->
  29. <ar-video-source video="#my-video"></ar-video-source>
  30. </ar-sources>
  31. <!-- The trackers we'll be using in AR -->
  32. <ar-trackers>
  33. <!-- We'll track images -->
  34. <ar-image-tracker>
  35. <!-- List the images that you intend to track
  36. Make sure to follow the guidelines for images (see the docs) -->
  37. <ar-reference-image name="mage" src="../assets/mage.webp"></ar-reference-image>
  38. <ar-reference-image name="cat" src="../assets/cat.webp"></ar-reference-image>
  39. </ar-image-tracker>
  40. </ar-trackers>
  41. <!-- The AR viewport -->
  42. <ar-viewport>
  43. <!-- A 2D overlay displayed in front of the AR scene -->
  44. <ar-hud>
  45. <!-- The info button -->
  46. <a id="info" href="NOTICE.html" draggable="false"></a>
  47. <!-- The like button -->
  48. <a id="like" href="../assets/promo.html" draggable="false"></a>
  49. <!-- The scan gimmick -->
  50. <ar-scan-gimmick opacity="0.75"></ar-scan-gimmick>
  51. </ar-hud>
  52. </ar-viewport>
  53. <!--
  54. +=================================================+
  55. | Now let's create the virtual elements |
  56. | Whatever you add to <ar-root> will appear in AR |
  57. +=================================================+
  58. -->
  59. <!-- A 3D camera adapted for AR -->
  60. <ar-camera></ar-camera>
  61. <!-- Light -->
  62. <a-light type="ambient" intensity="1.0"></a-light>
  63. <!-- The mage -->
  64. <ar-root reference-image="mage">
  65. <!-- Switch from top view to front view -->
  66. <a-entity rotation="-90 0 0" position="0 -0.8 0">
  67. <!-- 3D model -->
  68. <a-entity
  69. gltf-model="#mage-model" gltf-anim="clip: Idle"
  70. rotation="90 0 0" scale="0.7 0.7 0.7">
  71. </a-entity>
  72. <!-- Magic circle -->
  73. <a-plane width="4" height="4"
  74. material="src: #magic-circle; color: #beefff; side: double; shader: flat; transparent: true; opacity: 1"
  75. animation="property: object3D.rotation.z; from: 360; to: 0; dur: 8000; loop: true; easing: linear">
  76. </a-plane>
  77. </a-entity>
  78. </ar-root>
  79. <!-- The cat -->
  80. <ar-root reference-image="cat">
  81. <a-entity rotation="-90 0 0" position="0 -0.8 0">
  82. <a-entity
  83. gltf-model="#cat-model" gltf-anim="clip: Cheer"
  84. rotation="90 0 0" scale="0.7 0.7 0.7">
  85. </a-entity>
  86. <a-plane width="4" height="4"
  87. material="src: #magic-circle; color: #ffa; side: double; shader: flat; transparent: true; opacity: 1"
  88. animation="property: object3D.rotation.z; from: 360; to: 0; dur: 8000; loop: true; easing: linear">
  89. </a-plane>
  90. <a-entity position="0 -0.5 2">
  91. <a-plane width="3" height="1.5" rotation="90 0 0"
  92. material="src: #it-works; color: #fff; side: double; shader: flat; transparent: true; opacity: 1">
  93. </a-plane>
  94. </a-entity>
  95. </a-entity>
  96. </ar-root>
  97. <!-- Declare external media files here -->
  98. <a-assets>
  99. <a-asset-item id="cat-model" src="../assets/cat.glb"></a-asset-item>
  100. <a-asset-item id="mage-model" src="../assets/mage.glb"></a-asset-item>
  101. <img id="magic-circle" src="../assets/magic-circle.png">
  102. <img id="it-works" src="../assets/it-works.png">
  103. </a-assets>
  104. </a-scene>
  105. <!-- Feed the Image Tracker with this video -->
  106. <video id="my-video" hidden muted loop playsinline autoplay>
  107. <source src="../assets/my-video.webm" type="video/webm" />
  108. <source src="../assets/my-video.mp4" type="video/mp4" />
  109. </video>
  110. </body>
  111. </html>