Skip to content
Lucas Damian Johnson edited this page Feb 13, 2023 · 23 revisions

In order to add a voxel to DVE you will need to register three things.

  1. The textures the voxel will use. This is done in the Render thread.
  2. The data for the voxel. This is done in the World thread.
  3. An object that will construct the voxel. This is done in the Constructor thread.

Here is an example of adding one voxel to the engine:

Render Thread

 DVER.textures.registerTexture([
  {
   type: "#dve_solid",
   id: "debug",
   frames: 0,
   variations: {
    top: { frames: 0 },
    bottom: { frames: 0 },
    north: { frames: 0 },
    south: { frames: 0 },
    east: { frames: 0 },
    west: { frames: 0 },
   },
  }
]);

World Thread

 DVEW.voxelManager.registerVoxelData([
  {
   id: "dve_debugbox",
   tags: [
    ["#dve_substance", "#dve_solid"],
    ["#dve_shape_id", "#dve_box"],
    ["#dve_is_light_source", true],
    ["#dve_light_value", [15, 15, 15]],
    ["#dve_collider_id", "#dve_box"],
    ["#dve_check_collisions", true],
    ["#dve_material", "stone"],
   ],
  }
]);

Constructor Thread

 DVEC.voxelManager.registerVoxel([
  DVEC.voxelManager.defaults.box.simple("dve_debugbox", {
   top: ["#dve_solid", "debug", "top"],
   bottom: ["#dve_solid", "debug", "bottom"],
   north: ["#dve_solid", "debug", "north"],
   south: ["#dve_solid", "debug", "south"],
   east: ["#dve_solid", "debug", "east"],
   west: ["#dve_solid", "debug", "west"],
  })
]);

Clone this wiki locally