# Gold Bar

> A shiny stamped gold ingot: a tapered, bevelled bar with a recessed hallmark plate, embossed purity lines and a round assay seal on top, centered on the origin for floating pickups. Real bullion size (about 0.25 m long) that doubles as a game-pickup treasure; switch on the stack of three for vaults, heist loot, pirate hoards and shop rewards.

![Gold Bar preview](https://codels.download/m/gold-bar.png)

Multi-view sheet (3/4, front, side, top): https://codels.download/m/gold-bar.sheet.png

## Facts

- Category: Items & Weapons › Collectibles
- Size (W × H × D): 0.24 × 0.05 × 0.08 m — units are meters, +Y up, front faces +Z
- Origin: center of the model (it floats — pickups, planets)
- Triangles: 184 · Meshes: 7 · Materials: 3
- License: CC0-1.0 (Codels built-in)
- Tags: currency, gold-bar, reward, treasure, cartoon, low-poly, stylized, fantasy, modern, pirate, platformer, rpg, collectible, pickup, gold, metal, game-ready, mobile-friendly, parametric, color-orange, size-tiny, poly-ultra-low
- Page: https://codels.download/models/gold-bar

## Files

| Format | URL |
|---|---|
| three.js ES module (`createGoldBar()`) | https://codels.download/m/gold-bar.js |
| React Three Fiber component (`<GoldBar />`) | https://codels.download/m/gold-bar.jsx |
| Instancing module (`createGoldBarInstances(count, place)`, one draw call per material) | https://codels.download/m/gold-bar.instanced.js |
| Standalone HTML demo | https://codels.download/m/gold-bar.html |
| glTF binary | https://codels.download/m/gold-bar.glb |
| glTF binary, Meshopt-compressed (2–3× smaller; GLTFLoader needs `setMeshoptDecoder(MeshoptDecoder)`) | https://codels.download/m/gold-bar.glb?compress=meshopt |
| glTF JSON | https://codels.download/m/gold-bar.gltf |
| OBJ (vertex colors) + MTL | https://codels.download/m/gold-bar.obj · https://codels.download/m/gold-bar.mtl |
| STL | https://codels.download/m/gold-bar.stl |
| CodelSpec JSON | https://codels.download/m/gold-bar.json |

## Parameters

Append them as query parameters to any URL above to get a customized variant (e.g. `?stack=...`).

| Param | Type | Range / options | Default | Current |
|---|---|---|---|---|
| `stack` | boolean | true \| false | false | false |
| `color` | color | #rrggbb | #f7c437 | #f7c437 |
| `length` | number | 0.1 – 0.6 | 0.25 | 0.25 |

## Parts

- ingot (group)
  - bar (group)
    - barBody (lathe · gold)
    - barPlate (box · plate)
    - barSeal (cylinder · emboss)
    - barSealCore (cylinder · plate)
    - barMark1 (box · emboss)
    - barMark2 (box · emboss)
    - barMark3 (box · emboss)

## How to use

Save the code below as `gold-bar.js`, then:

```js
import { createGoldBar } from './gold-bar.js';
const model = createGoldBar();
scene.add(model);
```

## Code

```js
/**
 * Gold Bar — Codels 3D model library (https://codels.download/models/gold-bar)
 * License: CC0-1.0 · Units: meters · Y-up · Front: +Z · Origin: center of the model (it floats — pickups, planets)
 * Triangles: 184 · Size (W × H × D): 0.24 × 0.05 × 0.08 m
 *
 * Usage:
 *   import { createGoldBar } from './gold-bar.js';
 *   
 *   const model = createGoldBar();
 *   model.position.set(0, 0, 0);
 *   scene.add(model);
 */
import * as THREE from 'three';

// Revolve a 2D profile [[radius, y], ...] around the Y axis.
function lathe(points, segments, phiStart = 0, phiLength = Math.PI * 2) {
  return new THREE.LatheGeometry(points.map(([x, y]) => new THREE.Vector2(x, y)), segments, phiStart, phiLength);
}

export function createGoldBar() {
  const root = new THREE.Group();
  root.name = 'GoldBar';

  // Materials
  const goldMat = new THREE.MeshStandardMaterial({ name: 'gold', color: 0xf7c437, roughness: 0.28, metalness: 0.85, flatShading: true });
  const plateMat = new THREE.MeshStandardMaterial({ name: 'plate', color: 0xcba12d, roughness: 0.4, metalness: 0.85, flatShading: true });
  const embossMat = new THREE.MeshStandardMaterial({ name: 'emboss', color: 0xf9d369, roughness: 0.25, metalness: 0.85, flatShading: true });

  // Parts
  const ingot = new THREE.Group();
  ingot.name = 'ingot';
  ingot.position.set(0, -0.0245, 0);
  root.add(ingot);
  const bar = new THREE.Group();
  bar.name = 'bar';
  ingot.add(bar);
  const barBody = new THREE.Mesh(lathe([[0, 0], [0.0545, 0], [0.0589, 0.0032], [0.0446, 0.041], [0.0382, 0.045], [0, 0.045]], 4, Math.PI / 4, Math.PI * 2), goldMat);
  barBody.name = 'barBody';
  barBody.scale.set(2.9412, 1, 1);
  bar.add(barBody);
  const barPlate = new THREE.Mesh(new THREE.BoxGeometry(0.13, 0.002, 0.04), plateMat);
  barPlate.name = 'barPlate';
  barPlate.position.set(0.012, 0.0458, 0);
  bar.add(barPlate);
  const barSeal = new THREE.Mesh(new THREE.CylinderGeometry(0.014, 0.014, 0.003, 12), embossMat);
  barSeal.name = 'barSeal';
  barSeal.position.set(-0.066, 0.0465, 0);
  bar.add(barSeal);
  const barSealCore = new THREE.Mesh(new THREE.CylinderGeometry(0.0085, 0.0085, 0.0036, 12), plateMat);
  barSealCore.name = 'barSealCore';
  barSealCore.position.set(-0.066, 0.0468, 0);
  bar.add(barSealCore);
  const barMark1 = new THREE.Mesh(new THREE.BoxGeometry(0.1, 0.003, 0.005), embossMat);
  barMark1.name = 'barMark1';
  barMark1.position.set(0.024, 0.0475, 0.011);
  bar.add(barMark1);
  const barMark2 = new THREE.Mesh(new THREE.BoxGeometry(0.076, 0.003, 0.005), embossMat);
  barMark2.name = 'barMark2';
  barMark2.position.set(0.012, 0.0475, 0);
  bar.add(barMark2);
  const barMark3 = new THREE.Mesh(new THREE.BoxGeometry(0.052, 0.003, 0.005), embossMat);
  barMark3.name = 'barMark3';
  barMark3.position.set(0.036, 0.0475, -0.011);
  bar.add(barMark3);

  root.traverse((o) => {
    if (o.isMesh) {
      o.castShadow = true;
      o.receiveShadow = true;
    }
  });
  return root;
}

export default createGoldBar;
```

---
Codels — 3D models as code for three.js. Search more: https://codels.download/api/v1/models?q=<query> · Guide: https://codels.download/llms.txt
