Skip to content

Commit

Permalink
Wrought iron bar example
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonsturges committed Nov 7, 2024
1 parent f99cacb commit bf0b58b
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
7 changes: 7 additions & 0 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ <h2>Models</h2>
</ul>
</div>

<div>
<header>Fence</header>
<ul>
<li><a href="/three-low-poly/models/fence/wrought-iron-bar">Wrought Iron Bar</a></li>
</ul>
</div>

<div>
<header>Furniture</header>
<ul>
Expand Down
57 changes: 57 additions & 0 deletions examples/models/fence/wrought-iron-bar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Three Low Poly</title>
<style>
body {
margin: 0;
}
canvas {
display: block;
color: #dfd9bc;
}
</style>
</head>
<body>
<script type="module">
import * as THREE from "three";
import GUI from "lil-gui";
import { centerMesh, Mound } from "../../../src/index.js";
import { createOrbitScene } from "../../utils/orbitScene.js";
import { WroughtIronBar } from "../../../src/models/fence/WroughtIronBar.js";

const { scene } = createOrbitScene();
scene.background = new THREE.Color(0xe64d4d);

// Default parameters
const params = {
barHeight: 2.0,
barRadius: 0.05,
spikeHeight: 0.3,
spikeRadius: 0.075,
radialSegments: 8,
};

let wroughtIronBar = new WroughtIronBar(params);
scene.add(wroughtIronBar);
centerMesh(wroughtIronBar);

const gui = new GUI();

gui.add(params, "barHeight", 0.1, 5).name("Bar Height").step(0.1).onChange(update);
gui.add(params, "barRadius", 0.01, 0.3).name("Bar Radius").step(0.05).onChange(update);
gui.add(params, "spikeHeight", 1, 5).name("Spike Height").step(0.1).onChange(update);
gui.add(params, "spikeRadius", 0.01, 0.3).name("Spike Radius").step(0.005).onChange(update);
gui.add(params, "radialSegments", 8, 64, 1).name("Radial Segments").step(1).onChange(update);

function update() {
scene.remove(wroughtIronBar);
wroughtIronBar = new WroughtIronBar(params);
scene.add(wroughtIronBar);
centerMesh(wroughtIronBar);
}
</script>
</body>
</html>

0 comments on commit bf0b58b

Please sign in to comment.