import { YogaProperties } from "@coconut-xr/flex"; import { ForwardedRef } from "react"; import { Box2, Plane, Vector2, Vector3, Vector4 } from "three"; import { Bucket } from "./bucket.js"; import { R3FRoot } from "./events.js"; import { RootStorage } from "./root.js"; import { ScrollHandler } from "./scroll-handler.js"; import { Transformation, Transition } from "./transition.js"; import { VectorX } from "./vector.js"; import { Node as YogaNode, Yoga } from "yoga-wasm-web"; export declare const zFightingOffset = 0.5; export declare enum SetPropertyEffect { Changed = 0, Unchanged = 1, UnknownProperty = 2 } export type AnimationState = { [Key in string]: VectorX; } & { translate: Vector3; scale: Vector3; borderSize: Vector4; }; export declare function cloneState(state: Readonly): Readonly; export type AnimationConfig = { toBirthState: (state: object) => void; toDeathState: (state: object) => void; transition: Transition; isDead: (current: object) => boolean; }; export declare const distanceFadeAnimation: AnimationConfig; export declare const noAnimation: AnimationConfig; export declare abstract class BaseNode extends ScrollHandler { readonly id: string; readonly precision: number; protected requestLayoutCalculation: () => void; protected bucket: Bucket; protected root: R3FRoot; private cleanupReference; readonly yoga: YogaNode; readonly children: Array; protected nextParent: BaseNode | undefined; protected parent: BaseNode | undefined; protected properties: YogaProperties; abstract target: Readonly; protected current: Readonly | undefined; protected currentLocalTransformation: Transformation; protected targetLocalTransformation: Transformation; protected measuredLocalTranslate: Vector2; protected measuredLocalScale: Vector2; protected measuredGlobalScale: Vector2; protected measuredGlobalPadding: Vector4; protected measuredNormalizedContentBounds: Box2; protected manualTransformation: { translate: Vector3; scale: Vector3; }; protected normalizedScrollOffset: Vector3; protected depth: number; protected clippingPlanes: Array | null; protected overflowClipped: boolean; protected clippingBounds: Vector4; index: number; animationConfig: AnimationConfig; constructor(yoga: Yoga, id: string, precision: number, requestLayoutCalculation: () => void, bucket: Bucket, root: R3FRoot, cleanupReference: () => void); protected onScroll(distanceX: number, distanceY: number): boolean; private updateScroll; /** * should only be executed on the root node */ calculateLayout(): void; private commitChildren; destroy(): void; private hardDestroy; private measureLayout; private updateLayout; setProperties(properties: YogaProperties): void; abstract onInit(): void; abstract onLayout(): void; abstract onUpdate(current: Readonly): void; abstract onCleanup(): void; abstract linkCurrent(current: S): void; abstract applyClippingPlanes(planes: Array | null): void; setManualTransformation(x: number, y: number, z: number, scaleX: number, scaleY: number, scaleZ: number): void; setDepth(depth: number): void; setParent(parent: BaseNode | undefined): boolean; private removeChild; update(deltaTime: number): void; /** * called after the parent updates it's transformation (e.g. through a layout update, changing the transformation, or the depth) * accumulates: parent target translate, parent innerOffset, own target offset, own target custom transform */ private updateTransformationTarget; } export type NodeClass = { new (yoga: Yoga, id: string, precision: number, requestLayoutCalculation: () => void, bucket: Bucket, root: R3FRoot, cleanupReference: () => void): T; }; export declare function useNode({ yoga, precision, bucket, nodeMap, requestLayoutCalculation }: RootStorage, parentId: string | undefined, index: number | undefined, providedId: string | undefined, nodeClass: NodeClass, ref: ForwardedRef | undefined): T;