Build a Three.js 3D Card Mockup with Codex Game Studio
Use OpenAI's Game Studio skill to build a local card mockup. Check 30-degree Y-axis rotation, Z-axis separation and perspective projection with a repeatable Three.js fixture.
中文Setup for Codex
Codex with the OpenAI Game Studio plugin and a local Node.js project. The numerical fixture runs in Node.js without a browser or Figma account. Use a WebGL-capable browser to render the mockup. This alternative works with a Three.js scene that you own.
- In Codex, open /plugins, search for Game Studio in the OpenAI marketplace and install it for your project.
- If you use the Codex CLI and the curated marketplace is configured, run codex plugin add game-studio@openai-curated. For API key login, use codex plugin add game-studio@openai-api-curated when that marketplace is available.
- Open a local JavaScript or TypeScript scratch project. Ask Codex to use Game Studio's three-webgl-game skill and provide the fixture dimensions, object rotation and camera values below.
Example task
In an empty folder, run `npm init -y` and `npm install --save-exact three@0.183.2`. Save this fixture as `transforms.mjs`, then run `node transforms.mjs`. The last assertions check that resetting the Y-axis rotation puts both edges of the front card back at the same depth.
import assert from 'node:assert/strict';
import { Mesh, MeshBasicMaterial, PerspectiveCamera, PlaneGeometry, Scene, Vector3 } from 'three';
const scene = new Scene();
const camera = new PerspectiveCamera(45, 4 / 3, 0.1, 100);
camera.position.z = 8;
camera.updateMatrixWorld(true);
const geometry = new PlaneGeometry(2, 1.2);
const front = new Mesh(geometry, new MeshBasicMaterial());
const back = front.clone();
front.position.z = 0.75;
back.position.z = -0.75;
front.rotation.y = back.rotation.y = Math.PI / 6;
scene.add(front, back);
scene.updateMatrixWorld(true);
const left = card => card.localToWorld(new Vector3(-1, 0, 0));
const right = card => card.localToWorld(new Vector3(1, 0, 0));
const width = card => 400 * (right(card).project(camera).x - left(card).project(camera).x);
assert.equal(front.position.z - back.position.z, 1.5);
assert.ok(Math.abs(left(front).z - 1.25) < 1e-9);
assert.ok(Math.abs(right(front).z - 0.25) < 1e-9);
assert.ok(width(front) > width(back));
console.log({ nearWidthPx: +width(front).toFixed(1), farWidthPx: +width(back).toFixed(1) });
front.rotation.y = 0;
scene.updateMatrixWorld(true);
assert.equal(left(front).z, right(front).z);
console.log('Reset verified.');Expected result
The cards remain 1.5 world units apart. The near card's edges sit at depths 1.25 and 0.25 after its 30-degree tilt. At 800 pixels of screen width, the projected edges span 173.9 px for the near card and 143.8 px for the far card. The last line confirms that reset succeeded.
Upstream documentation
Original SKILL.md on GitHub · MIT license · Source reviewed
Frequently asked question
Where does this alternative apply when I need Figma-style depth and perspective?
Use it to prototype the visual effect in a local Three.js scene. You can control the card pose and perspective camera and test screen projection using the actual scene matrices. Editing transforms inside a Figma document still requires Figma's native workflow.