flutter_model_viewer 0.0.7
flutter_model_viewer: ^0.0.7 copied to clipboard
load glb/gltf.
import 'package:flutter/material.dart';
import 'package:flutter_model_viewer/flutter_model_viewer.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
static const String src1 = 'https://modelviewer.dev/shared-assets/models/Horse.glb';
static const String src2 = 'https://superd.oss-cn-beijing.aliyuncs.com/pub_upload/2022-03-04/ciawb49ie51dq3f0ho.glb';
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Colors.blue,
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: ModelViewer(
src: src1,
backgroundColor: const Color.fromRGBO(0, 0, 0, 0),
autoRotate: true,
autoPlay: true,
rotationPerSecond: "50deg",
autoRotateDelay: 500,
cameraControls: true,
openCache: true,
onLoadError: (){
//模型加载出错
},
onLoadSuccess: (){
//模型加载完成
// _modelViewController.zoomModel(4.0);
},
),
floatingActionButton: FloatingActionButton(onPressed: () {
},child: const Text('缩放'),),
),
);
}
}