Your system asks for reduced motion, so VFX-JS draws nothing. Demos on this site show plain HTML.
Class
HoloEffect
effects/src/holo.ts:877 ↗import { HoloEffect } from "@vfx-js/effects";Holographic foil: the diffraction foils of holo.spot (Prism Rainbow and friends) on an element, ported from holospot (MIT). The element is lit as a card by holo.spot's spectral studio lights and tilts toward the pointer. Settings use holo.spot's ids, so a look copied from holo.spot carries over.
Example
vfx.add(el, {
effect: new HoloEffect({
holo: [
HoloEffect.looks.card,
{ material: "prism", settings: { "prism.pitch": 1200, "prism.pattern": "radial" } },
],
}),
});
Remarks
The model
The element is a card of real size (sizeMm, else its CSS size at 96 dpi), lit by holo.spot's studio rig and
seen by holospot's camera (lens). By default the card turns in 3D with the pose (pointer tilt, idle wobble,
pose), and the output grows by about 21 % per side so the turned card and its glare fit. With flat: true the
card stays in place and the light rig turns the other way instead.
holospot's physics is kept: the grating equation, order efficiencies, η renormalisation, material- and SPD-convolved spectral tables, LTC rect lights, the studio environment, coat, wear, glare, grain and tone curves. Its GLSL is used as is, without comments. What differs:
- The environment is a prefiltered octahedral atlas (an importance-sampled GGX lobe per level) instead of three's PMREM.
- The pose is the port's: a spring toward the rest pose plus the pointer tilt, and an idle wobble.
- The foil's shape comes from the element (
sourceChannel), andinktints the foil with its colours.
Params
The params are the holo.spot side, holo, and how the element becomes the card: sourceChannel, ink, flat,
sizeMm and antialias. setParams assigns params as other effects do, and so does writing effect.params
(effect.params.flat = true); a new holo (not one changed in place) applies on the next frame.
holo takes what holo.spot's "Copy settings" button copies, holo.spot settings by id with the kit's options and
the scene shorthands, or a list of them: { holo: [HoloEffect.looks.card, { exposure: 1 }], flat: true }. A list
applies in order over holo.spot's parameter defaults, and later values win. settings are holo.spot ids
(HoloSettingId), merged by id. null removes an id, so the default or the look's value applies again.
- Looks:
HoloEffect.looksare the looks holo.spot ships: their scene insettings, and the quality holospot ships each with. Put a look in the list as its own element, not spread into an object that has its ownsettings. - Starting points:
HoloEffect.startingPointsare holospot's material starting points. - Presets: a light rig (
studio.preset) oremboss.stockwrites its values where it is given. Ids given after it win; ids given before it lose. - Copy settings: a holo.spot "Copy settings" blob (
HoloCopyBlob) replaces the settings given before it and brings its material, pose and structure scale. - Checks: values are checked against holo.spot's ranges. Out-of-range values are clamped, and bad values and unknown ids are dropped, each with one console warning. holo.spot ids the port does not render (depth of field blur, bump maps, card borders) warn when set away from holospot's default.
The scene shorthands write holo.spot ids with holospot's units and ranges:
| Shorthand | holo.spot id |
|---|---|
exposure (EV, ±3), tone |
display.ev, display.tone |
glare (0–0.1), grain (0–0.6, 0 = off) |
display.glare, grain.amount |
studio |
studio.preset |
background (black, white, #rgb, #rrggbb) |
scene.background, scene.bgColor |
bow (mm, 0–2), pose (±35°) |
card.bow, motion.pose |
lens (mm, 24–200: the field of view, no blur) |
dof.lens |
pointer, tiltRange (5–35°) |
motion.pointer, motion.tiltRange |
wobble, wobbleAmp (0–25°) |
motion.wobble, motion.wobbleAmp |
Foil Emboss
material: "emboss" is a paper card with a foil logo pressed into it, and the whole element is the paper.
- Logo:
emboss.logotakes a URL, an<img>, a canvas or anImageBitmap. Without one there is no logo. The logo is cut into foil / no foil:sourceChannelpicks how the image is read ("alpha"or"luminance"), andemboss.thresholdsets where it is cut. A photo becomes a one-tone stamp. - Placement: in CSS px of the element.
emboss.xandemboss.yare the logo's centre from the top left, andemboss.widthits width. Unset, the logo is centred at 36/63 of the element's width. - Print: by default the element is printed on the paper.
emboss.printprints an image instead, fitted likebackground-size: cover. While it loads, and if it fails, the paper is plain. - The element as the logo:
"emboss.logo": "element"presses the element itself in foil, 1:1. It is read back once, and again on a resize or whenholois set again, so it suits a still element. The ground isemboss.printoremboss.paperColour, and transparent without both, so CSS can show what is behind. - Loading: the logo, paper and print load in the background.
readyresolves after a frame with them, anderrorslists what failed (a cross-origin image needs CORS).
Code loading
Each material's code (its shaders; for emboss also the logo and paper builders) is a separate chunk, loaded
when the material is first used. init waits for it. After holo changes the material, the effect keeps drawing
the previous material until the new one has loaded, and ready waits for it. HoloEffect.preload(...) loads
materials ahead. @vfx-js/effects/holo/static exports the same class with every material built in: one file,
and a material change never waits for code.
Differences from holo.spot
- Port-only:
sourceChannel,ink,flat,sizeMm,antialias, the"none"pointer,emboss.thresholdand the element as the emboss logo. - Changed defaults: grain is 0.07 (the value holo.spot's looks use), and there is no default emboss logo
(holo.spot's marks are not included). A blob's references to holo.spot's marks or uploaded images
(
emboss.logo,emboss.print) are ignored with a warning. - Changed units: the emboss placement is in px, not mm on holo.spot's 63 × 88 mm card. A blob's mm placement is ignored.
- Different names:
studioinstead oflights,startingPoints, andflat, because holospot useslightsandViewfor other things. - Not ported: the Volume Hologram and the emboss hologram stickers, multi-element emboss cards
(
emboss.doc), depth of field blur, bump maps, and card borders and thickness. holo.spot's cloth, stickers and flag objects are not either: a Copy settings blob of one is drawn as the flat card, with a warning.
Rendered next to holospot in Chromium, the foils differ by about 1 per channel (0–255) on average. Glitter
glints differ per pixel, but match within 1 after a slight blur. holospot's and three.js's MIT notices ship in
the package's THIRD_PARTY_NOTICES.md.
Constructors
new HoloEffect()
new HoloEffect(initial?: Partial<HoloParams> = {}): HoloEffect
Example
new HoloEffect({ holo: copiedFromHoloSpot });
new HoloEffect({
holo: [HoloEffect.looks.card, HoloEffect.startingPoints.prism.compactDisc, { exposure: 1 }],
flat: true,
});
Properties
params
params: HoloParams
The params; see HoloParams.
looks static
readonly looks: Readonly<{
card: Readonly<{ quality: HoloQuality; settings: HoloSettings }>;
image: Readonly<{
material: HoloMaterial;
quality: HoloQuality;
settings: HoloSettings;
}>;
object: Readonly<{ quality: HoloQuality; settings: HoloSettings }>;
}>
Default: ...
The looks holo.spot ships, as inputs: card (its holographic card), object (its 3D object), image (its
Foil Emboss paper card; sets material: "emboss"). Each sets the scene (lights, pose, exposure, …, all in
settings) and the quality holospot ships it with. Without one, the effect starts from holo.spot's parameter
defaults. Put a look in holo as its own element, not spread, so the settings after it merge by id.
Example
new HoloEffect({ holo: [HoloEffect.looks.card, { material: "shatter", studio: "softbox" }] });
startingPoints static
readonly startingPoints: HoloStartingPoints
Default: ...
The "Starting points" of holospot's material docs, as inputs (material and settings). They set the material
only, not the lights or the pose, so combine them with a look:
new HoloEffect({ holo: [HoloEffect.looks.card, HoloEffect.startingPoints.prism.compactDisc] }).
Accessors
errors
get errors(): readonly string[]
Loading errors (a logo that could not be fetched or read, …), newest last; cleared when the input changes.
material
get material(): HoloMaterial
The material in effect: the last one holo sets, else "prism".
ready
get ready(): Promise<void>
Resolves once the effect has drawn a frame with everything it loads in place: the material's code, and for
emboss the logo, the paper maps and emboss.print, which load in the background (until then the card is
drawn without them). A load that fails does not reject it; see errors. It also resolves when the effect is
disposed.
Methods
outputRect
outputRect(dims: EffectDims): readonly [number, number, number, number] | undefined
Perspective mode grows the output so the tilted card and its glare fit.
resolvedSettings
resolvedSettings(): Readonly<Record<string, HoloSettingValue | HoloLogo>>
The settings in effect, by holo.spot id: holo.spot's defaults with settings over them, checked (clamped to
the ranges, invalid values dropped). Useful to show a control's current value.
setParams
setParams(updates: Partial<HoloParams>): void
Assigns params, as other effects do. A new holo replaces the whole holo.spot side.
preload static
preload(...materials: HoloMaterial[]): Promise<void>
Loads materials' code ahead of use, so switching material later draws at once. HoloEffect loads a material's
code (its shaders, and for emboss the logo and paper builders) when it is first used; @vfx-js/effects/holo/static
has every material built in instead.
settingSpecs static
settingSpecs(material: HoloMaterial): readonly HoloSettingSpec[]
The holo.spot settings a material understands (its own ids, then the scene's), for building controls. Ids, ranges
and meanings follow holospot's docs (docs/materials/<material>.md, docs/scene-settings.md).