Code Monkey home page Code Monkey logo

flutter_cube's People

Contributors

thienvu18 avatar wolcy97 avatar zesage avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flutter_cube's Issues

Shadow doesn't show

Seems that this widget doesn't show any shadows, even when the illum is set in the mtl file. Any ideas?

   Object modelo = new Object(
     backfaceCulling: false,
     fileName: 'assets/mask2.obj', scale: Vector3(10.0, 10.0, 10.0));


  Widget obj3d2() {
    Cube cube = new Cube(
      interactive: orientable,
      onSceneCreated: (Scene scene) {
        scene.world.add(modelo);
      },
    );

    return cube;
  }

how to explicit mtl file ?

hello
a simple question i suppose..

i have 3 assets:

  • test.obj
  • test.mtl
  • texture_map.png

i create

  _test = Object(
        name: 'test',
        scale: Vector3(10.0, 10.0, 10.0),
        backfaceCulling: true,
        fileName: 'assets/test/test.obj');
    _scene.world.add(_test!);
    _scene.updateTexture();

only the 3D object appear. not the texture.
Could you help me ?
thx

how to load in mtl,texture from local storage/sdcard

Hi all, i am able to render the obj and its texture/mtl from assets.
Currently i am trying to render the 3d object from local storage instead, however when i add:
obj = cube3d.Object(
fileName: '/storage/emulated/0/Download/testfolder/texturedMesh.obj',
isAsset: false);
using isAsset as false, i am only able to get the mesh of the object with not texture.

I am confused with how to use loadMtl, loadTexture to load the texture on top of the mesh. Any help will be great! :)

Dynamic Materials

Hi,

Wonderful package ! :)

I contact you to know if it is possible to dynamically modify the material associated to an object?
Example : modify the ambient/diffuse/reflec...

Many thanks :)

Loader for object

hey, how can I add circular spinner loader till my object is loaded on scenecreated.

Auto rotation

There is a way to have a spherical object (like a earth map) that dosent mess up with the screen???
Or something to make the obj auto rotate on x axis?

Higher res texture

I took the planet example, and provided a higher res picture for the texture, but when I zoom in, the same pixelation occurs on the same level. What am I doing wrong?

No color when running

I'm using the package but when running it doesn't bring color, is it a recurring problem?

Quick question, what have I done wrong, for some reason the texture is glitching.

So I tried having a cube that rotates according to the mpu6050 which data is read and send via a Arduino Uno. It works perfectly expect for the cube glitching in textures (I tried using different cubes/objects) but the same thing happened.

Also feel free to let me know if I could have done anything else better. Thanks in advance.

import 'dart:convert';
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter_cube/flutter_cube.dart';
import 'package:funduinoblecontroller/bluetooth/bluetoothmanager.dart';

class CubeScreen extends StatefulWidget {
  BluetoothManager blemanager;
  CubeScreen({Key? key, required this.blemanager}) : super(key: key);

  @override
  _CubeScreenState createState() => _CubeScreenState();
}

class _CubeScreenState extends State<CubeScreen> with SingleTickerProviderStateMixin {
  late Scene _scene;
  Object? _cube;
  bool run = true;
  double xAngle = 0;
  double yAngle = 0;
  double zAngle = 0;
  double prevXAngle = 0;
  double prevYAngle = 0;
  double prevZAngle = 0;

  double defaultvalueX = 0;
  double defaultvalueY = 0;
  double defaultvalueZ = 0;

  bool isDefaultSet = false;
  late AnimationController _controller;

void _onSceneCreated(Scene scene) {
  _scene = scene;
  scene.camera.position.z = 27;
  // set light
  _cube = Object(scale: Vector3(8.0, 8.0, 8.0), backfaceCulling: false , isAsset: true, 
  lighting: true, 
  
  fileName: 'assets/cube/cube.obj');
  // enable lighting
  scene.world.add(_cube!);
  // position the light behind the camera
  scene.light.position.z = -1;
}


