@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.
33 lines (32 loc) • 1.33 kB
TypeScript
import type { SceneData } from "needle-bindings";
export type { SceneData };
import type { IContext } from "./engine_types.js";
/**
* Quick access to the current Needle Engine context from anywhere — no need to pass `ctx` around.
* Use it in React/Svelte/Vue components, button handlers, or plain JavaScript.
*
* Safe to import at module level, including in SSR environments.
* For pages with multiple `<needle-engine>` elements, use `ctx` directly instead.
*
* @experimental This API may change in future releases.
*
* @example
* import { needle } from "@needle-tools/engine";
* button.onclick = () => {
* needle.sceneData.Camera.OrbitControls.autoRotate = true;
* };
*/
export declare const needle: IContext;
/**
* Returns a lazily-resolved proxy typed as {@link SceneData}.
* The proxy is cached per context — each context gets exactly one instance.
*
* Shape mirrors the generated `needle-bindings.gen.d.ts`:
* ctx.sceneData.MyGlb.Camera.$components.OrbitControls.autoRotate = true;
* ctx.sceneData.MyGlb.Camera.$object // → THREE.Camera
* ctx.sceneData.MyGlb.UI.Button.$components.Button // → Needle Button component
*
* GLB name is ignored at runtime (scene is already loaded).
* Node lookup starts at the scene root.
*/
export declare function getSceneData(ctx: IContext): SceneData;