lightmap.js integration

This commit is contained in:
JustAGenericUsername 2024-06-16 14:44:19 -04:00
parent ba3a1cad1b
commit b88be64f12
2 changed files with 51 additions and 0 deletions

View File

@ -36,6 +36,26 @@ const heatfunc = function(pixel){
}
let weight = (1-(ctemp/1.3))
pixel.color = "rgb(" + weightedAverage(pixel.ogR, newR, weight) + "," + weightedAverage(pixel.ogG, newG, weight) + "," + weightedAverage(pixel.ogB, newB, weight) + ")";
// lightmap.js integration below
if (enabledMods.includes("mods/lightmap.js")){
if (pixel.temp <= (gethigh) - halftemp){
ctemp = 0;
} else if (pixel.temp > (gethigh)-halftemp && pixel.temp <= gethigh){
ctemp = ((1/halftemp)*pixel.temp)-(((gethigh)-halftemp)/halftemp)
}
if (ctemp <= 0.5){
LnewR = (((510-(2*0))*ctemp)+0);
LnewG = ((0-((2*0)*ctemp))+0);
LnewB = ((0-((2*0)*ctemp))+0);
}else if (ctemp > 0.5){
LnewR = 255;
LnewG = ((510*ctemp)-255);
LnewB= ((280*ctemp)-140);
}
let x = Math.floor(pixel.x / lightmapScale);
let y = Math.floor(pixel.y / lightmapScale);
lightmap[y][x] = { color: [LnewR/3, LnewG/3, LnewB/3]};
}
}}};
if (!eLists.metals) { eLists.metals = [] }
eLists.metals = eLists.metals.concat(["iron", "glass", "copper", "gold", "brass","steel","nickel","zinc","silver","aluminum","bronze","metal_scrap","oxidized_copper","tin","lead", "rose_gold", "tungsten"])

View File

@ -226,4 +226,35 @@ elements.oganesson = {
}
}
}
}
// lightmap.js integration function
if (enabledMods.includes("mods/lightmap.js")){
function nobleGasTick(pixel){
if (pixel.charge || pixel.chargeCD){
let color = elements[pixel.element].colorOn
let randcolor = color[Math.floor(Math.random()*color.length)]
let rgbcolor = hexToRGB(randcolor)
console.log(color)
console.log(randcolor)
console.log(rgbcolor)
let x = Math.floor(pixel.x / lightmapScale);
let y = Math.floor(pixel.y / lightmapScale);
lightmap[y][x] = { color: [rgbcolor.r, rgbcolor.g, rgbcolor.b] };
}
}
let nobleGases = ["argon", "liquid_argon", "frozen_argon", "krypton", "liquid_krypton", "frozen_krypton", "xenon", "liquid_xenon", "frozen_xenon", "radon", "liquid_radon", "frozen_radon", "oganesson"]
for (let i = 0; i < nobleGases.length; i++){
let nobleGas = nobleGases[i]
if (elements[nobleGas].tick){
oldTick = elements[nobleGas].tick
elements[nobleGas].tick = function(pixel){
nobleGasTick(pixel)
oldTick(pixel)
}
}else{
elements[nobleGas].tick = function(pixel){
nobleGasTick(pixel)
}
}
}
}