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

feat: add transform property for xyz at once #4

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions packages/uikit/src/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ export type TransformProperties = {
transformTranslateX?: number
transformTranslateY?: number
transformTranslateZ?: number
transformTranslate?: [number, number, number]

transformRotateX?: number
transformRotateY?: number
transformRotateZ?: number
transformRotate?: [number, number, number]

transformScaleX?: number
transformScaleY?: number
Expand All @@ -26,16 +28,18 @@ export type TransformProperties = {
const tX = 'transformTranslateX'
const tY = 'transformTranslateY'
const tZ = 'transformTranslateZ'
const tXYZ = 'transformTranslate'

const rX = 'transformRotateX'
const rY = 'transformRotateY'
const rZ = 'transformRotateZ'
const rXYZ = 'transformRotate'

const sX = 'transformScaleX'
const sY = 'transformScaleY'
const sZ = 'transformScaleZ'

const propertyKeys: Array<keyof TransformProperties> = [tX, tY, tZ, rX, rY, rZ, sX, sY, sZ]
const propertyKeys: Array<keyof TransformProperties> = [tX, tY, tZ, tXYZ, rX, rY, rZ, rXYZ, sX, sY, sZ]

const tHelper = new Vector3()
const sHelper = new Vector3()
Expand Down Expand Up @@ -84,8 +88,8 @@ export function useTransformMatrix(collection: ManagerCollection, node: FlexNode
originVector.negate()
}

const r: Vector3Tuple = [get(rX) ?? 0, get(rY) ?? 0, get(rZ) ?? 0]
const t: Vector3Tuple = [get(tX) ?? 0, -(get(tY) ?? 0), get(tZ) ?? 0]
const r: Vector3Tuple = get(rXYZ) ?? [get(rX) ?? 0, get(rY) ?? 0, get(rZ) ?? 0]
const t: Vector3Tuple = get(tXYZ) ?? [get(tX) ?? 0, -(get(tY) ?? 0), get(tZ) ?? 0]
const s: Vector3Tuple = [get(sX) ?? 1, get(sY) ?? 1, get(sZ) ?? 1]
if (t.some((v) => v != 0) || r.some((v) => v != 0) || s.some((v) => v != 1)) {
result.multiply(
Expand Down