  // dispose remove the listener and reset the scene cube etc
  @override
  void dispose(){
    run = false;
    _controller.dispose(); 
    _cube = null;
    _scene = Scene();
    super.dispose();
  }


  Future<void> getMessages() async {
    while (run) {
      await Future.delayed(Duration(milliseconds: 20));
      try {
        // Replace with your actual bluetooth reading logic
        await Future.delayed(Duration(milliseconds: 20));
        try {
        List<int> readValue = await widget.blemanager.selectedCharacteristic!.read();
          if(!utf8.decode(readValue).contains(widget.blemanager.messagebuffertemp)){ 
            widget.blemanager.messagebuffertemp = utf8.decode(readValue);
          await widget.blemanager.updatebuffer();
        }
      } catch (e) { }

      String message = widget.blemanager.messagebuffer;

        RegExp exp = RegExp(r'([XYZ])([+-]?\d+(\.\d+)?)');
        Iterable<RegExpMatch> matches = exp.allMatches(message);

        Map<String, double> values = {};
        for (var match in matches) {
          String? value = match.group(1); // X, Y, or Z
          String? count = match.group(2); // value
          values[value!] = double.parse(count!);
        }

        if (values.containsKey("X")) {
          xAngle = values["X"]!;
        }

        if (values.containsKey("Y")) {
          yAngle = values["Y"]!;
        }

        if (values.containsKey("Z")) {
          zAngle = values["Z"]!;
        }

        // If default values are not set, set them and take them as reference
        if (!isDefaultSet) {
          defaultvalueX = xAngle;
          defaultvalueY = yAngle;
          defaultvalueZ = zAngle;
          isDefaultSet = true;
        } else {
          xAngle -= defaultvalueX;
          yAngle -= defaultvalueY;
          zAngle -= defaultvalueZ;
        }

        if (xAngle != prevXAngle || yAngle != prevYAngle || zAngle != prevZAngle) {
          try{
            setState(() {
              if (_cube != null) {
                var x = xAngle;
                var y = yAngle;
                var z = zAngle;
                _cube!.position.x = 5.0;
                _cube!.position.y = 5.0;
                _cube!.position.z = 5.0;

                // The X,Y,Z are not assigned to themselfs due to the mpu6050 sensor
                // not being mounted in the same orientation as the cube
                _cube!.rotation.x = -y;
                _cube!.rotation.y = z;
                _cube!.rotation.z = -x;
                
                _cube!.position.x = 0.0;
                _cube!.position.y = 0.0;
                _cube!.position.z = 0.0;
                _cube!.updateTransform();
                _scene.update();
              }
            });
          }catch (e){
            run = false;
          }
        }

        // Store the current values for the next comparison
        prevXAngle = xAngle;
        prevYAngle = yAngle;
        prevZAngle = zAngle;
      } catch (e) {
        run = false;
      }
    }
  }

@override
void initState() {
  super.initState();
  _controller = AnimationController(duration: Duration(milliseconds: 600), vsync: this)
    ..addListener(() {
      if (_cube != null) {
        _cube!.lighting = true;
        _cube!.updateTransform();
        _scene.update();
      }
    })
    ..repeat();
  getMessages();
}


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("MPU Cube"),
      ),
      body: Stack(
        children: [
          Center(
            child: Cube(
              interactive: false,
              onSceneCreated: _onSceneCreated,
            ),
          ),
        ],
      ),
    );
      
  }
}

Here are some images of the problem:

https://imgur.com/a/XfW59jC

texture not visible on my 3d object.

Hi, I am facing an issue when rendering the 3d Object.

this is my mask image.

image

my asset folder structure
image

this is my code

Cube(
    onSceneCreated: (Scene scene) {
      scene.world.add(
        Object(
          fileName: 'assets/shoe.obj',
          scale: Vector3.all(5),
          lighting: true,
        ),
      );
    },
  )

my mtl file

Material Count: 1

