UNPKG

@needle-tools/engine

Version:

Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in.

37 lines (35 loc) 1.63 kB
// @ts-check /** * Needle Engine — HTML binding DTS generator * * Scans all GLB/glTF files in the project's assets directory, extracts * NEEDLE_components data, and emits a `needle-bindings.d.ts` virtual-module * declaration so that TypeScript can type-check HTML ↔ 3D component bindings. * * Typical generated output: * * declare module "needle-bindings" { * interface SceneData { * Sphere: { * MyBall: { speed: number; label: string; }; * }; * } * } * * How component field types are resolved: * - For built-in Needle Engine components, types are read from * `components.needle.json` which lists only @serializable fields with * their proper TypeScript types. * - For user-defined components (not in the manifest), types are inferred * from the JSON value in the GLB (number/string/boolean → typed, else → unknown). * - Known Three.js types (Color, Vector3, Object3D, …) are emitted as * `import("three").TypeName` and known Needle types (RGBAColor, AssetReference, …) * as `import("@needle-tools/engine").TypeName`. * - Truly unknown types fall back to `unknown`. */ export { resolveEntrypointGlbs, collectSceneFiles } from './glb.discovery.js'; export { readGlbJsonChunk, readGltfJsonFile, readRemoteGlbJsonChunk } from './glb.reader.js'; export { extractComponentBindings, sanitizeNodeName, inferNodeThreeType, inferTsType } from './glb.extractor.js'; export { scanBindings } from './dts.scan.js'; export { generateDts, generateHtmlCustomData } from './dts.codegen.js'; export { generateBindingsDts } from './dts.writer.js';