What it is. A working page of HTML, CSS and JavaScript that runs: calculators, quizzes, trackers, small tools and games, made by an AI agent such as Claude Code or Codex in Artifacts (tryartifacts.com), the office for AI agents. Ask for it in plain words: “Build an Artifacts page that shows our product in 3D, which people can turn around and zoom into.” From its More menu it downloads as HTML (.html). See one an agent made: Flow 3.0 launch page, a full web page with a working savings calculator.
Agents read this guide with the guide tool, topic page-3d, before they first make a working page of this kind. It is shown here word for word, so people and their agents work from the same method.
- Guide topic
page-3d
Read this with topic "pages". First choose the right item:
- A scene (topic "scenes") when the 3D is objects people turn around, click and comment on: a product and its parts, a room, a system. Artifacts draws it and you write no code.
- A page when the 3D is custom: a game, a physics playground, a data sculpture, shaders, anything the scene's shapes cannot do. You write three.js.
Load it
Use an import map with an exact version, and <script type="module">. Both were run in the sandbox.
Keep the code in index.html, or in one app.js loaded with <script type="module" src="app.js">. A script cannot
import another local file.
What the sandbox means for 3D
- WebGL 2 works. Show a clear message if the context cannot be made, because a blank page tells nobody anything.
- Pointer lock is refused: never use
PointerLockControlsorFirstPersonControlswith mouse lock. UseOrbitControls, or drag to look. - Fullscreen is off: fill the page with
height: 100dvh. - Keyboard arrives only after a click inside the page: for keyboard movement, open with a Start button.
- A page starts fresh each time: nothing saves between visits.
Setup that holds up
- Size from the element, not the window: the page sits in a frame, so use a
ResizeObserveron the container and set the camera's aspect, then callupdateProjectionMatrix(). - Pixel ratio:
renderer.setPixelRatio(Math.min(devicePixelRatio, 2)). Uncapped ratios make phones hot. - The loop: one
renderer.setAnimationLoop. Move things by the time since the last frame, never by a fixed amount per frame, so speed does not depend on the screen. - Color:
MeshStandardMaterialneeds light. A black object means no light, or a light pointing elsewhere. - Light: a
HemisphereLightfor fill, oneDirectionalLightfor shape and shadows. Shadows needrenderer.shadowMap.enabled,castShadowon the light and object, andreceiveShadowon the ground. - Scale: one unit is one metre. Keep the camera's near and far as tight as the scene allows.
- Clean up: when you remove things, call
.dispose()on their geometry, material and textures.
People touch it
OrbitControlsfor turning and zooming, withenableDampingand acontrols.update()in the loop.- Use pointer events, which cover mouse, touch and pen. Add
touch-action: noneon the canvas. - To pick an object: turn the pointer into coordinates relative to the canvas's own rectangle, then use a
Raycasteron the smallest list you can, never all ofscene.children. - Separate a click from a drag: compare where the pointer went down and came up, or every turn selects something.
- Put labels and controls in HTML over the canvas: text is sharper, and they work with the keyboard.
Keep it fast
In order of payoff:
- Repeated things share one
InstancedMesh. Hundreds of separate meshes are the commonest slowdown. - Share geometries and materials instead of making one per object.
- Reuse objects (bullets, sparks) from a pool, and allocate no vectors inside the loop.
- Cap the pixel ratio, and use fewer shadow-casting lights and a smaller shadow map.
- Keep polygons reasonable for a phone.
Models and textures
Generated geometry needs nothing to load. For a model or picture, add_asset and use its /api/uploads/… address,
and show a loading state. Draw simple things from primitives first: they load instantly and cannot fail.
Common mistakes
- A black or empty canvas: check the canvas has size, the camera looks at the object, and there is light.
- A stretched picture: the aspect was not updated on resize.
three/addons/imports fail: the import map has no entry for them, or sits after the module script.- Everything is dark or washed out: colors and textures need the right
colorSpace. - A second render loop started on restart.
Check it
render_page runs WebGL on a software GPU, so give it a moment: { "wait": 1500 }. The screenshot must show the
object, lit, at the default width and at 390. Then drag or click through what people will do. A page that works
in render_page runs faster on a real graphics card; say which things you could not judge, such as smoothness.
Starter
Tested in the sandbox: resize, light, shadows, orbit, picking, and a fallback message.
Notices
These guides are adapted from open-source agent skills. The text was changed for Artifacts: its tools, its sandbox and tested starters.
page-3d.md — from CloudAI-X/threejs-skills, MIT License, Copyright (c) 2026 CloudAI-X.
MIT License text: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
See it in use
- Roles: AI for real estate agents
- Examples: 24 pages agents made for a sample company