bonjour
document.addEventListener('DOMContentLoaded', function () {
const { THREE, OrbitControls, OBJLoader, MTLLoader } = ThreeWP;
const container = document.getElementById('three-container'); const width = container.clientWidth; const height = container.clientHeight;
const scene = new THREE.Scene(); const camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000); camera.position.z = 500; camera.rotation.y = Math.PI /2 ; camera.lookAt(0, 0, 0); //camera.rotation.z = Math.PI / 2;
const renderer = new THREE.WebGLRenderer(); renderer.setSize(width, height); container.appendChild(renderer.domElement);
const textureLoader = new THREE.TextureLoader();
const texture = textureLoader.load('https://917.be/wp-content/uploads/2025/06/emi4.png');
/*const texture2 = textureLoader.load( 'https://917.be/wp-content/uploads/2025/06/IMG_20210607_190426.jpg', //'https://917.be/wp-content/uploads/2025/06/terre.jpg', () => { texture2.wrapS = texture2.wrapT = THREE.RepeatWrapping; texture.offset.set( 0, 0 ); texture.repeat.set( 100, 100 ); } );*/ //const texture2 = textureLoader.load('https://917.be/wp-content/uploads/2025/06/IMG_20210607_190426.jpg');
/*const geometry = new THREE.BoxGeometry(1, 1, 1);*/ /*const geometry = new THREE.SphereGeometry(0.75, 32, 32);
const material = new THREE.MeshStandardMaterial({ map: texture }); const sphere = new THREE.Mesh(geometry, material); scene.add(sphere);*/ const light = new THREE.AmbientLight(0xffffff); scene.add(light);
/*const loader = new OBJLoader(); loader.load( 'https://raw.githubusercontent.com/simonGiz917/testobj/refs/heads/main/simon4.obj', function (object) { object.traverse(function (child) { if (child.isMesh) { child.material = new THREE.MeshStandardMaterial({ map: texture2 }); } }); scene.add(object); }, function (xhr) { console.log((xhr.loaded / xhr.total * 100) + '% loaded'); } );*/
const manager = new THREE.LoadingManager(); const mtlLoader = new MTLLoader(manager);
mtlLoader.load( 'https://raw.githubusercontent.com/simonGiz917/testobj/refs/heads/main/simon5.mtl', function (materials) { materials.preload(); const objLoader = new OBJLoader(manager); objLoader.setMaterials(materials); objLoader.load( 'https://raw.githubusercontent.com/simonGiz917/testobj/refs/heads/main/simon5.obj', function (object) { scene.add(object); } ); });
const controls = new OrbitControls( camera, renderer.domElement, );
controls.enableDamping = true; // Adds smoothness when dragging controls.dampingFactor = 0.03; controls.autoRotate = true; controls.autoRotateSpeed = 10; function animate(t = 0) { requestAnimationFrame(animate); controls.update(); renderer.render(scene, camera); } animate();
window.addEventListener('resize', () => { const width = container.clientWidth; const height = container.clientHeight; camera.aspect = width / height; camera.updateProjectionMatrix(); renderer.setSize(width, height); });
});