forked from JannisX11/blockbench-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upd: labPBR support / Material presets (#3)
* refactor: Split into multiple files - Added registry, setups, and teardowns to control plugin actions * feat: Reset exposure Action - Added messages to baking failures - Added reset exposure button - Added changelog build script * feat: labPBR output Action * feat: Decode labPBR channels * chore: Remove unused code - Revert normal map usage in PbrMaterial.getMaterial() * fix: labPBR specular map logic - Fixed bug in alpha channel - Added better specular and normal export names * feat: Material brush presets * feat: Channel assignment panel - Created panel to list current channel assignments * upd: Channel component cleanup * upd: Style channel list * feat: Material brush presets library - Created Dialog for editing, saving and loading material brush presets * upd: Change Action icon - Changed material brush Action icon * upd: Channel assignment condition
- Loading branch information
1 parent
9942879
commit 0aba465
Showing
32 changed files
with
3,878 additions
and
2,306 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import readline from "node:readline/promises"; | ||
import { writeFile, readFile } from "node:fs/promises"; | ||
|
||
const rl = readline.createInterface({ | ||
input: process.stdin, | ||
output: process.stdout, | ||
}); | ||
|
||
const changelog = "./plugins/pbr_preview/changelog.json"; | ||
|
||
function createChangelog(version, changes, author, title = null, date = null) { | ||
const changelog = { | ||
[version.toString()]: { | ||
title: title ?? `Version ${version}`, | ||
date: date || new Date().toISOString().split("T")[0], | ||
author, | ||
categories: [], | ||
}, | ||
}; | ||
|
||
for (const change of changes) { | ||
changelog[version].categories.push({ | ||
title: "", | ||
list: [], | ||
...change, | ||
}); | ||
} | ||
|
||
return changelog; | ||
} | ||
|
||
async function amendChangelog( | ||
version, | ||
changes, | ||
author, | ||
title = null, | ||
date = null, | ||
) { | ||
const data = JSON.parse(await readFile(changelog, "utf-8")); | ||
const newChangelog = createChangelog(version, changes, author, title, date); | ||
const mergedChangelog = { ...data, ...newChangelog }; | ||
|
||
await writeFile(changelog, JSON.stringify(mergedChangelog, null, 4)); | ||
} | ||
|
||
async function main() { | ||
const version = await rl.question("Enter the version number: "); | ||
const author = await rl.question("Enter the author: "); | ||
const title = await rl.question( | ||
"Enter the title (leave blank for default): ", | ||
); | ||
|
||
const changes = []; | ||
let makingChanges = true; | ||
let writingDescriptions = false; | ||
|
||
while (makingChanges) { | ||
const change = await rl.question( | ||
"Enter a change title (leave blank to exit): ", | ||
); | ||
|
||
makingChanges = change.length > 0; | ||
|
||
if (!makingChanges) { | ||
break; | ||
} | ||
|
||
const descriptions = []; | ||
writingDescriptions = true; | ||
|
||
while (writingDescriptions) { | ||
const description = await rl.question( | ||
"Enter a description (leave blank to finish): ", | ||
); | ||
|
||
writingDescriptions = description.length > 0; | ||
|
||
if (!writingDescriptions) { | ||
break; | ||
} | ||
|
||
descriptions.push(description); | ||
} | ||
|
||
changes.push({ | ||
title: change, | ||
list: descriptions, | ||
}); | ||
} | ||
|
||
await amendChangelog( | ||
version, | ||
changes, | ||
author, | ||
title ?? `Version ${version}`, | ||
new Date().toISOString().split("T")[0], | ||
); | ||
} | ||
|
||
main() | ||
.then(() => { | ||
console.log("Changelog updated!"); | ||
process.exit(0); | ||
}) | ||
.catch((err) => { | ||
console.error(err); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import type { IChannel, IRegistry } from "./types"; | ||
import { three as THREE } from "./deps"; | ||
|
||
export const NA_CHANNEL = "_NONE_"; | ||
export const CHANNELS: Record<IChannel["id"], IChannel> = { | ||
albedo: { | ||
id: "albedo", | ||
label: "Albedo", | ||
description: "The color of the material", | ||
map: "map", | ||
icon: "tonality", | ||
default: new THREE.Color(0xffffff), | ||
}, | ||
metalness: { | ||
id: "metalness", | ||
label: "Metalness", | ||
description: "The material's metalness map", | ||
map: "metalnessMap", | ||
icon: "brightness_6", | ||
default: new THREE.Color(0), | ||
}, | ||
emissive: { | ||
id: "emissive", | ||
label: "Emissive", | ||
description: "The material's emissive map", | ||
map: "emissiveMap", | ||
icon: "wb_twilight", | ||
default: new THREE.Color(0), | ||
}, | ||
roughness: { | ||
id: "roughness", | ||
label: "Roughness", | ||
description: "The material's roughness map", | ||
map: "roughnessMap", | ||
icon: "grain", | ||
default: new THREE.Color(0xffffff), | ||
}, | ||
height: { | ||
id: "height", | ||
label: "Height", | ||
description: "The material's height map", | ||
map: "bumpMap", | ||
icon: "landscape", | ||
default: new THREE.Color(0xffffff), | ||
}, | ||
normal: { | ||
id: "normal", | ||
label: "Normal", | ||
description: "The material's normal map", | ||
map: "normalMap", | ||
icon: "looks", | ||
default: new THREE.Color("rgb(128, 128, 255)"), | ||
}, | ||
ao: { | ||
id: "ao", | ||
label: "Ambient Occlusion", | ||
description: "The material's ambient occlusion map", | ||
map: "aoMap", | ||
icon: "motion_mode", | ||
default: new THREE.Color(0xffffff), | ||
}, | ||
}; | ||
|
||
/** | ||
* Collection of registered Blockbench UI elements | ||
* Used for component communication as well as to simplify cleanup | ||
*/ | ||
export const registry: Partial<IRegistry> = {}; | ||
|
||
export const setups: Array<() => void> = []; | ||
export const teardowns: Array<() => void> = []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// @ts-expect-error THREE UMD is OK | ||
const three = THREE; | ||
// @ts-expect-error Vue UMD is OK | ||
const vue = Vue; | ||
const bb = Blockbench; | ||
|
||
export { three, bb, vue }; |
Oops, something went wrong.