aframe

aframe

跨平台虚拟和增强现实Web开发框架

A-Frame是一个开源Web框架,用于创建跨平台虚拟现实和增强现实体验。它采用HTML声明式语法,支持实体组件架构,注重性能优化,并提供内置3D检查器。开发者无需深入的3D或WebXR知识即可创建沉浸式应用。该框架适用于多种VR/AR设备,拥有活跃社区和丰富组件生态,是WebVR/AR项目开发的有力工具。

A-Frame虚拟现实WebXR3D框架开源项目Github
<h1 align="center">A-Frame</h1> <p align="center"><a href="https://aframe.io" target="_blank"><img width="480" alt="A-Frame" src="https://yellow-cdn.veclightyear.com/835a84d5/b2e7f40c-63d5-4883-b196-ba8be65b10e3.jpg"></a></p> <p align="center"><b>用于构建虚拟现实体验的网页框架。</b></p> <p align="center"> <a href="https://codecov.io/gh/aframevr/aframe"> <img src="https://yellow-cdn.veclightyear.com/835a84d5/e2522ade-bc0c-4a70-94bd-022902904ce0.svg" alt="覆盖率状态"> </a> <a href="https://npmjs.org/package/aframe"> <img src="https://yellow-cdn.veclightyear.com/835a84d5/742106da-4299-42df-a1e3-e4e33e425112.svg?style=flat-square" alt="下载量"> </a> <a href="https://npmjs.org/package/aframe"> <img src="https://yellow-cdn.veclightyear.com/835a84d5/5af0bb02-2c03-4a39-88e5-8c75df240993.svg?style=flat-square" alt="版本"> </a> <a href="https://npmjs.com/package/aframe"> <img src="https://yellow-cdn.veclightyear.com/835a84d5/b5c6fad0-0d49-4bfd-b471-726220cef5a1.svg?style=flat-square" alt="许可证"></a> </a> </p> <div align="center"> <a href="https://aframe.io">网站</a> &mdash; <a href="https://aframe.io/docs/">文档</a> &mdash; <a href="https://aframe.io/school/">学校</a> &mdash; <a href="https://aframevr.slack.com/join/shared_invite/zt-f6rne3ly-ekVaBU~Xu~fsZHXr56jacQ">Slack</a> &mdash; <a href="https://aframe.io/blog/">博客</a> &mdash; <a href="https://aframe.io/subscribe/">新闻订阅</a> </div>

示例

<a href="https://supermedium.com/supercraft"> <img alt="Supercraft" target="_blank" src="https://yellow-cdn.veclightyear.com/835a84d5/a64eb7d0-f82d-4dab-a5c2-cf227eb07d73.gif" height="190" width="32%"> </a> <a href="https://aframe.io/a-painter/?url=https://ucarecdn.com/962b242b-87a9-422c-b730-febdc470f203/"> <img alt="A-Painter" target="_blank" src="https://yellow-cdn.veclightyear.com/835a84d5/8f079098-5785-4c3f-bab7-96e9ddb757f6.gif" height="190" width="32%"> </a> <a href="https://supermedium.com"> <img alt="Supermedium" target="_blank" src="https://yellow-cdn.veclightyear.com/835a84d5/4329852c-6f14-4854-a21e-95e27e203836.png" height="190" width="32%"> </a> <a href="https://aframe.io/a-blast/"> <img alt="A-Blast" target="_blank" src="https://yellow-cdn.veclightyear.com/835a84d5/daf6f750-73f5-46e5-935a-dbb8bb5ede7e.gif" height="190" width="32%"> </a> <a href="https://aframe.io/a-saturday-night/"> <img alt="A-Saturday-Night" target="_blank" src="https://yellow-cdn.veclightyear.com/835a84d5/9b6a2c5e-ae3a-4d20-bb03-aceeb22a2494.gif" height="190" width="32%"> </a> <a href="https://github.com/googlecreativelab/webvr-musicalforest"> <img alt="Musical Forest by @googlecreativelab" target="_blank" src="https://yellow-cdn.veclightyear.com/835a84d5/0b858afd-f28d-4dc4-a4e4-cc7b137e015e.gif" height="190" width="32%"> </a>

