> Aperture 0.1.0 — experimental, unpublished. [Package archive](/downloads/bolted-aperture-0.1.0.tgz).

# Nacre and Unseal — optional material covers

These two reveal engines are shipped in the main Aperture package. They import Three.js through separate entrypoints. The root SVG entrypoint, React hook, catalog, and SVG recipe helpers do not import Three.js. Install the local Aperture archive first; it is not yet on npm. Then install the optional peer:

```sh
npm install three@^0.186.1
```

Use `createNacre` from `@bolted/aperture/nacre` or `createUnseal` from `@bolted/aperture/unseal`. Do not pass `preset: "nacre"` or `preset: "unseal"` to `createAperture` or `useAperture`. Each material has its own versioned recipe and schema. The original SVG recipe format is unchanged.

## Mount a material

```ts
import { createNacre, defaultNacreRecipe } from "@bolted/aperture/nacre";

const reveal = createNacre({
  host,
  content, // direct child; real HTML, image, or muted video
  label: "Something\nworth opening.",
  recipe: { ...defaultNacreRecipe(), finish: "opal", duration: 2.4 },
  onFallback: (reason) => console.info("Using an instant reveal:", reason),
});
const result = await reveal.open({ x: 0.2, y: 0.7 });
// Only move focus after result.status === "completed" and progress === 1.
await reveal.close();
reveal.destroy();
```

Give the host a height, `position: relative`, `overflow: hidden`, and no padding. Content fills the host absolutely. Put open/close controls outside content. Each host/content pair has one controller. The cover is procedural artwork with optional plain-text `label` (up to 100 characters, three rendered lines), not a screenshot of the hidden website. It does not alter or capture destination media. An empty label gives an unlettered material.

Both return direct controllers: `open`, `close`, `toggle`, `seek`, `destroy`, `progress`, `phase`, `mode`, `recipe`, `setRecipe`, `setLabel`, and `setOptions({ easing, reducedMotion })`. Common creation options also accept `driver`, `onUpdate`, `onComplete`, and an `AbortSignal` (`signal`). A pre-aborted signal rejects before graphics allocation; later abort destroys the controller. Callbacks should not throw. The default easing is `smooth`; pass `gentle` to match the showcase. Full opening duration comes from `recipe.duration`; closing uses 80% and partial travel scales proportionally, as in the main controller.

Recipes are objects, not JSON strings: parse JSON first, then call the matching `parseNacreRecipe` or `parseUnsealRecipe`. The parsers validate finite numbers and bounded values, discard extra fields, and return defensive copies. `setRecipe(unknown)` validates before committing; `recipe` returns a fresh copy. Export with `JSON.stringify(reveal.recipe)`. A material recipe cannot be imported by the SVG workbench or `@bolted/aperture/recipes`.

## Nacre

- `cells`: integer 4–16. Aspect ratio determines the rows, capped at 16; four triangular facets per cell, up to 1,024 instances in one mesh.
- `fold`: .3–1.4; `twist` and `stagger`: 0–1.
- `finish`: `opal`, `ink`, or `alloy`.
- `origin`: normalized x/y 0–1. `open(pointOrHTMLElement)` latches an origin when completely closed. Reversing a partially open journey preserves it. Use `originFromClient(host.getBoundingClientRect(), clientX, clientY)` for click coordinates.
- `duration`: 0–12 seconds. Format: `version: 1`, `engine: "aperture-nacre"`.

[Schema](schema/nacre-v1.schema.json). The module exports `defaultNacreRecipe`, `parseNacreRecipe`, `originFromClient`, `nacreRecipeSchema`, and public recipe/controller/options types.

## Unseal

```ts
import { createUnseal, defaultUnsealRecipe } from "@bolted/aperture/unseal";
const reveal = createUnseal({
  host, content,
  label: "A letter,\nwaiting.",
  recipe: defaultUnsealRecipe("letter"),
  quality: "balanced",
});
reveal.seek(0.35); // inspect the roll or drive it with your own gesture
reveal.setRecipe({ ...reveal.recipe, curl: 0.18 });
await reveal.open();
reveal.destroy();
```

- `surface`: `letter`, `signal`, or `atlas` — cover artwork and material finish. `defaultUnsealRecipe(surface)` supplies a matching seam.
- `seam`: 2–32 `{x,y}` points; x .08–.92, y 0–1. First y must equal 0, last y 1, with each successive y increasing by at least .01. The parser enforces these cross-point rules in addition to schema validation.
- `curl`: .04–.22; `travel`: 0–1.2; `direction`: `down` or `up`.
- `duration`: 0–8 seconds. Format: `version: 1`, `engine: "aperture-unseal"`.
- Extra controller method `setQuality("balanced" | "fine")` and read-only `quality`. Default balanced caps the backing buffer at 900,000 pixels and DPR 1.5; fine raises these to 1,800,000 and DPR 2. Quality is a device setting, not serialized in the recipe.

Opening follows the authored seam and direction. Passing an origin to `open()` does not relocate that seam; edit the recipe instead. [Schema](schema/unseal-v1.schema.json). The module exports `defaultUnsealRecipe`, `parseUnsealRecipe`, `seamX`, `unsealRecipeSchema`, and public types.

## React, Next.js, and other frameworks

Import the effect in a client component, create a fresh controller inside a mount effect, and destroy it in cleanup. Check both refs before creation. Next.js needs a `"use client"` boundary. Do not use the SVG `useAperture` hook with these factories, or reuse a disposed controller across Strict Mode mounts. Importing a material module is SSR-safe when Three.js is installed; it allocates no canvas or GPU context until creation. Geometry changes belong in `setRecipe` rather than remounting on each render.

## Capabilities and ownership

The materials use WebGL2, not WebGPU/vgpu. They work with the optional GSAP driver. Allocation, shader compilation, or render failure switches to a plain cover and instant DOM handoff. `onFallback` receives `unavailable`, `context-lost`, or `render-failed` once. A lost context is released; an in-flight journey settles its intended endpoint and its old promise resolves as interrupted. Recreate the controller if you explicitly want to retry graphics.

Content remains inert/ARIA-hidden until progress 1; the canvas is hidden from assistive technology and does not intercept pointer events. The controller restores its owned content/host state on destruction. The app still owns focus, Escape, modal semantics, and meaningful no-JS content. System Reduce Motion and `reducedMotion: "always"` settle automatic playback instantly; manual inspection remains available on capable browsers. Offscreen or background journeys pause at their current progress; they do not auto-resume.

No ambient render loop runs. Surfaces draw when progress, settings, texture, or dimensions change, and stop drawing when fully open, offscreen, or the document is hidden. Each controller owns its context, bounded textures, meshes, lights, observers, and event listeners. Avoid mounting many covers simultaneously; lazy-mount a visible interaction and destroy it afterward. These budgets are implementation limits, not measured frame-rate guarantees. Physical iPhone/Safari and broader device benchmarks remain pending.
