FlutterWebGL은 WebGL을 사용하여 Flutter 애플리케이션에서 3D 그래픽 렌더링을 가능하게 하는 Flutter 플러그인입니다. Flutter와 WebGL 사이의 다리를 제공하여 Android, iOS 및 Windows 앱에 고성능 3D 콘텐츠를 직접 통합할 수 있도록 합니다. 상호작용 가능한 3D 장면, 실시간 렌더링 및 Three.js와 같은 인기 있는 3D 라이브러리와의 통합을 지원합니다. 몰입형 시각적 경험을 원하는 개발자를 위해 설계되었으며, Flutter 생태계 내에서 WebGL 사용을 간소화합니다.
사용 사례
인터랙티브 3D 대시보드 만들기
증강 현실 인터페이스 구축
복잡한 3D 모델 렌더링
3D 환경을 갖춘 게임 개발
3차원에서 과학 데이터 시각화
주요 기능
Flutter와의 WebGL 통합
크로스 플랫폼 3D 렌더링
Three.js 및 유사 라이브러리 지원
실시간 3D 장면 업데이트
경량이고 성능이 뛰어남
적합한 대상
3D 시각화 개발자
다양한 플랫폼을 대상으로 하는 게임 개발자
고급 그래픽이 필요한 UI 디자이너
교육 앱 제작자
데이터 시각화 전문가
고려 사항
WebGL 또는 3D API에 대한 지식이 필요합니다
제한된 네이티브 3D 프레임워크 지원
성능은 기기마다 다릅니다
사용자 정의 쉐이더 프로그래밍이 필요할 수 있습니다
간단한 UI에는 적합하지 않습니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
FlutterWebGL
So far there is no way to render 3D objects efficiently in Flutter. Also directly accessing and programming the GPU from Dart isn't supported yet. This plugin shall close this gap.
Originally @kentcb and I were working on a wrapper for OpenGL for a project for the company Aaronia. Although we got pretty far with that one looking at the fact the Apple deprecated OpenGL I wondered if this still is the right approach.
Luckily Simon made me aware that there is the Angle project from Google that implements an OpenGL ES API for all platforms that don't support them
This project will solve two goals:
Offer a low-level Dart FFI layer to render into a Flutter Texture Widget with the OpenGL ES 3.0 API
Realise a Dart Version of the WebGL interface which covers most of the functionality of OpenGL ES, but without the hassle to deal with FFI NativeTypes and proper error handling.
On top of that other packages can build easier to use 3D APIs, e.g. there is a Dart port of the JS 3D framework three.js
How does this work:
Flutter has a Texture widget which is a placeholder for graphic content that is rendered onto a native Texture object. This works by creating a Texture object in the native part of this plugin and registering this texture with the Flutter Engine. The Engine returns an id which can then be used in Texture widgets in Flutter.
Flutter will then display the current content of that texture. If the content of this texture was changed by native code we have to inform the Flutter Engine, so that it can update the linked Texture Widgets.
This plugin uses OpenGL ES to render to that native textures. Because of the way OpenGL works we can access the OpenGL "render buffer object" (RBO) from the native part of the plugin as well over the Dart-FFI bindings to the OpenGL ES API so that we can write all rendering code (with the exception of Shaders) in Dart.
To use this you have to do:
Call FlutterWebGL.initOpenGL() which will setup all the needed infrastructure on the Dart and native side of the plugin
Create a Texture with FlutterWebGL.createTexture which will return you the textureID to use it in the TextureWidget
Activate the Texture to access it with OpenGL commands (this part isn't done yet, so far only one texture is supported).
Render to this texture with OpenGL ES low level or WebGL commands
Inform the Flutter Engine that new content is available on that texture by calling FlutterWebGL.updateTexture.
Check out the example to see how it works.
So far the handling of rendering is intentionally not connected to any special widget, but kept separate. This will make it possible to update the texture content even from a separate Isolate which opens a lot of possibilities.
Roadmap
Luckily Aaronia supports this project by that I can work part of the time I do for them on this project.
As there is a lot to do, and it needs knowledge of the tool chains for the different platforms it would be amazing if you could join this project.
Currently, I see the following tasks that need to be solved.
[ ] Build the Angle Framework for
[x] Windows
[ ] Linux,(not necessary until the Flutter Engine supports native Textures on Linux, see this stale PR )
[ ] MacOS
[ ] iOS (it seems that the main Angle project hasn't caught up with its fork metalangle so we probably should use this one)
[x] Create a Dart-FFI layer for OpenGL ES 3.0 API and EGL 1.5
[ ] Implement native plugin parts that register and update the textures
[x] Windows
[ ] Android
[ ] iOS
[ ] macOS
[ ] Linux (see above)
[ ] Web??? I have no idea how, but maybe someone else does :-)
[ ] Implement WebGL in Dart
[ ] add a way to render text. My current idea would be to render text using Flutter onto a canvas and pass that down to OpenGL so that it can be used as a texture on Polygons.
[ ] design widgets that let you use WebGL without needing to care about Texture allocation and notifying