您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

video.html 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width,initial-scale=1">
  6. <title>encantar.js WebAR demo with A-Frame</title>
  7. <link href="demo.css" rel="stylesheet">
  8. <script src="../../dist/encantar.min.js"></script>
  9. <script src="https://cdn.jsdelivr.net/npm/aframe@1.4.2/dist/aframe-v1.4.2.min.js"></script>
  10. <script src="../../plugins/aframe-with-encantar.js"></script>
  11. <script src="../../plugins/extras/aframe-scan-gimmick-for-encantar.js"></script>
  12. <script src="../../plugins/extras/aframe-gltf-anim.js"></script>
  13. </head>
  14. <body>
  15. <!-- The AR scene -->
  16. <a-scene ar-session="stats: true; gizmos: true">
  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 (see <a-assets>) -->
  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 about button -->
  46. <a id="about" href="NOTICE.html" draggable="false"></a>
  47. <!-- The scan gimmick -->
  48. <a-entity ar-scan-gimmick="opacity: 0.75"></a-entity>
  49. </ar-hud>
  50. </ar-viewport>
  51. <!--
  52. +=================================================+
  53. | Now let's create the virtual elements |
  54. | Whatever you add to <ar-root> will appear in AR |
  55. +=================================================+
  56. -->
  57. <!-- A 3D camera adapted for AR -->
  58. <ar-camera></ar-camera>
  59. <!-- The mage -->
  60. <ar-root reference-image="mage">
  61. <!-- Switch from top view to front view -->
  62. <a-entity rotation="-90 0 0" position="0 -0.5 0">
  63. <!-- Light -->
  64. <a-light type="ambient" intensity="1.5"></a-light>
  65. <!-- 3D model -->
  66. <a-entity
  67. gltf-model="#mage-model" gltf-anim="clip: Idle"
  68. rotation="90 0 0" scale="0.7 0.7 0.7">
  69. </a-entity>
  70. <!-- Magic circle -->
  71. <a-plane width="4" height="4"
  72. material="src: #magic-circle; color: #beefff; side: double; shader: flat; transparent: true; opacity: 1"
  73. animation="property: object3D.rotation.z; from: 360; to: 0; dur: 8000; loop: true; easing: linear">
  74. </a-plane>
  75. </a-entity>
  76. </ar-root>
  77. <!-- The cat -->
  78. <ar-root reference-image="cat">
  79. <a-entity rotation="-90 0 0" position="0 -0.5 0">
  80. <a-light type="ambient" intensity="1.5"></a-light>
  81. <a-entity
  82. gltf-model="#cat-model" gltf-anim="clip: Cheer"
  83. rotation="90 0 0" scale="0.7 0.7 0.7">
  84. </a-entity>
  85. <a-plane width="4" height="4"
  86. material="src: #magic-circle; color: #ffa; side: double; shader: flat; transparent: true; opacity: 1"
  87. animation="property: object3D.rotation.z; from: 360; to: 0; dur: 8000; loop: true; easing: linear">
  88. </a-plane>
  89. <a-entity position="0 -0.5 2">
  90. <a-plane width="3" height="1.5" rotation="90 0 0"
  91. material="src: #it-works; color: #fff; side: double; shader: flat; transparent: true; opacity: 1">
  92. </a-plane>
  93. </a-entity>
  94. </a-entity>
  95. </ar-root>
  96. <!-- Declare external media files here -->
  97. <a-assets>
  98. <a-asset-item id="cat-model" src="../assets/cat.glb"></a-asset-item>
  99. <a-asset-item id="mage-model" src="../assets/mage.glb"></a-asset-item>
  100. <img id="magic-circle" src="../assets/magic-circle.png">
  101. <img id="it-works" src="../assets/it-works.png">
  102. <video id="my-video" hidden muted loop playsinline autoplay>
  103. <source src="../assets/my-video.webm" type="video/webm" />
  104. <source src="../assets/my-video.mp4" type="video/mp4" />
  105. </video>
  106. </a-assets>
  107. </a-scene>
  108. </body>
  109. </html>