A-Frame 無需安裝任何東西,採用 HTML 文件開發,使其易於上手,用於構建虛擬實境 (VR) 體驗的網路框架。A-Frame 不僅僅是 3D 場景圖或標記語言,它的核心更是一個強大的實體組件框架。
範例一:
程式碼:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <!DOCTYPE html> <html> <head> <script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script> </head> <body> <a-scene> <a-box position="-1 0.5 -3" rotation="0 45 0" color="#4CC3D9"></a-box> <a-sphere position="0 1.25 -5" radius="1.25" color="#EF2D5E"></a-sphere> <a-cylinder position="1 0.75 -3" radius="0.5" height="1.5" color="#FFC65D"></a-cylinder> <a-plane position="0 0 -4" rotation="-90 0 0" width="4" height="4" color="#7BC8A4"></a-plane> <a-sky color="#ECECEC"></a-sky> </a-scene> </body> </html> |
範例二:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | <!DOCTYPE html> <head> <meta charset="utf-8"> <title>Model Viewer AR - VR</title> <meta name="description" content="Model Viewer (VR / AR) • A-Frame"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script> <script src="info-message.js"></script> <script src="https://unpkg.com/aframe-extras@3.3.0/dist/aframe-extras.min.js"></script> <script src="hide-on-enter-ar.js"></script> <script src="ar-shadows.js"></script> <script src="ar-hit-test.js"></script> <script src="model-viewer.js"></script> <script src="background-gradient.js"></script> </head> <body> <a-scene renderer="colorManagement: true;" info-message="htmlSrc: #messageText" model-viewer="gltfModel: #triceratops; title: Triceratops"> <a-assets> <!-- Model source: https://sketchfab.com/3d-models/triceratops-d16aabe33dc24f8ab37e3df50c068265 Model author: https://sketchfab.com/VapTor Model license: Sketcfab Standard --> <a-asset-item id="triceratops" src="https://cdn.aframe.io/examples/ar/models/triceratops/scene.gltf" response-type="arraybuffer" crossorigin="anonymous"></a-asset-item> <a-asset-item id="reticle" src="https://cdn.aframe.io/examples/ar/models/reticle/reticle.gltf" response-type="arraybuffer" crossorigin="anonymous"></a-asset-item> <img id="shadow" src="https://cdn.glitch.com/20600112-c04b-492c-8190-8a5ccc06f37d%2Fshadow.png?v=1606338852399"></img> <a-asset-item id="messageText" src="message.html"></a-asset-item> </a-assets> </a-scene> </body> </html> |
沒有留言:
張貼留言