add ForceFieldBare and a useDatablock hook (#14)

This commit is contained in:
Brian Beck 2025-12-03 14:35:06 -08:00 committed by GitHub
parent 10984c3c0f
commit fda9f6a3d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 406 additions and 20 deletions

View file

@ -0,0 +1,18 @@
import type { TorqueObject } from "../torqueScript";
import { useRuntime } from "./RuntimeProvider";
/**
* Look up a datablock by name from the runtime. Use with getProperty/getInt/getFloat.
*
* FIXME: This is not currently reactive! If new datablocks are defined, this
* won't find them. We'd need to add an event/subscription system to the runtime
* that fires when new datablocks are defined. Technically we should do the same
* for the scene graph.
*/
export function useDatablock(
name: string | undefined,
): TorqueObject | undefined {
const runtime = useRuntime();
if (!name) return undefined;
return runtime.state.datablocks.get(name);
}