I find how make array that texture directory.
example…
function loadAll( folderName : string){
let textureDirs : string[] = ??
return textureDirs;
}
console.log( loadAll( 'icons' );
// ['/...directory/icons/icon1.png', '/...directory/icons/icon2.jpg', '/...directory/icons/icon_Knight.bmp' ]
please help me about this code’s ‘??’ part. (is prey. not clap. )
Hey, can you elaborate more on what you want to do?
Do you want to create Texture objects?
If the question is about reading the content of a folder, unfortunately this is not possible from a browser (for obvious security reasons)
Dad72
June 21, 2019, 10:14pm
3
You can read an entire content of a folder using PHP and get the result with ajax
Thank’s for answers.
I want to create materials with Loops.
and then all textures has different names.
ex) apple.jpg, orang_A.png, orange_B.png, drink1, Drink.png…
By the way, if I think about it again, I will write DB.
However, thanks everyone!
Dad72
June 24, 2019, 9:57am
5
Ok, I would browse the directory of your images with PHP to retrieve the names. then with ajax I would create the materials.
For example :
PHP file “getImages.php” :
$listeImage = "";
$root = "./images/"
$MyDirectory = opendir($root);
while($Entry = @readdir($MyDirectory)) {
if($Entry != '.' && $Entry != '..') {
$listeImage .= $Entry.";";
}
}
closedir($MyDirectory);
echo $listeImage;
Ajax: In your Javascript code to process the content retrieve with PHP
$.ajax({ type: "POST", url: 'getImages.php',
success: (msg) => {
msg = msg.split(";");
for(let i = 0; i < msg.length; i++)
{
//image liste
let image = msg[i];
// Create materiaux here
//....
}
}
});
I hope it helps
I’ll refer to your code and study AJAX.
Thank you!