Worldspace Wry #53
Replies: 3 comments 1 reply
-
|
Thank you for the suggestion! I also wanted this feature. I think there are two main approaches to rendering the WebView as a texture:
For approach 2, you’d leverage a headless browser’s API both for user input (keyboard, mouse, etc.) and for graphics. There is also a library called ultralight-sys with more stars, but it appears unmaintained, so it’s best to be cautious. There are two ways to draw as texture: CPU binding and GPU binding.
2. create surfaces with ultralightPlease refer to Integrating With Games. The surfaces created here should be components of the same entity as the material if they can be made thread-safe, and if not possible, it is recommended to create a HashMap called struct UltralightSurfaces(bevy::platform::collections::HashMap<Entity, {SURFACE}>);3. Create a bitmap from the surfacePlease refer to Using a Custom Surface. 4. Create a bevy Image from the bitmap and rewrite the Image of the existing material.As an image, it can be done by creating a system like the following and having it run myframe. /// A marker component
#[derive(Component)]
struct UltraLightWebview;
fn draw_webview_bitmap(
mut images: ResMut<Assets<Image>>,
materials: Res<Assets<StandardMaterial>>,
surfaces: NonSend<UltraLightSurfaces>,
webviews: Query<(Entity, &MeshMaterial3d<StandardMaterial>), With<UltraLightWebview>>,
){
for (webview_entity, handle) in webviews.iter() {
if let Some(material) = materials.get(&handle.id())
&& let Some(surface) = surfaces.get_surface(webview_entity)
&& let Some(mut image) = images.get_mut(&material.base_color_texture)
{
*image = surface.bitmap().into();
}
}
}Pre-translated text英訳して 提案ありがとうございます! 私もこの機能については欲しいと思っていました。 テクスチャとしてWebviewを表示させる方法は大きく分けて2つのアプローチがあると思います。 1. 自力でHTMLを解析する 2. ヘッドレスブラウザを使用してテクスチャ情報をBevyに送信する。1.に関しては、言い換えれば自作のブラウザを実装する必要があります。これはほぼほぼ不可能だと断言していいでしょう。 ヘッドレスブラウザの例としてはUltralightがあげられます。 テクスチャとして描画する方法はCPUバインディングとGPUバインディングの2つがあり、まずは簡単なCPUバインディングから実装することをお勧めします。
2.ultralightでサーフェースを作成Integrating With Gamesを参考にしてください。 struct UltralightSurfaces(bevy::platform::collections::HashMap<Entity, {SURFACE}>);3.サーフェースからビットマップを取得Using a Custom SurfaceにサーフェースからBitmapを取得する方法が記載されています。 4. ビットマップからbevyのImageを作成して既存のマテリアルのImageを書き換える。イメージとしては以下のようなシステムを作ってマイフレーム実行させればできると思います。 |
Beta Was this translation helpful? Give feedback.
-
|
The app I'm creating will soon be ready for release, so I'll probably have some spare time. |
Beta Was this translation helpful? Give feedback.
-
|
@MiniMinerX |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Does anyone know of any way we could start to include worldspace texture rendering and input mapping. I know this is a hard challenge but I am willing to work on it and would love to see websites rendered within bevy worldspace.
Beta Was this translation helpful? Give feedback.
All reactions