@divinevoxel/vlox 0.0.79 → 0.0.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Builder/Tools/Brush/BrushTool.d.ts +12 -2
- package/Builder/Tools/Brush/BrushTool.js +53 -28
- package/Builder/Tools/Debug/DebugTool.d.ts +18 -0
- package/Builder/Tools/Debug/DebugTool.js +36 -0
- package/Builder/Tools/Path/PahtTool.d.ts +1 -1
- package/Builder/Tools/Path/PahtTool.js +1 -1
- package/Builder/Tools/Sculpt/SculptTool.js +8 -0
- package/Builder/Tools/Wrench/WrenchTool.js +10 -23
- package/Builder/Util/SurfaceBoxSelection.js +2 -0
- package/Builder/VoxelBuildSpace.js +3 -3
- package/Contexts/Base/Remote/InitDataSync.js +1 -1
- package/Math/UtilFunctions.js +7 -8
- package/Math/VoxelFaces.d.ts +2 -2
- package/Math/VoxelFaces.js +46 -55
- package/Math/WorldIndexing.d.ts +11 -0
- package/Math/WorldIndexing.js +34 -0
- package/Mesher/Geometry/Geometry.types.d.ts +2 -2
- package/Mesher/Geometry/Geometry.types.js +7 -20
- package/Mesher/Geometry/Primitives/QuadVertexData.js +118 -119
- package/Mesher/Geometry/Primitives/TriangleVertexData.js +89 -90
- package/Mesher/Geometry/Proto/ProtoMesh.d.ts +1 -1
- package/Mesher/Geometry/Proto/ProtoMesh.js +22 -29
- package/Mesher/Geometry/Proto/ProtoMeshBuffer.d.ts +4 -2
- package/Mesher/Geometry/Proto/ProtoMeshBuffer.js +14 -6
- package/Mesher/Geometry/Shapes/Box.js +6 -7
- package/Mesher/Geometry/Transform/TransformBox.js +8 -9
- package/Mesher/Geometry/Transform/TransformQuad.js +4 -5
- package/Mesher/Geometry/Transform/TransformTriangle.js +3 -4
- package/Mesher/InitMesher.js +4 -9
- package/Mesher/Items/Geometry/ItemGeometryBuilder.js +7 -8
- package/Mesher/Items/MeshTexture.js +125 -57
- package/Mesher/Voxels/Base/BuildVoxel.d.ts +6 -0
- package/Mesher/Voxels/Base/BuildVoxel.js +101 -0
- package/Mesher/Voxels/Base/CompactVoxelSectionMesh.js +1 -21
- package/Mesher/Voxels/Base/MeshSectionBase.js +3 -26
- package/Mesher/Voxels/Geometry/VoxelGeometryBuilder.js +33 -31
- package/Mesher/Voxels/Geometry/VoxelShaderData.js +3 -7
- package/Mesher/Voxels/MeshTemplate.js +6 -26
- package/Mesher/Voxels/MeshVoxel.js +5 -10
- package/Mesher/Voxels/Models/Common/Calc/CalcConstants.js +41 -42
- package/Mesher/Voxels/Models/Common/Calc/FaceDataCalc.js +6 -9
- package/Mesher/Voxels/Models/Common/Faces/CullRulledFace.js +64 -47
- package/Mesher/Voxels/Models/Common/Faces/ShadeRulledFace.js +57 -43
- package/Mesher/Voxels/Models/Nodes/Custom/Liquid/FlowGradient.js +4 -5
- package/Mesher/Voxels/Models/Nodes/Custom/Liquid/LiquidGeometryNode.d.ts +1 -1
- package/Mesher/Voxels/Models/Nodes/Custom/Liquid/LiquidGeometryNode.js +116 -118
- package/Mesher/Voxels/Models/Nodes/Default/QuadVoxelGeometryNode.js +4 -4
- package/Mesher/Voxels/Models/Nodes/VoxelGeometryConstructor.js +2 -2
- package/Mesher/Voxels/Models/Procedures/Default/OutlinedTextureProcedure.js +19 -21
- package/Mesher/Voxels/Models/Procedures/Default/PillarTextureProcedure.js +45 -38
- package/Mesher/Voxels/Models/RenderedMaterials.d.ts +1 -1
- package/Mesher/Voxels/Models/RenderedMaterials.js +8 -5
- package/Mesher/Voxels/Models/VoxelGeometryBuilderCacheSpace.d.ts +18 -4
- package/Mesher/Voxels/Models/VoxelGeometryBuilderCacheSpace.js +135 -22
- package/Mesher/Voxels/Models/VoxelGeometryBuilderCacheSpaceN.d.ts +33 -0
- package/Mesher/Voxels/Models/VoxelGeometryBuilderCacheSpaceN.js +204 -0
- package/Mesher/Voxels/Models/{VoxelModelConstructorRegister.d.ts → VoxelGeometryConstructorRegister.d.ts} +1 -6
- package/Mesher/Voxels/Models/VoxelGeometryConstructorRegister.js +20 -0
- package/Mesher/Voxels/Models/VoxelModelBuilder.js +15 -16
- package/Mesher/Voxels/Models/VoxelModelEffect.d.ts +1 -3
- package/Mesher/Voxels/Models/VoxelModelEffect.js +1 -3
- package/Renderer/DVERenderNode.types.d.ts +1 -0
- package/Renderer/InitTasks.js +2 -0
- package/Tasks/Paint/Erase/EraseVoxel.js +1 -1
- package/Tasks/Propagation/Illumanation/RGBUpdate.js +191 -48
- package/Tasks/Propagation/Illumanation/SunUpdate.d.ts +1 -1
- package/Tasks/Propagation/Illumanation/SunUpdate.js +167 -63
- package/Tasks/Propagation/Illumanation/WorldSun.js +96 -60
- package/Tasks/WorldGeneration/WorldGenBrush.d.ts +2 -0
- package/Tasks/WorldGeneration/WorldGenBrush.js +31 -0
- package/Templates/Archive/ArchivedVoxelTemplate.js +1 -1
- package/Templates/Archive/Functions/CreateArchivedTemplate.js +1 -1
- package/Templates/Archive/Functions/CreateArchivedTemplateFromFull.d.ts +6 -0
- package/Templates/Archive/Functions/CreateArchivedTemplateFromFull.js +174 -0
- package/Textures/Classes/CompactedTextureReader.d.ts +22 -0
- package/Textures/Classes/CompactedTextureReader.js +90 -0
- package/Textures/Classes/CompiledTexture.d.ts +4 -1
- package/Textures/Classes/CompiledTexture.js +36 -8
- package/Textures/Classes/TextureAtlasIndex.d.ts +7 -0
- package/Textures/Classes/TextureAtlasIndex.js +14 -0
- package/Textures/Classes/TextureLoader.d.ts +20 -0
- package/Textures/Classes/TextureLoader.js +95 -0
- package/Textures/Functions/BuildTextureData.d.ts +1 -1
- package/Textures/Functions/BuildTextureData.js +19 -122
- package/Textures/Functions/CreateCompactedTexture.d.ts +6 -0
- package/Textures/Functions/CreateCompactedTexture.js +105 -0
- package/Textures/Functions/ReadCompactedTexture.d.ts +2 -0
- package/Textures/Functions/ReadCompactedTexture.js +42 -0
- package/Textures/Texture.types.d.ts +14 -0
- package/Textures/TextureManager.d.ts +7 -1
- package/Textures/TextureManager.js +13 -0
- package/Tools/Brush/Brush.d.ts +4 -2
- package/Tools/Brush/Brush.js +28 -6
- package/Util/BinaryBuffer/Functions/BinaryBufferConvert.d.ts +1 -1
- package/Util/TickInterval.d.ts +3 -0
- package/Util/TickInterval.js +31 -3
- package/Voxels/Archive/VoxelPaletteArchiveReader.d.ts +1 -0
- package/Voxels/Archive/VoxelPaletteArchiveReader.js +9 -10
- package/Voxels/Archive/VoxelPaletteArechive.js +5 -4
- package/Voxels/Cursor/VoxelCursor.interface.d.ts +1 -1
- package/Voxels/Cursor/VoxelCursor.interface.js +22 -16
- package/Voxels/Data/VoxelLUT.d.ts +69 -42
- package/Voxels/Data/VoxelLUT.js +110 -53
- package/Voxels/Functions/BuildLUTs.js +100 -45
- package/Voxels/Functions/Geometry/CalcFunctions.js +6 -7
- package/Voxels/Functions/Geometry/Compile/BuildCompiled.d.ts +1 -1
- package/Voxels/Functions/Geometry/Inputs/BuildBoxInputs.d.ts +1 -1
- package/Voxels/Functions/Geometry/Inputs/BuildCustomInputs.d.ts +1 -1
- package/Voxels/Functions/Geometry/Inputs/BuildQuadInputs.d.ts +1 -1
- package/Voxels/Functions/Geometry/Inputs/BuildTriangleInputs.d.ts +1 -1
- package/Voxels/Functions/Geometry/Inputs/BuildTriangleInputs.js +3 -0
- package/Voxels/Indexes/VoxelIndex.js +3 -1
- package/Voxels/InitVoxelData.js +3 -1
- package/Voxels/Interaction/Functions/PickVoxel.js +3 -5
- package/Voxels/Interaction/Functions/PickVoxelWorld.js +4 -6
- package/Voxels/Models/Defaults/Examples.d.ts +2 -0
- package/Voxels/Models/Defaults/Examples.js +151 -2
- package/Voxels/State/Reltional/ReltionalStateBuilder.js +2 -0
- package/Voxels/State/Schema/BinarySchema.d.ts +1 -0
- package/Voxels/State/Schema/BinarySchema.js +14 -0
- package/Voxels/State/VoxelSchemas.d.ts +11 -4
- package/Voxels/State/VoxelSchemas.js +42 -9
- package/Voxels/Types/PaintVoxelData.js +6 -2
- package/World/Archive/Classes/ImportedSection.js +1 -1
- package/World/Archive/Classes/ImportedSector.js +0 -1
- package/World/Archive/Functions/Sector/ArchiveSector.js +2 -2
- package/World/Archive/Functions/Sector/ImportSector.d.ts +1 -0
- package/World/Archive/Functions/Sector/ImportSector.js +183 -7
- package/World/Cursor/SectorCursor.js +1 -4
- package/World/Cursor/WorldCursor.d.ts +12 -3
- package/World/Cursor/WorldCursor.js +60 -30
- package/World/InitTasks.js +1 -1
- package/World/Lock/Function/LockSectors.js +5 -1
- package/World/Lock/Function/UnLockSectors.js +5 -1
- package/World/SnapShot/SectionSnapShot.d.ts +7 -3
- package/World/SnapShot/SectionSnapShot.js +47 -21
- package/World/SnapShot/SectionSnapShotCursor.d.ts +4 -2
- package/World/SnapShot/SectionSnapShotCursor.js +23 -11
- package/World/SnapShot/SnapShots.d.ts +1 -2
- package/World/SnapShot/SnapShots.js +3 -3
- package/World/WorldSpaces.d.ts +7 -0
- package/World/WorldSpaces.js +35 -13
- package/WorldSimulation/Dimensions/DimensionSegment.d.ts +2 -0
- package/WorldSimulation/Dimensions/DimensionSegment.js +9 -1
- package/WorldSimulation/Dimensions/DimensionSimulation.js +6 -7
- package/WorldSimulation/Dimensions/Generator.d.ts +4 -0
- package/WorldSimulation/Dimensions/Generator.js +15 -1
- package/WorldSimulation/Dimensions/SimulationSector.d.ts +1 -0
- package/WorldSimulation/Dimensions/SimulationSector.js +18 -0
- package/WorldSimulation/Internal/WorldSimulationTasks.js +11 -7
- package/WorldSimulation/Procedures/InitalLoad.d.ts +1 -0
- package/WorldSimulation/Procedures/InitalLoad.js +18 -8
- package/WorldSimulation/Tasks/SimulationTaskBase.d.ts +4 -1
- package/WorldSimulation/Tasks/SimulationTaskBase.js +13 -2
- package/WorldSimulation/Tasks/TaskSegment.d.ts +4 -2
- package/WorldSimulation/Tasks/TaskSegment.js +36 -22
- package/WorldSimulation/Voxels/Ticks/Types/LiquidVoxelUpdate.js +1 -2
- package/WorldSimulation/WorldSimulation.d.ts +6 -3
- package/WorldSimulation/WorldSimulation.js +44 -20
- package/package.json +1 -1
- package/Mesher/Items/MeshTextureO.d.ts +0 -1
- package/Mesher/Items/MeshTextureO.js +0 -277
- package/Mesher/Voxels/Models/VoxelConstructor.d.ts +0 -8
- package/Mesher/Voxels/Models/VoxelConstructor.js +0 -78
- package/Mesher/Voxels/Models/VoxelModelConstructorRegister.js +0 -37
- package/WorldSimulation/Procedures/BuildOnly.d.ts +0 -10
- package/WorldSimulation/Procedures/BuildOnly.js +0 -55
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { VoxelSchemas } from "../State/VoxelSchemas";
|
|
2
2
|
import { BinarySchema } from "../State/Schema/BinarySchema";
|
|
3
3
|
import { BinaryBuffer } from "../../Util/BinaryBuffer/BinaryBuffer";
|
|
4
|
-
const temp = ["", 0, 0];
|
|
5
4
|
export class VoxelPaletteArchiveReader {
|
|
5
|
+
temp = ["", 0, 0];
|
|
6
6
|
voxelPalette;
|
|
7
7
|
_voxels = [];
|
|
8
8
|
_voxelStateSchema = new Map();
|
|
@@ -21,26 +21,27 @@ export class VoxelPaletteArchiveReader {
|
|
|
21
21
|
this._modSchema.set(voxel.id, binarySchema);
|
|
22
22
|
}
|
|
23
23
|
if (voxel.stateSchemaId && this._stateSchemas.has(voxel.stateSchemaId)) {
|
|
24
|
-
this._voxelStateSchema.set(voxel.
|
|
24
|
+
this._voxelStateSchema.set(voxel.id, this._stateSchemas.get(voxel.stateSchemaId));
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
this.voxelPalette = BinaryBuffer.ToTypedArray(palettes.voxelPalette);
|
|
28
28
|
}
|
|
29
29
|
getVoxelData(id) {
|
|
30
|
+
const temp = this.temp;
|
|
30
31
|
const index = id * 3;
|
|
31
32
|
const voxelId = this._voxels[this.voxelPalette[index]]?.id;
|
|
32
33
|
temp[0] = voxelId;
|
|
34
|
+
temp[1] = 0;
|
|
35
|
+
temp[2] = 0;
|
|
33
36
|
if (temp[0] == "dve_air") {
|
|
34
|
-
temp[1] = 0;
|
|
35
|
-
temp[2] = 0;
|
|
36
37
|
return temp;
|
|
37
38
|
}
|
|
38
39
|
const currentStateSchema = VoxelSchemas.getStateSchema(voxelId);
|
|
39
|
-
let finalStateValue = 0;
|
|
40
40
|
if (this._voxelStateSchema.has(voxelId)) {
|
|
41
41
|
const stateSchema = this._voxelStateSchema.get(voxelId);
|
|
42
42
|
const stateValue = this.voxelPalette[index + 1];
|
|
43
43
|
stateSchema.startEncoding(stateValue);
|
|
44
|
+
currentStateSchema.startEncoding(0);
|
|
44
45
|
for (const node of stateSchema.nodes) {
|
|
45
46
|
if (node.valuePalette) {
|
|
46
47
|
currentStateSchema.setValue(node.name, stateSchema.getValue(node.name));
|
|
@@ -49,15 +50,14 @@ export class VoxelPaletteArchiveReader {
|
|
|
49
50
|
currentStateSchema.setNumber(node.name, stateSchema.getNumber(node.name));
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
|
-
|
|
53
|
+
temp[1] = currentStateSchema.getEncoded();
|
|
53
54
|
}
|
|
54
|
-
temp[1] = finalStateValue;
|
|
55
|
-
let finalModValue = 0;
|
|
56
55
|
const currentModSchema = VoxelSchemas.mod.get(voxelId);
|
|
57
56
|
if (this._modSchema.has(voxelId)) {
|
|
58
57
|
const modSchema = this._modSchema.get(voxelId);
|
|
59
58
|
const modValue = this.voxelPalette[index + 2];
|
|
60
59
|
modSchema.startEncoding(modValue);
|
|
60
|
+
currentModSchema.startEncoding(0);
|
|
61
61
|
for (const node of modSchema.nodes) {
|
|
62
62
|
if (node.valuePalette) {
|
|
63
63
|
currentModSchema.setValue(node.name, modSchema.getValue(node.name));
|
|
@@ -66,9 +66,8 @@ export class VoxelPaletteArchiveReader {
|
|
|
66
66
|
currentModSchema.setNumber(node.name, modSchema.getNumber(node.name));
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
|
|
69
|
+
temp[2] = currentModSchema.getEncoded();
|
|
70
70
|
}
|
|
71
|
-
temp[2] = finalModValue;
|
|
72
71
|
return temp;
|
|
73
72
|
}
|
|
74
73
|
}
|
|
@@ -36,13 +36,13 @@ export class VoxelArchivePalette {
|
|
|
36
36
|
register(id) {
|
|
37
37
|
if (this._voxelsRegistered.has(id))
|
|
38
38
|
return this._voxelsRegistered.get(id);
|
|
39
|
-
const stringId = VoxelLUT.voxelIds.getStringId(VoxelLUT.
|
|
39
|
+
const stringId = VoxelLUT.voxelIds.getStringId(VoxelLUT.voxelIdToTrueId[id]);
|
|
40
40
|
let voxelId = 0;
|
|
41
41
|
if (!this._ids.isRegistered(stringId)) {
|
|
42
42
|
voxelId = this._ids.register(stringId);
|
|
43
43
|
const modelId = VoxelLUT.models.getStringId(VoxelLUT.modelsIndex[VoxelLUT.voxelIds.getNumberId(stringId)]);
|
|
44
|
-
const stateData = VoxelSchemas.getStateSchema(stringId)
|
|
45
|
-
const modData = VoxelSchemas.mod.get(stringId)
|
|
44
|
+
const stateData = VoxelSchemas.getStateSchema(stringId)?.getSchema();
|
|
45
|
+
const modData = VoxelSchemas.mod.get(stringId)?.getSchema();
|
|
46
46
|
if (stateData && stateData?.length) {
|
|
47
47
|
this._stateShemas[modelId] = stateData;
|
|
48
48
|
}
|
|
@@ -60,7 +60,8 @@ export class VoxelArchivePalette {
|
|
|
60
60
|
else {
|
|
61
61
|
voxelId = this._ids.getNumberId(stringId);
|
|
62
62
|
}
|
|
63
|
-
const
|
|
63
|
+
const state = VoxelLUT.voxelIdToState[id];
|
|
64
|
+
const mod = VoxelLUT.voxelIdToMod[id];
|
|
64
65
|
this._voxelPalette.push(voxelId, state, mod);
|
|
65
66
|
const paletteId = this._voxelCount;
|
|
66
67
|
this._voxelsRegistered.set(id, paletteId);
|
|
@@ -61,11 +61,11 @@ export declare abstract class VoxelCursorInterface {
|
|
|
61
61
|
getStringId(): string;
|
|
62
62
|
setName(name: string, state?: number, mod?: number): this;
|
|
63
63
|
getName(): string;
|
|
64
|
-
getIndexData(): [voxelId: number, state: number, mod: number];
|
|
65
64
|
getMod(): number;
|
|
66
65
|
setMod(mod: number): this;
|
|
67
66
|
getState(): number;
|
|
68
67
|
setState(state: number): this;
|
|
68
|
+
isFullBlock(): boolean;
|
|
69
69
|
isSameVoxel(voxel: VoxelCursorInterface): boolean;
|
|
70
70
|
copy(cursor: VoxelCursorInterface): this;
|
|
71
71
|
setRaw(raw: RawVoxelData): this;
|
|
@@ -18,10 +18,12 @@ export class VoxelCursorInterface {
|
|
|
18
18
|
process() {
|
|
19
19
|
this.id = this.ids[this._index];
|
|
20
20
|
this.secondaryId = this.secondary[this._index];
|
|
21
|
-
this._voxelId = this.
|
|
21
|
+
this._voxelId = this.__readingSecondaryVoxel
|
|
22
|
+
? VoxelLUT.voxelIdToTrueId[this.secondary[this._index]]
|
|
23
|
+
: VoxelLUT.voxelIdToTrueId[this.ids[this._index]];
|
|
22
24
|
this.tags = VoxelTagsRegister.VoxelTags[this._voxelId];
|
|
23
25
|
this.substanceTags =
|
|
24
|
-
VoxelTagsRegister.SubstanceTags[VoxelLUT.
|
|
26
|
+
VoxelTagsRegister.SubstanceTags[VoxelLUT.substanceMap[this._voxelId]];
|
|
25
27
|
}
|
|
26
28
|
setSecondary(enable) {
|
|
27
29
|
this.__readingSecondaryVoxel = enable;
|
|
@@ -188,7 +190,10 @@ export class VoxelCursorInterface {
|
|
|
188
190
|
}
|
|
189
191
|
/**Get the true voxel id. Meaning the numeric id for the string id of the voxel */
|
|
190
192
|
getVoxelId() {
|
|
191
|
-
|
|
193
|
+
if (this.__readingSecondaryVoxel) {
|
|
194
|
+
return VoxelLUT.voxelIdToTrueId[this.secondary[this._index]];
|
|
195
|
+
}
|
|
196
|
+
return VoxelLUT.voxelIdToTrueId[this.ids[this._index]];
|
|
192
197
|
}
|
|
193
198
|
setVoxelId(id, state = 0, mod = 0) {
|
|
194
199
|
return this.setId(VoxelLUT.getVoxelId(id, state, mod));
|
|
@@ -197,7 +202,7 @@ export class VoxelCursorInterface {
|
|
|
197
202
|
return this.setVoxelId(VoxelLUT.voxelIds.getNumberId(id), state, mod);
|
|
198
203
|
}
|
|
199
204
|
getStringId() {
|
|
200
|
-
return VoxelLUT.voxelIds.getStringId(this.
|
|
205
|
+
return VoxelLUT.voxelIds.getStringId(this.getVoxelId());
|
|
201
206
|
}
|
|
202
207
|
setName(name, state = 0, mod = 0) {
|
|
203
208
|
return this.setVoxelId(VoxelLUT.voxelIds.getNumberId(VoxelLUT.voxelNametoIdMap.get(name)), state, mod);
|
|
@@ -205,30 +210,31 @@ export class VoxelCursorInterface {
|
|
|
205
210
|
getName() {
|
|
206
211
|
return VoxelLUT.voxelIdToNameMap.get(this.getStringId());
|
|
207
212
|
}
|
|
208
|
-
|
|
213
|
+
getMod() {
|
|
209
214
|
if (this.__readingSecondaryVoxel) {
|
|
210
|
-
return VoxelLUT.
|
|
215
|
+
return VoxelLUT.voxelIdToMod[this.secondary[this._index]];
|
|
211
216
|
}
|
|
212
|
-
return VoxelLUT.
|
|
213
|
-
}
|
|
214
|
-
getMod() {
|
|
215
|
-
return VoxelLUT.voxels[this.ids[this._index]][2];
|
|
217
|
+
return VoxelLUT.voxelIdToMod[this.ids[this._index]];
|
|
216
218
|
}
|
|
217
219
|
setMod(mod) {
|
|
218
|
-
|
|
219
|
-
this.setId(VoxelLUT.getVoxelId(index[0], index[1], mod));
|
|
220
|
+
this.setId(VoxelLUT.getVoxelId(this.getVoxelId(), this.getState(), mod));
|
|
220
221
|
return this;
|
|
221
222
|
}
|
|
222
223
|
getState() {
|
|
223
|
-
|
|
224
|
+
if (this.__readingSecondaryVoxel) {
|
|
225
|
+
return VoxelLUT.voxelIdToState[this.secondary[this._index]];
|
|
226
|
+
}
|
|
227
|
+
return VoxelLUT.voxelIdToState[this.ids[this._index]];
|
|
224
228
|
}
|
|
225
229
|
setState(state) {
|
|
226
|
-
|
|
227
|
-
this.setId(VoxelLUT.getVoxelId(index[0], state, index[2]));
|
|
230
|
+
this.setId(VoxelLUT.getVoxelId(this.getVoxelId(), state, this.getMod()));
|
|
228
231
|
return this;
|
|
229
232
|
}
|
|
233
|
+
isFullBlock() {
|
|
234
|
+
return this.tags["dve_full_block"];
|
|
235
|
+
}
|
|
230
236
|
isSameVoxel(voxel) {
|
|
231
|
-
return this.
|
|
237
|
+
return this.getVoxelId() == voxel.getVoxelId();
|
|
232
238
|
}
|
|
233
239
|
copy(cursor) {
|
|
234
240
|
this.ids[this._index] = cursor.ids[cursor._index];
|
|
@@ -5,31 +5,39 @@ export type VoxelLUTExport = {
|
|
|
5
5
|
substance: string[];
|
|
6
6
|
substanceMap: number[];
|
|
7
7
|
voxelIds: string[];
|
|
8
|
-
voxelNametoIdMap: [
|
|
9
|
-
voxelIdToNameMap: [
|
|
8
|
+
voxelNametoIdMap: [string, string][];
|
|
9
|
+
voxelIdToNameMap: [string, string][];
|
|
10
10
|
models: string[];
|
|
11
11
|
modelsIndex: number[];
|
|
12
|
-
totalStates:
|
|
13
|
-
totalMods:
|
|
14
|
-
totalReltionalStates:
|
|
15
|
-
totalReltionalMods:
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
totalStates: ArrayBufferLike;
|
|
13
|
+
totalMods: ArrayBufferLike;
|
|
14
|
+
totalReltionalStates: ArrayBufferLike;
|
|
15
|
+
totalReltionalMods: ArrayBufferLike;
|
|
16
|
+
totalVoxelIds: number;
|
|
17
|
+
totalRelationalVoxelIds: number;
|
|
18
|
+
totalCombinedIds: number;
|
|
19
|
+
modelStateMaps: [number, number][][];
|
|
20
|
+
modelRelationalStateMaps: [number, number][][];
|
|
21
|
+
voxelModMaps: [number, number][][];
|
|
22
|
+
voxelRelationalModMaps: [number, number][][];
|
|
23
|
+
voxelIdToTrueId: ArrayBufferLike;
|
|
24
|
+
voxelIdToState: ArrayBufferLike;
|
|
25
|
+
voxelIdToMod: ArrayBufferLike;
|
|
26
|
+
voxelRecordStartIndex: ArrayBufferLike;
|
|
27
|
+
voxelRecord: ArrayBufferLike;
|
|
28
|
+
relationalVoxelIdToTrueId: ArrayBufferLike;
|
|
29
|
+
relationalVoxelIdToState: ArrayBufferLike;
|
|
30
|
+
relationalVoxelIdToMod: ArrayBufferLike;
|
|
31
|
+
relationalVoxelRecordStartIndex: ArrayBufferLike;
|
|
32
|
+
relationalVoxelRecord: ArrayBufferLike;
|
|
33
|
+
geometryIndex: ArrayBufferLike;
|
|
34
|
+
geometryInputsIndex: ArrayBufferLike;
|
|
18
35
|
conditionalGeometryIndex: [
|
|
19
36
|
geometryId: number,
|
|
20
37
|
modelState: number,
|
|
21
38
|
modelReltionalState: boolean[]
|
|
22
39
|
][][];
|
|
23
40
|
conditionalGeometryInputIndex: number[][][];
|
|
24
|
-
voxels: [voxelId: number, state: number, mod: number][];
|
|
25
|
-
voxelRecord: number[][][];
|
|
26
|
-
voxelIdToModelState: number[];
|
|
27
|
-
reltioanlVoxels: [
|
|
28
|
-
voxelId: number,
|
|
29
|
-
reltionalState: number,
|
|
30
|
-
reltioanlMod: number
|
|
31
|
-
][];
|
|
32
|
-
reltionalVoxelRecord: number[][][];
|
|
33
41
|
};
|
|
34
42
|
export declare class VoxelLUT {
|
|
35
43
|
static material: StringPalette;
|
|
@@ -41,43 +49,62 @@ export declare class VoxelLUT {
|
|
|
41
49
|
static voxelIdToNameMap: Map<string, string>;
|
|
42
50
|
static models: StringPalette;
|
|
43
51
|
static modelsIndex: number[];
|
|
44
|
-
static totalStates:
|
|
45
|
-
static totalMods:
|
|
46
|
-
static totalReltionalStates:
|
|
47
|
-
static totalReltionalMods:
|
|
48
|
-
static
|
|
49
|
-
static
|
|
52
|
+
static totalStates: Uint16Array;
|
|
53
|
+
static totalMods: Uint16Array;
|
|
54
|
+
static totalReltionalStates: Uint16Array;
|
|
55
|
+
static totalReltionalMods: Uint16Array;
|
|
56
|
+
static totalVoxelIds: number;
|
|
57
|
+
static totalRelationalVoxelIds: number;
|
|
58
|
+
/** totalVoxelIds * totalRelationalVoxelIds */
|
|
59
|
+
static totalCombinedIds: number;
|
|
60
|
+
/**Maps model ids to their state maps */
|
|
61
|
+
static modelStateMaps: Map<number, number>[];
|
|
62
|
+
/**Maps model ids to their relational state maps */
|
|
63
|
+
static modelRelationalStateMaps: Map<number, number>[];
|
|
64
|
+
/**Maps voxel true ids to their mod maps */
|
|
65
|
+
static voxelModMaps: Map<number, number>[];
|
|
66
|
+
/**Maps voxel true ids to their relational mod maps */
|
|
67
|
+
static voxelRelationalModMaps: Map<number, number>[];
|
|
68
|
+
/**Maps voxel id to its true voxel id */
|
|
69
|
+
static voxelIdToTrueId: Uint16Array;
|
|
70
|
+
/**Maps voxel id to its state */
|
|
71
|
+
static voxelIdToState: Uint16Array;
|
|
72
|
+
/**Maps voxel id to its mod */
|
|
73
|
+
static voxelIdToMod: Uint16Array;
|
|
74
|
+
/** Maps a voxels true id to where it starts in the voxel record.*/
|
|
75
|
+
static voxelRecordStartIndex: Uint16Array;
|
|
76
|
+
/** Maps a voxels true id to its state x mod to get the actual final voxel id*/
|
|
77
|
+
static voxelRecord: Uint16Array;
|
|
78
|
+
/**Maps voxel id to its true voxel id */
|
|
79
|
+
static relationalVoxelIdToTrueId: Uint16Array;
|
|
80
|
+
/**Maps voxel id to its state */
|
|
81
|
+
static relationalVoxelIdToState: Uint16Array;
|
|
82
|
+
/**Maps voxel id to its mod */
|
|
83
|
+
static relationalVoxelIdToMod: Uint16Array;
|
|
84
|
+
/** Maps a voxels true id to where it starts in the voxel record.*/
|
|
85
|
+
static relationalVoxelRecordStartIndex: Uint16Array;
|
|
86
|
+
/** Maps a voxels true id to its state x mod to get the actual final voxel id*/
|
|
87
|
+
static relationalVoxelRecord: Uint16Array;
|
|
88
|
+
static geometryIndex: Uint16Array;
|
|
89
|
+
static geometryInputsIndex: Uint16Array;
|
|
50
90
|
static conditionalGeometryIndex: [
|
|
51
91
|
geometryId: number,
|
|
52
92
|
modelState: number,
|
|
53
93
|
modelReltionalState: boolean[]
|
|
54
94
|
][][];
|
|
55
95
|
static conditionalGeometryInputIndex: number[][][];
|
|
56
|
-
|
|
57
|
-
static
|
|
58
|
-
/**Palette of true voxel ids to state then their mod then the final palette voxel id */
|
|
59
|
-
static voxelRecord: number[][][];
|
|
60
|
-
static voxelIdToModelState: number[];
|
|
61
|
-
/**Palette of voxel ids to their tree id, state, and mod value */
|
|
62
|
-
static reltioanlVoxels: [
|
|
63
|
-
voxelId: number,
|
|
64
|
-
reltionalState: number,
|
|
65
|
-
reltioanlMod: number
|
|
66
|
-
][];
|
|
67
|
-
/**Palette of true voxel ids to reltional state then theirreltional mod then the final reltional palette voxel id */
|
|
68
|
-
static reltionalVoxelRecord: number[][][];
|
|
69
|
-
static getVoxelId(id: number, state?: number, mod?: number): number;
|
|
96
|
+
static getStateIndex(x: number, y: number, boundsX: number): number;
|
|
97
|
+
static getVoxelId(trueId: number, state?: number, mod?: number): number;
|
|
70
98
|
static getVoxelIdFromString(id: string, state?: number, mod?: number): number;
|
|
71
|
-
static
|
|
72
|
-
static
|
|
73
|
-
static
|
|
74
|
-
static getGeometryInputIndex(voxelId?: number, reltioanlId?: number): number;
|
|
99
|
+
static getReltionalVoxelId(trueId: number, relationalState?: number, relationalMod?: number): number;
|
|
100
|
+
static getGeometryIndex(voxelId?: number, relationalId?: number): number;
|
|
101
|
+
static getGeometryInputIndex(voxelId?: number, relationalId?: number): number;
|
|
75
102
|
static getConditionalGeometryNodes(trueVoxelId: number): [
|
|
76
103
|
geometryId: number,
|
|
77
104
|
modelState: number,
|
|
78
105
|
modelReltionalState: boolean[]
|
|
79
106
|
][];
|
|
80
|
-
static getConditionalGeometryInputIndex(getIndex: number, voxelId?: number,
|
|
107
|
+
static getConditionalGeometryInputIndex(getIndex: number, voxelId?: number, relationalId?: number): number;
|
|
81
108
|
static export(): VoxelLUTExport;
|
|
82
109
|
static import(exported: VoxelLUTExport): void;
|
|
83
110
|
}
|
package/Voxels/Data/VoxelLUT.js
CHANGED
|
@@ -16,55 +16,86 @@ export class VoxelLUT {
|
|
|
16
16
|
static models = new StringPalette();
|
|
17
17
|
//maps true voxel ids to their model palette id
|
|
18
18
|
static modelsIndex = [];
|
|
19
|
+
//TOTALS
|
|
19
20
|
//maps true voxel ids to the total number of states
|
|
20
|
-
static totalStates
|
|
21
|
+
static totalStates;
|
|
21
22
|
//maps true voxel ids to the total number of mod states
|
|
22
|
-
static totalMods
|
|
23
|
+
static totalMods;
|
|
23
24
|
//maps true voxel ids to the total number of reltional states
|
|
24
|
-
static totalReltionalStates
|
|
25
|
+
static totalReltionalStates;
|
|
25
26
|
//maps true voxel ids to the total number of reltional mod states
|
|
26
|
-
static totalReltionalMods
|
|
27
|
+
static totalReltionalMods;
|
|
28
|
+
static totalVoxelIds = 1;
|
|
29
|
+
static totalRelationalVoxelIds = 1;
|
|
30
|
+
/** totalVoxelIds * totalRelationalVoxelIds */
|
|
31
|
+
static totalCombinedIds = 0;
|
|
32
|
+
//MAPS
|
|
33
|
+
/**Maps model ids to their state maps */
|
|
34
|
+
static modelStateMaps = [];
|
|
35
|
+
/**Maps model ids to their relational state maps */
|
|
36
|
+
static modelRelationalStateMaps = [];
|
|
37
|
+
/**Maps voxel true ids to their mod maps */
|
|
38
|
+
static voxelModMaps = [];
|
|
39
|
+
/**Maps voxel true ids to their relational mod maps */
|
|
40
|
+
static voxelRelationalModMaps = [];
|
|
41
|
+
//VOXELS IDS
|
|
42
|
+
/**Maps voxel id to its true voxel id */
|
|
43
|
+
static voxelIdToTrueId;
|
|
44
|
+
/**Maps voxel id to its state */
|
|
45
|
+
static voxelIdToState;
|
|
46
|
+
/**Maps voxel id to its mod */
|
|
47
|
+
static voxelIdToMod;
|
|
48
|
+
/** Maps a voxels true id to where it starts in the voxel record.*/
|
|
49
|
+
static voxelRecordStartIndex;
|
|
50
|
+
/** Maps a voxels true id to its state x mod to get the actual final voxel id*/
|
|
51
|
+
static voxelRecord;
|
|
52
|
+
//RELATIONAL VOXEL IDS
|
|
53
|
+
/**Maps voxel id to its true voxel id */
|
|
54
|
+
static relationalVoxelIdToTrueId;
|
|
55
|
+
/**Maps voxel id to its state */
|
|
56
|
+
static relationalVoxelIdToState;
|
|
57
|
+
/**Maps voxel id to its mod */
|
|
58
|
+
static relationalVoxelIdToMod;
|
|
59
|
+
/** Maps a voxels true id to where it starts in the voxel record.*/
|
|
60
|
+
static relationalVoxelRecordStartIndex;
|
|
61
|
+
/** Maps a voxels true id to its state x mod to get the actual final voxel id*/
|
|
62
|
+
static relationalVoxelRecord;
|
|
63
|
+
//GEOMETRY
|
|
27
64
|
//maps [voxel id x reltional voxel id] to the geometry index
|
|
28
|
-
static geometryIndex
|
|
65
|
+
static geometryIndex;
|
|
29
66
|
//maps [voxel id x reltional voxel id] to the geometry inputs index
|
|
30
|
-
static geometryInputsIndex
|
|
31
|
-
//maps
|
|
67
|
+
static geometryInputsIndex;
|
|
68
|
+
//maps model id to its conditional nodes and the needed voxel id and reltional voxel id
|
|
32
69
|
static conditionalGeometryIndex = [];
|
|
33
70
|
//maps [geometry id x voxel id x reltional voxel id] to the geometry index
|
|
34
71
|
static conditionalGeometryInputIndex = [];
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
/**Palette of true voxel ids to state then their mod then the final palette voxel id */
|
|
38
|
-
static voxelRecord = [];
|
|
39
|
-
//Maps the voxel id to the model state
|
|
40
|
-
static voxelIdToModelState = [];
|
|
41
|
-
/**Palette of voxel ids to their tree id, state, and mod value */
|
|
42
|
-
static reltioanlVoxels = [];
|
|
43
|
-
/**Palette of true voxel ids to reltional state then theirreltional mod then the final reltional palette voxel id */
|
|
44
|
-
static reltionalVoxelRecord = [];
|
|
45
|
-
static getVoxelId(id, state = 0, mod = 0) {
|
|
46
|
-
return this.voxelRecord[id][mod][state];
|
|
72
|
+
static getStateIndex(x, y, boundsX) {
|
|
73
|
+
return x + y * boundsX;
|
|
47
74
|
}
|
|
48
|
-
static
|
|
49
|
-
return this.voxelRecord[this.
|
|
75
|
+
static getVoxelId(trueId, state = 0, mod = 0) {
|
|
76
|
+
return this.voxelRecord[this.voxelRecordStartIndex[trueId] +
|
|
77
|
+
this.getStateIndex(this.modelStateMaps[this.modelsIndex[trueId]].get(state) ?? 0, this.voxelModMaps[trueId].get(mod) ?? 0, this.totalStates[trueId])];
|
|
50
78
|
}
|
|
51
|
-
static
|
|
52
|
-
|
|
79
|
+
static getVoxelIdFromString(id, state = 0, mod = 0) {
|
|
80
|
+
if (id == "dve_air")
|
|
81
|
+
return 0;
|
|
82
|
+
return this.getVoxelId(this.voxelIds.getNumberId(id), state, mod);
|
|
53
83
|
}
|
|
54
|
-
static getReltionalVoxelId(
|
|
55
|
-
return this.
|
|
84
|
+
static getReltionalVoxelId(trueId, relationalState = 0, relationalMod = 0) {
|
|
85
|
+
return this.relationalVoxelRecord[this.relationalVoxelRecordStartIndex[trueId] +
|
|
86
|
+
this.getStateIndex(this.modelRelationalStateMaps[this.modelsIndex[trueId]].get(relationalState), this.voxelRelationalModMaps[trueId].get(relationalMod), this.totalReltionalStates[trueId])];
|
|
56
87
|
}
|
|
57
|
-
static getGeometryIndex(voxelId = 0,
|
|
58
|
-
return this.geometryIndex[voxelId]
|
|
88
|
+
static getGeometryIndex(voxelId = 0, relationalId = 0) {
|
|
89
|
+
return this.geometryIndex[VoxelLUT.getStateIndex(voxelId, relationalId, VoxelLUT.totalVoxelIds)];
|
|
59
90
|
}
|
|
60
|
-
static getGeometryInputIndex(voxelId = 0,
|
|
61
|
-
return this.geometryInputsIndex[voxelId]
|
|
91
|
+
static getGeometryInputIndex(voxelId = 0, relationalId = 0) {
|
|
92
|
+
return this.geometryInputsIndex[VoxelLUT.getStateIndex(voxelId, relationalId, VoxelLUT.totalVoxelIds)];
|
|
62
93
|
}
|
|
63
94
|
static getConditionalGeometryNodes(trueVoxelId) {
|
|
64
95
|
return this.conditionalGeometryIndex[trueVoxelId];
|
|
65
96
|
}
|
|
66
|
-
static getConditionalGeometryInputIndex(getIndex, voxelId = 0,
|
|
67
|
-
return this.conditionalGeometryInputIndex[getIndex][voxelId][
|
|
97
|
+
static getConditionalGeometryInputIndex(getIndex, voxelId = 0, relationalId = 0) {
|
|
98
|
+
return this.conditionalGeometryInputIndex[getIndex][voxelId][relationalId];
|
|
68
99
|
}
|
|
69
100
|
static export() {
|
|
70
101
|
return {
|
|
@@ -77,19 +108,33 @@ export class VoxelLUT {
|
|
|
77
108
|
voxelIdToNameMap: [...this.voxelIdToNameMap],
|
|
78
109
|
models: this.models._palette,
|
|
79
110
|
modelsIndex: this.modelsIndex,
|
|
80
|
-
totalStates: this.totalStates,
|
|
81
|
-
totalMods: this.totalMods,
|
|
82
|
-
totalReltionalStates: this.totalReltionalStates,
|
|
83
|
-
totalReltionalMods: this.totalReltionalMods,
|
|
84
|
-
|
|
85
|
-
|
|
111
|
+
totalStates: this.totalStates.buffer,
|
|
112
|
+
totalMods: this.totalMods.buffer,
|
|
113
|
+
totalReltionalStates: this.totalReltionalStates.buffer,
|
|
114
|
+
totalReltionalMods: this.totalReltionalMods.buffer,
|
|
115
|
+
totalVoxelIds: this.totalVoxelIds,
|
|
116
|
+
totalRelationalVoxelIds: this.totalRelationalVoxelIds,
|
|
117
|
+
totalCombinedIds: this.totalCombinedIds,
|
|
118
|
+
modelStateMaps: this.modelStateMaps.map((m) => [...m]),
|
|
119
|
+
modelRelationalStateMaps: this.modelRelationalStateMaps.map((m) => [
|
|
120
|
+
...m,
|
|
121
|
+
]),
|
|
122
|
+
voxelModMaps: this.voxelModMaps.map((m) => [...m]),
|
|
123
|
+
voxelRelationalModMaps: this.voxelRelationalModMaps.map((m) => [...m]),
|
|
124
|
+
voxelIdToTrueId: this.voxelIdToTrueId.buffer,
|
|
125
|
+
voxelIdToState: this.voxelIdToState.buffer,
|
|
126
|
+
voxelIdToMod: this.voxelIdToMod.buffer,
|
|
127
|
+
voxelRecordStartIndex: this.voxelRecordStartIndex.buffer,
|
|
128
|
+
voxelRecord: this.voxelRecord.buffer,
|
|
129
|
+
relationalVoxelIdToTrueId: this.relationalVoxelIdToTrueId.buffer,
|
|
130
|
+
relationalVoxelIdToState: this.relationalVoxelIdToState.buffer,
|
|
131
|
+
relationalVoxelIdToMod: this.relationalVoxelIdToMod.buffer,
|
|
132
|
+
relationalVoxelRecordStartIndex: this.relationalVoxelRecordStartIndex.buffer,
|
|
133
|
+
relationalVoxelRecord: this.relationalVoxelRecord.buffer,
|
|
134
|
+
geometryIndex: this.geometryIndex.buffer,
|
|
135
|
+
geometryInputsIndex: this.geometryInputsIndex.buffer,
|
|
86
136
|
conditionalGeometryIndex: this.conditionalGeometryIndex,
|
|
87
137
|
conditionalGeometryInputIndex: this.conditionalGeometryInputIndex,
|
|
88
|
-
voxels: this.voxels,
|
|
89
|
-
voxelRecord: this.voxelRecord,
|
|
90
|
-
voxelIdToModelState: this.voxelIdToModelState,
|
|
91
|
-
reltioanlVoxels: this.reltioanlVoxels,
|
|
92
|
-
reltionalVoxelRecord: this.reltionalVoxelRecord,
|
|
93
138
|
};
|
|
94
139
|
}
|
|
95
140
|
static import(exported) {
|
|
@@ -102,18 +147,30 @@ export class VoxelLUT {
|
|
|
102
147
|
this.voxelIdToNameMap = new Map(exported.voxelIdToNameMap);
|
|
103
148
|
this.models.load(exported.models);
|
|
104
149
|
this.modelsIndex = exported.modelsIndex;
|
|
105
|
-
this.totalStates = exported.totalStates;
|
|
106
|
-
this.totalMods = exported.totalMods;
|
|
107
|
-
this.totalReltionalStates = exported.totalReltionalStates;
|
|
108
|
-
this.totalReltionalMods = exported.totalReltionalMods;
|
|
109
|
-
this.
|
|
110
|
-
this.
|
|
150
|
+
this.totalStates = new Uint16Array(exported.totalStates);
|
|
151
|
+
this.totalMods = new Uint16Array(exported.totalMods);
|
|
152
|
+
this.totalReltionalStates = new Uint16Array(exported.totalReltionalStates);
|
|
153
|
+
this.totalReltionalMods = new Uint16Array(exported.totalReltionalMods);
|
|
154
|
+
this.totalVoxelIds = exported.totalVoxelIds;
|
|
155
|
+
this.totalRelationalVoxelIds = exported.totalRelationalVoxelIds;
|
|
156
|
+
this.totalCombinedIds = exported.totalCombinedIds;
|
|
157
|
+
this.modelStateMaps = exported.modelStateMaps.map((m) => new Map(m));
|
|
158
|
+
this.modelRelationalStateMaps = exported.modelRelationalStateMaps.map((m) => new Map(m));
|
|
159
|
+
this.voxelModMaps = exported.voxelModMaps.map((m) => new Map(m));
|
|
160
|
+
this.voxelRelationalModMaps = exported.voxelRelationalModMaps.map((m) => new Map(m));
|
|
161
|
+
this.voxelIdToTrueId = new Uint16Array(exported.voxelIdToTrueId);
|
|
162
|
+
this.voxelIdToState = new Uint16Array(exported.voxelIdToState);
|
|
163
|
+
this.voxelIdToMod = new Uint16Array(exported.voxelIdToMod);
|
|
164
|
+
this.voxelRecordStartIndex = new Uint16Array(exported.voxelRecordStartIndex);
|
|
165
|
+
this.voxelRecord = new Uint16Array(exported.voxelRecord);
|
|
166
|
+
this.relationalVoxelIdToTrueId = new Uint16Array(exported.relationalVoxelIdToTrueId);
|
|
167
|
+
this.relationalVoxelIdToState = new Uint16Array(exported.relationalVoxelIdToState);
|
|
168
|
+
this.relationalVoxelIdToMod = new Uint16Array(exported.relationalVoxelIdToMod);
|
|
169
|
+
this.relationalVoxelRecordStartIndex = new Uint16Array(exported.relationalVoxelRecordStartIndex);
|
|
170
|
+
this.relationalVoxelRecord = new Uint16Array(exported.relationalVoxelRecord);
|
|
171
|
+
this.geometryIndex = new Uint16Array(exported.geometryIndex);
|
|
172
|
+
this.geometryInputsIndex = new Uint16Array(exported.geometryInputsIndex);
|
|
111
173
|
this.conditionalGeometryIndex = exported.conditionalGeometryIndex;
|
|
112
174
|
this.conditionalGeometryInputIndex = exported.conditionalGeometryInputIndex;
|
|
113
|
-
this.voxels = exported.voxels;
|
|
114
|
-
this.voxelRecord = exported.voxelRecord;
|
|
115
|
-
this.voxelIdToModelState = exported.voxelIdToModelState;
|
|
116
|
-
this.reltioanlVoxels = exported.reltioanlVoxels;
|
|
117
|
-
this.reltionalVoxelRecord = exported.reltionalVoxelRecord;
|
|
118
175
|
}
|
|
119
176
|
}
|