パッケージ、リポジトリ、アプリカテゴリを検索

babylonjs_viewer のカバー
パッケージ詳細v1.3.0

babylonjs_viewer

BabylonJS ビューアによる 3D モデルのレンダリング

AndroidiOSmacOS
30日間ダウンロード
110
いいね数
68
Pub ポイント
140

パッケージをインストール

flutter pub add babylonjs_viewer

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

babylonjs_viewer パッケージは、強力な JavaScript 3D エンジンである BabylonJS を使用して、Flutter アプリで 3D モデルのレンダリングを可能にします。Android、iOS、macOS で 3D アセットを表示および操作するためのプラットフォーム非依存の方法を提供します。WebView を通じたウェブベースのレンダリングを活用することで、ネイティブの 3D エンジン実装なしに豊富な 3D 可視化を統合できます。製品プレビュー、建築可視化、教育ツールなど、インタラクティブな 3D コンテンツが必要なアプリケーションに最適です。

用途

  • 3D製品ビジュアライゼーション
  • インタラクティブな建築モデル
  • 教育用3Dコンテンツ
  • バーチャルツアー
  • ゲームアセットのプレビュー

主な機能

  • WebViewを介したウェブベースの3Dレンダリング
  • 複数の3D形式のサポート
  • クロスプラットフォーム互換性
  • インタラクティブカメラコントロール
  • 軽量な統合

適している対象

  • 3D対応のFlutterアプリを開発する開発者
  • 軽量な3Dレンダリングを必要とするアプリ
  • 3D体験のプロトタイピング
  • モバイルおよびデスクトップ向けのプロジェクト

注意事項

  • WebViewのパフォーマンス制限
  • 制限されたネイティブ3D APIアクセス
  • 外部のBabylonJSライブラリに依存しています
  • 複雑なモデルのメモリ使用量が高くなる
  • バンドルされていない場合、初期読み込みにインターネットが必要です

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

babylonjs_viewer

3D Model viewer with BabylonJS Viewer for Flutter. This project highly inspired from model_viewer flutter pub package. Its simple model viewer, next release, json settings will be implented

Pub.dev

https://pub.dev/packages/babylonjs_viewer

Install

This will add a line like this to your package's pubspec.yaml (and run an implicit dart pub get):

dependencies:
  babylonjs_viewer: ^1.3.0
What's new in 1.3.0
  • Update dependency to webview_flutter 4.10.0
Why I need Controller

Controller is optional. You can use this controller for run Javascript code, go back, get current url, change url and many others that WebView Flutter can allow. Functions is optional. You can use this parameter for add javascript code to your viewer. Examples can be found at bottom of this document

Requirements

On your Android Project (android/app/build.gradle) set the "minSdkVersion" to 19

defaultConfig {
        applicationId "com.example.example"
        minSdkVersion 19
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

Then add the line "android:usesCleartextTraffic="true"" to your android manifest (android/app/src/main/AndroidManifest.xml)

<application
        android:label="example"
        android:icon="@mipmap/ic_launcher"
        android:usesCleartextTraffic="true">

On your iOS Project go to the info.plist file (ios/Runner/Info.plist) and add the following line

<key>io.flutter.embedded_views_preview</key>
<true/>

Import it

Now in your Dart code, you can use:

import 'package:babylonjs_viewer/babylonjs_viewer.dart';

Using

  class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        home: Scaffold(
          appBar: AppBar(title: Text("BabylonJS Viewer")),
          body: BabylonJSViewer(
            src: 'https://models.babylonjs.com/boombox.glb',
          ),
        ),
      );
    }
  }

Asset, FILE or HTTP(s)

HTTP(s)

  BabylonJSViewer(
    src: 'https://models.babylonjs.com/boombox.glb',
  ),

FILE

  BabylonJSViewer(
    src: 'file:///path/to/MyModel.glb',
  ),

Asset

  BabylonJSViewer(
    src: 'assets/MyModel.glb',
  ),
Controller and Function Example

Add webview_flutter to your pubspec.yaml

dependencies:
  webview_flutter: ^4.10.0

Add this to your state

import 'package:webview_flutter/webview_flutter.dart';

WebViewController? _controller;

Add your custom javascript functions. This will print to your flutter console.

BabylonJSViewer(
  controller: (WebViewController controller) {
    _controller = controller;
  },
  functions:
      '''function sayHello() { Print.postMessage("Hello World!"); }''',
  src:
      'https://models.babylonjs.com/boombox.glb',
),

Use this function wherever you want

ElevatedButton(
  onPressed: () {
      _controller?.runJavaScript('''
sayHello();
''');
  },
  child: const Text("Run Function")),
Use case for Controller and Function

You can access to viewer variable of babylonjs viewer. You can found all methods on there

In this example show you that how you can toggle auto rotate.

BabylonJSViewer(
  controller: (WebViewController controller) {
    _controller = controller;
  },
  functions: '''
function toggleAutoRotate(texture) {
let viewer = BabylonViewer.viewerManager.getViewerById('viewer-id');
viewer.sceneManager.camera.useAutoRotationBehavior = !viewer.sceneManager.camera.useAutoRotationBehavior
}
''',
  src:
      'https://models.babylonjs.com/boombox.glb',
),

use this function

ElevatedButton(
  onPressed: () {
      _controller?.runJavascript('''
toggleAutoRotate();
''');
  },
  child: const Text("Toggle")),

カテゴリー

依存関係

依存関係一覧 1 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。