shuffle list obj

This commit is contained in:
mpelissi 2023-03-10 15:19:08 +01:00
parent 16e469e664
commit 19cc671c62
2 changed files with 27 additions and 9 deletions

View File

@ -77,11 +77,11 @@ function init_variable(premier_appel){
R = 2.5 R = 2.5
// Enchainement des pages // Enchainement des pages
page_contexte = true page_contexte = false
page_inscription = false // true page_inscription = false // true
page_explication = false page_explication = false
page_explication_bis = false page_explication_bis = false
page_vues = false // false page_vues = true // false
page_analyse = false page_analyse = false
// Pour afiicher les recap dans la partie analys,e on les conserve tous // 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 // Caméra
camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 0.01, 1000 ); camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 0.01, 1000 );
camera.position.x = 2; // camera.position.x = 2;
camera.position.y = 0; // camera.position.y = 0;
camera.position.z = 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.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(0, 0, 0)
//camera.lookAt (new THREE.Vector3(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) setUp_light(R)
// Data 3D // 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(); 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/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/BVS-study/main/graphics/3DMesh/'+obj_file[idx_mesh], (event) => {
const root = event.detail.loaderRootNode; const root = event.detail.loaderRootNode;
scene.add(root); scene.add(root);
}); });

View File

@ -156,3 +156,21 @@ function shortcuts(xyMove, I_shortcut, x_shortcut, y_shortcut, w_shortcut, h_sho
} }
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;
}