File tree Expand file tree Collapse file tree 4 files changed +55
-8
lines changed Expand file tree Collapse file tree 4 files changed +55
-8
lines changed Original file line number Diff line number Diff line change @@ -73,14 +73,13 @@ export function apply2dTransforms({
73
73
}
74
74
}
75
75
76
- const Transform2d = ( {
77
- children,
76
+ export function use2dTransformations ( {
78
77
parentMatrixWorld,
79
78
translate,
80
79
scale,
81
80
rotate,
82
81
multiplicationOrder = 'POST' ,
83
- } : Transform2dProps ) => {
82
+ } : Omit < Transform2dProps , 'children' > ) {
84
83
const safeParentMatrixWorld = useFactoryRef < mat2d > (
85
84
( ) => parentMatrixWorld || mat2d . create ( ) ,
86
85
) ;
@@ -101,6 +100,28 @@ const Transform2d = ({
101
100
rotate,
102
101
} ) ;
103
102
103
+ return {
104
+ matrix,
105
+ matrixWorld,
106
+ } ;
107
+ }
108
+
109
+ const Transform2d = ( {
110
+ children,
111
+ parentMatrixWorld,
112
+ translate,
113
+ scale,
114
+ rotate,
115
+ multiplicationOrder = 'POST' ,
116
+ } : Transform2dProps ) => {
117
+ const { matrixWorld } = use2dTransformations ( {
118
+ parentMatrixWorld,
119
+ translate,
120
+ scale,
121
+ rotate,
122
+ multiplicationOrder,
123
+ } ) ;
124
+
104
125
const render = useRender < mat2d > ( {
105
126
cssMatrixPrefix : 'matrix' ,
106
127
matrixWorld,
Original file line number Diff line number Diff line change @@ -80,15 +80,14 @@ export function apply3dTransforms({
80
80
}
81
81
}
82
82
83
- const Transform3d = ( {
84
- children,
83
+ export function use3dTransformations ( {
85
84
parentMatrixWorld,
86
85
translate,
87
86
scale,
88
87
rotate,
89
88
rotateAxis,
90
89
multiplicationOrder = 'POST' ,
91
- } : Transform3dProps ) => {
90
+ } : Omit < Transform3dProps , 'children' > ) {
92
91
const safeParentMatrixWorld = useFactoryRef < mat4 > (
93
92
( ) => parentMatrixWorld || mat4 . create ( ) ,
94
93
) ;
@@ -112,6 +111,30 @@ const Transform3d = ({
112
111
rotateAxis,
113
112
} ) ;
114
113
114
+ return {
115
+ matrix,
116
+ matrixWorld,
117
+ } ;
118
+ }
119
+
120
+ const Transform3d = ( {
121
+ children,
122
+ parentMatrixWorld,
123
+ translate,
124
+ scale,
125
+ rotate,
126
+ rotateAxis,
127
+ multiplicationOrder = 'POST' ,
128
+ } : Transform3dProps ) => {
129
+ const { matrixWorld } = use3dTransformations ( {
130
+ parentMatrixWorld,
131
+ translate,
132
+ scale,
133
+ rotate,
134
+ rotateAxis,
135
+ multiplicationOrder,
136
+ } ) ;
137
+
115
138
const render = useRender < mat4 > ( {
116
139
cssMatrixPrefix : 'matrix3d' ,
117
140
matrixWorld,
Original file line number Diff line number Diff line change 1
1
export * from './propTypes' ;
2
2
export { useFactoryRef } from './useFactoryRef' ;
3
- export { default as Transform2d } from './Transform2d' ;
4
- export { default as Transform3d } from './Transform3d' ;
3
+ export { default as Transform2d , use2dTransformations } from './Transform2d' ;
4
+ export { default as Transform3d , use3dTransformations } from './Transform3d' ;
5
5
export type { Transform2dProps } from './Transform2d' ;
6
6
export type { Transform3dProps } from './Transform3d' ;
7
+ export type { GLMatrixType , Vec2Object , Vec3Object } from './types' ;
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ exports[`index export modules for react-css-transform 1`] = `
7
7
" mat2dGlMatrix" : [Function ],
8
8
" mat4GlMatrix" : [Function ],
9
9
" mat4GlMatrixValidator" : [Function ],
10
+ " use2dTransformations" : [Function ],
11
+ " use3dTransformations" : [Function ],
10
12
" useFactoryRef" : [Function ],
11
13
" vec2GlMatrix" : [Function ],
12
14
" vec2Obj" : [Function ],
You can’t perform that action at this time.
0 commit comments