Reorganise modules into two discrete packages
@ -1,4 +1,4 @@
|
||||
name: Build
|
||||
name: Build-Core
|
||||
on: push
|
||||
jobs:
|
||||
build:
|
||||
@ -6,6 +6,8 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install modules
|
||||
working-directory: ./Core
|
||||
run: npm ci
|
||||
- name: Run build
|
||||
working-directory: ./Core
|
||||
run: npm run build
|
||||
13
.github/workflows/build_editor.js.yml
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
name: Build-Editor
|
||||
on: push
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install modules
|
||||
working-directory: ./Editor
|
||||
run: npm ci
|
||||
- name: Run build
|
||||
working-directory: ./Editor
|
||||
run: npm run build
|
||||
@ -1,4 +1,4 @@
|
||||
name: Tests
|
||||
name: Tests-Core
|
||||
on: push
|
||||
jobs:
|
||||
build:
|
||||
@ -6,6 +6,8 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install modules
|
||||
working-directory: ./Core
|
||||
run: npm ci
|
||||
- name: Run tests
|
||||
working-directory: ./Core
|
||||
run: npm test
|
||||
13
.github/workflows/tests_editor.js.yml
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
name: Tests-Editor
|
||||
on: push
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install modules
|
||||
working-directory: ./Editor
|
||||
run: npm ci
|
||||
- name: Run tests
|
||||
working-directory: ./Editor
|
||||
run: npm test
|
||||
36
.gitignore
vendored
@ -1,25 +1,13 @@
|
||||
/node_modules
|
||||
ObjToSchematic-win32-x64
|
||||
ObjToSchematic-linux-x64
|
||||
ObjToSchematic-darwin-x64
|
||||
/res/atlases/*.atlas
|
||||
/res/atlases/*.png
|
||||
!/res/atlases/vanilla.atlas
|
||||
!/res/atlases/vanilla.png
|
||||
/res/palettes/empty.palette
|
||||
/dist
|
||||
/dev
|
||||
/gen
|
||||
/tools/blocks
|
||||
/tools/models
|
||||
/tests/out
|
||||
/tests/__mocks__
|
||||
/logs/
|
||||
/release/
|
||||
notes.txt
|
||||
# Common
|
||||
*.DS_Store
|
||||
dependencygraph.svg
|
||||
.firebase
|
||||
/webpack/
|
||||
.firebaserc
|
||||
dependencies.jpg
|
||||
|
||||
# Core
|
||||
/Core/node_modules
|
||||
/Core/tests/out
|
||||
/Core/lib
|
||||
|
||||
# Editor
|
||||
/Editor/node_modules
|
||||
/Editor/.firebase
|
||||
/Editor/.firebaserc
|
||||
/Editor/webpack/
|
||||
3
Core/index.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export function testExport(x: number, y: number) {
|
||||
return x + y;
|
||||
}
|
||||
35
Core/package-lock.json
generated
Normal file
@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "ots-core",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "ots-core",
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"typescript": "^5.2.2"
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.2.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz",
|
||||
"integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==",
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.17"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"typescript": {
|
||||
"version": "5.2.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz",
|
||||
"integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w=="
|
||||
}
|
||||
}
|
||||
}
|
||||
19
Core/package.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "ots-core",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "lib/index.js",
|
||||
"directories": {
|
||||
"test": "tests"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"typescript": "^5.2.2"
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
import { RGBA } from '../runtime/colour';
|
||||
import { RGBA } from './colour';
|
||||
import { UV } from './util';
|
||||
|
||||
export interface TextureInfo {
|
||||
@ -1,7 +1,7 @@
|
||||
import { Atlas, TAtlasBlock } from '../runtime/atlas';
|
||||
import { AtlasPalette } from '../runtime/block_assigner';
|
||||
import { Atlas, TAtlasBlock } from './atlas';
|
||||
import { AtlasPalette } from './block_assigner';
|
||||
import { BlockInfo } from './block_atlas';
|
||||
import { RGBA_255, RGBAUtil } from '../runtime/colour';
|
||||
import { RGBA_255, RGBAUtil } from './colour';
|
||||
import { AppRuntimeConstants } from './constants';
|
||||
import { Ditherer } from './dither';
|
||||
import { BlockMeshLighting } from './lighting';
|
||||
@ -1,7 +1,5 @@
|
||||
import { TBrand } from './util/type_util';
|
||||
|
||||
const hsv_rgb = require('hsv-rgb');
|
||||
|
||||
export type RGBA = {
|
||||
r: number,
|
||||
g: number,
|
||||
@ -12,23 +10,58 @@ export type RGBA = {
|
||||
export type RGBA_255 = TBrand<RGBA, '255'>;
|
||||
|
||||
export namespace RGBAUtil {
|
||||
|
||||
export function toString(a: RGBA) {
|
||||
return `(${a.r}, ${a.g}, ${a.b}, ${a.a})`;
|
||||
}
|
||||
|
||||
// h: [0, 360], s: [0, 1], v: [0, 1]
|
||||
export function fromHSV(h: number, s: number, v: number): RGBA {
|
||||
const c = v * s;
|
||||
const x = c * (1 - Math.abs(((h / 60) % 2) - 1));
|
||||
const m = v - c;
|
||||
|
||||
let output = RGBAUtil.copy(RGBAColours.BLACK);
|
||||
if (h < 60) {
|
||||
output.r = c;
|
||||
output.g = x;
|
||||
output.b = 0;
|
||||
} else if (h < 120) {
|
||||
output.r = x;
|
||||
output.g = c;
|
||||
output.b = 0;
|
||||
} else if (h < 180) {
|
||||
output.r = 0;
|
||||
output.g = c;
|
||||
output.b = x;
|
||||
} else if (h < 240) {
|
||||
output.r = 0;
|
||||
output.g = x;
|
||||
output.b = c;
|
||||
} else if (h < 300) {
|
||||
output.r = x;
|
||||
output.g = 0;
|
||||
output.b = c;
|
||||
} else {
|
||||
output.r = c;
|
||||
output.g = 0;
|
||||
output.b = x;
|
||||
}
|
||||
|
||||
output.r += m;
|
||||
output.g += m;
|
||||
output.b += m;
|
||||
output.a = 1.0;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
export function randomPretty(): RGBA {
|
||||
const hue = Math.random() * 360;
|
||||
const sat = 65;
|
||||
const val = 85;
|
||||
const sat = 65/255;
|
||||
const val = 85/255;
|
||||
|
||||
const rgb: number[] = hsv_rgb(hue, sat, val);
|
||||
|
||||
return {
|
||||
r: rgb[0] / 255,
|
||||
g: rgb[1] / 255,
|
||||
b: rgb[2] / 255,
|
||||
a: 1.0,
|
||||
}
|
||||
return RGBAUtil.fromHSV(hue, sat, val);
|
||||
}
|
||||
|
||||
export function random(): RGBA {
|
||||
@ -1,4 +1,4 @@
|
||||
import { RGBA_255 } from '../runtime/colour';
|
||||
import { RGBA_255 } from './colour';
|
||||
import { ASSERT } from './util/error_util';
|
||||
import { Vector3 } from './vector';
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { NBT, TagType } from 'prismarine-nbt';
|
||||
|
||||
import { BLOCK_IDS } from '../../../res/block_ids';
|
||||
import { BLOCK_IDS } from '../../../Editor/res/block_ids';
|
||||
import { BlockMesh } from '../block_mesh';
|
||||
import { LOG_WARN } from '../util/log_util';
|
||||
import { saveNBT } from '../util/nbt_util';
|
||||
@ -1,5 +1,5 @@
|
||||
import { LinearAllocator } from '../src/runtime/linear_allocator';
|
||||
import { Vector3 } from '../src/runtime/vector';
|
||||
import { LinearAllocator } from '../src/linear_allocator';
|
||||
import { Vector3 } from '../src/vector';
|
||||
import { TEST_PREAMBLE } from './preamble';
|
||||
|
||||
test('RegExpBuilder', () => {
|
||||
@ -1,6 +1,6 @@
|
||||
import { OtS_VoxelMesh } from '../src/runtime/ots_voxel_mesh';
|
||||
import { ASSERT } from '../src/runtime/util/error_util';
|
||||
import { Vector3 } from '../src/runtime/vector';
|
||||
import { OtS_VoxelMesh } from '../src/ots_voxel_mesh';
|
||||
import { ASSERT } from '../src/util/error_util';
|
||||
import { Vector3 } from '../src/vector';
|
||||
|
||||
test('VoxelMesh #1', () => {
|
||||
const voxelMesh = new OtS_VoxelMesh();
|
||||
@ -1,6 +1,6 @@
|
||||
import { RGBAColours } from '../src/runtime/colour';
|
||||
import { OtS_VoxelMesh } from '../src/runtime/ots_voxel_mesh';
|
||||
import { OtS_FaceVisibility, OtS_VoxelMesh_Neighbourhood } from '../src/runtime/ots_voxel_mesh_neighbourhood';
|
||||
import { RGBAColours } from '../src/colour';
|
||||
import { OtS_VoxelMesh } from '../src/ots_voxel_mesh';
|
||||
import { OtS_FaceVisibility, OtS_VoxelMesh_Neighbourhood } from '../src/ots_voxel_mesh_neighbourhood';
|
||||
|
||||
test('VoxelMesh Neighbourhood #1', () => {
|
||||
const voxelMesh = new OtS_VoxelMesh();
|
||||
@ -1,7 +1,7 @@
|
||||
import fs from 'fs';
|
||||
|
||||
import { Logger } from '../src/runtime/util/log_util';
|
||||
import { AppPaths, PathUtil } from '../src/runtime/util/path_util';
|
||||
import { Logger } from '../src/util/log_util';
|
||||
import { AppPaths, PathUtil } from '../src/util/path_util';
|
||||
|
||||
export const TEST_PREAMBLE = () => {
|
||||
Logger.Get.disableLogToFile();
|
||||
@ -1,7 +1,7 @@
|
||||
import { Axes, Ray, rayIntersectTriangle } from '../src/runtime/ray';
|
||||
import { Triangle } from '../src/runtime/triangle';
|
||||
import { ASSERT } from '../src/runtime/util/error_util';
|
||||
import { Vector3 } from '../src/runtime/vector';
|
||||
import { Axes, Ray, rayIntersectTriangle } from '../src/ray';
|
||||
import { Triangle } from '../src/triangle';
|
||||
import { ASSERT } from '../src/util/error_util';
|
||||
import { Vector3 } from '../src/vector';
|
||||
import { TEST_PREAMBLE } from './preamble';
|
||||
|
||||
test('rayIntersectTriangle x-axis #1', () => {
|
||||
@ -1,6 +1,6 @@
|
||||
import { AppUtil } from '../src/runtime/util';
|
||||
import { ASSERT } from '../src/runtime/util/error_util';
|
||||
import { REGEX_NUMBER, REGEX_NZ_ANY, RegExpBuilder } from '../src/runtime/util/regex_util';
|
||||
import { AppUtil } from '../src/util';
|
||||
import { ASSERT } from '../src/util/error_util';
|
||||
import { REGEX_NUMBER, REGEX_NZ_ANY, RegExpBuilder } from '../src/util/regex_util';
|
||||
import { TEST_PREAMBLE } from './preamble';
|
||||
|
||||
test('RegExpBuilder', () => {
|
||||
@ -1,13 +1,13 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import { ObjImporter } from "../src/runtime/importers/obj_importer";
|
||||
import { OtS_VoxelMesh_Converter } from '../src/runtime/ots_voxel_mesh_converter';
|
||||
import { BlockMesh } from '../src/runtime/block_mesh';
|
||||
import { PALETTE_ALL_RELEASE } from '../res/palettes/all';
|
||||
import { ObjImporter } from "../src/importers/obj_importer";
|
||||
import { OtS_VoxelMesh_Converter } from '../src/ots_voxel_mesh_converter';
|
||||
import { BlockMesh } from '../src/block_mesh';
|
||||
import { PALETTE_ALL_RELEASE } from '../../Editor/res/palettes/all';
|
||||
import { createReadableStream, createOtSTexture } from './util';
|
||||
import { TexturedMaterial } from 'src/runtime/materials';
|
||||
import { ASSERT } from 'src/runtime/util/error_util';
|
||||
import { TexturedMaterial } from 'Core/src/materials';
|
||||
import { ASSERT } from 'Core/src/util/error_util';
|
||||
|
||||
(async () => {
|
||||
const pathModel = path.join(__dirname, '../res/samples/skull.obj');
|
||||
@ -3,9 +3,9 @@ import fs from 'fs';
|
||||
import path from 'path';
|
||||
import sharp from 'sharp';
|
||||
|
||||
import { ASSERT } from '../src/runtime/util/error_util';
|
||||
import { RGBAUtil } from '../src/runtime/colour';
|
||||
import { RGBA } from '../src/runtime/colour';
|
||||
import { ASSERT } from '../src/util/error_util';
|
||||
import { RGBAUtil } from '../src/colour';
|
||||
import { RGBA } from '../src/colour';
|
||||
|
||||
export function getAverageColour(image: Uint8ClampedArray): RGBA {
|
||||
let r = 0;
|
||||
@ -1,5 +1,5 @@
|
||||
import { PALETTE_ALL_RELEASE } from '../res/palettes/all';
|
||||
import { Vector3 } from '../src/runtime/vector';
|
||||
import { PALETTE_ALL_RELEASE } from '../../Editor/res/palettes/all';
|
||||
import { Vector3 } from '../src/vector';
|
||||
import { THeadlessConfig } from './headless';
|
||||
|
||||
export const headlessConfig: THeadlessConfig = {
|
||||
@ -1,7 +1,7 @@
|
||||
import { StatusHandler } from '../src/editor/status';
|
||||
import { LOG_MAJOR, Logger, TIME_END, TIME_START } from '../src/runtime/util/log_util';
|
||||
import { WorkerClient } from '../src/editor/worker/worker_client';
|
||||
import { AssignParams, ExportParams, ImportParams, VoxeliseParams } from '../src/editor/worker/worker_types';
|
||||
import { StatusHandler } from '../../Editor/src/status';
|
||||
import { LOG_MAJOR, Logger, TIME_END, TIME_START } from '../src/util/log_util';
|
||||
import { WorkerClient } from '../../Editor/src/worker/worker_client';
|
||||
import { AssignParams, ExportParams, ImportParams, VoxeliseParams } from '../../Editor/src/worker/worker_types';
|
||||
|
||||
export type THeadlessConfig = {
|
||||
import: ImportParams.Input,
|
||||
@ -1,5 +1,5 @@
|
||||
import { LOG_MAJOR } from '../src/runtime/util/log_util';
|
||||
import { AppPaths, PathUtil } from '../src/runtime/util/path_util';
|
||||
import { LOG_MAJOR } from '../src/util/log_util';
|
||||
import { AppPaths, PathUtil } from '../src/util/path_util';
|
||||
import { runHeadless } from './headless';
|
||||
import { headlessConfig } from './headless-config';
|
||||
|
||||
@ -2,7 +2,7 @@ import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { PNG } from 'pngjs';
|
||||
import { decode as jpegDecode } from 'jpeg-js';
|
||||
import { OtS_Texture } from 'src/runtime/ots_texture';
|
||||
import { OtS_Texture } from 'Core/src/ots_texture';
|
||||
|
||||
export function createReadableStream(p: fs.PathLike) {
|
||||
return new ReadableStream({
|
||||
15
Core/tsconfig.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": [ "es2022" ],
|
||||
"module": "commonjs",
|
||||
"target": "es2022",
|
||||
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
|
||||
"outDir": "lib"
|
||||
},
|
||||
"include": ["src/**/*", "index.ts"]
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
import { DeepPartial } from '../src/runtime/util/type_util';
|
||||
import { DeepPartial } from '../../Core/src/util/type_util';
|
||||
import { en_GB } from './en_GB';
|
||||
import { en_US } from './en_US';
|
||||
import { fr_FR } from './fr_FR';
|
||||
16
Editor/package.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "ots-editor",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"directories": {
|
||||
"test": "tests"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
||||
|
Before Width: | Height: | Size: 309 KiB After Width: | Height: | Size: 309 KiB |
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 1.6 MiB After Width: | Height: | Size: 1.6 MiB |
|
Before Width: | Height: | Size: 5.2 MiB After Width: | Height: | Size: 5.2 MiB |
|
Before Width: | Height: | Size: 537 KiB After Width: | Height: | Size: 537 KiB |