-
Notifications
You must be signed in to change notification settings - Fork 15
How To Use Textures
Lucas Damian Johnson edited this page Feb 13, 2023
·
8 revisions
You can use the textures you registered with a VoxelConstructor
.
Here is an example of a custom VoxelConstructor
that grabs the registered texture data and uses it.
import type { DivineVoxelEngineConstructor } from "../../../out/Constructor/DivineVoxelEngineConstructor";
export function GetMarkerBox(DVEC: DivineVoxelEngineConstructor) {
const textures: number[] = [];
DVEC.hooks.texturesRegistered.addToRun((textureMangager) => {
for (let i = 0; i < 16; i++) {
textures.push(
textureMangager.getTextureUV(["#dve_solid", "light-debug", `light-level-${i}`])
);
}
});
return DVEC.voxelManager.registerVoxel({
id: "dve_markerbox",
process(templater) {
const uv = textures[templater.currentVoxel.getState()];
if (templater.isFaceExpposed("top")) {
templater.addUV(textures[uv]).addOverlayUVs([0]);
}
if (templater.isFaceExpposed("bottom")) {
templater.addUV(textures[uv]).addOverlayUVs([0]);
}
if (templater.isFaceExpposed("east")) {
templater.addUV(textures[uv]).addOverlayUVs([0]);
}
if (templater.isFaceExpposed("west")) {
templater.addUV(textures[uv]).addOverlayUVs([0]);
}
if (templater.isFaceExpposed("south")) {
templater.addUV(textures[uv]).addOverlayUVs([0]);
}
if (templater.isFaceExpposed("north")) {
templater.addUV(textures[uv]).addOverlayUVs([0]);
}
templater.processVoxelLight();
},
});
}
You will only have access to the texture data in the texturesRegistered
hook.
So, just make sure to grab the textures you need and store them how you see fit.
const textures: number[] = [];
DVEC.hooks.texturesRegistered.addToRun((textureMangager) => {
for (let i = 0; i < 16; i++) {
textures.push(
textureMangager.getTextureUV(["#dve_solid", "light-debug", `light-level-${i}`])
);
}
});