空间小程序:可嵌入空间的 Web 运行时

  • 支持 Web-standard APIs、TypeScript 以及 Babylon.js
  • 空间运行安全,空间小程序运行在空间隔离框架中,互不干扰
  • 通过应用层与渲染层代码逻辑分离,实现接近原生的渲染性能
YodaOS JSAR: The embeddable AR runtime for JavaScript Developers
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 42 43 44 45 46 47 48 49 50 <xsml version="1.0"> <head> <title>YodaOS JSAR Gallery</title> <link id="model" rel="mesh" type="octstream/glb" href="./model/rokid_robot.small.glb" /> <style type="text/scss"> @keyframes rotate-self { 0% { rotation: 0 0 0; } 50% { rotation: 0 180 0; } 100% { rotation: 0 360 0; } } @material yellow { diffuse-color: #fdd276; backface-culling: false; side-orientation: frontside; } @material red { diffuse-color: #ad3525; backface-culling: false; side-orientation: frontside; } #model { animation: rotate-self 12s linear; } #face { material: "yellow"; position: 39 0 150; } #body { material: "red"; position: 39 -10 160; rotation: 0 0 0.3; } </style> <script src="./main.ts"></script> </head> <space> <mesh id="model" ref="model" selector="__root__" /> <bound id="main"> <cylinder id="body" height="140" diameter-top="30" diameter-bottom="80" tessellation="4" /> <cube id="face" width="80" height="80" depth="80" /> </bound> </space> </xsml>

如 Web 一般
但用于空间小程序开发

空间小程序还原最开始的 Web 开发体验,并所见即所得。
我们引入了 XSML,它是一种类似于 HTML 的语言,用于描述组件的空间结构。
我们引入了 SCSS,它是一种类似于 CSS 的语言,用于描述组件的空间样式。
同样地,JSAR 使用 TypeScript / JavaScript 作为空间小程序的脚本语言。

TypeScript 内置

JSAR 运行时在执行小程序时,可直接解析 TypeScript 代码,因此开发者无需任何编译和配置即可运行 TypeScript 代码。
TypeScript
  • 简单一步配置即可使用 TypeScript
  • 在 Visual Studio Code 中享受 TypeScript 的智能提示
  • 通过 TypeScript 源码进行应用发布,无需额外构建
Babylon.js

使用 Babylon.js

Babylon.js 是一个支持多后端(WebGL、WebGPU、服务端以及 Native)的开源 3D 渲染引擎,它提供了一系列的游戏场景 API,可用于开发 3D 游戏和应用。
JSAR 实现了 Babylon.js Engine 部分的接口,因此开发者可直接使用 Babylon.js 的 API 进行开发(不过还存在不完全支持的情况)。
Babylon.js

Unity 一同构建

使用 JSAR 开发的空间小程序可以在任何一个 Unity 场景中运行,我们提供了 JSAR UPM 插件,按需实现底层数据接口,即可在你的 Unity 应用中使用 JSAR 空间小程序。