Comparing version 0.0.8 to 0.0.9
{ | ||
"name": "voxel-toy", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "Tool for converting .vox files to other useful formats", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
#!/usr/bin/env node | ||
const args = require("args"); | ||
const { splash, question, abolsutePath, changeExtension, readBuffer, writeText, matches } = require("./utils"); | ||
const { splash, question, abolsutePath, fileName, changeExtension, readBuffer, writeText, matches } = require("./utils"); | ||
const assert = require("assert"); | ||
@@ -28,3 +28,4 @@ const parseVoxels = require("vox-reader"); | ||
const voxelData = parseVoxels(voxBuffer); | ||
const t3dText = convertToT3D(voxelData, size, compress); | ||
const folderName = fileName(file); | ||
const t3dText = convertToT3D({ voxelData, size, compress, folderName }); | ||
const t3dFile = changeExtension(voxFile, ".t3d"); | ||
@@ -31,0 +32,0 @@ |
const _ = require("lodash"); | ||
const box = ({ x, y, z, offsetX, offsetY, offsetZ, name }) => { | ||
const box = ({ x, y, z, offsetX, offsetY, offsetZ, name, folderName }) => { | ||
return ` | ||
@@ -109,3 +109,3 @@ Begin Actor Class=Brush Name=${name} Archetype=Brush'/Script/Engine.Default__Brush' | ||
ActorLabel="${name}" | ||
FolderPath="VoxelToyGeometry" | ||
FolderPath="${folderName}" | ||
End Actor | ||
@@ -162,3 +162,3 @@ `; | ||
const convertToT3D = (voxelData, size = 200, compressionFlag = true) => { | ||
const convertToT3D = ({ voxelData, size = 200, compress: compressionFlag = true, folderName = "VoxelToyGeometry" } = {}) => { | ||
let voxels = voxelData.children.find(x => x.id == "XYZI").data.values; | ||
@@ -182,3 +182,4 @@ | ||
offsetZ: vox.sideZ * size * 0.5, | ||
name: `Box${idx}` | ||
name: `Box${idx}`, | ||
folderName | ||
}) | ||
@@ -185,0 +186,0 @@ ); |
@@ -35,2 +35,8 @@ const readline = require("readline"); | ||
const fileName = file => { | ||
const ext = path.extname(file); | ||
return path.basename(file, ext); | ||
}; | ||
const changeExtension = (file, newExt) => { | ||
@@ -68,2 +74,3 @@ const originalExt = path.extname(file); | ||
abolsutePath, | ||
fileName, | ||
changeExtension, | ||
@@ -70,0 +77,0 @@ readBuffer, |
15424
276