Create an All-Over Print Tee
This guide will walk you through how to create a simple all-over print tee using the SDK. We'll load a custom image and place it on every part of the model.
Contents
Step 1 — The Code
In this step we'll create a new design and render it in the browser. We'll show the full snippet here so that you can get a sense of the entire process and we'll break down each part afterwards.
- index.ts
1import { Core3D, Material, Model } from '@core3d/sdk';2import { Adapter } from '@core3d/sdk-adapter-three';34const core3d = new Core3D({5 apiKey: '...', // your Core3D API token6 createAdapter: ctx => new Adapter(ctx),7});89const design = core3d.createDesign();10const model = await core3d.loadModel(Model.Tee);11const cotton = await core3d.loadMaterial(Material.Cotton);+12const pattern = await core3d.loadPattern('core3d:upload:018d43a7-6826-715d-a20f-91a2eef87642');1314design.setModel(model);1516for (const mesh of design.listMeshes()) {17 design.apply(cotton, mesh);+18 design.apply(pattern, mesh);19}2021await design.render();2223const scene = await core3d.loadScene({24 layout: 'front',25 size: [512, 512],26 target: design,27});2829scene.fit();30scene.start();3132document.body.append(scene.element);
Step 2 — Breaking It Down
First, we add a new line to load a pattern.
const pattern = await core3d.loadPattern('core3d:upload:018d43a7-6826-715d-a20f-91a2eef87642');
Then we apply it to every mesh after applying the cotton
material.
design.apply(pattern, mesh);
You'll have to swap in an Upload URI (core3d:upload:...
) that your account has access to -- you can create an upload by using the Create Upload endpoint, an SDK method (await core3d.api.uploads.create({ file: File })
), or follow the Generate An Image guide to utilize our AI features.
And the result is...