804 Tris1,44 × 4,76 × 0,58 m
Im Code verwenden
Im Editor remixenstreet-lamp.js · 139 Zeilen
Eigenständiges ES-Modul — hängt nur von three ab. Ruf die Factory auf und füge die Gruppe deiner Szene hinzu.
/**
* Street Lamp — Codels 3D model library
* License: CC0-1.0 · Units: meters · Y-up · Front: +Z · Origin: center of the base (y = 0)
* Triangles: 804 · Size (W × H × D): 1.44 × 4.76 × 0.57 m
*
* Usage:
* import { createStreetLamp } from './street-lamp.js';
*
* const model = createStreetLamp();
* model.position.set(0, 0, 0);
* scene.add(model);
*/
import * as THREE from 'three';
const deg = THREE.MathUtils.degToRad;
// 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);
}
// Tube along a smooth curve through the given points.
function tube(path, radius, tubularSegments, radialSegments, closed = false) {
const curve = new THREE.CatmullRomCurve3(path.map(([x, y, z]) => new THREE.Vector3(x, y, z)), closed);
return new THREE.TubeGeometry(curve, tubularSegments, radius, radialSegments, closed);
}
export function createStreetLamp() {
const root = new THREE.Group();
root.name = 'StreetLamp';
// Materials
const poleMat = new THREE.MeshStandardMaterial({ name: 'pole', color: 0x2f3c37, roughness: 0.5, metalness: 0.5, flatShading: true });
const accentMat = new THREE.MeshStandardMaterial({ name: 'accent', color: 0xb08d4a, roughness: 0.4, metalness: 0.7, flatShading: true });
const glassMat = new THREE.MeshStandardMaterial({ name: 'glass', color: 0xfff1c2, roughness: 0.2, emissive: 0xffd36b, emissiveIntensity: 1.2, flatShading: true });
// Shared geometries
const cylinderGeo = new THREE.CylinderGeometry(0.095, 0.095, 0.07, 8);
// Parts
const lamp = new THREE.Group();
lamp.name = 'lamp';
lamp.position.set(-0.47, 0, 0);
root.add(lamp);
const base = new THREE.Mesh(lathe([[0.24, 0], [0.24, 0.07], [0.18, 0.12], [0.17, 0.2], [0.14, 0.55], [0.11, 0.66], [0.075, 0.72]], 8), poleMat);
base.name = 'base';
lamp.add(base);
const pole = new THREE.Mesh(new THREE.CylinderGeometry(0.055, 0.075, 3.8, 8), poleMat);
pole.name = 'pole';
pole.position.set(0, 2.6, 0);
lamp.add(pole);
const collar = new THREE.Mesh(cylinderGeo, poleMat);
collar.name = 'collar';
collar.position.set(0, 0.755, 0);
lamp.add(collar);
const collar2 = new THREE.Mesh(cylinderGeo, poleMat);
collar2.name = 'collar';
collar2.position.set(0, 1.635, 0);
lamp.add(collar2);
const collar3 = new THREE.Mesh(cylinderGeo, poleMat);
collar3.name = 'collar';
collar3.position.set(0, 3.985, 0);
lamp.add(collar3);
const poleTop = new THREE.Mesh(new THREE.SphereGeometry(0.09, 8, 5), poleMat);
poleTop.name = 'poleTop';
poleTop.position.set(0, 4.52, 0);
lamp.add(poleTop);
const finial = new THREE.Mesh(new THREE.ConeGeometry(0.05, 0.18, 6), accentMat);
finial.name = 'finial';
finial.position.set(0, 4.67, 0);
lamp.add(finial);
const arm = new THREE.Mesh(tube([[0, 4, 0], [0.04, 4.35, 0], [0.25, 4.56, 0], [0.6, 4.6, 0], [0.88, 4.48, 0], [0.95, 4.28, 0]], 0.035, 20, 6), poleMat);
arm.name = 'arm';
lamp.add(arm);
const scroll = new THREE.Mesh(new THREE.TorusGeometry(0.12, 0.022, 4, 12, Math.PI * 1.5), poleMat);
scroll.name = 'scroll';
scroll.position.set(0.2, 4.3, 0);
scroll.rotation.set(0, 0, deg(200));
lamp.add(scroll);
const lantern = new THREE.Group();
lantern.name = 'lantern';
lantern.position.set(0.95, 4.26, 0);
lantern.scale.setScalar(1.25);
lamp.add(lantern);
const lanternHook = new THREE.Mesh(new THREE.CylinderGeometry(0.05, 0.05, 0.08, 6), poleMat);
lanternHook.name = 'lanternHook';
lanternHook.position.set(0, -0.02, 0);
lantern.add(lanternHook);
const lanternRoof = new THREE.Mesh(new THREE.ConeGeometry(0.22, 0.2, 6), poleMat);
lanternRoof.name = 'lanternRoof';
lanternRoof.position.set(0, -0.16, 0);
lantern.add(lanternRoof);
const lanternBrim = new THREE.Mesh(new THREE.CylinderGeometry(0.23, 0.23, 0.04, 6), accentMat);
lanternBrim.name = 'lanternBrim';
lanternBrim.position.set(0, -0.28, 0);
lantern.add(lanternBrim);
const lanternGlass = new THREE.Mesh(new THREE.CylinderGeometry(0.19, 0.13, 0.42, 6), glassMat);
lanternGlass.name = 'lanternGlass';
lanternGlass.position.set(0, -0.51, 0);
lantern.add(lanternGlass);
const lanternFrame = new THREE.Mesh(tube([[0, -0.72, 0.135], [0, -0.3, 0.195]], 0.012, 1, 4), poleMat);
lanternFrame.name = 'lanternFrame';
lantern.add(lanternFrame);
const lanternFrame2 = new THREE.Mesh(tube([[0.1169, -0.72, 0.0675], [0.1689, -0.3, 0.0975]], 0.012, 1, 4), poleMat);
lanternFrame2.name = 'lanternFrame';
lantern.add(lanternFrame2);
const lanternFrame3 = new THREE.Mesh(tube([[0.1169, -0.72, -0.0675], [0.1689, -0.3, -0.0975]], 0.012, 1, 4), poleMat);
lanternFrame3.name = 'lanternFrame';
lantern.add(lanternFrame3);
const lanternFrame4 = new THREE.Mesh(tube([[0, -0.72, -0.135], [0, -0.3, -0.195]], 0.012, 1, 4), poleMat);
lanternFrame4.name = 'lanternFrame';
lantern.add(lanternFrame4);
const lanternFrame5 = new THREE.Mesh(tube([[-0.1169, -0.72, -0.0675], [-0.1689, -0.3, -0.0975]], 0.012, 1, 4), poleMat);
lanternFrame5.name = 'lanternFrame';
lantern.add(lanternFrame5);
const lanternFrame6 = new THREE.Mesh(tube([[-0.1169, -0.72, 0.0675], [-0.1689, -0.3, 0.0975]], 0.012, 1, 4), poleMat);
lanternFrame6.name = 'lanternFrame';
lantern.add(lanternFrame6);
const lanternBottom = new THREE.Mesh(new THREE.CylinderGeometry(0.14, 0.1, 0.06, 6), poleMat);
lanternBottom.name = 'lanternBottom';
lanternBottom.position.set(0, -0.75, 0);
lantern.add(lanternBottom);
const lanternDrop = new THREE.Mesh(new THREE.ConeGeometry(0.04, 0.1, 6), accentMat);
lanternDrop.name = 'lanternDrop';
lanternDrop.position.set(0, -0.81, 0);
lanternDrop.rotation.set(deg(180), 0, 0);
lantern.add(lanternDrop);
root.traverse((o) => {
if (o.isMesh) {
o.castShadow = true;
o.receiveShadow = true;
}
});
return root;
}
export default createStreetLamp;
Bewertungen & Kommentare
—
Noch keine Bewertungen — gib die erste ab.
5
0
4
0
3
0
2
0
1
0
Melde dich an, um zu bewerten und zu kommentieren.
0 Kommentare
Noch keine Kommentare. Erzähl, wie du dieses Modell genutzt hast oder was besser sein könnte.
Ähnliche Modelle
Gleiche Kategorie oder ähnliche Tags









