Open wangcker opened 2 weeks ago
the whole code :
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter_scene/camera.dart';
import 'package:flutter_scene/node.dart';
import 'package:flutter_scene/scene.dart';
import 'package:vector_math/vector_math.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
MyAppState createState() => MyAppState();
}
class MyAppState extends State<MyApp> with SingleTickerProviderStateMixin {
double elapsedSeconds = 0;
Scene scene = Scene();
@override
void initState() {
createTicker((elapsed) {
debugPrint("time ${elapsed.inMilliseconds.toDouble() / 1000}");
setState(() {
elapsedSeconds = elapsed.inMilliseconds.toDouble() / 1000;
});
}).start();
Node.fromAsset('build/models/DamagedHelmet.model').then((model) {
model.name = 'Helmet';
scene.add(model);
});
super.initState();
}
@override
Widget build(BuildContext context) {
final painter = ScenePainter(
scene: scene,
camera: PerspectiveCamera(
position: Vector3(sin(elapsedSeconds) * 2, 2, cos(elapsedSeconds) * 2),
target: Vector3(0, 0, 0),
),
);
return MaterialApp(
title: '我的 3D 应用',
home: CustomPaint(painter: painter),
);
}
}
class ScenePainter extends CustomPainter {
ScenePainter({required this.scene, required this.camera});
Scene scene;
Camera camera;
@override
void paint(Canvas canvas, Size size) {
scene.render(camera, canvas, viewport: Offset.zero & size);
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) => true;
}
@wangcker did you run using flutter scene locally like in #38 ? I'm curious if were you able to resolve that issue when you ran the demo
@wangcker did you run using flutter scene locally like in #38 ? I'm curious if were you able to resolve that issue when you ran the demo
no,the problem still exists , so change the flutter_scene ref from pub.dev.
@wangcker did you run using flutter scene locally like in #38 ? I'm curious if were you able to resolve that issue when you ran the demo
i fix it #43
Some questions:
it`s may be producted by memory leak
The demo program runs not smoothly and stutters on the Android system, but it run smoothly on the iOS system
android runs video:
https://github.com/user-attachments/assets/171e7477-208c-4c9b-a6c2-78f10b81e4ce