question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unexhaustive handling for rotateX when using transform (rotate)

See original GitHub issue

I am trying to rotate text by a certain amount, tried using ‘45deg’ like in the Transforms documentation from React Native but doesnt work either. Also tested skewX and it works.

        <Group key={`tick-${d}`}>
          <Group transform={[{ rotateX: 45 }]}>
            <Text
              x={labelX}
              y={labelY}
              text={d}
              color={textColor}
              familyName="serif"
              size={9}
            />
          </Group>

          <Path path={path} color={strokeColor} />
        </Group>

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8

github_iconTop GitHub Comments

3reactions
thomas-coldwellcommented, Aug 2, 2022

Just to give a small example of the workaround you can do the following:

  • Copy the Matrix4.ts code from redash
  • Create you’re 3D transforms using a 4x4 matrix
  • Get a 3x3 matrix using const mat3 = toMatrix3(matrix4)
  • Get an SkMatrix - const matrix = Skia.Matrix(mat3)
  • Pass this matrix into the matrix prop on the <Group /> component
// Copy this from redash 
import { processTransform3d } from './Matrix4' 

const clock = useClockValue();

const matrix = useComputedValue(() => {
  const rotation = (Math.sin(clock.current / 500) * Math.PI) / 4;
  return processTransform3d([
    { rotateY: rotation },
    { perspective: 500 },
  ]);
}, [clock]);

<Group matrix={matrix}>
</Group>

https://user-images.githubusercontent.com/31568400/182338383-1d949488-c388-4623-908d-edfbb5cd3bb8.MP4

1reaction
thomas-coldwellcommented, Aug 4, 2022

Hey @naraB this might be to do with the perspective matrix function I had to change the index as per what RN uses internally for its transform calculations - I think this has something to do with it using a transposed matrix so m34 gets swapped with m43 (my matrix math is a little rusty though 😅):

const perspective = (p: number): Matrix4 => {
  let mat = identity4;
  mat[11] = -1 / p;
  return mat;
};

This might explain the change a bit better: https://stackoverflow.com/a/35825372

Hope this helps 🙌

Read more comments on GitHub >

github_iconTop Results From Across the Web

rotateX() - CSS: Cascading Style Sheets - MDN Web Docs
The rotateX() CSS function defines a transformation that rotates an element around the abscissa (horizontal axis) without deforming it.
Read more >
Actions · Shopify/react-native-skia - GitHub
High-performance React Native Graphics using Skia. ... Unexhaustive handling for rotateX when using transform (rotate) Contributor License Agreement (CLA) ...
Read more >
Error while animating rotateX in react native - Stack Overflow
I am trying to rotate an icon on press ...
Read more >
rotate | CSS-Tricks
The rotate property in CSS turns an element around one or more axes. Think of it like poking one or more pins into...
Read more >
Reference Frame Notes # - DREAM.3D
When dealing with orientation data such as Euler angles, Quaternions and ... A rotations always transforms the sample reference frame to the crystal ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found