Merge pull request #109 from LucasDower/0.7.1

0.7.1 Hotfix
This commit is contained in:
Lucas Dower 2023-02-10 21:04:05 +00:00 committed by GitHub
commit ba161ad886
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 22 additions and 13 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "objtoschematic",
"version": "0.7.0",
"version": "0.7.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "objtoschematic",
"version": "0.7.0",
"version": "0.7.1",
"license": "BSD-3-Clause",
"dependencies": {
"bvh-tree": "^1.0.1",

View File

@ -1,7 +1,7 @@
{
"name": "objtoschematic",
"private": true,
"version": "0.7.0",
"version": "0.7.1",
"description": "A tool to convert .obj files into voxels and then into Minecraft Schematic files",
"main": "./dist/src/main.js",
"engines": {

View File

@ -1,5 +1,3 @@
import fs from 'fs';
import { Atlas, TAtlasBlock } from './atlas';
import { AtlasPalette, EFaceVisibility } from './block_assigner';
import { BlockInfo } from './block_atlas';
@ -163,8 +161,11 @@ export class BlockMesh {
ProgressManager.Get.progress(taskHandle, index / grassLikeBlocksBuffer.length);
const examined = grassLikeBlocksBuffer[index];
const examinedBlock = this._blocks[examined.id];
const topBlockId = this._blocks.findIndex((b) => b.voxel.position.equals(Vector3.add(examinedBlock.voxel.position, new Vector3(0, 1, 0))));
if (topBlockId > -1 && !AppRuntimeConstants.Get.TRANSPARENT_BLOCKS.includes(this._blocks[topBlockId].blockInfo.name)) {
const topBlockPosition = Vector3.add(examinedBlock.voxel.position, new Vector3(0, 1, 0));
const topBlockIndex = this._voxelMesh.getVoxelIndex(topBlockPosition);
if (topBlockIndex !== undefined && !AppRuntimeConstants.Get.TRANSPARENT_BLOCKS.includes(this._blocks[topBlockIndex].blockInfo.name)) {
const block = atlasPalette.getBlock(examined.voxelColour, nonGrassLikeBlockCollection, examined.faceVisibility, examined.errWeight);
examinedBlock.blockInfo = block;
this._blocks[examined.id] = examinedBlock;

View File

@ -41,7 +41,7 @@ export class AppConfig {
private constructor() {
this.RELEASE_MODE = true;
this.RELEASE_VERSION = '0.7.0r';
this.RELEASE_VERSION = '0.7.1r';
this.VOXEL_BUFFER_CHUNK_SIZE = 5_000;
const configFile = fs.readFileSync(PathUtil.join(AppPaths.Get.resources, 'config.json'), 'utf8');

View File

@ -53,9 +53,9 @@ export class AppRuntimeConstants {
this.TRANSPARENT_BLOCKS = JSON.parse(transparentBlocksString).transparent_blocks;
const emissiveBlocksString = fs.readFileSync(PathUtil.join(AppPaths.Get.resources, 'emissive_blocks.json'), 'utf-8');
this.GRASS_LIKE_BLOCKS = JSON.parse(emissiveBlocksString).emissive_blocks;
this.EMISSIVE_BLOCKS = JSON.parse(emissiveBlocksString).emissive_blocks;
const grassLikeBlocksString = fs.readFileSync(PathUtil.join(AppPaths.Get.resources, 'grass_like_blocks.json'), 'utf-8');
this.EMISSIVE_BLOCKS = JSON.parse(grassLikeBlocksString).grass_like_blocks;
this.GRASS_LIKE_BLOCKS = JSON.parse(grassLikeBlocksString).grass_like_blocks;
}
}

View File

@ -104,6 +104,14 @@ export class Texture {
}
}
private _correctTexcoord(a: number) {
if (Number.isInteger(a)) {
return a > 0.5 ? 1.0 : 0.0;
}
const frac = Math.abs(a) - Math.floor(Math.abs(a));
return a < 0.0 ? 1.0 - frac : frac;
}
/**
* UV can be in any range and is not limited to [0, 1]
*/
@ -114,13 +122,13 @@ export class Texture {
uv.u = clamp(inUV.u, 0.0, 1.0);
uv.v = clamp(inUV.v, 0.0, 1.0);
} else {
uv.u = Math.abs(inUV.u) - Math.floor(Math.abs(inUV.u));
uv.v = Math.abs(inUV.v) - Math.floor(Math.abs(inUV.v));
uv.u = this._correctTexcoord(inUV.u);
uv.v = this._correctTexcoord(inUV.v);
}
ASSERT(uv.u >= 0.0 && uv.u <= 1.0, 'Texcoord UV.u OOB');
ASSERT(uv.v >= 0.0 && uv.v <= 1.0, 'Texcoord UV.v OOB');
uv.v = 1.0 - uv.v;
const diffuse = (interpolation === 'nearest') ?
this._getNearestRGBA(this._image, uv) :
this._getLinearRGBA(this._image, uv);