From 19cc671c62f4dcf8072733bab3a92d95fc282e16 Mon Sep 17 00:00:00 2001 From: mpelissi Date: Fri, 10 Mar 2023 15:19:08 +0100 Subject: [PATCH] shuffle list obj --- static/MAIN.js | 16 ++++++++-------- static/fonctions_utiles.js | 20 +++++++++++++++++++- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/static/MAIN.js b/static/MAIN.js index 4a63d0a..8a92828 100644 --- a/static/MAIN.js +++ b/static/MAIN.js @@ -77,11 +77,11 @@ function init_variable(premier_appel){ R = 2.5 // Enchainement des pages - page_contexte = true + page_contexte = false page_inscription = false // true page_explication = false page_explication_bis = false - page_vues = false // false + page_vues = true // false page_analyse = false // Pour afiicher les recap dans la partie analys,e on les conserve tous @@ -151,9 +151,9 @@ function setUp_3D(idx_mesh, idx_i_init, idx_j_init){ // Caméra camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 0.01, 1000 ); - camera.position.x = 2; - camera.position.y = 0; - camera.position.z = 0; + // camera.position.x = 2; + // camera.position.y = 0; + // camera.position.z = 0; camera.position.set(R*Math.cos(delta_init)*Math.cos(theta_init), R*Math.sin(theta_init), R*Math.sin(delta_init)*Math.cos(theta_init)) // repère JS camera.lookAt(0, 0, 0) //camera.lookAt (new THREE.Vector3(0,0,0)) @@ -206,10 +206,10 @@ function setUp_3D(idx_mesh, idx_i_init, idx_j_init){ setUp_light(R) // Data 3D - obj_file = ['dragon_update_user_study.obj', 'camel_update_user_study_normed.obj', 'gorgoile_update_user_study_centered_normed.obj', 'horse_update_user_study_normed.obj'] + obj_file = shuffle(['dragon_update_user_study_normed.obj', 'camel_update_user_study_normed.obj', 'gorgoile_update_user_study_centered_normed.obj', 'horse_update_user_study_normed.obj']) const objLoader = new THREE.OBJLoader2(); - objLoader.load('https://raw.githubusercontent.com/PelissierCombescure/User_study/main/3DMesh/'+obj_file[idx_mesh], (event) => { - //objLoader.load('https://raw.githubusercontent.com/PelissierCombescure/BVS-study/main/graphics/3DMesh/'+obj_file[idx_mesh], (event) => { + //objLoader.load('https://raw.githubusercontent.com/PelissierCombescure/User_study/main/3DMesh/'+obj_file[idx_mesh], (event) => { + objLoader.load('https://raw.githubusercontent.com/PelissierCombescure/BVS-study/main/graphics/3DMesh/'+obj_file[idx_mesh], (event) => { const root = event.detail.loaderRootNode; scene.add(root); }); diff --git a/static/fonctions_utiles.js b/static/fonctions_utiles.js index 0501a8b..f5254ab 100644 --- a/static/fonctions_utiles.js +++ b/static/fonctions_utiles.js @@ -155,4 +155,22 @@ function shortcuts(xyMove, I_shortcut, x_shortcut, y_shortcut, w_shortcut, h_sho } -} \ No newline at end of file +} + +function shuffle(array) { + let currentIndex = array.length, randomIndex; + + // While there remain elements to shuffle. + while (currentIndex != 0) { + + // Pick a remaining element. + randomIndex = Math.floor(Math.random() * currentIndex); + currentIndex--; + + // And swap it with the current element. + [array[currentIndex], array[randomIndex]] = [ + array[randomIndex], array[currentIndex]]; + } + + return array; + } \ No newline at end of file