Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Add new shape 'ARCorePlane'? Add (png) image as material for ARCorePlane to display an image #66

Closed
BrutalCoding opened this issue Sep 21, 2020 · 6 comments
Labels
enhancement New feature or request

Comments

@BrutalCoding
Copy link
Contributor

BrutalCoding commented Sep 21, 2020

Hi,

Could anyone (or @giandifra himself) see if they can expand the current shapes (cube, cylinder, sphere) with a 'plane'? I would like to display an 2D image. Right now I'm showing a flat cube with the image as its texture, but it has a white reflectance that I can't get rid of.

When using a (flat) cube with certain png's as its texture, I'm getting "Unhandled Exception: PlatformException(error, Invalid Bitmap: Bitmap's configuration must be ARGB_8888, but it was RGBA_F16, null)" when trying to display certain png's. These png's work fine with ARKit's Flutter plugin (https://pub.dev/packages/arkit_plugin).

ARKit code example:

   final material = ARKitMaterial(
      lightingModelName: ARKitLightingModel.lambert,
      diffuse: ARKitMaterialProperty(image: imageUrl),
    );

    final geometry = ARKitPlane(
      materials: [material],
      width: 0.4,
      height: 0.4,
    );
    final node = ARKitNode(geometry: geometry, position: vector.Vector3(0, 0, -.8), name: 'some_name');
    _arkitController.add(node); 

I tried to add this feature myself but it seemed more involved than I hoped. If I got it working myself I'll close this issue, but I'm not that familiar with Kotlin and Android in general.

@BrutalCoding BrutalCoding changed the title [Feature request] Add new shape 'ARCorePlane'? Add 2D (png) image as material for ARCorePlane to display an image [Feature request] Add new shape 'ARCorePlane'? Add (png) image as material for ARCorePlane to display an image Sep 21, 2020
@giandifra giandifra added the enhancement New feature or request label Sep 22, 2020
@giandifra
Copy link
Owner

giandifra commented Oct 12, 2020

Hi, I'll try to implement this feature in this week!

Thank you

@BrutalCoding
Copy link
Contributor Author

Looking forward to it!

@giandifra
Copy link
Owner

I'm releasing new version...

You can add image now:

 Future _addImage(ArCoreHitTestResult hit) async {
    final bytes =
        (await rootBundle.load('assets/earth.jpg')).buffer.asUint8List();

    final earth = ArCoreNode(
      image: ArCoreImage(bytes: bytes, width: 500, height: 500),
      position: hit.pose.translation + vector.Vector3(0.0, 0.0, 0.0),
      rotation: hit.pose.rotation + vector.Vector4(0.0, 0.0, 0.0, 0.0),
    );

    arCoreController.addArCoreNodeWithAnchor(earth);
  }

@BrutalCoding
Copy link
Contributor Author

Tested it and can confirm it works flawlessly! Closing this issue now. I'll sponsor you today 👍

@Chos92
Copy link

Chos92 commented Sep 10, 2021

Instead of the image could you display a video on it and play it on a loop ?

@BingHongLi
Copy link

Instead of the image could you display a video on it and play it on a loop ?

me too, i create a ARCoreMaterial instance, try to give video byte to textureByte

show imagedecode error..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants