패키지, 저장소 및 앱 카테고리 검색

babylonjs_viewer 표지
패키지 상세v1.3.0

babylonjs_viewer

BabylonJS 뷰어를 사용한 3D 모델 렌더링

AndroidiOSmacOS
30일 다운로드
110
좋아요
68
Pub 점수
140

패키지 설치

flutter pub add babylonjs_viewer

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

babylonjs_viewer 패키지는 강력한 자바스크립트 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 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.