Draw posture avatar
Render the front and side posture avatar for a Bodygram Scanner Platform response with two method calls.
Overview
Once you've captured a scan and called getBodygramScannerPlatformPhotoEstimation, the response includes both the avatar mesh (entry.avatar) and posture analysis (entry.posture). DrawUtils combines the two into a single drawing call per view, giving you the avatar with the posture overlay lines baked on top.
There are two methods, one per view:
drawFrontPosture(response, options)— renders the front-view avatar with shoulder, hip, and ear-tilt posture lines.drawSidePosture(response, options)— renders the right-view avatar with the body-line segments.
Both methods take the full response object returned by the photo-estimation call (not just the avatar field) and a draw-options object.
Usage
const utils = new BodygramSDKDrawUtils({ locale: 'en' });
utils.drawFrontPosture(response, { container: 'front-posture' });
utils.drawSidePosture(response, { container: 'side-posture' });<div id="front-posture"></div>
<div id="side-posture"></div>The methods return the rendered DOM node, so you can also append it yourself if you prefer:
const node = utils.drawFrontPosture(response, { container: null });
myCustomMount.appendChild(node);Reference
- Full method signatures, parameter tables, return values, and
throwssemantics →drawFrontPosture(...)anddrawSidePosture(...)in the API reference. - Mount target and presentation options →
DrawOptions, including the container resolution table.
Localization
Posture overlays render any text labels (when present in the avatar canvas template) in the locale passed to the DrawUtils constructor. See the supported locales table for the full list of accepted codes — the playground below exposes the selector.
Playground
Try it with the sample response, or upload your own. Each render pulls entry.avatar and entry.posture from the response and hands them to DrawUtils — no extra wiring required.
Interactive Demo
Scan response
Fetched from /success-response/platform-success-response-2.json.
Locale
Locale is forwarded to the rendered avatar canvas and reflected in the snippet on the right.
Front posture
Side posture
How it works
The playground does exactly what the snippet on the right does:
- Load three.js and DrawUtils. The UMD example loads
three@0.160.0first (the last UMD release on npm) so it attaches towindow.THREE, then loadssdk.drawutils.umd.jswhich readsTHREEoff the global. The ES example skips both globals and uses an importmap to resolve the bareimport "three"inside the ES build. - Fetch the scan response. In production you call your own server endpoint that proxies
getBodygramScannerPlatformPhotoEstimationso your API key never reaches the browser. The playground uses a static sample at/success-response/platform-success-response-2.json. - Construct DrawUtils. A single instance is reused for both views.
- Draw the front and side posture. Each call mounts an interactive avatar canvas inside the target container and returns the node.
Related
- DrawUtils API reference — full method signatures, options, and types.
- Loading DrawUtils — script URLs and the three.js peer-dependency rules.
getBodygramScannerPlatformPhotoEstimation— the call that produces the response DrawUtils consumes.- Visualizing the avatar — render the raw
.objavatar yourself with three.js (no DrawUtils).