主页A Week of A-FrameWebVR Directory上可以找到更多示例。

特性

:eyeglasses: 简化虚拟现实开发:A-Frame处理了跨平台(包括移动设备、桌面和所有头戴设备,兼容支持WebXR的浏览器)运行所需的3D和WebXR样板代码,只需添加<a-scene>即可。

:heart: 声明式HTML:HTML易于阅读和复制粘贴。由于A-Frame可以通过HTML使用,因此对所有人都是可访问的:Web开发者、VR和AR爱好者、教育工作者、艺术家、创客和儿童。

:electric_plug: 实体-组件架构:A-Frame是基于three.js的强大框架,为three.js提供了声明式、可组合、可重用的实体-组件结构。虽然A-Frame可以通过HTML使用,但开发者可以无限制地访问JavaScript、DOM API、three.js、WebXR和WebGL。

:zap: 性能:A-Frame是three.js之上的一个轻量级框架。尽管A-Frame使用DOM,但A-Frame不会触及浏览器布局引擎。性能是首要考虑因素,在高度交互的WebXR体验中经过了实战测试。

:globe_with_meridians: 跨平台:为任何支持WebXR的浏览器兼容的头戴设备构建VR和AR应用。没有头戴设备或控制器?没问题!A-Frame仍然可以在标准桌面和智能手机上运行。

:mag: 可视化检查器:A-Frame提供了内置的3D可视化检查器,其工作流程类似于浏览器的开发者工具,界面类似于Unity。打开任何A-Frame场景并按下<ctrl> + <alt> + i

:runner: 功能丰富:A-Frame的内置组件包括几何体、材质、灯光、动画、模型、射线投射器、阴影、位置音频、追踪控制器等,让你快速上手。通过社区组件,你可以获得更多功能,如粒子系统、物理引擎、多用户、海洋、山脉、语音识别或传送!

使用方法

示例

只需几行HTML代码就可以在浏览器中构建VR和AR场景!立即开始体验和发布,请在以下平台上重新混合入门示例:

重新混合 分叉

<html> <head> <script src="https://aframe.io/releases/1.6.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>

通过A-Frame的实体-组件架构,我们可以直接从HTML中将社区组件(如海洋、物理)从生态系统中引入并插入到我们的对象中:

重新混合 分叉

<html> <head> <script src="https://aframe.io/releases/1.6.0/aframe.min.js"></script> <script src="https://unpkg.com/aframe-particle-system-component@1.0.x/dist/aframe-particle-system-component.min.js"></script> <script src="https://unpkg.com/aframe-extras.ocean@%5E3.5.x/dist/aframe-extras.ocean.min.js"></script> <script src="https://unpkg.com/aframe-gradient-sky@1.5.0/dist/gradientsky.min.js"></script> </head> <body> <a-scene> <a-entity id="rain" particle-system="preset: rain; color: #24CAFF; particleCount: 5000"></a-entity> <a-entity id="sphere" geometry="primitive: sphere" material="color: #EFEFEF; shader: flat" position="0 0.15 -5" light="type: point; intensity: 5" animation="property: position; easing: easeInOutQuad; dir: alternate; dur: 1000; to: 0 -0.10 -5; loop: true"></a-entity> <a-entity id="ocean" ocean="density: 20; width: 50; depth: 50; speed: 4" material="color: #9CE3F9; opacity: 0.75; metalness: 0; roughness: 1" rotation="-90 0 0"></a-entity> <a-entity id="sky" geometry="primitive: sphere; radius: 5000" material="shader: gradient; topColor: 235 235 245; bottomColor: 185 185 210" scale="-1 1 1"></a-entity> <a-entity id="light" light="type: ambient; color: #888"></a-entity> </a-scene> </body> </html>

构建

要使用A-Frame的最新稳定版本,请引入aframe.min.js

<head> <script src="https://aframe.io/releases/1.6.0/aframe.min.js"></script> </head>

要查看稳定版和主分支构建,请参阅dist/文件夹

npm

