搜尋套件、儲存庫與 APP 分類

套件詳情v1.0.2+1

flutter_3d_objects

一個可渲染 Wavefront 3D 物件檔案的 Flutter 專案套件。

AndroidiOSmacOSWindowsLinux
近 30 天下載
2
喜歡數
5
Pub 分數
135

安裝套件

flutter pub add flutter_3d_objects

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個 Flutter 套件,可在 Flutter 應用中呈現 Wavefront (.obj) 3D 模型檔案。它支援多個平台,包括 Android、iOS、macOS、Windows 和 Linux,非常適合跨平台 3D 可視化。該套件與 Flutter 的 widget 系統無縫整合,讓開發者能夠在介面中嵌入互動式 3D 物件。對於需要顯示 3D 資產的應用程式(例如產品預覽、教育工具或擴增實境體驗)特別有用。

適用情境

  • 3D產品視覺化
  • 帶有3D模型的教育類應用程式
  • 增強現實介面
  • 互動式3D UI組件
  • 遊戲開發原型

主要特色

  • 支援 Wavefront .obj 檔案
  • 跨平台相容性
  • 與 Flutter 小部件整合
  • 輕便且易於使用
  • 即時3D渲染

適合對象

  • 開發支援3D的Flutter應用的開發者
  • 教育軟體創作者
  • 產品展示應用
  • AR/VR 原型設計團隊
  • UI 設計師探索 3D 元素

使用建議

  • 僅限 .obj 檔案格式
  • 無內建動畫支援
  • 需要3D模型優化
  • 可能對低階設備產生效能影響
  • 無紋理映射功能

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

[Flutter 3D Objects]

pub package style: effective dart License: MIT

This package allows Flutter developers to easily display 3D models in their applications. It supports the .obj file format and provides functionalities to manipulate the scene, including setting camera positions and adding objects with child objects.

Features:

  • Display 3D models from .obj files
  • Add and manipulate objects within the scene
  • Set camera positions to adjust the view
  • Support for hierarchical object structures

Setup

How to use this

  • Add dependency in pubspec.yaml
dependencies:
  flutter:
    sdk: flutter
flutter_3d_objects:
  • Add 3D Models in assets, file type should be .obj
flutter:
assets:
  - assets/p.obj
  - assets/c.obj

Usage

void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: Cube(
            onSceneCreated: (Scene scene) {
              scene.world.add(
                Object(
                  fileName: 'assets/c.obj',
                  position: Vector3(1, 1, 1),
                  scale: Vector3(1, 1, 1),
                ),
              );
            },
          ),
        ),
      ),
    );
  }
}

Example

//Create a variable
late Scene _scene;
double x = 0;
double y = 3;
double z = 8;
late AnimationController _controller;
late Animation<double> _animation;
Object? _p;

// Create Function
void _onSceneCreated(Scene scene) {
   _scene = scene;
   scene.camera.position.z = z;
   scene.camera.position.y = y;
   scene.camera.position.x = x;
   _p = Object(
       position: Vector3(0, -2.5, 0),
       scale: Vector3(4, 4, 4),
       fileName: 'assets/p.obj',
       children: [
         Object(
           fileName: 'assets/c.obj',
           position: Vector3(0.25, 0.15, -0.24),
           scale: Vector3(0.8, 0.8, 0.8),
         ),
       ]);
   scene.world.add(_p!);
 }

//Function to rotate
void rotateLeft() {
   _animateRotation(90);
 }

 void rotateRight() {
   _animateRotation(-90);
 }

 void _animateRotation(double angle) {
   final double begin = _p!.rotation.y;
   final double end = _p!.rotation.y + angle;

   _animation = Tween<double>(begin: begin, end: end).animate(_controller)
     ..addListener(() {
       setState(() {
         _p!.rotation.y = _animation.value;
         _p!.updateTransform();
         _scene.update();
       });
     });

   _controller.forward(from: 0);
 }

// In main widget function
Scaffold(
     appBar: AppBar(
       title: const Text(''),
     ),
     body: Stack(
       children: [
         Cube(
           interactive: false,
           zoom: false,
           onSceneCreated: _onSceneCreated,
         ),
         Positioned(
           bottom: 10,
           left: 0,
           right: 0,
           child: Row(
             mainAxisAlignment: MainAxisAlignment.spaceEvenly,
             children: [
               ElevatedButton(
                 onPressed: rotateLeft,
                 child: const Text('Left'),
               ),
               ElevatedButton(
                 onPressed: rotateRight,
                 child: const Text('Right'),
               ),
             ],
           ),
         ),
       ],
     ),
   );

所屬分類

依賴

依賴清單 2 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。