ConstThe scene wrapper managing this entity's lifecycle and siblings
const scene = useCurrentScene();
useInitialization(() => {
// Example: spawn a floating damage number when hit
const showDamage = (amount: number) => {
scene.spawn(
<DamagePopup x={rect.x} y={rect.y - 40} value={amount} />
);
};
// ... later in useExports or event handler
return { showDamage };
});
Returns the scene this component/entity was spawned into.
This hook MUST be called at the top level of a component function — never inside loops, conditions, nested functions, or callbacks. The call order of all hooks is strictly fixed across every refresh; reordering calls will corrupt internal state.
Useful when you need to interact with the scene directly (e.g. spawn additional root-level entities, check paused state, access scene-specific data, or manipulate the entity collection).