<!DOCTYPE html>
<html>
<head>
<title>Swimming Pool Fun</title>
<style>
body { margin: 0; }
canvas { display: block; }
#hud {
position: absolute;
top: 10px;
left: 10px;
background-color: rgba(0, 0, 0, 0.7);
color: white;
padding: 10px;
font-family: sans-serif;
z-index: 1000;
}
#click-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.8);
color: white;
display: flex;
justify-content: center;
align-items: center;
font-size: 2em;
z-index: 1001;
cursor: pointer;
}
</style>
</head>
<body>
<div id="hud">
Pee Meter: <span id="pee-meter">100%</span><br>
Bladder Health: <span id="bladder-health">Excellent</span><br>
Score: <span id="score">0</span>
</div>
<div id="click-overlay">Click to Play</div>
<script type="importmap">
{
"imports": {
"three": "https://cdn.jsdelivr.net/npm/three@0.161.0/build/three.module.js",
"three/addons/PointerLockControls": "https://cdn.jsdelivr.net/npm/three@0.161.0/examples/js/controls/PointerLockControls.js",
"three/addons/particles/GPUParticleSystem": "https://cdn.jsdelivr.net/npm/three@0.161.0/examples/js/particles/GPUParticleSystem.js"
}
}
</script>
<script>
import * as THREE from 'three';
import { PointerLockControls } from 'three/addons/PointerLockControls';
import { GPUParticleSystem } from 'three/addons/particles/GPUParticleSystem';
let scene, camera, renderer, controls;
let peeMeter = 100;
let bladderHealth = "Excellent";
let score = 0;
let isStreaming = false;
let waterLevel = 0;
let particles = [];
const poolTileTextureURL = 'https://i.imgur.com/w9w9w9w.jpg'; // Replace with a suitable tile texture URL
init();
animate();
function init() {
scene = new THREE.Scene();
scene.background = new THREE.Color(0x87CEEB); // Sky blue
scene.fog = new THREE.Fog(0x87CEEB, 10, 20);
camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 100);
camera.position.set(0, 5, 0);
renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
controls = new PointerLockControls(camera, renderer.domElement);
const blocker = document.getElementById('click-overlay');
blocker.addEventListener('click', function() {
controls.lock();
blocker.style.display = 'none';
});
// Lights
const ambientLight = new THREE.HemisphereLight(0xffffff, 0x888888, 1);
scene.add(ambientLight);
const directionalLight = new THREE.DirectionalLight(0xffffff, 0.5);
directionalLight.position.set(1, 1, 1);
scene.add(directionalLight);
// Pool Deck
const deckGeometry = new THREE.PlaneGeometry(20, 20);
const deckMaterial = new THREE.MeshStandardMaterial({ color: 0xCD853F });
const deck = new THREE.Mesh(deckGeometry, deckMaterial);
deck.rotation.x = -Math.PI / 2;
deck.position.set(0, 0, 0);
scene.add(deck);
// Pool
const poolWidth = 10;
const poolLength = 15;
const poolDepth = 5;
const poolGeometry = new THREE.BoxGeometry(poolWidth, poolDepth, poolLength);
const poolMaterial = new THREE.MeshStandardMaterial({
map: new THREE.TextureLoader().load(poolTileTextureURL),
roughness: 0.8,
metalness: 0.2
});
const pool = new THREE.Mesh(poolGeometry, poolMaterial);
pool.position.set(0, poolDepth / 2, 0);
scene.add(pool);
// Water Surface
const waterGeometry = new THREE.PlaneGeometry(poolWidth + 1, poolLength + 1);
const waterMaterial = new THREE.MeshBasicMaterial({ color: 0x0077cc, transparent: true, opacity: 0.7 });
const water = new THREE.Mesh(waterGeometry, waterMaterial);
waterLevel = poolDepth;
water.position.set(0, waterLevel, 0);
water.rotation.x = -Math.PI / 2;
scene.add(water);
// Event Listeners for Streaming
document.addEventListener('mousedown', (event) => {
if (event.button === 0) { // Left mouse button
isStreaming = true;
}
});
document.addEventListener('mouseup', (event) => {
if (event.button === 0) { // Left mouse button
isStreaming = false;
}
});
// Update HUD
updateHUD();
// Add a basic box to represent the player
const playerGeometry = new THREE.BoxGeometry(1, 2, 1);
const playerMaterial = new THREE.MeshStandardMaterial({ color: 0x00ff00 });
const player = new THREE.Mesh(playerGeometry, playerMaterial);
player.position.set(0, 2, 0);
scene.add(player);
camera.lookAt(player.position);
}
function animate() {
requestAnimationFrame(animate);
if (controls.isLocked) {
const moveDistance = 0.1;
if (controls.moveForward) camera.translateZ(-moveDistance);
if (controls.moveBackward) camera.translateZ(moveDistance);
if (controls.moveLeft) camera.translateX(-moveDistance);
if (controls.moveRight) camera.translateX(moveDistance);
// Simple Jumping
const jumpHeight = 1;
const jumpSpeed = 0.5;
if (controls.jump && camera.position.y === 0) {
camera.translateY(jumpHeight);
}
// Gravity and Collision
if (camera.position.y > 0) {
camera.translateY(-0.1);
if (camera.position.y < 0) {
camera.position.y = 0;
}
}
// Water Interaction
if (camera.position.y < waterLevel) {
// Buoyancy
const buoyancyForce = 0.05;
camera.translateY(buoyancyForce);
if (camera.position.y > waterLevel) {
camera.position.y = waterLevel;
}
// Water Resistance
const waterResistance = 0.2;
if (controls.moveForward) camera.translateZ(-moveDistance * waterResistance);
if (controls.moveBackward) camera.translateZ(moveDistance * waterResistance);
if (controls.moveLeft) camera.translateX(-moveDistance * waterResistance);
if (controls.moveRight) camera.translateX(moveDistance * waterResistance);
// Disable Jumping
controls.jump = false;
} else {
controls.jump = true;
}
// Streaming and Particle Emission
if (isStreaming) {
const particle = new THREE.Mesh(new THREE.SphereGeometry(0.05), new THREE.MeshBasicMaterial({ color: bladderHealth === "Critical" ? 0xff0000 : 0xffff00 }));
particle.position.copy(camera.position);
particle.direction = new THREE.Vector3();
camera.getWorldDirection(particle.direction);
particle.velocity = new THREE.Vector3();
particle.velocity.copy(particle.direction).multiplyScalar(2);
particles.push(particle);
scene.add(particle);
// Update Pee Meter and Score
peeMeter -= 0.1;
score += 1;
updateHUD();
// Update Bladder Health
updateBladderHealth();
}
// Particle Physics
for (let i = particles.length - 1; i >= 0; i--) {
const particle = particles[i];
particle.position.add(particle.velocity);
particle.velocity.y -= 0.01; // Gravity
if (particle.position.y <= waterLevel) {
scene.remove(particle);
particles.splice(i, 1);
}
}
}
renderer.render(scene, camera);
}
function updateHUD() {
document.getElementById('pee-meter').textContent = Math.max(0, peeMeter).toFixed(0) + "%";
document.getElementById('score').textContent = score;
}
function updateBladderHealth() {
if (peeMeter > 80) {
bladderHealth = "Excellent";
} else if (peeMeter > 50) {
bladderHealth = "Good";
} else if (peeMeter > 20) {
bladderHealth = "Warning";
} else {
bladderHealth = "Critical";
}
document.getElementById('bladder-health').textContent = bladderHealth;
}
</script>
</body>
</html>