fix:3的模型动态修改模型文件
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:thermion_flutter/thermion_flutter.dart';
|
||||
// import 'package:thermion_dart/src/viewer/src/thermion_viewer_base.dart';
|
||||
|
||||
class CupPage1 extends StatelessWidget {
|
||||
const CupPage1({super.key});
|
||||
@@ -42,7 +43,7 @@ class CupPage extends StatefulWidget {
|
||||
|
||||
class _CupPageState extends State<CupPage> {
|
||||
bool _isLoading = true;
|
||||
String? _modelPath;
|
||||
String? _modelPath, modelUri;
|
||||
String _statusMessage = "正在加载本地模型...";
|
||||
|
||||
@override
|
||||
@@ -61,9 +62,17 @@ class _CupPageState extends State<CupPage> {
|
||||
final supportDir = await getApplicationSupportDirectory();
|
||||
final modelFile = File(p.join(supportDir.path, 'cup', 'model.gltf'));
|
||||
|
||||
String modelPath =
|
||||
File(p.join(supportDir.path, 'cup', 'model.gltf')).absolute.path;
|
||||
final cupDir = Directory('${supportDir.path}/cup');
|
||||
final modelUri = File('${cupDir.path}/model.gltf').uri;
|
||||
print('加载本地模modelPath: $modelPath');
|
||||
print('加载本地模modelUri: $modelUri');
|
||||
|
||||
if (await modelFile.exists()) {
|
||||
setState(() {
|
||||
_modelPath = modelFile.path;
|
||||
_modelPath = modelPath;
|
||||
|
||||
_isLoading = false;
|
||||
_statusMessage = "本地模型加载完成";
|
||||
});
|
||||
@@ -117,6 +126,7 @@ class _CupPageState extends State<CupPage> {
|
||||
)
|
||||
: ViewerWidget(
|
||||
assetPath: "file://$_modelPath",
|
||||
// assetPath: modelUri,
|
||||
skyboxPath: "assets/default_env_skybox.ktx",
|
||||
iblPath: "assets/default_env_ibl.ktx",
|
||||
transformToUnitCube: true,
|
||||
|
||||
Reference in New Issue
Block a user