vertex 0.1.1 copy "vertex: ^0.1.1" to clipboard
vertex: ^0.1.1 copied to clipboard

A small and flexible Flutter 3D engine than can parse, render and control .obj and .mtl files

vertex #

Introduction #

Vertex is a 3d rendering library that allows you to import and render .obj/.mtl files and easily create controllers to manage scenes. It's useful for creting differenciated 3d effects that will make your app more unique.

Specifying files and instances
RandomVertexController controller;

@override
void initState() {
	super.initState();
	controller = RandomVertexController(context, [
	ObjPath("star", "lib/assets/objects", "star.obj")
	], [
	InstanceInfo("star",
	position: Vector3(2, -3, 3), 
	scale: Vector3(.5, .5, .5)),
	rotation: vec.Quaternion(40,40,40,40)
	]);
}
Initializing a Controller
@override
Widget build(BuildContext context) {
    if (!controller.isReady) {
      controller.init();
    }
	return Container();
}
Rendering Instances
@override
Widget build(BuildContext context) {
    if (!controller.isReady) {
      controller.init();
    }
	return ListenableBuilder(
            listenable: controller,
            builder: (context) {
              if (controller.isReady)
                return SceneRenderer(controller.meshInstances);
              return Center(child: CircularProgressIndicator());
            },
	),
}
Interacting with a Controller
    @override
    Widget build(BuildContext context) {
        if (!controller.isReady) {
          controller.init();
        }
    	return ListenableBuilder(
            listenable: starController,
            builder: (context) {
              if (starController.isReady)
                return GestureDetector(
                    onPanUpdate: (details) {
                      starController.updateXY(details.delta);
                    },
                    child: BlendMask(
                        blendMode: BlendMode.exclusion,
                        child:
                            ObjectRenderer(starController.meshInstances[0])));
              return Container();
            },
          ),
    }
Creating a Controller
class MyController extends VertexDefaultController {
	//override methods to create controller

  // called only once in the start
  @override
  Future<void> loadDependencies() {
	print("hi");
    return super.loadDependencies();
  }

	//called only once, setup your controller variables here (Ticker)
  @override
  Future<void> start() {

    return super.start();
  }

//called in the beginning and when controller is unpaused
@override
  void play() {
    super.play();
  }
  
//pause your variables here
  @override
  void pause() {
    super.pause();
  }

//dipose your variables here
@override
  void dispose() {
    super.dispose();
  }

//create your own methods that update the instances
	void myMethod() {
		_instances.shuffle();
 }

}

Limitations:

Currently, vertex can only render triangular mesh .obj files Not all .mtl attributes are currently reconized, only diffuseColor and texture.

Performance:

Everything is rendered in 60fps, but rendering too many instances at once the framerate drops. Since flutter currently doesnt allow us to access OpenGL the performance isnt as good as it could be.

13
likes
40
pub points
0%
popularity

Publisher

unverified uploader

A small and flexible Flutter 3D engine than can parse, render and control .obj and .mtl files

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

flutter, path, vector_math

More

Packages that depend on vertex