script-components
Writing Script Components for Creator Hub
This document explains how to write .tsx files that are used inside a Script component on an entity in a Creator Hub scene. These scripts run as self-contained classes attached to individual entities.
Where script files must live
Script files referenced by a Script component MUST live inside the assets/ folder — use assets/scripts/ (e.g. assets/scripts/MyScript.ts). Do NOT place them in a root-level scripts/ folder.
Why: the scene's tsconfig.json only includes src/**/* and assets/**/*:
"include": ["src/**/*.ts", "src/**/*.tsx", "assets/**/*.ts", "assets/**/*.tsx"]
A file in a root-level scripts/ folder falls outside these globs, so the TypeScript type checker (and the build's type-check step) won't cover it. The Script component's path field is resolved relative to the project root, so it must match the real file location — e.g. "path": "assets/scripts/SitChair.ts".
Script structure
Every script is a single exported class with: