简体   繁体   English

在 flutter 中实施 3d model

[英]implement 3d model in flutter

I want to ask regarding implementing 3d model in flutter using HTML link.我想询问有关使用 HTML 链接在 flutter 中实施 3d model 的问题。 Does anyone knows how to implement it.有谁知道如何实现它。 I have tried babylonjs_viewer and model_viewer_plus packages examples but they didn't work for me.我已经尝试过 babylonjs_viewer 和 model_viewer_plus 包示例,但它们对我不起作用。 If anyone can help me with it, it will be great如果有人可以帮助我,那就太好了

Thank you谢谢

Would be great if you could provide more information regarding the error.如果您可以提供有关该错误的更多信息,那就太好了。

But this is how implemented my 3D model in a Flutter web browser.但这就是在 Flutter Z2567A5EC9705EB7AC2C984033E0618 浏览器中实现我的 3D model 的方式。

import 'dart:html';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/src/widgets/container.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:model_viewer_plus/model_viewer_plus.dart';

class My3DModel extends StatelessWidget {
  const My3DModel({super.key});

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      height: MediaQuery.of(context).size.height / 2.5,
      child: ModelViewer(
        src: "assets/3D_model/my_model.glb",
        alt: "A 3D model of Ritchie's model",
        autoRotate: false,
        cameraOrbit: "15deg 90deg -110m",
        cameraTarget: "0m 1.7m 0m",
        fieldOfView: "180deg",
      ),
    );
  }
}

I created my 3D model in a separate file, however, it's the same if you wanted to implement directly into the body of the app.我在一个单独的文件中创建了我的 3D model,但是,如果您想直接在应用程序主体中实现,则相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM