UNPKG

@vctrl/hooks

Version:

vctrl/hooks is a React hooks package designed to simplify 3D model loading and management within React applications. It's part of the vectreal-core ecosystem and is primarily used in the vctrl/viewer React component and the official website application.

30 lines (29 loc) 1.16 kB
import { InputFileOrDirectory, ServerSceneData } from '../types'; /** * Reconstructs GLTF and asset files from scene data received from the server. * * This function converts the server's scene data format (GLTF JSON + binary assets) * back into File objects that can be loaded by the model loader. This is the reverse * operation of what happens when a scene is saved to the server. * * The function: * 1. Converts binary asset data (stored as number arrays) back into File objects * 2. Creates a GLTF file from the JSON structure * 3. Returns an array of files compatible with the model loading system * * @param data - Scene data from the server containing GLTF JSON and assets * @returns Array of File objects ready to be loaded (GLTF file + asset files) * * @example * ```typescript * // Load scene data from server * const sceneData = await ServerCommunicationService.loadScene('scene-123') * * // Reconstruct files * const files = reconstructGltfFiles(sceneData) * * // Load into the viewer * await modelLoader.load(files) * ``` */ export declare function reconstructGltfFiles(data: ServerSceneData): InputFileOrDirectory;