Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
AiGptCode authored Apr 18, 2024
1 parent 67b80ae commit fb6348f
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@
renderer.setSize(window.innerWidth, window.innerHeight);
document.getElementById("lock-container").appendChild(renderer.domElement);

const loader = new THREE.TextureLoader();
const texture = loader.load("path/to/your/texture.jpg");

const geometry = new THREE.CylinderGeometry(0.5, 0.5, 0.1, 32);
const material = new THREE.MeshBasicMaterial({ color: 0xffffff });
const material = new THREE.MeshBasicMaterial({ map: texture });

const circles = [];
for (let i = 0; i < 4; i++) {
Expand All @@ -36,6 +39,10 @@

camera.position.z = 10;

const light = new THREE.PointLight(0xffffff, 1, 100);
light.position.set(0, 0, 10);
scene.add(light);

const password = "1234";
let currentCombination = "";

Expand Down Expand Up @@ -66,11 +73,37 @@

animate();

function onDocumentMouseDown(event) {
event.preventDefault();

const mouse = new THREE.Vector2();
mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;

const raycaster = new THREE.Raycaster();
raycaster.setFromCamera(mouse, camera);

const intersects = raycaster.intersectObjects(circles);

if (intersects.length > 0) {
const selectedCircle = intersects[0].object;
const index = circles.indexOf(selectedCircle);

new TWEEN.Tween(selectedCircle.rotation)
.to({ y: Math.PI * 2 * (password[index] - 1) }, 500)
.easing(TWEEN.Easing.Quadratic.InOut)
.start();
}
}

document.addEventListener("mousedown", onDocumentMouseDown, false);
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});

TWEEN.update();
</script>
</body>
</html>

0 comments on commit fb6348f

Please sign in to comment.