184 tris0.25 × 0.05 × 0.08 m
Use it in code
Remix in the editorgold-bar.js · 76 lines
Self-contained ES module — only depends on three. Call the factory and add the group to your scene.
/**
* Gold Bar — Codels 3D model library
* 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;
Ratings & comments
0 comments
No comments yet. Share how you used this model or what could be better.
Related models
Same category or similar tags









