diff --git a/Exercices/exercicesWebGLCorrection/cours1/1-3-ordre-sommets.js b/Exercices/exercicesWebGLCorrection/cours1/1-3-ordre-sommets.js index dfead5ab4da46be7d91e67cc796b225395091615..984791e962111d966218cd4ff92d8f90cd936cd2 100644 --- a/Exercices/exercicesWebGLCorrection/cours1/1-3-ordre-sommets.js +++ b/Exercices/exercicesWebGLCorrection/cours1/1-3-ordre-sommets.js @@ -12,21 +12,30 @@ import { OBJLoader } from 'three/addons/loaders/OBJLoader.js'; import { OrbitControls } from 'three/addons/controls/OrbitControls.js'; import {dat} from './lib/dat.gui.min.js'; -var camera, scene, renderer; +var camera, renderer; var windowScale; +window.scene = new THREE.Scene(); +import {Coordinates} from './lib/Coordinates.js'; function someObject(material) { - var geometry = new THREE.Geometry(); + var geometry = new THREE.BufferGeometry(); // Student: some data below must be fixed // for both triangles to appear ! - geometry.vertices.push( new THREE.Vector3( 3, 3, 0 ) ); - geometry.vertices.push( new THREE.Vector3( 7, 3, 0 ) ); - geometry.vertices.push( new THREE.Vector3( 7, 7, 0 ) ); - geometry.vertices.push( new THREE.Vector3( 3, 7, 0 ) ); + const vertices = new Float32Array( [ + 3, 3, 0, + 7, 3, 0, + 7, 7, 0, + + 7, 7, 0, + 3, 7, 0, + 3, 3, 0 + ] ); + + + + geometry.setAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) ); - geometry.faces.push( new THREE.Face3( 0, 1, 2 ) ); - geometry.faces.push( new THREE.Face3( 2, 0, 3 ) ); var mesh = new THREE.Mesh( geometry, material );