forked from mirror/ObjToSchematic
Fixed solid materials using colours by reference
* Solid materials now also get assigned a random colour
This commit is contained in:
parent
19c05231c3
commit
7ca5af2146
937
package-lock.json
generated
937
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -49,6 +49,7 @@
|
||||
"eslint-config-google": "^0.14.0",
|
||||
"eslint-plugin-simple-import-sort": "^8.0.0",
|
||||
"file-loader": "^6.2.0",
|
||||
"hsv-rgb": "^1.0.0",
|
||||
"html-webpack-plugin": "^5.5.0",
|
||||
"i18next": "^22.4.14",
|
||||
"images": "^3.2.3",
|
||||
|
@ -1,6 +1,8 @@
|
||||
import { AppConfig } from './config';
|
||||
import { TBrand } from './util/type_util';
|
||||
|
||||
const hsv_rgb = require('hsv-rgb');
|
||||
|
||||
export type RGBA = {
|
||||
r: number,
|
||||
g: number,
|
||||
@ -15,6 +17,21 @@ export namespace RGBAUtil {
|
||||
return `(${a.r}, ${a.g}, ${a.b}, ${a.a})`;
|
||||
}
|
||||
|
||||
export function randomPretty(): RGBA {
|
||||
const hue = Math.random() * 360;
|
||||
const sat = 65;
|
||||
const val = 85;
|
||||
|
||||
const rgb: number[] = hsv_rgb(hue, sat, val);
|
||||
|
||||
return {
|
||||
r: rgb[0] / 255,
|
||||
g: rgb[1] / 255,
|
||||
b: rgb[2] / 255,
|
||||
a: 1.0,
|
||||
}
|
||||
}
|
||||
|
||||
export function random(): RGBA {
|
||||
return {
|
||||
r: Math.random(),
|
||||
|
@ -11,7 +11,7 @@ export class AppConfig {
|
||||
public readonly RELEASE_MODE = true;
|
||||
public readonly MAJOR_VERSION = 0;
|
||||
public readonly MINOR_VERSION = 8;
|
||||
public readonly HOTFIX_VERSION = 3;
|
||||
public readonly HOTFIX_VERSION = 4;
|
||||
public readonly VERSION_TYPE: 'd' | 'a' | 'r' = 'r'; // dev, alpha, or release build
|
||||
public readonly MINECRAFT_VERSION = '1.19.4';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { RGBAColours } from './colour';
|
||||
import { RGBAColours, RGBAUtil } from './colour';
|
||||
import { MaterialMap, MaterialType } from './mesh';
|
||||
import { EImageChannel, TTransparencyTypes } from './texture';
|
||||
import { ASSERT } from './util/error_util';
|
||||
@ -59,7 +59,7 @@ export class MaterialMapManager {
|
||||
ASSERT(currentMaterial.type === MaterialType.textured, 'Old material expect to be texture');
|
||||
this.materials.set(materialName, {
|
||||
type: MaterialType.solid,
|
||||
colour: RGBAColours.MAGENTA,
|
||||
colour: RGBAUtil.randomPretty(),
|
||||
canBeTextured: true,
|
||||
needsAttention: true,
|
||||
});
|
||||
|
@ -194,7 +194,7 @@ export class Mesh {
|
||||
// No texcoords are defined, therefore make a solid material
|
||||
this._materials.set(tri.material, {
|
||||
type: MaterialType.solid,
|
||||
colour: RGBAColours.MAGENTA,
|
||||
colour: RGBAUtil.randomPretty(),
|
||||
canBeTextured: false,
|
||||
needsAttention: true,
|
||||
});
|
||||
@ -202,7 +202,7 @@ export class Mesh {
|
||||
// Texcoords exist
|
||||
this._materials.set(tri.material, {
|
||||
type: MaterialType.solid,
|
||||
colour: RGBAUtil.random(),
|
||||
colour: RGBAUtil.randomPretty(),
|
||||
canBeTextured: true,
|
||||
needsAttention: true,
|
||||
});
|
||||
@ -240,7 +240,7 @@ export class Mesh {
|
||||
LOG_WARN(`Could not find ${material.path} for material ${materialName}, changing to solid material`);
|
||||
this._materials.set(materialName, {
|
||||
type: MaterialType.solid,
|
||||
colour: RGBAColours.MAGENTA,
|
||||
colour: RGBAUtil.copy(RGBAColours.MAGENTA),
|
||||
canBeTextured: true,
|
||||
needsAttention: true,
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user