# Torch

> A medieval low-poly torch with a pitch-wrapped head and a layered, glowing flame made of emissive cones. Mount it on an iron wall bracket for castle corridors and dungeons, or plant it on a tall standing pole with stones at its base for camps and village paths. Recolor the flame or snuff it out.

![Torch preview](https://codels.download/m/wall-torch.png)

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

## Facts

- Category: Props › Lighting
- Size (W × H × D): 0.10 × 0.69 × 0.30 m — units are meters, +Y up, front faces +Z
- Origin: center of the base (y = 0)
- Triangles: 366 · Meshes: 16 · Materials: 8
- License: CC0-1.0 (Codels built-in)
- Tags: fire, torch, low-poly, stylized, fantasy, medieval, castle, cave, dungeon, adventure, roguelike, rpg, decoration, light-source, prop, energy, metal, wood, emissive, mobile-friendly, parametric, color-brown, color-gray, color-orange, size-small, poly-low
- Page: https://codels.download/models/wall-torch

## Files

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

## Parameters

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

| Param | Type | Range / options | Default | Current |
|---|---|---|---|---|
| `mount` | select | wall \| standing | wall | wall |
| `flame` | color | #rrggbb | #ff8a1e | #ff8a1e |
| `lit` | boolean | true \| false | true | true |

## Parts

- wallTorch (group)
  - wallPlate (box · iron)
  - rivet (cylinder · woodDark)
  - rivet (cylinder · woodDark)
  - arm (box · iron)
  - strut (box · iron)
  - collar (torus · iron)
  - torch (group)
    - handle (cylinder · wood)
    - head (cylinder · wrap)
    - band (cylinder · rope)
    - band (cylinder · rope)
    - flame (group)
      - flameBase (icosahedron · flameMid)
      - flameBack (cone · flameOuter)
      - tongueL (cone · flameOuter)
      - tongueR (cone · flameMid)
      - flameMid (cone · flameMid)
      - flameCore (cone · flameCore)

## How to use

Save the code below as `wall-torch.js`, then:

```js
import { createWallTorch } from './wall-torch.js';
const model = createWallTorch();
scene.add(model);
```

## Code

```js
/**
 * Torch — Codels 3D model library (https://codels.download/models/wall-torch)
 * License: CC0-1.0 · Units: meters · Y-up · Front: +Z · Origin: center of the base (y = 0)
 * Triangles: 366 · Size (W × H × D): 0.10 × 0.69 × 0.30 m
 *
 * Usage:
 *   import { createWallTorch } from './wall-torch.js';
 *   
 *   const model = createWallTorch();
 *   model.position.set(0, 0, 0);
 *   scene.add(model);
 */
import * as THREE from 'three';

const deg = THREE.MathUtils.degToRad;

// Deterministic vertex displacement (organic low-poly look).
function jitter(geometry, amount, seed) {
  const pos = geometry.attributes.position;
  const h = (a, b, c, s) => {
    let x = Math.imul(a, 73856093) ^ Math.imul(b, 19349663) ^ Math.imul(c, 83492791) ^ Math.imul(s, 2654435761);
    x = Math.imul(x ^ (x >>> 16), 2246822507);
    x = Math.imul(x ^ (x >>> 13), 3266489909);
    return ((x ^ (x >>> 16)) >>> 0) / 4294967295 - 0.5;
  };
  for (let i = 0; i < pos.count; i++) {
    const x = pos.getX(i), y = pos.getY(i), z = pos.getZ(i);
    const qx = Math.round(x * 1000), qy = Math.round(y * 1000), qz = Math.round(z * 1000);
    pos.setXYZ(i, x + h(qx, qy, qz, seed) * 2 * amount, y + h(qx, qy, qz, seed + 1) * 2 * amount, z + h(qx, qy, qz, seed + 2) * 2 * amount);
  }
  pos.needsUpdate = true;
  geometry.computeVertexNormals();
  return geometry;
}

export function createWallTorch() {
  const root = new THREE.Group();
  root.name = 'WallTorch';

  // Materials
  const woodMat = new THREE.MeshStandardMaterial({ name: 'wood', color: 0x8a5a32, roughness: 0.85, flatShading: true });
  const woodDarkMat = new THREE.MeshStandardMaterial({ name: 'woodDark', color: 0x5e3b20, roughness: 0.9, flatShading: true });
  const wrapMat = new THREE.MeshStandardMaterial({ name: 'wrap', color: 0x3a2a20, roughness: 1, flatShading: true });
  const ropeMat = new THREE.MeshStandardMaterial({ name: 'rope', color: 0xa07a4c, roughness: 0.95, flatShading: true });
  const ironMat = new THREE.MeshStandardMaterial({ name: 'iron', color: 0x4a4d54, roughness: 0.5, metalness: 0.5, flatShading: true });
  const flameOuterMat = new THREE.MeshStandardMaterial({ name: 'flameOuter', color: 0xff570f, roughness: 1, emissive: 0xff570f, emissiveIntensity: 1.3, flatShading: true });
  const flameMidMat = new THREE.MeshStandardMaterial({ name: 'flameMid', color: 0xff8a1e, roughness: 1, emissive: 0xff8a1e, emissiveIntensity: 1.7, flatShading: true });
  const flameCoreMat = new THREE.MeshStandardMaterial({ name: 'flameCore', color: 0xffd384, roughness: 1, emissive: 0xffd384, emissiveIntensity: 2, flatShading: true });

  // Shared geometries
  const cylinderGeo = new THREE.CylinderGeometry(0.01, 0.01, 0.006, 6);

  // Parts
  const wallTorch = new THREE.Group();
  wallTorch.name = 'wallTorch';
  wallTorch.position.set(0, 0, -0.15);
  root.add(wallTorch);
  const wallPlate = new THREE.Mesh(new THREE.BoxGeometry(0.09, 0.2, 0.014), ironMat);
  wallPlate.name = 'wallPlate';
  wallPlate.position.set(0, 0.14, 0.007);
  wallTorch.add(wallPlate);
  const rivet = new THREE.Mesh(cylinderGeo, woodDarkMat);
  rivet.name = 'rivet';
  rivet.position.set(0, 0.07, 0.016);
  rivet.rotation.set(deg(90), 0, 0);
  wallTorch.add(rivet);
  const rivet2 = new THREE.Mesh(cylinderGeo, woodDarkMat);
  rivet2.name = 'rivet';
  rivet2.position.set(0, 0.21, 0.016);
  rivet2.rotation.set(deg(90), 0, 0);
  wallTorch.add(rivet2);
  const arm = new THREE.Mesh(new THREE.BoxGeometry(0.022, 0.022, 0.1), ironMat);
  arm.name = 'arm';
  arm.position.set(0, 0.15, 0.06);
  wallTorch.add(arm);
  const strut = new THREE.Mesh(new THREE.BoxGeometry(0.018, 0.09, 0.018), ironMat);
  strut.name = 'strut';
  strut.position.set(0, 0.1, 0.05);
  strut.rotation.set(deg(-40), 0, 0);
  wallTorch.add(strut);
  const collar = new THREE.Mesh(new THREE.TorusGeometry(0.036, 0.009, 5, 10), ironMat);
  collar.name = 'collar';
  collar.position.set(0, 0.17, 0.11);
  collar.rotation.set(deg(70), 0, 0);
  wallTorch.add(collar);
  const torch = new THREE.Group();
  torch.name = 'torch';
  torch.position.set(0, 0, 0.0481);
  torch.rotation.set(deg(20), 0, 0);
  wallTorch.add(torch);
  const handle = new THREE.Mesh(new THREE.CylinderGeometry(0.024, 0.017, 0.42, 6), woodMat);
  handle.name = 'handle';
  handle.position.set(0, 0.21, 0);
  torch.add(handle);
  const head = new THREE.Mesh(new THREE.CylinderGeometry(0.042, 0.03, 0.1, 7), wrapMat);
  head.name = 'head';
  head.position.set(0, 0.42, 0);
  torch.add(head);
  const band = new THREE.Mesh(new THREE.CylinderGeometry(0.044, 0.044, 0.016, 7), ropeMat);
  band.name = 'band';
  band.position.set(0, 0.393, 0);
  torch.add(band);
  const band2 = new THREE.Mesh(new THREE.CylinderGeometry(0.046, 0.046, 0.016, 7), ropeMat);
  band2.name = 'band';
  band2.position.set(0, 0.448, 0);
  torch.add(band2);
  const flame = new THREE.Group();
  flame.name = 'flame';
  flame.position.set(0, 0.47, 0);
  torch.add(flame);
  const flameBase = new THREE.Mesh(new THREE.IcosahedronGeometry(0.048, 0), flameMidMat);
  flameBase.name = 'flameBase';
  flameBase.position.set(0, 0.03, 0);
  flameBase.scale.set(1, 0.8, 1);
  flame.add(flameBase);
  const flameBack = new THREE.Mesh(jitter(new THREE.ConeGeometry(0.052, 0.24, 6), 0.008, 2), flameOuterMat);
  flameBack.name = 'flameBack';
  flameBack.position.set(0, 0.13, -0.012);
  flameBack.rotation.set(deg(-6), 0, 0);
  flame.add(flameBack);
  const tongueL = new THREE.Mesh(new THREE.ConeGeometry(0.032, 0.14, 5), flameOuterMat);
  tongueL.name = 'tongueL';
  tongueL.position.set(-0.03, 0.09, 0.006);
  tongueL.rotation.set(0, 0, deg(18));
  flame.add(tongueL);
  const tongueR = new THREE.Mesh(new THREE.ConeGeometry(0.03, 0.13, 5), flameMidMat);
  tongueR.name = 'tongueR';
  tongueR.position.set(0.032, 0.085, 0.004);
  tongueR.rotation.set(0, 0, deg(-16));
  flame.add(tongueR);
  const flameMid = new THREE.Mesh(jitter(new THREE.ConeGeometry(0.04, 0.17, 6), 0.006, 5), flameMidMat);
  flameMid.name = 'flameMid';
  flameMid.position.set(0.004, 0.1, 0.016);
  flameMid.rotation.set(deg(8), 0, deg(-4));
  flame.add(flameMid);
  const flameCore = new THREE.Mesh(new THREE.ConeGeometry(0.026, 0.1, 5), flameCoreMat);
  flameCore.name = 'flameCore';
  flameCore.position.set(0, 0.065, 0.034);
  flameCore.rotation.set(deg(10), 0, 0);
  flame.add(flameCore);

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

export default createWallTorch;
```

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