diff --git a/assets/js/three-setup.js b/assets/js/three-setup.js new file mode 100644 index 0000000..599e897 --- /dev/null +++ b/assets/js/three-setup.js @@ -0,0 +1,47 @@ +import * as THREE from 'three'; +import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js'; + +// Setup scene, camera, and renderer +const scene = new THREE.Scene(); +const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000); +const renderer = new THREE.WebGLRenderer({ antialias: true }); +renderer.setSize(window.innerWidth * 0.75, window.innerHeight * 0.75); // Adjust size as needed +document.getElementById('threejs-container').appendChild(renderer.domElement); // Make sure you have a div with this id + +camera.position.set(0, 1, 2); // Adjust camera position as needed + +// Lighting +const ambientLight = new THREE.AmbientLight(0x404040); // Soft white light +scene.add(ambientLight); +const directionalLight = new THREE.DirectionalLight(0xffffff, 0.5); +directionalLight.position.set(0, 1, 0); // Adjust light position as needed +scene.add(directionalLight); + +// Load your 3D model +const loader = new GLTFLoader(); +loader.load( + 'assets/models/szch-3d-a_w.glb', + function (gltf) { + scene.add(gltf.scene); + animate(); + }, + undefined, + function (error) { + console.error(error); + } +); + +// Animation loop +function animate() { + requestAnimationFrame(animate); + renderer.render(scene, camera); +} + +// Responsive adjustments +window.addEventListener('resize', onWindowResize, false); + +function onWindowResize() { + camera.aspect = window.innerWidth / window.innerHeight; + camera.updateProjectionMatrix(); + renderer.setSize(window.innerWidth * 0.75, window.innerHeight * 0.75); +} diff --git a/assets/models/szch-3d-a_w.glb b/assets/models/szch-3d-a_w.glb new file mode 100644 index 0000000..8dd8437 Binary files /dev/null and b/assets/models/szch-3d-a_w.glb differ diff --git a/index.html b/index.html index f549dfc..032aace 100644 --- a/index.html +++ b/index.html @@ -9,6 +9,7 @@ +
@@ -82,6 +83,9 @@

talk2me

filip@value.ooo

+
+
+