Repository navigation
Releases
react-3d-mockups v0.2.0
Added
-
Experimental: screens that take input (
experimentalScreenInput). OnMockupCanvasand every one-liner mockup. Clicks, hover, wheel and touch scrolling, typing and focus reach the screen content as they do on the page, iframes included. Each screen's DOM stacks above the canvas and is clipped every frame (clip-path: path(evenodd, …)) to the part of it no hardware covers, traced from the pixels the canvas leaves transparent for it, so a laptop's base still hides the bottom of its display from below. Screens last took input by raycasting, which could only show or hide a whole screen; this clips per pixel instead. A tap is the content's and a drag still turns the model, unless the content claims it (form controls,data-mockup-no-rotate, or a pointer it captures withsetPointerCapture) orscreenDrag={false}- on the mockup, or on one slot - leaves every drag on the screen to the content. It costs a synchronous canvas readback per screen per drawn frame and about 2 KB gzip, loaded only once a screen takes input, and the screens join the accessibility tree. The name says it: it may change or go away in any release. Try it at/harness/screen-inputon the docs site. -
CreditCardMockupandCreditCard: a payment card with real embossing. An ISO/IEC 7810 ID-1 card (85.60×53.98×0.76 mm, 3.18 mm corners) with live full-bleedfrontandbackfaces, measured under the newcreditCardkind, checked against photographs of real cards. The print sits under a gloss laminate that picks up the studio lights as the card turns (finish="matte"for soft-touch), round a white core at the cut edge (edgeColor). Over the print stand a 13×11.4 mm EMV contact plate,chip="gold"or"silver", etched with its contacts and set in its milled cavity over the ISO/IEC 7816-2 contact field; and thenumber,nameandexpiryembossed as raised geometry up to 0.46 mm high - flat crests carrying silver, gold or any colour of foiltipping(or'none', which shades the print instead) on shoulders that slope into the print. The number is in a Farrington 7B-style face centred 21.42 mm above the bottom edge, the name and expiry in the ISO/IEC 7811-1 name-and-address area with a printed "VALID THRU" legend, and the back carries their mirrored, debossed impressions beside the magnetic stripe and the signature panel.emboss="flat"prints the lines in a thin line instead, as most new cards do, andemboss={false},chip={false},stripeandsignatureturn their piece off. The lettering is a stroke font in the core (STROKE_FONT,layoutStrokeText,normalizeStrokeText): no font files and nothing to download. Accented letters are transliterated (José embosses as JOSE); characters it still has no glyph for are dropped with a one-time development warning. -
Device lifecycle, and a way to retire old models. Every device variant now belongs to a product line in
DEVICE_LINEUP(react-3d-mockups/core), with the month it was announced, anddeviceLifecycle(kind, variant)says where it stands:current: the newest model in its line;superseded: a newer model in its line is in the catalog. Today that is the iPhone 17 Pro and Pro Max, the Galaxy Z Fold 7 and Z Flip 7, Apple Watch Series 11 and Galaxy Watch 8. Superseded models are fully supported;deprecated: scheduled for removal, with the release that removes it.
A deprecated model logs one development warning naming its replacement. A removed one throws an error that points to its replacement, through
REMOVED_DEVICES. Nothing is deprecated yet. CONTRIBUTING.md has the deprecation and removal process. The docs sidebar and gallery now show the newest model of each line, with the older ones one click away. -
TVSetPropsandDOOHTotemSize, named after their components.TVPropsandDoohTotemSizestay as aliases.MockupRegions<K>is the region mapmockupInfo(kind)returns for a kind. -
More warnings in development, each logged once:
- a mockup whose container has no height, which leaves it 0 px tall and invisible;
- a
colorthat is a colorway id of another variant (color="coralred"on a Flip 8), naming the variants that have it; - a slot of another mockup (
<AFrameSignMockup.Back>inside<BookMockup>), which used to land on any region with the same name and is now ignored; - a canvas whose WebGL context the browser dropped (see below).
Changed (breaking)
BusMockup's curb-side ad is a queen-size panel, 586×200 by default (was 960×200). The curb side used to mirror the street side's king-size panel, which ran across the rear door, so the door's glass drew over the left third of the art. The queen panel sits between the rear door and the front wheel arch, at the street side's print density. Lay curb-side art out for 586×200, or usecoverage="full", which is unchanged.catalog.jsonis version 2. The Fold and Flip rows carryopenAngle(version 1 named a nonexistentopenprop, so every folded row measured the open screen), the iPhone Duo is enumerated open and folded in both orientations, and the TV by variant: 95 rows. Code that filtered onprops.openshould filter onprops.openAngle.mockupInfo(kind).regionsis typed per kind.mockupInfo('book') .regions.cover.pxtypechecks, a misspelt region name is a type error, and a region with several surfaces (the van'slicensePlate) is an array. Code that narrowed the oldRegionInfo | RegionInfo[]union by hand may need the narrowing removed.XMockup.info()andXMockup.regionsare no longer optional on the built-in mockups, andinfo()requires its argument where the kind needs a size (CustomPanelMockup.info({ size })); calling it without one used to typecheck and then throw.
Changed
- Importing one mockup ships only that mockup. The ESM build is one file per module instead of one bundle, so
"sideEffects": falselets an app's bundler drop everything an import does not reach. ImportingBookMockupused to ship the whole library (~135 KB gzip); it is now about 15 KB, and a device about 60 KB, most of it the CSG engine the devices share. The docs' import-cost table is measured from the published build. - The main entry works in a Server Component. Only the component modules carry
'use client', somockupInfo, the colorways and the specs import fromreact-3d-mockupsinto server code as well as fromreact-3d-mockups/core. They used to be client references the server could not call. gl,onCreated,dprandpauseWhenOffscreenare mockup props. They always reached the canvas at runtime, but TypeScript rejected them on a*Mockup.BusShelterMockupandMailerBoxMockupframe the surface your content is on. The shelter's camera used to face the inner poster, so bare children were on the face turned away; the mailer's looked at its lid edge on. Both now show the primary region at the default pose.MailerBoxMockupprints every panel at one density,resolutionbeing the lid's width, andmockupInforeports the 520 px the lid renders (it said 513).- Sourcemaps no longer embed the sources, which were 4.5 MB of the package's 7.7 MB.
Fixed
- An unknown
variantthrows an error that names it. A misspelt variant on a device component, or passed tomockupInfo, used to throw a TypeError from inside the scene or the metrics resolver. It now throwsunknown variant "…"and lists the variants that exist. The TV, which used to fall back to its default design, does the same. - No console errors when a screen mounts. Every screen logged "Attempted to synchronously unmount a root while React was already rendering" in development, twice under StrictMode, because drei's
<Html>unmounted its React root inside React's commit. Screens now mount through their own portal (adapted from drei's<Html>), which gives every mount its own root and unmounts an outgoing one after the commit. - A canvas whose WebGL context is lost comes back. Browsers drop the oldest contexts when a page holds too many; such a canvas stayed blank. It now shows an empty placeholder and starts a fresh renderer the next time it scrolls into view.
- A bad millimetre
sizefails by name.CustomPanelandCustomBoxwithout asize, or any object given a zero, negative or non-finite dimension, used to render nothing and measureInfinity. They throw an error naming the component and showing a valid size. - A foldable's half pane reports the whole display to
useSurface(), not the fraction of it that half shows, so content laid out from it spans the fold correctly while the device is partly open.
react-3d-mockups v0.1.1
Changed
- The README, which is the package's npm page, says the package is in active development and that its API may change over the next few weeks. 0.1.0 shipped without that notice.
react-3d-mockups v0.1.0
First release: 33 procedurally generated devices and 24 objects (print, packaging, out-of-home formats, vehicles, a TV, and custom-size panels and boxes), the live-DOM screen bridge, the measurement API (mockupInfo, useSurface, the generated catalog), and the docs site.
In active development. The API may change over the next few weeks. Breaking changes are listed in the changelog with what to change; pin an exact version (npm install --save-exact react-3d-mockups) if you need it to stay put.