LiveItemtype
What a card shows in 3D: a key (items with the same key share their pictures) and a scene made from shared assets (assets.acquire).
Import it
import type { LiveItem } from "@johnmorrisdotca/fuda-cards/live-3d";
Definition
interface LiveItem<T extends ThreeLike = ThreeLike> {
key: string;
build(context: BuildContext<T>): LiveScene | Promise<LiveScene>;
}
Members
| Name | Type | Description |
|---|---|---|
key | string | |
build | (context: BuildContext<T>): LiveScene | Promise<LiveScene> |
Examples
import type { LiveItem } from "@johnmorrisdotca/fuda-cards/live-3d";
import { BoxGeometry, Mesh, MeshNormalMaterial, PerspectiveCamera, Scene } from "three";
const cube: LiveItem = {
key: "cube",
build() {
const object = new Mesh(new BoxGeometry(1, 1, 1), new MeshNormalMaterial());
return { scene: new Scene().add(object), camera: new PerspectiveCamera(40, 1, 0.1, 10), object };
},
};
console.log(cube.key);