# Blob shadow

> useBlobShadow puts a soft dark disc under something: the cheap shadow the era’s consoles actually used.

Example `blob-shadow`, running at https://nacatamalon.com/en/examples/blob-shadow. The whole catalogue: https://nacatamalon.com/llms/examples.md.

`useBlobShadow` puts a soft dark disc on the ground under something and keeps it there. It is the cheap shadow the target consoles actually used: not a shadow of the shape but a smudge under it, and **not a feature of the renderer at all**: a `useCircleGeometry` disc wearing a `mesh3d` material that fades from the middle, drawn down the ordinary model path. No pass, no texture, nothing reserved.

Both cubes hop identically; only the left one's shadow follows the height, and covering the shadows makes the two indistinguishable. The disc also opts out of casting a real shadow, so a scene that later turns on shadow mapping does not get a dark ring nothing explains.

## Code

`index.ts`:

```ts
import { createGame } from 'nacatamalon';
import * as Settings from './settings';
import { Scene } from './scenes/demo';

const game = createGame('#app', {
    width: Settings.WIDTH,
    height: Settings.HEIGHT,
    background: '#0a0a18',
});

// Declare Scenes
game({
    Scene
});
```

`components/hoppers.ts`:

```ts
import { createMesh, useBlobShadow, useCubeGeometry, useUpdate } from 'nacatamalon';
import * as Settings from '../settings';

export const Hoppers = () => {
    const cube = useCubeGeometry();

    const hopper = createMesh({
        geometry: cube,
        transform: {
            x: -1.8,
            y: 0.5
        },
        tint: Settings.HOPPER
    });

    const slider = createMesh({
        geometry: cube,
        transform: {
            x: 1.8,
            y: 0.5
        },
        tint: Settings.SLIDER
    });

    // One call each, then forget them: they follow on their own.
    useBlobShadow({
        target: hopper,
        radius: 0.75,
        opacity: 0.55,
        softness: 0.5,
        followHeight: true
    });
    useBlobShadow({
        target: slider,
        radius: 0.75,
        opacity: 0.55,
        softness: 0.5
    });

    useUpdate((dt, t) => {
        const hop = 0.5 + Math.abs(Math.sin(t * 2)) * 1.6;

        hopper.transform.y = hop;
        slider.transform.y = hop;
        hopper.transform.rotationY += dt * 0.8;
        slider.transform.rotationY += dt * 0.8;
    });
};
```

`scenes/demo.ts`:

```ts
import { createScene, createMesh, useCamera3d, usePlaneGeometry, useSpawn } from 'nacatamalon';
import * as Settings from '../settings';

import { Hoppers } from '../components/hoppers';

export const Scene = () => {
    useCamera3d({
        projection: 'perspective',
        fov: 55,
        near: 0.1,
        far: 100,
        transform: {
            y: 2.6,
            z: 6.5,
            rotationX: -0.5
        },
    });

    createMesh({
        geometry: usePlaneGeometry({
            width: 14,
            depth: 14
        }),
        tint: Settings.GROUND
    });

    useSpawn(Hoppers)();

    return createScene();
};
```

`settings.ts`:

```ts
import { getColor } from 'nacatamalon';

export const WIDTH = 480;
export const HEIGHT = 320;
export const GROUND = getColor('#3a3a4a');
export const HOPPER = getColor('#4cff91');
export const SLIDER = getColor('#ffcc4c');
```
