@divinevoxel/vlox 0.0.73 → 0.0.74
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/Contexts/Base/Remote/InitDataSync.js +4 -0
- package/Contexts/Base/Remote/InitWorldDataSync.js +1 -1
- package/Contexts/Render/DivineVoxelEngineRender.d.ts +1 -0
- package/Contexts/World/DivineVoxelEngineWorld.d.ts +1 -0
- package/Init/StartConstructor.js +2 -0
- package/Math/index.d.ts +5 -1
- package/Mesher/Functions/CompactVoxelSectionMesh.d.ts +4 -0
- package/Mesher/Functions/CompactVoxelSectionMesh.js +112 -0
- package/Mesher/Functions/MeshSection.d.ts +1 -1
- package/Mesher/Functions/MeshSection.js +15 -22
- package/Mesher/Geomtry/CompactedSectionVoxelMesh.d.ts +23 -0
- package/Mesher/Geomtry/CompactedSectionVoxelMesh.js +144 -0
- package/Mesher/Geomtry/VoxelGeometryBuilder.d.ts +1 -1
- package/Mesher/Geomtry/VoxelGeometryBuilder.js +118 -197
- package/Mesher/Geomtry/VoxelMesh.js +2 -2
- package/Mesher/Geomtry/VoxelMeshBVHBuilder.d.ts +8 -70
- package/Mesher/Geomtry/VoxelMeshBVHBuilder.js +18 -183
- package/Mesher/Geomtry/VoxelMeshBVHStructCursor.d.ts +22 -0
- package/Mesher/Geomtry/VoxelMeshBVHStructCursor.js +78 -0
- package/Mesher/Geomtry/VoxelMeshBuffers.js +2 -2
- package/Mesher/InitTask.js +5 -1
- package/Mesher/Models/Common/BoxGeometryNode.js +7 -7
- package/Mesher/Models/Common/Calc/CalcConstants.d.ts +1 -1
- package/Mesher/Models/Common/Calc/CalcConstants.js +1 -1
- package/Mesher/Models/Common/QuadGeometryNode.js +2 -2
- package/Mesher/Models/Nodes/Custom/Liquid/LiquidGeomtryNode.js +7 -7
- package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.js +22 -25
- package/Mesher/Models/Nodes/Ruled/QuadVoxelGeometryNode.js +2 -2
- package/Mesher/Models/Nodes/Ruleless/RulelessBoxVoxelGeometryNode.js +2 -2
- package/Mesher/Models/Nodes/Ruleless/RulelessQuadVoxelGeometryNode.js +2 -2
- package/Mesher/Models/VoxelConstructor.d.ts +3 -3
- package/Mesher/Models/VoxelConstructor.js +8 -8
- package/Mesher/Models/VoxelGeometryBuilderCacheSpace.d.ts +2 -2
- package/Mesher/Models/VoxelGeometryBuilderCacheSpace.js +8 -9
- package/Mesher/Models/VoxelModelBuilder.js +1 -8
- package/Mesher/Types/Mesher.types.d.ts +1 -0
- package/Models/Defaults/CubeVoxelModels.js +16 -39
- package/Models/Defaults/LiquidVoxelModel.js +3 -3
- package/Models/Defaults/PanelVoxelModels.js +10 -36
- package/Models/Defaults/StairVoxelModel.js +6 -21
- package/Models/Examples.js +23 -44
- package/Models/Rules/Classes/VoxelRulesModel.d.ts +1 -1
- package/Models/Rules/Classes/VoxelRulesModel.js +3 -3
- package/Models/Rules/Functions/BuildFinalInputs.d.ts +1 -1
- package/Models/Rules/Functions/BuildFinalInputs.js +13 -13
- package/Models/Rules/VoxelModelRuleBuilderRegister.js +8 -8
- package/Models/VoxelModel.types.d.ts +3 -3
- package/Renderer/Classes/DVESectionMeshes.d.ts +2 -3
- package/Renderer/InitTasks.js +1 -9
- package/Renderer/MeshManager.d.ts +1 -1
- package/Renderer/MeshManager.js +24 -23
- package/Renderer/MeshRegister.d.ts +5 -5
- package/Renderer/MeshRegister.js +2 -2
- package/Settings/EngineSettings.d.ts +1 -0
- package/Settings/EngineSettings.js +6 -3
- package/Settings/EngineSettings.types.d.ts +7 -21
- package/Settings/EngineSettings.types.js +6 -14
- package/Tasks/Logic/InitTasks.d.ts +1 -0
- package/Tasks/Logic/InitTasks.js +10 -0
- package/Tasks/Logic/VoxelLogicUpdate.d.ts +3 -0
- package/Tasks/Logic/VoxelLogicUpdate.js +71 -0
- package/Tasks/Propagation/Explosion/ExplosionManager.d.ts +2 -2
- package/Tasks/Propagation/Explosion/ExplosionManager.js +1 -2
- package/Tasks/Propagation/Flow/FlowManager.d.ts +4 -4
- package/Tasks/Propagation/Flow/FlowRemove.d.ts +2 -2
- package/Tasks/Propagation/Flow/FlowUpdate.d.ts +2 -2
- package/Tasks/Propagation/Flow/WorldFlow.d.ts +2 -2
- package/Tasks/Propagation/Illumanation/RGBUpdate.d.ts +3 -3
- package/Tasks/Propagation/Illumanation/SunUpdate.d.ts +3 -3
- package/Tasks/Propagation/Illumanation/WorldRGB.d.ts +2 -2
- package/Tasks/Propagation/Illumanation/WorldSun.d.ts +2 -2
- package/Tasks/Propagation/Illumanation/WorldSun.js +8 -15
- package/Tasks/Propagation/InitTasks.js +4 -4
- package/Tasks/Propagation/Power/PowerUpdate.d.ts +3 -0
- package/Tasks/Propagation/Power/PowerUpdate.js +80 -0
- package/Tasks/Tasks.types.d.ts +2 -2
- package/Tasks/TasksIds.d.ts +2 -1
- package/Tasks/TasksIds.js +1 -0
- package/Tasks/Update/Common.d.ts +3 -0
- package/Tasks/Update/Common.js +41 -0
- package/Tasks/Update/EreaseUpdate.d.ts +3 -0
- package/Tasks/Update/EreaseUpdate.js +66 -0
- package/Tasks/Update/InitTasks.d.ts +2 -2
- package/Tasks/Update/InitTasks.js +3 -1
- package/Tasks/Update/PaintUpdate.d.ts +3 -0
- package/Tasks/Update/PaintUpdate.js +89 -0
- package/Tasks/Update/VoxelUpdate.d.ts +2 -5
- package/Tasks/Update/VoxelUpdate.js +5 -147
- package/Tasks/{Update/UpdateTask.d.ts → VoxelUpdateTask.d.ts} +15 -7
- package/Tasks/{Update/UpdateTask.js → VoxelUpdateTask.js} +20 -7
- package/Tasks/WorldGeneration/WorldGenBrush.d.ts +3 -3
- package/Tasks/WorldGeneration/WorldGenBrush.js +2 -2
- package/Tasks/WorldGeneration/WorldGenRegister.d.ts +1 -1
- package/Templates/Functions/CreateTemplate.d.ts +1 -1
- package/Tools/Brush/AdvancedBrushTool.js +1 -1
- package/Tools/Brush/Brush.d.ts +2 -2
- package/Tools/Brush/Brush.js +1 -1
- package/Tools/Tasks/TasksTool.d.ts +1 -0
- package/Tools/Tasks/TasksTool.js +2 -0
- package/Util/Binary/BinaryBuffer.d.ts +17 -11
- package/Util/Binary/BinaryBuffer.js +65 -59
- package/Util/Binary/BinaryTree.d.ts +46 -0
- package/Util/Binary/BinaryTree.js +104 -0
- package/Voxels/Cursor/VoxelCursor.interface.d.ts +7 -2
- package/Voxels/Cursor/VoxelCursor.interface.js +46 -2
- package/Voxels/Cursor/VoxelLightData.js +1 -1
- package/Voxels/Data/VoxelTag.types.d.ts +17 -2
- package/Voxels/Data/VoxelTag.types.js +6 -1
- package/Voxels/Data/VoxelTagsRegister.js +5 -0
- package/Voxels/Functions/BuildStateData.d.ts +6 -6
- package/Voxels/Functions/BuildStateData.js +31 -31
- package/Voxels/Functions/BuildTagAndPaletteData.js +5 -0
- package/Voxels/Indexes/VoxelIndex.d.ts +2 -2
- package/Voxels/Indexes/VoxelIndex.js +16 -18
- package/Voxels/InitVoxelData.js +12 -8
- package/Voxels/Logic/Classes/Default/Types/VoxelPoweredLogicType.d.ts +5 -0
- package/Voxels/Logic/Classes/Default/Types/VoxelPoweredLogicType.js +6 -0
- package/Voxels/Logic/Classes/VoxelLogic.d.ts +11 -0
- package/Voxels/Logic/Classes/VoxelLogic.js +49 -0
- package/Voxels/Logic/Classes/VoxelLogicType.d.ts +4 -0
- package/Voxels/Logic/Classes/VoxelLogicType.js +2 -0
- package/Voxels/Logic/VoxelLogic.types.d.ts +23 -0
- package/Voxels/Logic/VoxelLogic.types.js +1 -0
- package/Voxels/Logic/VoxelLogicRegister.d.ts +9 -0
- package/Voxels/Logic/VoxelLogicRegister.js +15 -0
- package/Voxels/State/SchemaRegister.js +10 -5
- package/Voxels/State/State.types.d.ts +1 -1
- package/Voxels/State/StateTreeReader.d.ts +1 -1
- package/Voxels/State/StateTreeReader.js +2 -3
- package/Voxels/Types/Voxel.types.d.ts +3 -0
- package/Voxels/Types/VoxelModelCompiledData.types.d.ts +6 -4
- package/World/Archive/Archive.types.d.ts +31 -12
- package/World/Archive/Classes/ArchiveClasses.d.ts +66 -0
- package/World/Archive/Classes/ArchiveClasses.js +78 -0
- package/World/Archive/Classes/ImportedSection.d.ts +40 -0
- package/World/Archive/Classes/ImportedSection.js +307 -0
- package/World/Archive/Classes/ImportedSector.d.ts +23 -0
- package/World/Archive/Classes/ImportedSector.js +97 -0
- package/World/Archive/Functions/ArchiveArea.d.ts +1 -1
- package/World/Archive/Functions/ArchiveArea.js +39 -36
- package/World/Archive/Functions/ArchiveSector.js +210 -404
- package/World/Archive/Functions/CreateArchivedSection.d.ts +3 -0
- package/World/Archive/Functions/CreateArchivedSection.js +207 -0
- package/World/Archive/Functions/ImportSector.d.ts +1 -3
- package/World/Archive/Functions/ImportSector.js +13 -244
- package/World/Archive/Functions/RemoveDuplicates.d.ts +3 -0
- package/World/Archive/Functions/RemoveDuplicates.js +92 -0
- package/World/Archive/Functions/Shared.d.ts +2 -2
- package/World/Archive/Functions/Shared.js +15 -40
- package/World/Archive/InitTasks.js +7 -10
- package/World/Cursor/SectionCursor.d.ts +1 -1
- package/World/Cursor/SectorCursor.d.ts +1 -1
- package/World/Cursor/WorldCursor.d.ts +4 -3
- package/World/Cursor/WorldCursor.js +16 -13
- package/World/Cursor/WorldVoxelCursor.d.ts +0 -4
- package/World/Cursor/WorldVoxelCursor.js +23 -14
- package/World/Dimension/Dimension.d.ts +4 -1
- package/World/Dimension/Dimension.js +8 -1
- package/World/Section/Section.d.ts +17 -4
- package/World/Section/Section.js +68 -6
- package/World/Section/SectionState.d.ts +4 -2
- package/World/Section/SectionState.js +4 -2
- package/World/Sector/Sector.d.ts +7 -1
- package/World/Sector/Sector.js +37 -4
- package/World/Sector/SectorState.d.ts +3 -2
- package/World/Sector/SectorState.js +3 -2
- package/World/Types/WorldData.types.d.ts +2 -7
- package/World/WorldRegister.d.ts +9 -9
- package/World/WorldRegister.js +9 -6
- package/World/WorldSpaces.js +6 -6
- package/{Tasks/IWG → WorldSimulation}/Internal/Classes/DimensionSegment.d.ts +2 -2
- package/{Tasks/IWG → WorldSimulation}/Internal/Classes/Generator.d.ts +6 -4
- package/{Tasks/IWG → WorldSimulation}/Internal/Classes/Generator.js +9 -5
- package/WorldSimulation/Internal/Classes/Queues/BuildQueue.d.ts +5 -0
- package/WorldSimulation/Internal/Classes/Queues/BuildQueue.js +6 -0
- package/WorldSimulation/Internal/Classes/Queues/LogiccQueue.d.ts +5 -0
- package/WorldSimulation/Internal/Classes/Queues/LogiccQueue.js +6 -0
- package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorVisistedMap.js +1 -1
- package/WorldSimulation/Internal/Classes/TickQueue.d.ts +12 -0
- package/{Tasks/IWG/Internal/Classes/BuildQueue.js → WorldSimulation/Internal/Classes/TickQueue.js} +16 -7
- package/WorldSimulation/Internal/Classes/WorldSimulationTaskBase.d.ts +15 -0
- package/{Tasks/IWG/Internal/Classes/IWGTaskBase.js → WorldSimulation/Internal/Classes/WorldSimulationTaskBase.js} +6 -6
- package/{Tasks/IWG → WorldSimulation}/Internal/Functions/cullSectors.js +9 -9
- package/{Tasks/IWG → WorldSimulation}/Internal/Functions/getSectorState.d.ts +1 -1
- package/{Tasks/IWG → WorldSimulation}/Internal/Functions/getSectorState.js +4 -4
- package/WorldSimulation/Internal/Functions/runTickUpdate.d.ts +2 -0
- package/{Tasks/IWG/Internal/Functions/runBuildUpdate.js → WorldSimulation/Internal/Functions/runTickUpdate.js} +29 -19
- package/{Tasks/IWG → WorldSimulation}/Internal/Functions/runWorldUpdate.js +13 -13
- package/{Tasks/IWG → WorldSimulation}/Internal/TaskRegister.d.ts +2 -2
- package/{Tasks/IWG → WorldSimulation}/Internal/TaskRegister.js +1 -1
- package/WorldSimulation/Internal/WorldSimulationDimensions.d.ts +6 -0
- package/{Tasks/IWG/Internal/IWGDimensions.js → WorldSimulation/Internal/WorldSimulationDimensions.js} +1 -1
- package/WorldSimulation/Internal/WorldSimulationTasks.d.ts +30 -0
- package/{Tasks/IWG/Internal/IWGTasks.js → WorldSimulation/Internal/WorldSimulationTasks.js} +14 -14
- package/WorldSimulation/Internal/WorldSimulationTools.d.ts +8 -0
- package/{Tasks/IWG/Internal/IWGTools.js → WorldSimulation/Internal/WorldSimulationTools.js} +1 -1
- package/{Tasks/IWG → WorldSimulation}/Procedures/InitalLoad.d.ts +1 -1
- package/{Tasks/IWG → WorldSimulation}/Procedures/InitalLoad.js +11 -11
- package/{Tasks/IWG → WorldSimulation}/Procedures/SaveAllSectors.js +5 -5
- package/{Tasks/IWG/IWG.d.ts → WorldSimulation/WorldSimulation.d.ts} +5 -5
- package/{Tasks/IWG/IWG.js → WorldSimulation/WorldSimulation.js} +21 -21
- package/{Tasks/IWG → WorldSimulation}/index.d.ts +1 -1
- package/{Tasks/IWG → WorldSimulation}/index.js +1 -1
- package/package.json +1 -1
- package/Tasks/IWG/Internal/Classes/BuildQueue.d.ts +0 -11
- package/Tasks/IWG/Internal/Classes/IWGTaskBase.d.ts +0 -15
- package/Tasks/IWG/Internal/Functions/runBuildUpdate.d.ts +0 -2
- package/Tasks/IWG/Internal/IWGDimensions.d.ts +0 -6
- package/Tasks/IWG/Internal/IWGTasks.d.ts +0 -30
- package/Tasks/IWG/Internal/IWGTools.d.ts +0 -8
- /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/DimensionSegment.js +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorState.d.ts +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorState.js +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorVisistedMap.d.ts +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Internal/Functions/cullSectors.d.ts +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Internal/Functions/runWorldUpdate.d.ts +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Procedures/SaveAllSectors.d.ts +0 -0
|
@@ -170,14 +170,14 @@ function buildSchemas(binaryNodes, relationNodes) {
|
|
|
170
170
|
}
|
|
171
171
|
export function BuildStateData(model, geoPalette) {
|
|
172
172
|
const data = model.data;
|
|
173
|
-
const { baseSchema, schemaIdPalette, schemaValuePalette } = buildSchemas(data.
|
|
173
|
+
const { baseSchema, schemaIdPalette, schemaValuePalette } = buildSchemas(data.stateSchema, data.relationsSchema);
|
|
174
174
|
const geometryLinkPalette = new StringPalette();
|
|
175
175
|
//maps geo link ids to geomtry ids
|
|
176
176
|
const geometryLinkStateMap = [];
|
|
177
177
|
const log = model.data.id == "dve_simple_stair";
|
|
178
178
|
//add geomtry from main shape states
|
|
179
|
-
for (const key in data.
|
|
180
|
-
const nodeData = data.
|
|
179
|
+
for (const key in data.stateNodes) {
|
|
180
|
+
const nodeData = data.stateNodes[key];
|
|
181
181
|
for (const node of nodeData) {
|
|
182
182
|
if (geometryLinkPalette.isRegistered(node.id))
|
|
183
183
|
continue;
|
|
@@ -186,8 +186,8 @@ export function BuildStateData(model, geoPalette) {
|
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
//add geomtry from condiotnal shape states
|
|
189
|
-
for (const key in data.
|
|
190
|
-
const nodeData = data.
|
|
189
|
+
for (const key in data.conditonalNodes) {
|
|
190
|
+
const nodeData = data.conditonalNodes[key];
|
|
191
191
|
for (const node of nodeData) {
|
|
192
192
|
if (geometryLinkPalette.isRegistered(node.id))
|
|
193
193
|
continue;
|
|
@@ -195,31 +195,31 @@ export function BuildStateData(model, geoPalette) {
|
|
|
195
195
|
geometryLinkStateMap[linkId] = geoPalette.getNumberId(VoxelModelRuleBuilderRegister.getGeometryLinkId(node));
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
|
-
const
|
|
198
|
+
const stateRelativeGeometryMap = [];
|
|
199
199
|
const relativeGeometryByteIndexMap = [];
|
|
200
200
|
//build state trees
|
|
201
|
-
const
|
|
202
|
-
const
|
|
203
|
-
const
|
|
201
|
+
const stateTree = new StateTreeNode("root");
|
|
202
|
+
const stateGeoLinkPalette = [];
|
|
203
|
+
const stateGeometryPalette = [];
|
|
204
204
|
let relativeGeoId = 0;
|
|
205
205
|
let relativeByteCount = 0;
|
|
206
|
-
const
|
|
207
|
-
for (const key in data.
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
const nodeData = data.
|
|
206
|
+
const stateRecord = {};
|
|
207
|
+
for (const key in data.stateNodes) {
|
|
208
|
+
stateGeoLinkPalette.push(data.stateNodes[key].map((_) => geometryLinkPalette.getNumberId(_.id)));
|
|
209
|
+
stateGeometryPalette.push(data.stateNodes[key].map((_) => geoPalette.getNumberId(VoxelModelRuleBuilderRegister.getGeometryLinkId(_))));
|
|
210
|
+
stateRecord[key] = stateGeometryPalette.length - 1;
|
|
211
|
+
stateRelativeGeometryMap[stateRecord[key]] ??= [];
|
|
212
|
+
const nodeData = data.stateNodes[key];
|
|
213
213
|
for (const node of nodeData) {
|
|
214
|
-
|
|
214
|
+
stateRelativeGeometryMap[stateRecord[key]][geoPalette.getNumberId(VoxelModelRuleBuilderRegister.getGeometryLinkId(node))] = relativeGeoId;
|
|
215
215
|
relativeGeometryByteIndexMap[relativeGeoId] = relativeByteCount;
|
|
216
216
|
relativeGeoId++;
|
|
217
217
|
relativeByteCount += Math.ceil(VoxelModelRuleBuilderRegister.getGeomtryFromLink(node).faceCount / 8);
|
|
218
218
|
}
|
|
219
|
-
addPathToTree(
|
|
219
|
+
addPathToTree(stateTree, key
|
|
220
220
|
.split(",")
|
|
221
221
|
.map((pair) => pair.split("="))
|
|
222
|
-
.flat(),
|
|
222
|
+
.flat(), stateGeoLinkPalette.length - 1);
|
|
223
223
|
}
|
|
224
224
|
const condiotnalShapeStateRelativeGeometryMap = [];
|
|
225
225
|
const condiotnalShapeStateNodePalette = [];
|
|
@@ -227,13 +227,13 @@ export function BuildStateData(model, geoPalette) {
|
|
|
227
227
|
const condiotnalShapeStateNodeRecord = {};
|
|
228
228
|
const condiotnalStatements = [];
|
|
229
229
|
const compareOperations = Object.keys(StateCompareOperationsMap);
|
|
230
|
-
for (const key in data.
|
|
231
|
-
condiotnalShapeStateNodePalette.push(data.
|
|
232
|
-
condiotnalShapeStateGeometryPalette.push(data.
|
|
230
|
+
for (const key in data.conditonalNodes) {
|
|
231
|
+
condiotnalShapeStateNodePalette.push(data.conditonalNodes[key].map((_) => geometryLinkPalette.getNumberId(_.id)));
|
|
232
|
+
condiotnalShapeStateGeometryPalette.push(data.conditonalNodes[key].map((_) => geoPalette.getNumberId(VoxelModelRuleBuilderRegister.getGeometryLinkId(_))));
|
|
233
233
|
condiotnalShapeStateNodeRecord[key] =
|
|
234
234
|
condiotnalShapeStateGeometryPalette.length - 1;
|
|
235
235
|
condiotnalShapeStateRelativeGeometryMap[condiotnalShapeStateNodeRecord[key]] ??= [];
|
|
236
|
-
const nodeData = data.
|
|
236
|
+
const nodeData = data.conditonalNodes[key];
|
|
237
237
|
for (const node of nodeData) {
|
|
238
238
|
condiotnalShapeStateRelativeGeometryMap[condiotnalShapeStateNodeRecord[key]][geoPalette.getNumberId(VoxelModelRuleBuilderRegister.getGeometryLinkId(node))] =
|
|
239
239
|
relativeGeoId;
|
|
@@ -290,9 +290,9 @@ export function BuildStateData(model, geoPalette) {
|
|
|
290
290
|
condiotanlStatePalette.push(newStateCombo);
|
|
291
291
|
condiotanlGeometryStatePalette.push(newGeoCombo);
|
|
292
292
|
}
|
|
293
|
-
const
|
|
293
|
+
const stateTreeData = stateTree.toJSON();
|
|
294
294
|
const newShapeStateTree = [];
|
|
295
|
-
reMapTree(schemaIdPalette, schemaValuePalette,
|
|
295
|
+
reMapTree(schemaIdPalette, schemaValuePalette, stateTreeData, newShapeStateTree, model.data.id);
|
|
296
296
|
const modelEffects = [];
|
|
297
297
|
const tagEffects = [];
|
|
298
298
|
if (model.data.effects) {
|
|
@@ -358,21 +358,21 @@ export function BuildStateData(model, geoPalette) {
|
|
|
358
358
|
const finalData = {
|
|
359
359
|
schema: baseSchema,
|
|
360
360
|
effects: modelEffects,
|
|
361
|
-
|
|
361
|
+
stateGeometryPalette: stateGeometryPalette,
|
|
362
362
|
condiotnalShapeStateGeometryPalette,
|
|
363
|
-
|
|
363
|
+
stateTree: newShapeStateTree,
|
|
364
364
|
geometryLinkPalette: geometryLinkPalette._map,
|
|
365
365
|
geometryLinkStateMap,
|
|
366
366
|
relativeByteCount,
|
|
367
|
-
|
|
368
|
-
|
|
367
|
+
statePalette: stateGeoLinkPalette,
|
|
368
|
+
stateRecord: stateRecord,
|
|
369
369
|
condiotnalNodeStateTree,
|
|
370
370
|
condiotnalStatements,
|
|
371
|
-
|
|
371
|
+
condiotnalStatePalette: condiotnalShapeStateNodePalette,
|
|
372
372
|
condiotnalShapeStateRecord: condiotnalShapeStateNodeRecord,
|
|
373
373
|
condiotanlStatePalette,
|
|
374
374
|
condiotanlGeometryStatePalette,
|
|
375
|
-
|
|
375
|
+
stateRelativeGeometryMap: stateRelativeGeometryMap,
|
|
376
376
|
relativeGeometryByteIndexMap,
|
|
377
377
|
condiotnalShapeStateRelativeGeometryMap,
|
|
378
378
|
};
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { VoxelTagsRegister } from "../Data/VoxelTagsRegister";
|
|
2
2
|
import { VoxelPalettesRegister } from "../Data/VoxelPalettesRegister";
|
|
3
3
|
export function BuildTagAndPaletteData(props) {
|
|
4
|
+
const logic = {};
|
|
4
5
|
for (const voxel of props.voxels) {
|
|
5
6
|
const tags = {};
|
|
6
7
|
const voxelId = VoxelPalettesRegister.voxels.register(voxel.id);
|
|
7
8
|
VoxelPalettesRegister.voxelIdToNameMap.set(voxel.id, voxel.name || "");
|
|
8
9
|
VoxelPalettesRegister.voxelNametoIdMap.set(voxel.name || voxel.id, voxel.id);
|
|
10
|
+
if (voxel.properties["dve_logic_data"]) {
|
|
11
|
+
logic[voxel.id] = voxel.properties["dve_logic_data"];
|
|
12
|
+
}
|
|
9
13
|
for (const tag of VoxelTagsRegister.IncludedVoxelTags) {
|
|
10
14
|
if (voxel.properties[tag] === undefined) {
|
|
11
15
|
tags[tag] = VoxelTagsRegister.VoxelTagDefaults[tag] || false;
|
|
@@ -41,6 +45,7 @@ export function BuildTagAndPaletteData(props) {
|
|
|
41
45
|
}
|
|
42
46
|
return {
|
|
43
47
|
data: {
|
|
48
|
+
logic,
|
|
44
49
|
palette: VoxelPalettesRegister.voxels._palette,
|
|
45
50
|
tags: VoxelTagsRegister.VoxelTags,
|
|
46
51
|
idToNameMap: [...VoxelPalettesRegister.voxelIdToNameMap.entries()],
|
|
@@ -7,8 +7,8 @@ export declare class VoxelNamedState {
|
|
|
7
7
|
compiled: {
|
|
8
8
|
mod: number;
|
|
9
9
|
modAny: boolean;
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
state: number;
|
|
11
|
+
stateAny: boolean;
|
|
12
12
|
};
|
|
13
13
|
constructor(voxelId: string, data: VoxelNamedStateData);
|
|
14
14
|
getPaintData(): PaintVoxelData;
|
|
@@ -8,8 +8,8 @@ export class VoxelNamedState {
|
|
|
8
8
|
compiled = {
|
|
9
9
|
mod: 0,
|
|
10
10
|
modAny: false,
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
state: 0,
|
|
12
|
+
stateAny: false,
|
|
13
13
|
};
|
|
14
14
|
constructor(voxelId, data) {
|
|
15
15
|
this.voxelId = voxelId;
|
|
@@ -20,10 +20,10 @@ export class VoxelNamedState {
|
|
|
20
20
|
if (SchemaRegister.voxelModSchemaData.has(this.voxelId)) {
|
|
21
21
|
const schema = SchemaRegister.getVoxelSchemas(this.voxelId);
|
|
22
22
|
if (this.data.state == "*") {
|
|
23
|
-
this.compiled.
|
|
23
|
+
this.compiled.stateAny = true;
|
|
24
24
|
}
|
|
25
25
|
else if (this.data.state) {
|
|
26
|
-
this.compiled.
|
|
26
|
+
this.compiled.state = schema.state.readString(this.data.state);
|
|
27
27
|
}
|
|
28
28
|
if (this.data.mod == "*") {
|
|
29
29
|
this.compiled.modAny = true;
|
|
@@ -34,7 +34,7 @@ export class VoxelNamedState {
|
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
36
36
|
this.compiled.modAny = true;
|
|
37
|
-
this.compiled.
|
|
37
|
+
this.compiled.stateAny = true;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
getPaintData() {
|
|
@@ -43,7 +43,7 @@ export class VoxelNamedState {
|
|
|
43
43
|
id: this.voxelId,
|
|
44
44
|
level: 0,
|
|
45
45
|
levelState: 0,
|
|
46
|
-
state: this.compiled.
|
|
46
|
+
state: this.compiled.state,
|
|
47
47
|
mod: this.compiled.mod,
|
|
48
48
|
});
|
|
49
49
|
}
|
|
@@ -108,25 +108,23 @@ export class VoxelIndex {
|
|
|
108
108
|
const conatiner = this.states.get(data.id);
|
|
109
109
|
if (!conatiner)
|
|
110
110
|
return false;
|
|
111
|
-
const { mod, state
|
|
112
|
-
for (const
|
|
113
|
-
if ((mod ==
|
|
114
|
-
(
|
|
115
|
-
|
|
116
|
-
return state;
|
|
111
|
+
const { mod, state } = data;
|
|
112
|
+
for (const modelState of conatiner?.stateArray) {
|
|
113
|
+
if ((mod == modelState.compiled.mod || modelState.compiled.modAny) &&
|
|
114
|
+
(state == modelState.compiled.state || modelState.compiled.stateAny))
|
|
115
|
+
return modelState;
|
|
117
116
|
}
|
|
118
117
|
return false;
|
|
119
118
|
}
|
|
120
119
|
getStateFromRawData(data) {
|
|
121
|
-
const [id, light,
|
|
120
|
+
const [id, light, state, secondary, mod] = data;
|
|
122
121
|
const conatiner = this.states.get(VoxelPalettesRegister.voxels.getStringId(id));
|
|
123
122
|
if (!conatiner)
|
|
124
123
|
return false;
|
|
125
|
-
for (const
|
|
126
|
-
if ((mod ==
|
|
127
|
-
(
|
|
128
|
-
|
|
129
|
-
return state;
|
|
124
|
+
for (const modelState of conatiner?.stateArray) {
|
|
125
|
+
if ((mod == modelState.compiled.mod || modelState.compiled.modAny) &&
|
|
126
|
+
(state == modelState.compiled.state || modelState.compiled.stateAny))
|
|
127
|
+
return modelState;
|
|
130
128
|
}
|
|
131
129
|
return false;
|
|
132
130
|
}
|
package/Voxels/InitVoxelData.js
CHANGED
|
@@ -16,6 +16,7 @@ import { CacheManager } from "../Cache/CacheManager";
|
|
|
16
16
|
import { VoxelLightData } from "./Cursor/VoxelLightData";
|
|
17
17
|
import { VoxelTagIds } from "./Data/VoxelTag.types";
|
|
18
18
|
import { BuildTagAndPaletteData } from "./Functions/BuildTagAndPaletteData";
|
|
19
|
+
import { VoxelLogicRegister } from "./Logic/VoxelLogicRegister";
|
|
19
20
|
function GetModelData(data) {
|
|
20
21
|
if (CacheManager.cacheLoadEnabled && CacheManager.cachedData) {
|
|
21
22
|
const syncData = CacheManager.cachedData.models;
|
|
@@ -74,15 +75,15 @@ function GetModelData(data) {
|
|
|
74
75
|
effects: stateData.effects,
|
|
75
76
|
schema: stateData.schema,
|
|
76
77
|
geoLinkMap: stateData.geometryLinkStateMap,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
stateMap: stateData.statePalette,
|
|
79
|
+
stateGeometryMap: stateData.stateGeometryPalette,
|
|
80
|
+
stateTree: stateData.stateTree,
|
|
80
81
|
condiotnalStateTree: stateData.condiotnalNodeStateTree,
|
|
81
82
|
condiotnalStatements: stateData.condiotnalStatements,
|
|
82
|
-
condiotnalStateMap: stateData.
|
|
83
|
+
condiotnalStateMap: stateData.condiotnalStatePalette,
|
|
83
84
|
condiotnalShapeStateMap: stateData.condiotanlStatePalette,
|
|
84
85
|
condiotnalShapeStateGeometryMap: stateData.condiotanlGeometryStatePalette,
|
|
85
|
-
|
|
86
|
+
stateRelativeGeometryMap: stateData.stateRelativeGeometryMap,
|
|
86
87
|
relativeGeometryByteIndexMap: stateData.relativeGeometryByteIndexMap,
|
|
87
88
|
condiotnalShapeStateRelativeGeometryMap: stateData.condiotnalShapeStateRelativeGeometryMap,
|
|
88
89
|
});
|
|
@@ -91,8 +92,8 @@ function GetModelData(data) {
|
|
|
91
92
|
BuildGeomtryInputs(geometry);
|
|
92
93
|
} */
|
|
93
94
|
for (const [mainKey, model] of VoxelModelRuleBuilderRegister.models) {
|
|
94
|
-
const {
|
|
95
|
-
for (const v in
|
|
95
|
+
const { stateVoxelInputs, conditionalShapeStateVoxelInputs, transparentVoxelFaceIndexes, } = BuildFinalInputs(model);
|
|
96
|
+
for (const v in stateVoxelInputs) {
|
|
96
97
|
const stateData = model.voxelModData.get(v);
|
|
97
98
|
SchemaRegister.registerVoxel(v, mainKey, stateData.modSchema);
|
|
98
99
|
syncData.voxels.push({
|
|
@@ -102,7 +103,7 @@ function GetModelData(data) {
|
|
|
102
103
|
transparentFaceIndex: transparentVoxelFaceIndexes[v].data,
|
|
103
104
|
modSchema: stateData.modSchema,
|
|
104
105
|
modStateTree: stateData.modStateTree,
|
|
105
|
-
baseGeometryInputMap:
|
|
106
|
+
baseGeometryInputMap: stateVoxelInputs[v],
|
|
106
107
|
condiotnalGeometryInputMap: conditionalShapeStateVoxelInputs[v],
|
|
107
108
|
});
|
|
108
109
|
}
|
|
@@ -243,6 +244,9 @@ export function InitVoxelData(data) {
|
|
|
243
244
|
materials,
|
|
244
245
|
});
|
|
245
246
|
let models = GetModelData(data);
|
|
247
|
+
for (const id in voxelData.data.logic) {
|
|
248
|
+
VoxelLogicRegister.register(id, voxelData.data.logic[id]);
|
|
249
|
+
}
|
|
246
250
|
return {
|
|
247
251
|
models,
|
|
248
252
|
...voxelData,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { VoxelCursorInterface } from "../../Cursor/VoxelCursor.interface";
|
|
2
|
+
import { VoxelLogicData } from "../VoxelLogic.types";
|
|
3
|
+
import { VoxelLogicType } from "./VoxelLogicType";
|
|
4
|
+
export declare class VoxelLogic {
|
|
5
|
+
types: VoxelLogicType[];
|
|
6
|
+
effectedTags: Map<string, VoxelLogicType[]>;
|
|
7
|
+
constructor(data: VoxelLogicData[]);
|
|
8
|
+
getTagValue(tagId: string, cursor: VoxelCursorInterface): any;
|
|
9
|
+
registerEffectOnTag(tagId: string, effect: VoxelLogicType): void;
|
|
10
|
+
hasTag(tag: string): boolean;
|
|
11
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { VoxelLogicRegister } from "../VoxelLogicRegister";
|
|
2
|
+
export class VoxelLogic {
|
|
3
|
+
types = [];
|
|
4
|
+
effectedTags = new Map();
|
|
5
|
+
constructor(data) {
|
|
6
|
+
for (const type of data) {
|
|
7
|
+
const logicType = VoxelLogicRegister.types.get(type.type);
|
|
8
|
+
this.types.push(logicType);
|
|
9
|
+
if (type.type == "powered") {
|
|
10
|
+
for (const effect of type.on)
|
|
11
|
+
if (effect.type == "tag")
|
|
12
|
+
this.registerEffectOnTag(effect.tagId, logicType);
|
|
13
|
+
for (const effect of type.off)
|
|
14
|
+
if (effect.type == "tag")
|
|
15
|
+
this.registerEffectOnTag(effect.tagId, logicType);
|
|
16
|
+
}
|
|
17
|
+
if (type.type == "state") {
|
|
18
|
+
for (const effect of type.true)
|
|
19
|
+
if (effect.type == "tag")
|
|
20
|
+
this.registerEffectOnTag(effect.tagId, logicType);
|
|
21
|
+
for (const effect of type.false)
|
|
22
|
+
if (effect.type == "tag")
|
|
23
|
+
this.registerEffectOnTag(effect.tagId, logicType);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
getTagValue(tagId, cursor) {
|
|
28
|
+
let effects = this.effectedTags.get(tagId);
|
|
29
|
+
if (!effects)
|
|
30
|
+
return null;
|
|
31
|
+
let finalValue = null;
|
|
32
|
+
for (let i = 0; i < effects.length; i++) {
|
|
33
|
+
const effect = effects[i];
|
|
34
|
+
finalValue = effect.run(cursor);
|
|
35
|
+
}
|
|
36
|
+
return finalValue;
|
|
37
|
+
}
|
|
38
|
+
registerEffectOnTag(tagId, effect) {
|
|
39
|
+
let effects = this.effectedTags.get(tagId);
|
|
40
|
+
if (!effects) {
|
|
41
|
+
effects = [];
|
|
42
|
+
this.effectedTags.set(tagId, effects);
|
|
43
|
+
}
|
|
44
|
+
effects.push(effect);
|
|
45
|
+
}
|
|
46
|
+
hasTag(tag) {
|
|
47
|
+
return this.effectedTags.has(tag);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type VoxelLogicEffects = {
|
|
2
|
+
type: "tag";
|
|
3
|
+
tagId: string;
|
|
4
|
+
value: any;
|
|
5
|
+
} | {
|
|
6
|
+
type: "state";
|
|
7
|
+
key: string;
|
|
8
|
+
value: string | number;
|
|
9
|
+
} | {
|
|
10
|
+
type: "mod";
|
|
11
|
+
key: string;
|
|
12
|
+
value: string | number;
|
|
13
|
+
};
|
|
14
|
+
export type VoxelLogicData = {
|
|
15
|
+
type: "powered";
|
|
16
|
+
on: VoxelLogicEffects[];
|
|
17
|
+
off: VoxelLogicEffects[];
|
|
18
|
+
} | {
|
|
19
|
+
type: "state";
|
|
20
|
+
value: string;
|
|
21
|
+
true: VoxelLogicEffects[];
|
|
22
|
+
false: VoxelLogicEffects[];
|
|
23
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { VoxelLogic } from "./Classes/VoxelLogic";
|
|
2
|
+
import { VoxelLogicData } from "./VoxelLogic.types";
|
|
3
|
+
import { VoxelLogicType } from "./Classes/VoxelLogicType";
|
|
4
|
+
export declare class VoxelLogicRegister {
|
|
5
|
+
static voxels: VoxelLogic[];
|
|
6
|
+
static types: Map<string, VoxelLogicType>;
|
|
7
|
+
static register(id: string, logicData: VoxelLogicData[]): void;
|
|
8
|
+
static registerType(id: string, logic: VoxelLogicType): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { VoxelPalettesRegister } from "../../Voxels/Data/VoxelPalettesRegister";
|
|
2
|
+
import { VoxelLogic } from "./Classes/VoxelLogic";
|
|
3
|
+
import { VoxelPoweredLogicType } from "./Classes/Default/Types/VoxelPoweredLogicType";
|
|
4
|
+
export class VoxelLogicRegister {
|
|
5
|
+
static voxels = [];
|
|
6
|
+
static types = new Map();
|
|
7
|
+
static register(id, logicData) {
|
|
8
|
+
const voxelId = VoxelPalettesRegister.voxels.getNumberId(id);
|
|
9
|
+
this.voxels[voxelId] = new VoxelLogic(logicData);
|
|
10
|
+
}
|
|
11
|
+
static registerType(id, logic) {
|
|
12
|
+
this.types.set(id, logic);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
VoxelLogicRegister.registerType("powered", new VoxelPoweredLogicType());
|
|
@@ -9,7 +9,12 @@ export class SchemaRegister {
|
|
|
9
9
|
static voxelModelMap = new Map();
|
|
10
10
|
static voxelSchemas = new Map();
|
|
11
11
|
static hasVoxelSchema(voxelId) {
|
|
12
|
-
|
|
12
|
+
if (this.voxelSchemas.has(voxelId))
|
|
13
|
+
return true;
|
|
14
|
+
if (this.modelStateSchemaData.has(this.voxelModelMap.get(voxelId) || "") &&
|
|
15
|
+
this.voxelModSchemaData.has(voxelId))
|
|
16
|
+
return true;
|
|
17
|
+
return false;
|
|
13
18
|
}
|
|
14
19
|
static getVoxelSchemas(voxelId) {
|
|
15
20
|
if (this.voxelSchemas.has(voxelId)) {
|
|
@@ -18,12 +23,12 @@ export class SchemaRegister {
|
|
|
18
23
|
const modelId = this.voxelModelMap.get(voxelId);
|
|
19
24
|
if (!modelId)
|
|
20
25
|
throw new Error(`Voxel ${voxelId} is not registered`);
|
|
21
|
-
let
|
|
22
|
-
if (!
|
|
26
|
+
let stateSchema = this.modelStaeSchemas.get(modelId);
|
|
27
|
+
if (!stateSchema) {
|
|
23
28
|
const schemaData = this.modelStateSchemaData.get(modelId);
|
|
24
29
|
if (!schemaData)
|
|
25
30
|
throw new Error(`Model ${modelId} is not registered`);
|
|
26
|
-
|
|
31
|
+
stateSchema = new BinarySchema(schemaData);
|
|
27
32
|
}
|
|
28
33
|
let modSchema = this.voxelModSchemas.get(voxelId);
|
|
29
34
|
if (!modSchema) {
|
|
@@ -32,7 +37,7 @@ export class SchemaRegister {
|
|
|
32
37
|
throw new Error(`Voxel ${voxelId} is not registered`);
|
|
33
38
|
modSchema = new BinarySchema(schemaData);
|
|
34
39
|
}
|
|
35
|
-
const voxelSchema = new VoxelSchema(voxelId,
|
|
40
|
+
const voxelSchema = new VoxelSchema(voxelId, stateSchema, modSchema);
|
|
36
41
|
this.voxelSchemas.set(voxelId, voxelSchema);
|
|
37
42
|
return voxelSchema;
|
|
38
43
|
}
|
|
@@ -8,15 +8,14 @@ export class StateTreeReader {
|
|
|
8
8
|
this.defaultValue = defaultValue;
|
|
9
9
|
this.tree = tree;
|
|
10
10
|
}
|
|
11
|
-
getState(
|
|
11
|
+
getState(state) {
|
|
12
12
|
if (!this.tree.length)
|
|
13
13
|
return this.defaultValue;
|
|
14
14
|
let found = -1;
|
|
15
15
|
let index = this.startingIndex;
|
|
16
16
|
let curretNode = this.tree;
|
|
17
17
|
while (found == -1) {
|
|
18
|
-
curretNode =
|
|
19
|
-
curretNode[index][this.schema.nodes[index].getValue(shapeState)];
|
|
18
|
+
curretNode = curretNode[index][this.schema.nodes[index].getValue(state)];
|
|
20
19
|
if (typeof curretNode == "number") {
|
|
21
20
|
return curretNode;
|
|
22
21
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { TextureId } from "../../Textures/index";
|
|
2
2
|
import { VoxelModelConstructorData } from "../../Models/VoxelModel.types";
|
|
3
3
|
import { VoxelTags } from "../Data/VoxelTag.types";
|
|
4
|
+
import { VoxelLogicData } from "../Logic/VoxelLogic.types";
|
|
4
5
|
export interface VoxelDataArrays {
|
|
5
6
|
/**The runtime numeric voxel ids */
|
|
6
7
|
ids: Uint16Array;
|
|
@@ -65,6 +66,8 @@ export type RawVoxelData = [
|
|
|
65
66
|
];
|
|
66
67
|
interface VoxelProperties extends Partial<VoxelTags> {
|
|
67
68
|
[key: string]: any;
|
|
69
|
+
/**Logic data for a the voxel */
|
|
70
|
+
dve_logic_data?: VoxelLogicData[];
|
|
68
71
|
/** Named states associated with the voxel. */
|
|
69
72
|
dve_named_states?: VoxelNamedStateData[];
|
|
70
73
|
/** Model data used to construct the voxel's appearance. */
|
|
@@ -7,8 +7,10 @@ import { VoxelGeometryData, VoxelGeometryNodes } from "../../Models/VoxelModel.t
|
|
|
7
7
|
import { VoxelEffectSyncData } from "../Effects/VoxelEffects.types";
|
|
8
8
|
import { VoxelTagStatesData } from "../Data/VoxelTagStates";
|
|
9
9
|
import { VoxelSubstanceTags, VoxelTags } from "../Data/VoxelTag.types";
|
|
10
|
+
import { VoxelLogicData } from "../../Voxels/Logic/VoxelLogic.types";
|
|
10
11
|
export type CompiledVoxelTagAndPaletteData = {
|
|
11
12
|
data: {
|
|
13
|
+
logic: Record<string, VoxelLogicData[]>;
|
|
12
14
|
tags: VoxelTags[];
|
|
13
15
|
palette: string[];
|
|
14
16
|
nameToIdMap: [string, string][];
|
|
@@ -60,10 +62,10 @@ export interface CompiledVoxelModelData {
|
|
|
60
62
|
schema: VoxelModelStateSchemaData[];
|
|
61
63
|
effects: VoxelEffectSyncData[];
|
|
62
64
|
geoLinkMap: number[];
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
stateTree: any[];
|
|
66
|
+
stateMap: number[][];
|
|
67
|
+
stateGeometryMap: number[][];
|
|
68
|
+
stateRelativeGeometryMap: number[][];
|
|
67
69
|
relativeGeometryByteIndexMap: number[];
|
|
68
70
|
condiotnalStatements: StateLogicStatement[];
|
|
69
71
|
condiotnalStateMap: number[][];
|