newmtl Material
	Ns 323.999994
	Ka 1.000000 1.000000 1.000000
	Kd 0.800000 0.800000 0.800000
	Ks 0.500000 0.500000 0.500000
	Ke 0.0 0.0 0.0
	Ni 1.450000
	d 1.000000
	illum 2
	map_Kd diffuse.png

any solution to this?

Faces flicker on a custom mesh

Hey,

This package is great, I've noticed an issue where certain faces will flicker in and out of existence when the user rotates around the object.

flickering_faces

When I import a wavefront file from the web, it works fine, so it's almost definitely something I'm doing in the export process. My .obj file has two objects in it, could this be the source of the problem? I've also triangulated faces etc to no avail.

coudn't load my own .obj file

Hi , I've put my own obj file into assets folder and try to load it but couldnt work, is there a guide on how to do it?

something is wrong

onSceneCreated: (Scene scene) {
scene.world.add(Object(fileName: 'assets/cube/cube.obj'));
},
not working !!!

heavy scene.updateTexture();

hello
some time scene.updateTexture(); is very heavy and have lag
we need add one loading view for updateTexture event

are you have sulotion ?

thank you

Ruby example is not responding on Android

Application ruby is launching and the app bar is visible but the body is empty. After a few seconds, the application is closing.
Example cube_app works perfectly.
Logcat:

2019-12-26 20:39:00.674 764-1631/? I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.example.ruby/.MainActivity bnds=[35,1344][237,1633]} from uid 10063 on display 0
2019-12-26 20:39:00.768 764-9223/? I/ActivityManager: Start proc 14946:com.example.ruby/u0a110 for activity com.example.ruby/.MainActivity
2019-12-26 20:39:00.935 14946-14946/? I/om.example.ruby: type=1400 audit(0.0:834): avc: denied { open } for path="/dev/mali0" dev="tmpfs" ino=8197 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:device:s0 tclass=chr_file permissive=1
2019-12-26 20:39:00.935 14946-14946/? I/om.example.ruby: type=1400 audit(0.0:835): avc: denied { getattr } for path="/dev/mali0" dev="tmpfs" ino=8197 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:device:s0 tclass=chr_file permissive=1
2019-12-26 20:39:01.766 14946-14990/com.example.ruby I/[MALI][Gralloc]: [+]r_hnd(0x7f7747b720), client(72), share_fd(73)
2019-12-26 20:39:01.773 14946-14990/com.example.ruby I/[MALI][Gralloc]: [+]r_hnd(0x7f7747b860), client(72), share_fd(76)
2019-12-26 20:39:01.782 764-784/? I/ActivityManager: Displayed com.example.ruby/.MainActivity: +1s61ms
2019-12-26 20:39:01.789 14946-14990/com.example.ruby I/[MALI][Gralloc]: [+]r_hnd(0x7f7747c260), client(72), share_fd(79)
2019-12-26 20:39:04.110 14946-14965/com.example.ruby I/[MALI][Gralloc]: [+]r_hnd(0x7f563f7820), client(72), share_fd(75)
2019-12-26 20:39:04.140 764-9189/? I/ActivityManager: Fully drawn com.example.ruby/.MainActivity: +3s419ms
2019-12-26 20:39:16.339 764-9224/? I/ActivityManager: Process com.example.ruby (pid 14946) has died
2019-12-26 20:39:16.341 764-9222/? I/WindowManager: WIN DEATH: Window{1fd8e54 u0 com.example.ruby/com.example.ruby.MainActivity}
2019-12-26 20:39:16.350 764-9224/? W/ActivityManager: Force removing ActivityRecord{acfaf8e u0 com.example.ruby/.MainActivity t2206}: app died, no saved state
2019-12-26 20:39:16.367 764-9222/? W/WindowManager: Force-removing child win Window{5a1fef2 u0 SurfaceView - com.example.ruby/com.example.ruby.MainActivity} from container Window{1fd8e54 u0 com.example.ruby/com.example.ruby.MainActivity}

Integration flutter_cube with flame

