Skip to content

Commit

Permalink
Update pipe.html
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuv6vvyv authored Feb 9, 2025
1 parent 294f80e commit 77cf72f
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions pipe.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,31 +114,34 @@
renderer.setSize(window.innerWidth, window.innerHeight);

// Lighting.
const ambientLight = new THREE.AmbientLight(0xffffff, 0.8);
scene.add(ambientLight);
const directionalLight1 = new THREE.DirectionalLight(0xffffff, 1);
directionalLight1.position.set(1, 1, 1);
scene.add(directionalLight1);
const directionalLight2 = new THREE.DirectionalLight(0xffffff, 0.8);
directionalLight2.position.set(-1, -1, -1);
scene.add(directionalLight2);
const hemisphereLight = new THREE.HemisphereLight(0xffffff, 0x444444, 0.5);
scene.add(hemisphereLight);
const ambientLight = new THREE.AmbientLight(0xfff700, 5.0);
scene.add(ambientLight);

const directionalLight1 = new THREE.DirectionalLight(0x000500, 5.5);
directionalLight1.position.set(1, 1, 1);
scene.add(directionalLight1);

const directionalLight2 = new THREE.DirectionalLight(0xFFf347, 5.0);
directionalLight2.position.set(-1, -1, -1);
scene.add(directionalLight2);

const hemisphereLight = new THREE.HemisphereLight(0xFFf500, 0x000700, 5.5);
scene.add(hemisphereLight);

// Material.
let pipeMaterial = new THREE.MeshStandardMaterial({
color: 0x4488ff,
metalness: 0.7,
roughness: 0.2,
emissive: 0x112244,
emissiveIntensity: 0.2
color: 0x00FFFF, // Bright cyan base color
metalness: 4, // High metalness for a sleek finish
roughness: 0.8, // Slight roughness to avoid a flat look
emissive: 0xf7f010, // Matching neon glow color
emissiveIntensity: 2.8
});

// Global array for pipe segments.
let pipes = [];

// Constants to limit complexity.
const MAX_PIPE_COUNT = 2500; // Maximum count of fully grown pipes.
const MAX_PIPE_COUNT = 1500; // Maximum count of fully grown pipes.
const PIPE_LIFECYCLE = 300000; // 5 minutes.

// PipeSegment class.
Expand Down Expand Up @@ -424,11 +427,11 @@
let d = pipe.mesh.position.length();
if (d > maxDistance) maxDistance = d;
});
let desiredCamDist = baseCamDist + maxDistance * 1.1;
let desiredCamDist = baseCamDist + maxDistance * 0.5;
// Use a slow lerp to reduce jitter.
camera.position.z = THREE.MathUtils.lerp(camera.position.z, desiredCamDist, 0.015);
camera.position.x = 0;
camera.position.y = 0;
camera.position.z = THREE.MathUtils.lerp(camera.position.z, desiredCamDist, 0.01);
camera.position.x = 1;
camera.position.y = 1;
camera.lookAt(scene.position);

renderer.render(scene, camera);
Expand Down

0 comments on commit 77cf72f

Please sign in to comment.