npm install --save aframe # 或 yarn add aframe
require('aframe') // 例如,使用Browserify或Webpack。

本地开发

git clone https://github.com/aframevr/aframe.git # 克隆仓库。 cd aframe && npm install # 安装依赖。 npm start # 启动本地开发服务器。

然后在浏览器中打开**http://localhost:9000**。

生成构建

npm run dist

问题

如有问题和需要支持,请在StackOverflow上提问

保持联系

并与维护者取得联系!

贡献

参与进来!查看贡献指南了解如何开始。

你还可以通过购买独特设计的精美A-Frame T恤来支持开发。

许可证

该程序是自由软件,根据MIT许可证分发。

编辑推荐精选

音述AI

音述AI

全球首个AI音乐社区

音述AI是全球首个AI音乐社区,致力让每个人都能用音乐表达自我。音述AI提供零门槛AI创作工具,独创GETI法则帮助用户精准定义音乐风格,AI润色功能支持自动优化作品质感。音述AI支持交流讨论、二次创作与价值变现。针对中文用户的语言习惯与文化背景进行专门优化,支持国风融合、C-pop等本土音乐标签,让技术更好地承载人文表达。

QoderWork

QoderWork

阿里Qoder团队推出的桌面端AI智能体

QoderWork 是阿里推出的本地优先桌面 AI 智能体,适配 macOS14+/Windows10+,以自然语言交互实现文件管理、数据分析、AI 视觉生成、浏览器自动化等办公任务,自主拆解执行复杂工作流,数据本地运行零上传,技能市场可无限扩展,是高效的 Agentic 生产力办公助手。

lynote.ai

lynote.ai

一站式搞定所有学习需求

不再被海量信息淹没,开始真正理解知识。Lynote 可摘要 YouTube 视频、PDF、文章等内容。即时创建笔记,检测 AI 内容并下载资料,将您的学习效率提升 10 倍。

AniShort

AniShort

为AI短剧协作而生

专为AI短剧协作而生的AniShort正式发布,深度重构AI短剧全流程生产模式,整合创意策划、制作执行、实时协作、在线审片、资产复用等全链路功能,独创无限画布、双轨并行工业化工作流与Ani智能体助手,集成多款主流AI大模型,破解素材零散、版本混乱、沟通低效等行业痛点,助力3人团队效率提升800%,打造标准化、可追溯的AI短剧量产体系,是AI短剧团队协同创作、提升制作效率的核心工具。

seedancetwo2.0

seedancetwo2.0

能听懂你表达的视频模型

Seedance two是基于seedance2.0的中国大模型,支持图像、视频、音频、文本四种模态输入,表达方式更丰富,生成也更可控。

nano-banana纳米香蕉中文站

nano-banana纳米香蕉中文站

国内直接访问,限时3折

输入简单文字,生成想要的图片,纳米香蕉中文站基于 Google 模型的 AI 图片生成网站,支持文字生图、图生图。官网价格限时3折活动

扣子-AI办公

扣子-AI办公

职场AI,就用扣子

AI办公助手,复杂任务高效处理。办公效率低?扣子空间AI助手支持播客生成、PPT制作、网页开发及报告写作,覆盖科研、商业、舆情等领域的专家Agent 7x24小时响应,生活工作无缝切换,提升50%效率!

堆友

堆友

多风格AI绘画神器

堆友平台由阿里巴巴设计团队创建,作为一款AI驱动的设计工具,专为设计师提供一站式增长服务。功能覆盖海量3D素材、AI绘画、实时渲染以及专业抠图,显著提升设计品质和效率。平台不仅提供工具,还是一个促进创意交流和个人发展的空间,界面友好,适合所有级别的设计师和创意工作者。

图像生成AI工具AI反应堆AI工具箱AI绘画GOAI艺术字堆友相机AI图像热门
码上飞

码上飞

零代码AI应用开发平台

零代码AI应用开发平台,用户只需一句话简单描述需求,AI能自动生成小程序、APP或H5网页应用,无需编写代码。

Vora

Vora

免费创建高清无水印Sora视频

Vora是一个免费创建高清无水印Sora视频的AI工具

下拉加载更多