I want to render a 3d object in a game currently developing with flame and forge2d. Is there any way I can use flutter_cube in my game?
Like flutter_cube is a widget but I want to render the 3d object with a physical body component.

Zoom with mouse

How to zoom in and out using mouse or keyboard in windows/web?

Error: RangeError (index): Index out of range: index should be less than 6291456: 6291456

Hello thanks for this great package!

I've cloned your project and run the planet example on WEB (chrome) and get this error :

Error: RangeError (index): Index out of range: index should be less than 6291456: 6291456

Then I tried to remove stars & clouds from the scene and keep only earth object, which Is working. But not with clouds & stars.

How could we solve this? This is only happened on WEB (works great on mobile)
Thank you

Support for GLTF files

Hi
Just tested this with .obj file downloaded from Google Poly. Good Plugin.
However, I wish to use a .gltf file created by me in Blender. Is there a support or plans to include this format in the new versions?

Change lighting on scale/drag

Hi, is it possible to adjust the position of the light source while moving the 3D object? or maybe add multiple lights?

What is the maxiumum poly count allowed?

Hello,
I'm currently writing an application that is meant to display photogrammetry 3D models. These models usually have high poly counts, ranging from hundreds of thousands to millions. I tried decimating the models in Blender to get a result I'm happy with (Usually around 100,000 - 250,000 faces), but whenever I put those models in my app, they show up as a garbled mess of polygons sort of like this:

Screenshot_1632180210

I tried decimating them some more (around 50,000 face count) and they look fine in the app, but in that range, they start to lose a little too much detail for my liking.

Screenshot_1632180210(1)

Do y'all know what the maximum poly count flutter_cube allows before garbling up the models? I wanna try and keep as much detail as possible as some models can be very intricate and lose a ton of detail when decimated...

Or better yet, does anyone know how we can potentially raise the maximum polycount? or would that be too taxing for mobile devices to have rendered more than what's already the maximum?

Thanks for reading

lighting is invalid when the model file map to a tga file

As the cube_app example, if we enable the lighting and change the last line of cube.mtl

map_Kd flutter.png

to a tga file.

map_Kd some.tga

The model and image can be loaded, but the lighting has no effect at all.

I tested many obj models with tga textures, all failed.

Scene lighting support?

Are there any plans to release a new version of the library to pub.dev with lighting support available?

I would like to use it in my project but the latest published package version (0.0.5) does not include it yet, though it is in the master branch of the repository.

Grey objects with no textures rendering

Looks like the texture isn't loading but the meshes are still able to render.

Heres what I see with the cube example.
image

There was a prior issue that mentioned this, but it was self closed with no posted solution.

Change camera position

I see that zooming and rotating is possible out of the box. How would one be able to pan the object? Or otherwise, how can one best change the camera position manually?

Thanks!

why /almost/ include Mousewheel Zoom?

i can see in the code that you thought about including it, but then deemed it unnecessary - and now a noob like me is trying to figure out how to do it :)

can anyone help?

Update texture

i have a scene and a 3d object (parent) with 2 childreen.
cube0= Object(filename: 'assets/parent.obj');
cube1 = Object(filename: 'assets/child1.obj');
cube2 = Object(filename: 'assets/child2obj');
cube0.add(cube1);
cube0.add(cube2);
scene.world.add(cube0);

i want to update the texture of cube1 with an image
If i write:
cube1.mesh.texture = (load image /image1.jpg)
scene.updateTexture(); // not working

If i want to update the texture of cube0 with an image and i write:
cube0.mesh.texture = (load image /image0.jpg)
scene.updateTexture(); // update cube0 and his sons

Any solution?

map_Bump & map_Ns

Hi guys, in my .mtl file i have a map_Bump with the normal and map_Ns with the roughness but in material.dart switch it is only evaluated the map_Kd where i have the albedo transparency and map_Ka there is any solution with this? Thank you so much.

image
image

show 3d object from server

i want get 3d object from server and show in my game with package , but this package just show 3d object from local asset , how i can fix this issuse ?
like Imgae.network(url);
i wanna get object from server

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.