@divinevoxel/vlox 0.0.75 → 0.0.76
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/RayProvider.d.ts +6 -0
- package/Builder/RayProvider.js +1 -0
- package/Builder/Tools/Box/BoxSelection.d.ts +12 -0
- package/Builder/Tools/Box/BoxSelection.js +27 -0
- package/Builder/Tools/Box/BoxTool.d.ts +31 -0
- package/Builder/Tools/Box/BoxTool.js +91 -0
- package/Builder/Tools/Box/BoxToolTemplate.d.ts +13 -0
- package/Builder/Tools/Box/BoxToolTemplate.js +23 -0
- package/Builder/Tools/Brush/BrushTool.d.ts +48 -0
- package/Builder/Tools/Brush/BrushTool.js +146 -0
- package/Builder/Tools/BuilderToolBase.d.ts +3 -0
- package/Builder/Tools/BuilderToolBase.js +3 -0
- package/Builder/Tools/Hand/HandTool.d.ts +22 -0
- package/Builder/Tools/Hand/HandTool.js +56 -0
- package/Builder/Tools/Path/PahtTool.d.ts +29 -0
- package/Builder/Tools/Path/PahtTool.js +117 -0
- package/Builder/Tools/Wand/WandTool.d.ts +28 -0
- package/Builder/Tools/Wand/WandTool.js +67 -0
- package/Builder/Tools/Wrench/WrenchTool.d.ts +47 -0
- package/Builder/Tools/Wrench/WrenchTool.js +175 -0
- package/Builder/VoxelBuildSpace.d.ts +61 -0
- package/Builder/VoxelBuildSpace.js +165 -0
- package/Builder/VoxelBuilder.types.d.ts +0 -0
- package/Builder/VoxelBuilder.types.js +1 -0
- package/Builder/World/InitTasks.d.ts +1 -0
- package/Builder/World/InitTasks.js +134 -0
- package/Builder/World/VoxelBuildSpaceWorld.d.ts +4 -0
- package/Builder/World/VoxelBuildSpaceWorld.js +10 -0
- package/Contexts/Render/DivineVoxelEngineRender.d.ts +5 -5
- package/Contexts/World/DivineVoxelEngineWorld.d.ts +5 -5
- package/Mesher/Functions/Base/MeshSectionBase.js +3 -0
- package/Mesher/Functions/MeshVoxel.js +2 -0
- package/Mesher/Geomtry/VoxelMeshBVHBuilder.d.ts +2 -2
- package/Mesher/Models/Common/Calc/CalcConstants.d.ts +1 -1
- package/Mesher/Models/Procedures/Default/OutlinedTextureProcedure.js +8 -8
- package/Tasks/Paint/Erase/EraseVoxel.js +1 -1
- package/Tasks/Paint/Paint/PaintVoxel.js +1 -1
- package/Templates/Archive/ArchivedVoxelTemplate.d.ts +1 -0
- package/Templates/Archive/ArchivedVoxelTemplate.js +4 -0
- package/Templates/Archive/Functions/CreateArchivedTemplate.js +4 -2
- package/Templates/Cursor/TemplateCursor.js +3 -1
- package/Templates/Cursor/TemplateProxy.d.ts +1 -0
- package/Templates/Cursor/TemplateProxy.js +14 -0
- package/Templates/Full/FullVoxelTemplate.d.ts +1 -0
- package/Templates/Full/FullVoxelTemplate.js +4 -0
- package/Templates/Path/VoxelPath.d.ts +4 -0
- package/Templates/Path/VoxelPath.js +17 -0
- package/Templates/Path/VoxelPath.types.d.ts +1 -0
- package/Templates/Selection/VoxelBFSSelection.d.ts +3 -0
- package/Templates/Selection/VoxelBFSSelection.js +11 -0
- package/Templates/Selection/VoxelBoxSelection.d.ts +3 -0
- package/Templates/Selection/VoxelBoxSelection.js +11 -0
- package/Templates/Selection/VoxelPointSelection.d.ts +17 -0
- package/Templates/Selection/VoxelPointSelection.js +48 -0
- package/Templates/Selection/VoxelSelecton.d.ts +3 -0
- package/Templates/Selection/VoxelSurfaceSelection.d.ts +3 -0
- package/Templates/Selection/VoxelSurfaceSelection.js +18 -0
- package/Templates/Selection/VoxelTemplateSelection.d.ts +3 -0
- package/Templates/Selection/VoxelTemplateSelection.js +10 -0
- package/Templates/Shapes/BasicVoxelShapeTemplate.d.ts +1 -0
- package/Templates/Shapes/BoxVoxelTemplate.d.ts +1 -0
- package/Templates/Shapes/BoxVoxelTemplate.js +8 -0
- package/Templates/Shapes/ConeVoxelTemplate.d.ts +1 -0
- package/Templates/Shapes/ConeVoxelTemplate.js +4 -0
- package/Templates/Shapes/CylinderVoxelTemplate.d.ts +1 -0
- package/Templates/Shapes/CylinderVoxelTemplate.js +4 -0
- package/Templates/Shapes/EllipsoidVoxelTemplate.d.ts +23 -0
- package/Templates/Shapes/EllipsoidVoxelTemplate.js +89 -0
- package/Templates/Shapes/OctahedronVoxelTemplate.d.ts +1 -0
- package/Templates/Shapes/OctahedronVoxelTemplate.js +4 -0
- package/Templates/Shapes/PyramidVoxelTemplate.d.ts +1 -0
- package/Templates/Shapes/PyramidVoxelTemplate.js +8 -0
- package/Templates/Shapes/SphereVoxelTemplate.d.ts +3 -12
- package/Templates/Shapes/SphereVoxelTemplate.js +21 -59
- package/Templates/Shapes/TorusVoxelTemplate.d.ts +1 -0
- package/Templates/Shapes/TorusVoxelTemplate.js +4 -0
- package/Templates/Shapes/VoxelShapeTemplate.types.d.ts +2 -0
- package/Templates/Shapes/VoxelShapeTemplate.types.js +6 -1
- package/Templates/VoxelTemplates.types.d.ts +1 -0
- package/Textures/Classes/TextureAnimationTexture.d.ts +1 -1
- package/Util/BinaryBuffer/Functions/BinaryBufferConvert.d.ts +1 -1
- package/Util/BinaryBuffer/Functions/BinaryBufferToTypedArray.d.ts +1 -1
- package/Util/LocationData.d.ts +1 -1
- package/Voxels/Cursor/VoxelCursor.interface.d.ts +2 -0
- package/Voxels/Cursor/VoxelCursor.interface.js +2 -0
- package/Voxels/Interaction/Functions/PickVoxelWorld.js +15 -43
- package/Voxels/Interaction/VoxelPickResult.d.ts +1 -0
- package/Voxels/Interaction/VoxelPickResult.js +3 -0
- package/Voxels/State/Schema/BinarySchemaNode.d.ts +2 -1
- package/Voxels/State/Schema/BinarySchemaNode.js +5 -2
- package/Voxels/State/Schema/Conditions/SameVoxelConditions.js +2 -0
- package/Voxels/Types/PaintVoxelData.d.ts +11 -1
- package/Voxels/Types/PaintVoxelData.js +100 -14
- package/World/Archive/Functions/Shared/LightSegments.d.ts +1 -1
- package/World/Sector/Sector.d.ts +1 -1
- package/WorldSimulation/Dimensions/SimulationSector.d.ts +1 -1
- package/package.json +1 -1
|
@@ -31,26 +31,26 @@ export declare class DivineVoxelEngineRender {
|
|
|
31
31
|
getSettingsCopy(): any;
|
|
32
32
|
createEventListener<K extends "synced">(type: K, listener: EventListenerObject | ((event: CustomEvent<{
|
|
33
33
|
synced: {
|
|
34
|
-
settings: any;
|
|
34
|
+
settings: /*elided*/ any;
|
|
35
35
|
};
|
|
36
36
|
}[K]>) => void) | null): EventListenerObject | ((event: CustomEvent<{
|
|
37
37
|
synced: {
|
|
38
|
-
settings: any;
|
|
38
|
+
settings: /*elided*/ any;
|
|
39
39
|
};
|
|
40
40
|
}[K]>) => void) | null;
|
|
41
41
|
addEventListener<K extends "synced">(type: K, listener: EventListenerObject | ((event: CustomEvent<{
|
|
42
42
|
synced: {
|
|
43
|
-
settings: any;
|
|
43
|
+
settings: /*elided*/ any;
|
|
44
44
|
};
|
|
45
45
|
}[K]>) => void) | null, options?: AddEventListenerOptions): void;
|
|
46
46
|
removeEventListener<K extends "synced">(type: K, listener: EventListenerObject | ((event: CustomEvent<{
|
|
47
47
|
synced: {
|
|
48
|
-
settings: any;
|
|
48
|
+
settings: /*elided*/ any;
|
|
49
49
|
};
|
|
50
50
|
}[K]>) => void) | null): void;
|
|
51
51
|
dispatch<K extends "synced">(type: K, detail: {
|
|
52
52
|
synced: {
|
|
53
|
-
settings: any;
|
|
53
|
+
settings: /*elided*/ any;
|
|
54
54
|
};
|
|
55
55
|
}[K]): boolean;
|
|
56
56
|
dispatchEvent(event: Event): boolean;
|
|
@@ -22,26 +22,26 @@ export declare class DivineVoxelEngineWorld {
|
|
|
22
22
|
getSettingsCopy(): any;
|
|
23
23
|
createEventListener<K extends "synced">(type: K, listener: EventListenerObject | ((event: CustomEvent<{
|
|
24
24
|
synced: {
|
|
25
|
-
settings: any;
|
|
25
|
+
settings: /*elided*/ any;
|
|
26
26
|
};
|
|
27
27
|
}[K]>) => void) | null): EventListenerObject | ((event: CustomEvent<{
|
|
28
28
|
synced: {
|
|
29
|
-
settings: any;
|
|
29
|
+
settings: /*elided*/ any;
|
|
30
30
|
};
|
|
31
31
|
}[K]>) => void) | null;
|
|
32
32
|
addEventListener<K extends "synced">(type: K, listener: EventListenerObject | ((event: CustomEvent<{
|
|
33
33
|
synced: {
|
|
34
|
-
settings: any;
|
|
34
|
+
settings: /*elided*/ any;
|
|
35
35
|
};
|
|
36
36
|
}[K]>) => void) | null, options?: AddEventListenerOptions): void;
|
|
37
37
|
removeEventListener<K extends "synced">(type: K, listener: EventListenerObject | ((event: CustomEvent<{
|
|
38
38
|
synced: {
|
|
39
|
-
settings: any;
|
|
39
|
+
settings: /*elided*/ any;
|
|
40
40
|
};
|
|
41
41
|
}[K]>) => void) | null): void;
|
|
42
42
|
dispatch<K extends "synced">(type: K, detail: {
|
|
43
43
|
synced: {
|
|
44
|
-
settings: any;
|
|
44
|
+
settings: /*elided*/ any;
|
|
45
45
|
};
|
|
46
46
|
}[K]): boolean;
|
|
47
47
|
dispatchEvent(event: Event): boolean;
|
|
@@ -12,6 +12,9 @@ const bvhTool = new VoxelMeshBVHBuilder();
|
|
|
12
12
|
function meshVoxel(x, y, z, voxel, worldCursor, sectionCursor) {
|
|
13
13
|
let added = false;
|
|
14
14
|
const constructor = VoxelModelConstructorRegister.constructorsPaltte[voxel.getVoxelId()];
|
|
15
|
+
constructor.schema.dataCursor = worldCursor;
|
|
16
|
+
constructor.schema.dataCursor = worldCursor;
|
|
17
|
+
constructor.schema.voxel = voxel;
|
|
15
18
|
const builder = constructor.builder;
|
|
16
19
|
builder.origin.x = sectionCursor._voxelPosition.x;
|
|
17
20
|
builder.origin.y = sectionCursor._voxelPosition.y;
|
|
@@ -19,6 +19,8 @@ export function MeshVoxel(rawVoxelData) {
|
|
|
19
19
|
if (!constructor) {
|
|
20
20
|
throw new Error(`Could not find constructor for voxel [id:${voxel.getStringId()} name:${voxel.getName()}] `);
|
|
21
21
|
}
|
|
22
|
+
constructor.schema.dataCursor = templateCursor;
|
|
23
|
+
constructor.schema.voxel = voxel;
|
|
22
24
|
const builder = constructor.builder;
|
|
23
25
|
if (!builder) {
|
|
24
26
|
console.error(builder, constructor.id, constructor);
|
|
@@ -4,9 +4,9 @@ import { FlatBinaryTreeIndex } from "../../Util/FlatBinaryTreeIndex";
|
|
|
4
4
|
export declare class VoxelMeshBVHBuilder {
|
|
5
5
|
static AABBStructByteSize: number;
|
|
6
6
|
treeIndex: FlatBinaryTreeIndex;
|
|
7
|
-
tree: Float32Array
|
|
7
|
+
tree: Float32Array<ArrayBuffer>;
|
|
8
8
|
structCursor: VoxelMeshBVHStructCursor;
|
|
9
|
-
indices: Uint32Array
|
|
9
|
+
indices: Uint32Array<ArrayBuffer>;
|
|
10
10
|
reset(): void;
|
|
11
11
|
getMeshBounds(): {
|
|
12
12
|
min: Vec3Array;
|
|
@@ -2,7 +2,7 @@ import { QuadVerticies } from "../../../Geomtry/Geometry.types";
|
|
|
2
2
|
import { VoxelFaces } from "../../../../Math";
|
|
3
3
|
import { Vec4Array } from "@amodx/math";
|
|
4
4
|
export declare const GradientCheckSets: Record<VoxelFaces, Record<QuadVerticies, number[]>>;
|
|
5
|
-
export declare const GradientCheckSetsArray: Int8Array
|
|
5
|
+
export declare const GradientCheckSetsArray: Int8Array<ArrayBuffer>;
|
|
6
6
|
export declare const GeometryCheckSetIndexes: Record<VoxelFaces, Record<QuadVerticies, [number, number, number]>>;
|
|
7
7
|
export declare const CenterDirectionIndex: number;
|
|
8
8
|
export declare const DirectionIndexes: Record<VoxelFaces, number>;
|
|
@@ -72,32 +72,32 @@ const topAndDown = {
|
|
|
72
72
|
west: [[-1, 0, 0]],
|
|
73
73
|
};
|
|
74
74
|
const eastAndWest = {
|
|
75
|
-
|
|
75
|
+
north: [
|
|
76
76
|
[0, 1, 0],
|
|
77
77
|
[0, 1, 1],
|
|
78
78
|
[0, 1, -1],
|
|
79
79
|
],
|
|
80
|
-
|
|
80
|
+
south: [
|
|
81
81
|
[0, -1, 0],
|
|
82
82
|
[0, -1, 1],
|
|
83
83
|
[0, -1, -1],
|
|
84
84
|
],
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
east: [[0, 0, 1]],
|
|
86
|
+
west: [[0, 0, -1]],
|
|
87
87
|
};
|
|
88
88
|
const northAndSouth = {
|
|
89
|
-
|
|
89
|
+
north: [
|
|
90
90
|
[0, 1, 0],
|
|
91
91
|
[1, 1, 0],
|
|
92
92
|
[-1, 1, 0],
|
|
93
93
|
],
|
|
94
|
-
|
|
94
|
+
south: [
|
|
95
95
|
[0, -1, 0],
|
|
96
96
|
[1, -1, 0],
|
|
97
97
|
[-1, -1, 0],
|
|
98
98
|
],
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
east: [[1, 0, 0]],
|
|
100
|
+
west: [[-1, 0, 0]],
|
|
101
101
|
};
|
|
102
102
|
const CheckSets = {
|
|
103
103
|
[VoxelFaces.Up]: topAndDown,
|
|
@@ -17,7 +17,7 @@ export function EraseVoxel(location, updateData) {
|
|
|
17
17
|
voxel.secondary[voxel._index] = 0;
|
|
18
18
|
voxel.light[voxel._index] = 0;
|
|
19
19
|
voxel.updateVoxel(1);
|
|
20
|
-
updateArea(tasks, x, y, z, x, y, z);
|
|
20
|
+
updateArea(tasks, x - 1, y - 1, z - 1, x + 1, y + 1, z + 1);
|
|
21
21
|
voxel = tasks.sDataCursor.getVoxel(x, y, z);
|
|
22
22
|
if (ES.doPower) {
|
|
23
23
|
if (foundPower > -1) {
|
|
@@ -15,7 +15,7 @@ export function PaintVoxel(location, raw, updateData) {
|
|
|
15
15
|
voxel = tasks.sDataCursor.getVoxel(x, y, z);
|
|
16
16
|
voxel.setRaw(raw);
|
|
17
17
|
voxel.updateVoxel(0);
|
|
18
|
-
updateArea(tasks, x, y, z, x, y, z);
|
|
18
|
+
updateArea(tasks, x - 1, y - 1, z - 1, x + 1, y + 1, z + 1);
|
|
19
19
|
if (ES.doPower) {
|
|
20
20
|
if (voxel.tags["dve_can_be_powered"] ||
|
|
21
21
|
voxel.tags["dve_is_power_source"] ||
|
|
@@ -31,6 +31,7 @@ export declare class ArchivedVoxelTemplate implements IVoxelTemplate {
|
|
|
31
31
|
getLight(index: number): number;
|
|
32
32
|
getSecondary(index: number): number;
|
|
33
33
|
traverse(curosr?: TemplateCursor): Generator<TemplateCursor>;
|
|
34
|
+
clone(): ArchivedVoxelTemplate;
|
|
34
35
|
getRaw(index: number, rawRef?: RawVoxelData): RawVoxelData;
|
|
35
36
|
toJSON(): ArchivedVoxelTemplateData;
|
|
36
37
|
}
|
|
@@ -111,6 +111,10 @@ export class ArchivedVoxelTemplate {
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
+
clone() {
|
|
115
|
+
const newTemplate = new ArchivedVoxelTemplate(structuredClone(this.toJSON()));
|
|
116
|
+
return newTemplate;
|
|
117
|
+
}
|
|
114
118
|
getRaw(index, rawRef = [0, 0, 0, 0]) {
|
|
115
119
|
rawRef[0] = this.getId(index);
|
|
116
120
|
rawRef[1] = this.getLight(index);
|
|
@@ -147,14 +147,16 @@ export default function CreateArchivedTemplate(dataCursor, bounds) {
|
|
|
147
147
|
const palettes = {
|
|
148
148
|
...voxelPalette.toJSON(),
|
|
149
149
|
};
|
|
150
|
-
if (
|
|
150
|
+
if (levelPalette.size > 0 &&
|
|
151
|
+
!(levelPalette.size == 1 && levelPalette._palette[0] === 0)) {
|
|
151
152
|
palettes.level = BinaryBuffer.Create({
|
|
152
153
|
format: BinaryBufferFormat.Uint8,
|
|
153
154
|
byteLength: levelPalette._palette.length,
|
|
154
155
|
buffer: Uint8Array.from(levelPalette._palette).buffer,
|
|
155
156
|
});
|
|
156
157
|
}
|
|
157
|
-
if (
|
|
158
|
+
if (secondaryPalette.size > 0 &&
|
|
159
|
+
!(secondaryPalette.size == 1 && secondaryPalette._palette[0] === 0)) {
|
|
158
160
|
palettes.secondary = BinaryBuffer.Create({
|
|
159
161
|
format: BinaryBufferFormat.Uint16,
|
|
160
162
|
byteLength: secondaryPalette._palette.length,
|
|
@@ -5,7 +5,9 @@ export class TemplateCursor {
|
|
|
5
5
|
_proxy = null;
|
|
6
6
|
voxel = new TemplateVoxelCursor(this);
|
|
7
7
|
inBounds(x, y, z) {
|
|
8
|
-
|
|
8
|
+
if (!this._proxy)
|
|
9
|
+
return false;
|
|
10
|
+
return this._proxy.inBounds(x, y, z);
|
|
9
11
|
}
|
|
10
12
|
setTemplate(template) {
|
|
11
13
|
this._proxy = new TemplateProxy(template);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Vector3Like } from "@amodx/math";
|
|
2
|
+
const point = Vector3Like.Create();
|
|
1
3
|
export class TemplateProxy {
|
|
2
4
|
template;
|
|
3
5
|
ids;
|
|
@@ -19,4 +21,16 @@ export class TemplateProxy {
|
|
|
19
21
|
get: (_, index) => this.template.getSecondary(Number(index)),
|
|
20
22
|
});
|
|
21
23
|
}
|
|
24
|
+
inBounds(x, y, z) {
|
|
25
|
+
point.x = x;
|
|
26
|
+
point.y = y;
|
|
27
|
+
point.z = z;
|
|
28
|
+
const inBounds = this.template.bounds.intersectsPoint(point);
|
|
29
|
+
if (!inBounds)
|
|
30
|
+
return false;
|
|
31
|
+
const index = this.template.getIndex(x, y, z);
|
|
32
|
+
if (!this.template.isIncluded(index))
|
|
33
|
+
return false;
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
22
36
|
}
|
|
@@ -23,5 +23,6 @@ export declare class FullVoxelTemplate implements IVoxelTemplate {
|
|
|
23
23
|
getLevel(index: number): number;
|
|
24
24
|
getSecondary(index: number): number;
|
|
25
25
|
getRaw(index: number, rawRef?: RawVoxelData): RawVoxelData;
|
|
26
|
+
clone(): FullVoxelTemplate;
|
|
26
27
|
toJSON(): FullVoxelTemplateData;
|
|
27
28
|
}
|
|
@@ -93,6 +93,10 @@ export class FullVoxelTemplate {
|
|
|
93
93
|
rawRef[3] = this.getSecondary(index);
|
|
94
94
|
return rawRef;
|
|
95
95
|
}
|
|
96
|
+
clone() {
|
|
97
|
+
const newTemplate = new FullVoxelTemplate(structuredClone(this.toJSON()));
|
|
98
|
+
return newTemplate;
|
|
99
|
+
}
|
|
96
100
|
toJSON() {
|
|
97
101
|
return {
|
|
98
102
|
type: "full",
|
|
@@ -12,6 +12,7 @@ export declare class VoxelPathSegment extends TypedEventTarget<VoxelPathSegments
|
|
|
12
12
|
start: Vec3Array;
|
|
13
13
|
end: Vec3Array;
|
|
14
14
|
voxel: PaintVoxelData;
|
|
15
|
+
transient: boolean;
|
|
15
16
|
constructor(path: VoxelPath, index: number, data: VoxelPathSegmentData);
|
|
16
17
|
setPoints([sx, sy, sz]: Vec3Array, [ex, ey, ez]: Vec3Array): void;
|
|
17
18
|
getPoint(point: 0 | 1): Vec3Array;
|
|
@@ -27,6 +28,9 @@ export declare class VoxelPath extends TypedEventTarget<VoxelPathEvents> {
|
|
|
27
28
|
static CreateNew(data: Partial<VoxelPathData>): VoxelPathData;
|
|
28
29
|
segments: VoxelPathSegment[];
|
|
29
30
|
constructor(data: VoxelPathData);
|
|
31
|
+
get totalSegments(): number;
|
|
32
|
+
lastSegment(): VoxelPathSegment | null;
|
|
33
|
+
firstSegment(): VoxelPathSegment | null;
|
|
30
34
|
addSegment(data: VoxelPathSegmentData): boolean;
|
|
31
35
|
removeSegment(segment: VoxelPathSegment): boolean;
|
|
32
36
|
removePoint(segmentIndex: number, pointIndex: 0 | 1): false | undefined;
|
|
@@ -13,6 +13,7 @@ export class VoxelPathSegment extends TypedEventTarget {
|
|
|
13
13
|
start;
|
|
14
14
|
end;
|
|
15
15
|
voxel;
|
|
16
|
+
transient = false;
|
|
16
17
|
constructor(path, index, data) {
|
|
17
18
|
super();
|
|
18
19
|
this.path = path;
|
|
@@ -20,6 +21,7 @@ export class VoxelPathSegment extends TypedEventTarget {
|
|
|
20
21
|
this.start = data.start;
|
|
21
22
|
this.end = data.end;
|
|
22
23
|
this.voxel = data.voxel;
|
|
24
|
+
this.transient = data.transient || false;
|
|
23
25
|
}
|
|
24
26
|
setPoints([sx, sy, sz], [ex, ey, ez]) {
|
|
25
27
|
let updated = false;
|
|
@@ -36,6 +38,7 @@ export class VoxelPathSegment extends TypedEventTarget {
|
|
|
36
38
|
this.end[1] = ey;
|
|
37
39
|
this.end[2] = ez;
|
|
38
40
|
if (updated) {
|
|
41
|
+
console.warn("UPDATED");
|
|
39
42
|
this.dispatch("updated", {});
|
|
40
43
|
}
|
|
41
44
|
}
|
|
@@ -60,6 +63,7 @@ export class VoxelPathSegment extends TypedEventTarget {
|
|
|
60
63
|
start: [...this.start],
|
|
61
64
|
end: [...this.end],
|
|
62
65
|
voxel: { ...this.voxel },
|
|
66
|
+
...(this.transient ? { transient: true } : {}),
|
|
63
67
|
};
|
|
64
68
|
}
|
|
65
69
|
}
|
|
@@ -78,6 +82,19 @@ export class VoxelPath extends TypedEventTarget {
|
|
|
78
82
|
this.segments.push(new VoxelPathSegment(this, i, data.segments[i]));
|
|
79
83
|
}
|
|
80
84
|
}
|
|
85
|
+
get totalSegments() {
|
|
86
|
+
return this.segments.length;
|
|
87
|
+
}
|
|
88
|
+
lastSegment() {
|
|
89
|
+
if (!this.segments.length)
|
|
90
|
+
return null;
|
|
91
|
+
return this.segments[(this.totalSegments - 1) % this.totalSegments];
|
|
92
|
+
}
|
|
93
|
+
firstSegment() {
|
|
94
|
+
if (!this.segments.length)
|
|
95
|
+
return null;
|
|
96
|
+
return this.segments[0];
|
|
97
|
+
}
|
|
81
98
|
addSegment(data) {
|
|
82
99
|
const segment = new VoxelPathSegment(this, this.segments.length, data);
|
|
83
100
|
this.segments.push(segment);
|
|
@@ -2,6 +2,7 @@ import { Flat3DIndex, Vector3Like } from "@amodx/math";
|
|
|
2
2
|
import { IVoxelSelection } from "./VoxelSelecton";
|
|
3
3
|
import { DataCursorInterface } from "../../Voxels/Cursor/DataCursor.interface";
|
|
4
4
|
import { FullVoxelTemplate } from "../Full/FullVoxelTemplate";
|
|
5
|
+
import { BoundingBox } from "@amodx/math/Geomtry/Bounds/BoundingBox";
|
|
5
6
|
export interface VoxelBFSSelectionData {
|
|
6
7
|
origin: Vector3Like;
|
|
7
8
|
size: Vector3Like;
|
|
@@ -12,9 +13,11 @@ export declare class VoxelBFSSelection implements IVoxelSelection, VoxelBFSSelec
|
|
|
12
13
|
size: Vector3Like;
|
|
13
14
|
bitIndex: Uint8Array;
|
|
14
15
|
index: Flat3DIndex;
|
|
16
|
+
bounds: BoundingBox;
|
|
15
17
|
isSelected(x: number, y: number, z: number): boolean;
|
|
16
18
|
reConstruct(cursor: DataCursorInterface, position: Vector3Like, maxSize?: number): false | undefined;
|
|
17
19
|
toTemplate(cursor: DataCursorInterface): FullVoxelTemplate;
|
|
20
|
+
clone(): VoxelBFSSelection;
|
|
18
21
|
toJSON(): VoxelBFSSelectionData;
|
|
19
22
|
fromJSON(data: VoxelBFSSelectionData): void;
|
|
20
23
|
}
|
|
@@ -2,11 +2,13 @@ import { Flat3DIndex, Vector3Like } from "@amodx/math";
|
|
|
2
2
|
import { CardinalNeighbors3D } from "../../Math/CardinalNeighbors";
|
|
3
3
|
import { getBitArrayIndex, setBitArrayIndex, } from "../../Util/Binary/BinaryArrays";
|
|
4
4
|
import { FullVoxelTemplate } from "../Full/FullVoxelTemplate";
|
|
5
|
+
import { BoundingBox } from "@amodx/math/Geomtry/Bounds/BoundingBox";
|
|
5
6
|
export class VoxelBFSSelection {
|
|
6
7
|
origin = Vector3Like.Create();
|
|
7
8
|
size = Vector3Like.Create();
|
|
8
9
|
bitIndex;
|
|
9
10
|
index = Flat3DIndex.GetXZYOrder();
|
|
11
|
+
bounds = new BoundingBox();
|
|
10
12
|
isSelected(x, y, z) {
|
|
11
13
|
if (x < this.origin.x || x >= this.origin.x + this.size.x)
|
|
12
14
|
return false;
|
|
@@ -110,6 +112,15 @@ export class VoxelBFSSelection {
|
|
|
110
112
|
}
|
|
111
113
|
return template;
|
|
112
114
|
}
|
|
115
|
+
clone() {
|
|
116
|
+
const newSelection = new VoxelBFSSelection();
|
|
117
|
+
Vector3Like.Copy(newSelection.origin, this.origin);
|
|
118
|
+
Vector3Like.Copy(newSelection.size, this.size);
|
|
119
|
+
newSelection.bounds.setMinMax(this.bounds.min, this.bounds.max);
|
|
120
|
+
newSelection.bitIndex = structuredClone(this.bitIndex);
|
|
121
|
+
newSelection.index.setBounds(...this.index.getBounds());
|
|
122
|
+
return newSelection;
|
|
123
|
+
}
|
|
113
124
|
toJSON() {
|
|
114
125
|
return {
|
|
115
126
|
origin: { ...this.origin },
|
|
@@ -3,12 +3,15 @@ import { IVoxelSelection } from "./VoxelSelecton";
|
|
|
3
3
|
import { BoxVoxelTemplate } from "../Shapes/BoxVoxelTemplate";
|
|
4
4
|
import { IVoxelshapeTemplateBaseData } from "../Shapes/VoxelShapeTemplate.types";
|
|
5
5
|
import { DataCursorInterface } from "../../Voxels/Cursor/DataCursor.interface";
|
|
6
|
+
import { BoundingBox } from "@amodx/math/Geomtry/Bounds/BoundingBox";
|
|
6
7
|
export declare class VoxelBoxSelection implements IVoxelSelection {
|
|
7
8
|
origin: Vector3Like;
|
|
8
9
|
end: Vector3Like;
|
|
9
10
|
size: Vector3Like;
|
|
11
|
+
bounds: BoundingBox;
|
|
10
12
|
isSelected(x: number, y: number, z: number): boolean;
|
|
11
13
|
reConstruct(startPosition: Vector3Like, startNormal: Vector3Like, endPosition: Vector3Like, endNormal: Vector3Like, offset?: number): void;
|
|
14
|
+
clone(): VoxelBoxSelection;
|
|
12
15
|
toTemplate(data?: Partial<IVoxelshapeTemplateBaseData>): BoxVoxelTemplate;
|
|
13
16
|
toExtrudedTemplate(cursor: DataCursorInterface, normal: Vector3Like): void;
|
|
14
17
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Vec3ArrayLike, Vector3Like } from "@amodx/math";
|
|
2
2
|
import { BoxVoxelTemplate } from "../Shapes/BoxVoxelTemplate";
|
|
3
|
+
import { BoundingBox } from "@amodx/math/Geomtry/Bounds/BoundingBox";
|
|
3
4
|
const getMinMax = (...points) => {
|
|
4
5
|
if (points.length === 0) {
|
|
5
6
|
throw new Error("At least one point is required to calculate min/max.");
|
|
@@ -25,6 +26,7 @@ export class VoxelBoxSelection {
|
|
|
25
26
|
origin = Vector3Like.Create();
|
|
26
27
|
end = Vector3Like.Create();
|
|
27
28
|
size = Vector3Like.Create();
|
|
29
|
+
bounds = new BoundingBox();
|
|
28
30
|
isSelected(x, y, z) {
|
|
29
31
|
if (x < this.origin.x || x >= this.end.x)
|
|
30
32
|
return false;
|
|
@@ -91,6 +93,15 @@ export class VoxelBoxSelection {
|
|
|
91
93
|
this.size.y = finalSize[1];
|
|
92
94
|
this.size.z = finalSize[2];
|
|
93
95
|
}
|
|
96
|
+
this.bounds.setMinMax(this.origin, this.end);
|
|
97
|
+
}
|
|
98
|
+
clone() {
|
|
99
|
+
const newSelection = new VoxelBoxSelection();
|
|
100
|
+
Vector3Like.Copy(newSelection.origin, this.origin);
|
|
101
|
+
Vector3Like.Copy(newSelection.size, this.size);
|
|
102
|
+
Vector3Like.Copy(newSelection.end, this.end);
|
|
103
|
+
newSelection.bounds.setMinMax(this.bounds.min, this.bounds.max);
|
|
104
|
+
return newSelection;
|
|
94
105
|
}
|
|
95
106
|
toTemplate(data) {
|
|
96
107
|
const boxTemplate = BoxVoxelTemplate.CreateNew({
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Vector3Like } from "@amodx/math";
|
|
2
|
+
import { IVoxelSelection } from "./VoxelSelecton";
|
|
3
|
+
import { BoxVoxelTemplate } from "../Shapes/BoxVoxelTemplate";
|
|
4
|
+
import { IVoxelshapeTemplateBaseData } from "../Shapes/VoxelShapeTemplate.types";
|
|
5
|
+
import { DataCursorInterface } from "../../Voxels/Cursor/DataCursor.interface";
|
|
6
|
+
import { BoundingBox } from "@amodx/math/Geomtry/Bounds/BoundingBox";
|
|
7
|
+
export declare class VoxelPointSelection implements IVoxelSelection {
|
|
8
|
+
origin: Vector3Like;
|
|
9
|
+
end: Vector3Like;
|
|
10
|
+
size: Vector3Like;
|
|
11
|
+
bounds: BoundingBox;
|
|
12
|
+
isSelected(x: number, y: number, z: number): boolean;
|
|
13
|
+
reConstruct(position: Vector3Like): void;
|
|
14
|
+
clone(): VoxelPointSelection;
|
|
15
|
+
toTemplate(data?: Partial<IVoxelshapeTemplateBaseData>): BoxVoxelTemplate;
|
|
16
|
+
toExtrudedTemplate(cursor: DataCursorInterface, normal: Vector3Like): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Vector3Like } from "@amodx/math";
|
|
2
|
+
import { BoxVoxelTemplate } from "../Shapes/BoxVoxelTemplate";
|
|
3
|
+
import { BoundingBox } from "@amodx/math/Geomtry/Bounds/BoundingBox";
|
|
4
|
+
export class VoxelPointSelection {
|
|
5
|
+
origin = Vector3Like.Create();
|
|
6
|
+
end = Vector3Like.Create();
|
|
7
|
+
size = Vector3Like.Create();
|
|
8
|
+
bounds = new BoundingBox();
|
|
9
|
+
isSelected(x, y, z) {
|
|
10
|
+
if (x < this.origin.x || x >= this.end.x)
|
|
11
|
+
return false;
|
|
12
|
+
if (y < this.origin.y || y >= this.end.y)
|
|
13
|
+
return false;
|
|
14
|
+
if (z < this.origin.z || z >= this.end.z)
|
|
15
|
+
return false;
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
reConstruct(position) {
|
|
19
|
+
this.origin.x = position.x;
|
|
20
|
+
this.origin.y = position.y;
|
|
21
|
+
this.origin.z = position.z;
|
|
22
|
+
this.end.x = this.origin.x + 1;
|
|
23
|
+
this.end.y = this.origin.y + 1;
|
|
24
|
+
this.end.z = this.origin.z + 1;
|
|
25
|
+
this.size.x = 1;
|
|
26
|
+
this.size.y = 1;
|
|
27
|
+
this.size.z = 1;
|
|
28
|
+
this.bounds.setMinMax(this.origin, this.end);
|
|
29
|
+
}
|
|
30
|
+
clone() {
|
|
31
|
+
const newSelection = new VoxelPointSelection();
|
|
32
|
+
Vector3Like.Copy(newSelection.origin, this.origin);
|
|
33
|
+
Vector3Like.Copy(newSelection.size, this.size);
|
|
34
|
+
Vector3Like.Copy(newSelection.end, this.end);
|
|
35
|
+
newSelection.bounds.setMinMax(this.bounds.min, this.bounds.max);
|
|
36
|
+
return newSelection;
|
|
37
|
+
}
|
|
38
|
+
toTemplate(data) {
|
|
39
|
+
const boxTemplate = BoxVoxelTemplate.CreateNew({
|
|
40
|
+
width: this.size.x,
|
|
41
|
+
height: this.size.y,
|
|
42
|
+
depth: this.size.z,
|
|
43
|
+
...(data ? data : {}),
|
|
44
|
+
});
|
|
45
|
+
return new BoxVoxelTemplate(boxTemplate);
|
|
46
|
+
}
|
|
47
|
+
toExtrudedTemplate(cursor, normal) { }
|
|
48
|
+
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Vector3Like } from "@amodx/math";
|
|
2
|
+
import { BoundingBox } from "@amodx/math/Geomtry/Bounds/BoundingBox";
|
|
2
3
|
export interface IVoxelSelection {
|
|
3
4
|
origin: Vector3Like;
|
|
4
5
|
size: Vector3Like;
|
|
6
|
+
bounds: BoundingBox;
|
|
5
7
|
isSelected(x: number, y: number, z: number): boolean;
|
|
8
|
+
clone(): IVoxelSelection;
|
|
6
9
|
}
|
|
@@ -3,6 +3,7 @@ import { IVoxelSelection } from "./VoxelSelecton";
|
|
|
3
3
|
import { DataCursorInterface } from "../../Voxels/Cursor/DataCursor.interface";
|
|
4
4
|
import { PaintVoxelData } from "../../Voxels/Types/PaintVoxelData";
|
|
5
5
|
import { FullVoxelTemplate } from "../Full/FullVoxelTemplate";
|
|
6
|
+
import { BoundingBox } from "@amodx/math/Geomtry/Bounds/BoundingBox";
|
|
6
7
|
export interface VoxelSurfaceSelectionData {
|
|
7
8
|
origin: Vector3Like;
|
|
8
9
|
size: Vector3Like;
|
|
@@ -16,9 +17,11 @@ export declare class VoxelSurfaceSelection implements IVoxelSelection, VoxelSurf
|
|
|
16
17
|
normal: Vector3Like;
|
|
17
18
|
bitIndex: Uint8Array;
|
|
18
19
|
index: Flat3DIndex;
|
|
20
|
+
bounds: BoundingBox;
|
|
19
21
|
extrusion: number;
|
|
20
22
|
isSelected(x: number, y: number, z: number): boolean;
|
|
21
23
|
reConstruct(cursor: DataCursorInterface, position: Vector3Like, normal: Vector3Like, extrusion: number, maxSize?: number): false | undefined;
|
|
24
|
+
clone(): VoxelSurfaceSelection;
|
|
22
25
|
toTemplate(cursor: DataCursorInterface, voxelOrExtrude: PaintVoxelData | true): FullVoxelTemplate;
|
|
23
26
|
toTemplate(cursor: DataCursorInterface, extrude: true): FullVoxelTemplate;
|
|
24
27
|
toTemplate(cursor: DataCursorInterface, voxel: PaintVoxelData): FullVoxelTemplate;
|
|
@@ -3,12 +3,14 @@ import { CardinalNeighbors2D } from "../../Math/CardinalNeighbors";
|
|
|
3
3
|
import { getBitArrayIndex, setBitArrayIndex, } from "../../Util/Binary/BinaryArrays";
|
|
4
4
|
import { PaintVoxelData } from "../../Voxels/Types/PaintVoxelData";
|
|
5
5
|
import { FullVoxelTemplate } from "../Full/FullVoxelTemplate";
|
|
6
|
+
import { BoundingBox } from "@amodx/math/Geomtry/Bounds/BoundingBox";
|
|
6
7
|
export class VoxelSurfaceSelection {
|
|
7
8
|
origin = Vector3Like.Create();
|
|
8
9
|
size = Vector3Like.Create();
|
|
9
10
|
normal = Vector3Like.Create();
|
|
10
11
|
bitIndex;
|
|
11
12
|
index = Flat3DIndex.GetXZYOrder();
|
|
13
|
+
bounds = new BoundingBox();
|
|
12
14
|
extrusion = 0;
|
|
13
15
|
isSelected(x, y, z) {
|
|
14
16
|
if (x < this.origin.x || x >= this.origin.x + this.size.x)
|
|
@@ -113,6 +115,22 @@ export class VoxelSurfaceSelection {
|
|
|
113
115
|
this.origin.x = min.x;
|
|
114
116
|
this.origin.y = min.y;
|
|
115
117
|
this.origin.z = min.z;
|
|
118
|
+
this.bounds.setMinMax(this.origin, {
|
|
119
|
+
x: this.origin.x + this.size.x,
|
|
120
|
+
y: this.origin.y + this.size.y,
|
|
121
|
+
z: this.origin.z + this.size.z,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
clone() {
|
|
125
|
+
const newSelection = new VoxelSurfaceSelection();
|
|
126
|
+
Vector3Like.Copy(newSelection.origin, this.origin);
|
|
127
|
+
Vector3Like.Copy(newSelection.size, this.size);
|
|
128
|
+
newSelection.bounds.setMinMax(this.bounds.min, this.bounds.max);
|
|
129
|
+
newSelection.extrusion = this.extrusion;
|
|
130
|
+
newSelection.bitIndex = structuredClone(this.bitIndex);
|
|
131
|
+
newSelection.index.setBounds(...this.index.getBounds());
|
|
132
|
+
newSelection.bounds.setMinMax(this.bounds.min, this.bounds.max);
|
|
133
|
+
return newSelection;
|
|
116
134
|
}
|
|
117
135
|
toTemplate(cursor, voxelOrExtrude) {
|
|
118
136
|
let extrude = false;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { Vector3Like } from "@amodx/math";
|
|
2
2
|
import { IVoxelSelection } from "./VoxelSelecton";
|
|
3
3
|
import { IVoxelTemplate } from "../VoxelTemplates.types";
|
|
4
|
+
import { BoundingBox } from "@amodx/math/Geomtry/Bounds/BoundingBox";
|
|
4
5
|
export declare class VoxelTemplateSelection implements IVoxelSelection {
|
|
5
6
|
origin: Vector3Like;
|
|
6
7
|
size: Vector3Like;
|
|
8
|
+
bounds: BoundingBox;
|
|
7
9
|
template: IVoxelTemplate;
|
|
8
10
|
isSelected(x: number, y: number, z: number): boolean;
|
|
11
|
+
clone(): VoxelTemplateSelection;
|
|
9
12
|
setTemplate(template: IVoxelTemplate): void;
|
|
10
13
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Vector3Like } from "@amodx/math";
|
|
2
|
+
import { BoundingBox } from "@amodx/math/Geomtry/Bounds/BoundingBox";
|
|
2
3
|
export class VoxelTemplateSelection {
|
|
3
4
|
origin = Vector3Like.Create();
|
|
4
5
|
size = Vector3Like.Create();
|
|
6
|
+
bounds = new BoundingBox();
|
|
5
7
|
template;
|
|
6
8
|
isSelected(x, y, z) {
|
|
7
9
|
if (x < this.origin.x || x >= this.origin.x + this.size.x)
|
|
@@ -17,6 +19,14 @@ export class VoxelTemplateSelection {
|
|
|
17
19
|
return false;
|
|
18
20
|
return true;
|
|
19
21
|
}
|
|
22
|
+
clone() {
|
|
23
|
+
const newSelection = new VoxelTemplateSelection();
|
|
24
|
+
Vector3Like.Copy(newSelection.origin, this.origin);
|
|
25
|
+
Vector3Like.Copy(newSelection.size, this.size);
|
|
26
|
+
newSelection.bounds.setMinMax(this.bounds.min, this.bounds.max);
|
|
27
|
+
newSelection.template = this.template.clone();
|
|
28
|
+
return newSelection;
|
|
29
|
+
}
|
|
20
30
|
setTemplate(template) {
|
|
21
31
|
this.template = template;
|
|
22
32
|
this.size.x = template.bounds.size.x;
|
|
@@ -23,6 +23,7 @@ export declare abstract class BasicVoxelShapeTemplate<Type extends string, Data
|
|
|
23
23
|
getIndex(x: number, y: number, z: number): number;
|
|
24
24
|
setPosition(x: number, y: number, z: number): void;
|
|
25
25
|
abstract isIncluded(index: number): boolean;
|
|
26
|
+
abstract clone(): BasicVoxelShapeTemplate<Type, Data, Events>;
|
|
26
27
|
isAir(index: number): boolean;
|
|
27
28
|
getId(index: number): number;
|
|
28
29
|
getLight(index: number): number;
|