import 'package:flutter/material.dart'; /// 3D 化身查看组件(MVP 占位实现) /// /// v2 接入真实 3D 渲染的方式: /// 1. 服务端提供预烘焙 GLB 资产(/workspace/templates/avatar_f{face}_b{body}_s{skin}.glb) /// 2. pubspec 引入 three_dart ^0.0.16 + three_dart_jsm ^0.0.10 + flutter_gl ^0.0.20 /// (注意 flutter_gl 0.0.21 在 Flutter 3.44 下无法编译,需锁 0.0.20) /// 3. 用 flutter_gl 初始化 GL 上下文 + GLTFLoader 加载 GLB + 自动旋转渲染, /// 参考 three_dart 0.0.16 的 example/lib/webgl_loader_glb.dart class AvatarViewer extends StatelessWidget { final String? glbUrl; final String title; final String subtitle; final double height; const AvatarViewer({ super.key, required this.glbUrl, required this.title, required this.subtitle, this.height = 360, }); @override Widget build(BuildContext context) { final scheme = Theme.of(context).colorScheme; return Container( height: height, width: double.infinity, decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [ scheme.primaryContainer, scheme.primary.withValues(alpha: 0.3), ], ), borderRadius: BorderRadius.circular(16), ), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon(Icons.accessibility_new, size: 72, color: scheme.primary), const SizedBox(height: 12), Text(title, style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold)), const SizedBox(height: 4), Padding( padding: const EdgeInsets.symmetric(horizontal: 24), child: Text( subtitle.isEmpty ? '3D 渲染接入中(v2)' : subtitle, textAlign: TextAlign.center, style: const TextStyle(color: Colors.grey, fontSize: 12), ), ), ], ), ); } }