import type { TextureOptions, GeometryOptions, TypedArray } from '@predy-js/render-interface'; import type { GeometryOptionsJSON, BinaryPointer, TextureJSONOptions, BezierBinaryPointer, BezierPathBinaryPointer, Item } from '@predy-js/specification'; import type { BaseItemTransform, ItemType, Composition, BinaryType } from '@predy-js/specification'; import type { BinaryEnv } from '@predy-js/specification'; export interface CompositionGraph { name: string; id: string; nodes: CompositionGraphNode[]; } export interface CompositionGraphNode { name: string; id: string; type: ItemType | 'mesh' | 'light' | 'skybox' | 'camera' | 'tree' | string; transform: BaseItemTransform; parentId?: string; subType?: string; children?: CompositionGraphNode[]; } export declare function getCompositionGraph(comp: Composition): CompositionGraph; export interface ItemSerializationResult { data: ArrayBuffer; items: Item[]; pointers: Array; } export interface TextureSerializationResult { version: '1.0'; bins?: ArrayBuffer[]; images: Array; textures: Array; } export interface GeometrySerializationResult { version: '1.0'; data: ArrayBuffer; geometries: Array>; } export declare function getBinaryType(arr: TypedArray | ArrayBuffer): BinaryType; export declare class Serializer { /** * 将item的数据进行二进制化,其中新的item需要进行克隆,不要改变原始item的数据 * 需要进行如下处理: * item.transform二进制化, * particle的所有bezier进行二进制化 * tree的nodes进行二进制化 * @param items */ static serializeItemsAsync(items: Item[]): Promise; /** * 对Item进行反序列化,如果overwrite,直接修改原来的item, * 否则克隆item进行修改 * @param item * @param binaries */ static deserializeItem(item: Item, binaries: ArrayBuffer[], overwrite?: boolean): Item; /** * texture 序列化 * @param textures */ static serializeTexturesAsync(textures: TextureOptions[]): Promise; /** * geometry 序列化 * @param geometries * @param bufferIndex buffer所在的数组位置或者fs地址 */ static serializeGeometries(geometries: GeometryOptions[], bufferIndex?: T extends BinaryEnv.json ? number : string): GeometrySerializationResult; /** * geometry反序列化 * @param geo * @param binaries */ static deserializeGeometry(geo: GeometryOptionsJSON, binaries: ArrayBuffer[]): GeometryOptions; /** * 工具方法,按照4bytes对齐方式合并buffers,如果提供了pointer,会把原来的pointer转化为新的映射 * 返回的pointers数组和传入的pointers数组长度一致,并且一一对应 * @param buffers * @param pointers 如果不提供pointers,将返回整段buffers的pointer重映射 * @param overwrite 如果为true,将直接改写参数中的pointer值,否则生成新的pointer传出 */ static concatArrayBuffers(buffers: Array, pointers?: Array, overwrite?: boolean): { data: ArrayBuffer; pointers: BinaryPointer[]; }; /** * 重构TypedArray,返回的TypedArray如果修改,会反映到原始的ArrayBuffer中 * @param binaries * @param pointer */ static typedArrayFromBinary(binaries: ArrayBuffer[], pointer: BinaryPointer): TypedArray | ArrayBuffer; }