react-native-cube icon indicating copy to clipboard operation
react-native-cube copied to clipboard

not work in android

Open Rowandjj opened this issue 8 years ago • 14 comments

image

Rowandjj avatar Jul 07 '17 06:07 Rowandjj

Hello there :) It is because in Android, child view gets bounded by its parent view. If you give the container view greater size, there won't be a problem. I will try to fix this soon.

ochanje210 avatar Jul 07 '17 06:07 ochanje210

got it. thanks:)

Rowandjj avatar Jul 07 '17 07:07 Rowandjj

hi buddy:) still not work after tried many ways:(

Rowandjj avatar Jul 12 '17 03:07 Rowandjj

Did you ever get it to draw properly? I expanded the container and it works well, unfortunately, the angles of the faces seem off, despite the values being the same as iOS and the normals of the faces seem to be inverted

screen shot 2017-11-27 at 9 43 20 pm

bdanis avatar Nov 28 '17 02:11 bdanis

I've also attached the edited scripts i am using Cube.txt

bdanis avatar Nov 28 '17 02:11 bdanis

Any solution ?

AdamKraif avatar Feb 25 '18 23:02 AdamKraif

From what I've seen even when position is set to absolute Android won't respect the z values from the transform matrix when it comes to the draw order of the panels.

DylanVann avatar Apr 25 '18 20:04 DylanVann

It's still not working for me. I think we will need to change zIndex dynamically to make it work properly.

juniorerico avatar Feb 27 '19 19:02 juniorerico

zIndex does not work on android, you have to use elevation instead. I managed to make it work by setting it dynamically.

_rotateCube(dx) {
    dx %= 360
    const origin = { x: 0, y: 0, z: -yourCubeSideSize / 2 }
    let matrix = this._rotateX(dx)
    this._transformOrigin(matrix, origin)
    this.refViewFront.setNativeProps({
      style: {elevation: dx > 90 && dx < 270 ? 1 : 10, transform: [{ perspective: 1000}, { matrix: matrix }] }
    })

    matrix = this._rotateX(dx + 180)
    this._transformOrigin(matrix, origin)
    this.refViewBack.setNativeProps({
      style: {elevation: dx > 90 && dx < 270 ? 10 : 1, transform: [{ perspective: 1000 }, { matrix: matrix }] }
    })

    matrix = this._rotateX(dx + 90)
    this._transformOrigin(matrix, origin)
    this.refViewRight.setNativeProps({
      style: {elevation: dx > 180 ? 10 : 1, transform: [{ perspective: 1000 }, { matrix: matrix }] }
    })

    matrix = this._rotateX(dx - 90)
    this._transformOrigin(matrix, origin)
    this.refViewLeft.setNativeProps({
      style: {elevation: dx < 180 ? 10 : 1, transform: [{ perspective: 1000 }, { matrix: matrix }] }
    })
  }

Edit: This was a sandbox thing, not exactly adaptable for this project, but you get the gist.

Kouznetsov avatar Mar 25 '20 10:03 Kouznetsov

The issue for me is exactly as @bdanis describes. The faces seem to be a little bit skewed or have the wrong angle so the cube doesn't line up properly

AdamTyler avatar Jul 02 '20 01:07 AdamTyler

src_react_components_game_elements_Cube.txt this was our final thing, i remember doing a lot with the matrix

bdanis avatar Jul 02 '20 15:07 bdanis

Any fixes? Android support would be great!

SudarshanSuryaprakash avatar Jan 01 '21 13:01 SudarshanSuryaprakash

Add: backfaceVisibility: 'hidden', to the side style in my case - instead of zIndex: 10

raienko avatar Sep 02 '21 16:09 raienko

@raienko that worked for me. What a simple solution! Thanks.

wardjk87 avatar Jul 27 '22 01:07 wardjk87