New textures.json format

This commit is contained in:
Lukas Rieger (Blue) 2022-05-28 21:54:26 +02:00
parent aa4cf7285d
commit 77896b9c37
No known key found for this signature in database
GPG Key ID: 2D09EC5ED2687FF2
1 changed files with 10 additions and 5 deletions

View File

@ -239,14 +239,19 @@ export class Map {
* @param vertexShader {string}
* @param fragmentShader {string}
* @param uniforms {object}
* @param textures {object} the textures-data
* @param textures {{
* resourcePath: string,
* color: number[],
* halfTransparent: boolean,
* texture: string
* }[]} the textures-data
* @returns {ShaderMaterial[]} the hires Material (array because its a multi-material)
*/
createHiresMaterial(vertexShader, fragmentShader, uniforms, textures) {
let materials = [];
if (!Array.isArray(textures.textures)) throw new Error("Invalid texture.json: 'textures' is not an array!")
for (let i = 0; i < textures.textures.length; i++) {
let textureSettings = textures.textures[i];
if (!Array.isArray(textures)) throw new Error("Invalid texture.json: 'textures' is not an array!")
for (let i = 0; i < textures.length; i++) {
let textureSettings = textures[i];
let color = textureSettings.color;
if (!Array.isArray(color) || color.length < 4){
@ -254,7 +259,7 @@ export class Map {
}
let opaque = color[3] === 1;
let transparent = !!textureSettings.transparent;
let transparent = !!textureSettings.halfTransparent;
let texture = new Texture();
texture.image = stringToImage(textureSettings.texture);