@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { VoxelBuildSpace } from "../../VoxelBuildSpace";
|
|
2
|
+
import { VoxelBoxSelection } from "../../../Templates/Selection/VoxelBoxSelection";
|
|
3
|
+
import { Vector3Like } from "@amodx/math";
|
|
4
|
+
export declare class BoxSelection {
|
|
5
|
+
space: VoxelBuildSpace;
|
|
6
|
+
selection: VoxelBoxSelection;
|
|
7
|
+
planeOrigin: Vector3Like;
|
|
8
|
+
planeNormal: Vector3Like;
|
|
9
|
+
offset: number;
|
|
10
|
+
constructor(space: VoxelBuildSpace, selection: VoxelBoxSelection);
|
|
11
|
+
update(): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Vector3Like } from "@amodx/math";
|
|
2
|
+
export class BoxSelection {
|
|
3
|
+
space;
|
|
4
|
+
selection;
|
|
5
|
+
planeOrigin = Vector3Like.Create();
|
|
6
|
+
planeNormal = Vector3Like.Create();
|
|
7
|
+
offset = 0;
|
|
8
|
+
constructor(space, selection) {
|
|
9
|
+
this.space = space;
|
|
10
|
+
this.selection = selection;
|
|
11
|
+
}
|
|
12
|
+
update() {
|
|
13
|
+
const rayOrigin = this.space.rayProvider.origin;
|
|
14
|
+
const rayDirection = this.space.rayProvider.direction;
|
|
15
|
+
console.warn("SPACE", this.space);
|
|
16
|
+
console.warn("UPDATE BOX TOOL", [rayOrigin.x, rayOrigin.y, rayOrigin.z], [rayDirection.x, rayDirection.y, rayDirection.z]);
|
|
17
|
+
const distance = Vector3Like.Dot(Vector3Like.Subtract(this.planeOrigin, rayOrigin), this.planeNormal) / Vector3Like.Dot(rayDirection, this.planeNormal);
|
|
18
|
+
const intersectionPoint = Vector3Like.FloorInPlace(Vector3Like.Add(rayOrigin, Vector3Like.MultiplyScalar(rayDirection, distance)));
|
|
19
|
+
let offset = this.offset;
|
|
20
|
+
if (this.planeNormal.x > 0 ||
|
|
21
|
+
this.planeNormal.y > 0 ||
|
|
22
|
+
this.planeNormal.z > 0) {
|
|
23
|
+
offset++;
|
|
24
|
+
}
|
|
25
|
+
this.selection.reConstruct(this.planeOrigin, this.planeNormal, intersectionPoint, this.planeNormal, offset);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { VoxelPickResult } from "../../../Voxels/Interaction/VoxelPickResult";
|
|
2
|
+
import { VoxelBuildSpace } from "../../VoxelBuildSpace";
|
|
3
|
+
import { PaintVoxelData } from "../../../Voxels";
|
|
4
|
+
import { VoxelBoxSelection } from "../../../Templates/Selection/VoxelBoxSelection";
|
|
5
|
+
import { BoxSelection } from "./BoxSelection";
|
|
6
|
+
import { BoxToolTemplate } from "./BoxToolTemplate";
|
|
7
|
+
import { BuilderToolBase } from "../BuilderToolBase";
|
|
8
|
+
export declare enum BoxToolModes {
|
|
9
|
+
Fill = "Fill",
|
|
10
|
+
Extrude = "Extrude",
|
|
11
|
+
Template = "Template",
|
|
12
|
+
Remove = "Remove"
|
|
13
|
+
}
|
|
14
|
+
interface BoxToolEvents {
|
|
15
|
+
"template-created": BoxToolTemplate;
|
|
16
|
+
}
|
|
17
|
+
export declare class BoxTool extends BuilderToolBase<BoxToolEvents> {
|
|
18
|
+
space: VoxelBuildSpace;
|
|
19
|
+
static ToolId: string;
|
|
20
|
+
static ModeArray: BoxToolModes[];
|
|
21
|
+
mode: BoxToolModes;
|
|
22
|
+
selection: VoxelBoxSelection;
|
|
23
|
+
boxSelection: BoxSelection;
|
|
24
|
+
constructor(space: VoxelBuildSpace);
|
|
25
|
+
private _started;
|
|
26
|
+
isSelectionStarted(): boolean;
|
|
27
|
+
updateOffset(offset: number): void;
|
|
28
|
+
updatePlacer(picked: VoxelPickResult | null, placerMode?: "start" | "end" | null): void;
|
|
29
|
+
use(voxelData: PaintVoxelData, usePlacingStrategy?: boolean): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { VoxelBoxSelection } from "../../../Templates/Selection/VoxelBoxSelection";
|
|
2
|
+
import { Vector3Like } from "@amodx/math";
|
|
3
|
+
import { BoxSelection } from "./BoxSelection";
|
|
4
|
+
import { BoxToolTemplate } from "./BoxToolTemplate";
|
|
5
|
+
import { BuilderToolBase } from "../BuilderToolBase";
|
|
6
|
+
export var BoxToolModes;
|
|
7
|
+
(function (BoxToolModes) {
|
|
8
|
+
BoxToolModes["Fill"] = "Fill";
|
|
9
|
+
BoxToolModes["Extrude"] = "Extrude";
|
|
10
|
+
BoxToolModes["Template"] = "Template";
|
|
11
|
+
BoxToolModes["Remove"] = "Remove";
|
|
12
|
+
})(BoxToolModes || (BoxToolModes = {}));
|
|
13
|
+
export class BoxTool extends BuilderToolBase {
|
|
14
|
+
space;
|
|
15
|
+
static ToolId = "Box";
|
|
16
|
+
static ModeArray = [
|
|
17
|
+
BoxToolModes.Fill,
|
|
18
|
+
BoxToolModes.Extrude,
|
|
19
|
+
BoxToolModes.Template,
|
|
20
|
+
BoxToolModes.Remove,
|
|
21
|
+
];
|
|
22
|
+
mode = BoxToolModes.Fill;
|
|
23
|
+
selection = new VoxelBoxSelection();
|
|
24
|
+
boxSelection;
|
|
25
|
+
constructor(space) {
|
|
26
|
+
super();
|
|
27
|
+
this.space = space;
|
|
28
|
+
console.warn("CREATE BOX TOOL", this.space, this.selection);
|
|
29
|
+
this.boxSelection = new BoxSelection(this.space, this.selection);
|
|
30
|
+
}
|
|
31
|
+
_started = false;
|
|
32
|
+
isSelectionStarted() {
|
|
33
|
+
return this._started;
|
|
34
|
+
}
|
|
35
|
+
updateOffset(offset) {
|
|
36
|
+
this.boxSelection.offset = offset;
|
|
37
|
+
this.boxSelection.update();
|
|
38
|
+
}
|
|
39
|
+
updatePlacer(picked, placerMode = null) {
|
|
40
|
+
if (!this._started && !placerMode && picked) {
|
|
41
|
+
if (this.mode == BoxToolModes.Fill ||
|
|
42
|
+
this.mode == BoxToolModes.Template ||
|
|
43
|
+
this.mode == BoxToolModes.Extrude) {
|
|
44
|
+
this.selection.reConstruct(picked.normalPosition, picked.normal, Vector3Like.Add(picked.normalPosition, Vector3Like.Create(1, 1, 1)), picked.normal);
|
|
45
|
+
}
|
|
46
|
+
if (this.mode == BoxToolModes.Remove) {
|
|
47
|
+
this.selection.reConstruct(picked.position, picked.normal, Vector3Like.Add(picked.position, Vector3Like.Create(1, 1, 1)), picked.normal);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (!this._started && placerMode == "start" && picked) {
|
|
51
|
+
this.boxSelection.offset = 0;
|
|
52
|
+
Vector3Like.Copy(this.boxSelection.planeNormal, picked.normal);
|
|
53
|
+
if (this.mode == BoxToolModes.Fill ||
|
|
54
|
+
this.mode == BoxToolModes.Template ||
|
|
55
|
+
this.mode == BoxToolModes.Extrude) {
|
|
56
|
+
Vector3Like.Copy(this.boxSelection.planeOrigin, picked.normalPosition);
|
|
57
|
+
}
|
|
58
|
+
if (this.mode == BoxToolModes.Remove) {
|
|
59
|
+
Vector3Like.Copy(this.boxSelection.planeOrigin, picked.position);
|
|
60
|
+
}
|
|
61
|
+
this.boxSelection.update();
|
|
62
|
+
this._started = true;
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (this._started && !placerMode && !picked) {
|
|
66
|
+
this.boxSelection.update();
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (this._started && placerMode == "end") {
|
|
70
|
+
this.boxSelection.update();
|
|
71
|
+
this._started = false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async use(voxelData, usePlacingStrategy = true) {
|
|
75
|
+
if (this.mode == BoxToolModes.Fill) {
|
|
76
|
+
await this.space.paintTemplate(Vector3Like.ToArray(this.selection.origin), this.selection
|
|
77
|
+
.toTemplate({
|
|
78
|
+
fillVoxel: voxelData,
|
|
79
|
+
})
|
|
80
|
+
.toJSON());
|
|
81
|
+
}
|
|
82
|
+
if (this.mode == BoxToolModes.Template) {
|
|
83
|
+
const boxTemplate = new BoxToolTemplate(this.space, this.selection.clone());
|
|
84
|
+
await boxTemplate.create();
|
|
85
|
+
this.dispatch("template-created", boxTemplate);
|
|
86
|
+
}
|
|
87
|
+
if (this.mode == BoxToolModes.Remove) {
|
|
88
|
+
await this.space.eraseTemplate(Vector3Like.ToArray(this.selection.origin), this.selection.toTemplate({}).toJSON());
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FullVoxelTemplate } from "../../../Templates/Full/FullVoxelTemplate";
|
|
2
|
+
import { VoxelBoxSelection } from "../../../Templates/Selection/VoxelBoxSelection";
|
|
3
|
+
import { VoxelBuildSpace } from "../../VoxelBuildSpace";
|
|
4
|
+
export declare class BoxToolTemplate {
|
|
5
|
+
space: VoxelBuildSpace;
|
|
6
|
+
selection: VoxelBoxSelection;
|
|
7
|
+
template: FullVoxelTemplate;
|
|
8
|
+
private _created;
|
|
9
|
+
constructor(space: VoxelBuildSpace, selection: VoxelBoxSelection);
|
|
10
|
+
create(): Promise<void>;
|
|
11
|
+
place(): Promise<void>;
|
|
12
|
+
clear(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export class BoxToolTemplate {
|
|
2
|
+
space;
|
|
3
|
+
selection;
|
|
4
|
+
template;
|
|
5
|
+
_created = false;
|
|
6
|
+
constructor(space, selection) {
|
|
7
|
+
this.space = space;
|
|
8
|
+
this.selection = selection;
|
|
9
|
+
}
|
|
10
|
+
async create() {
|
|
11
|
+
if (this._created)
|
|
12
|
+
return;
|
|
13
|
+
const bounds = this.selection.bounds.getMinMax();
|
|
14
|
+
this.template = await this.space.createTemplate(bounds);
|
|
15
|
+
this._created = true;
|
|
16
|
+
}
|
|
17
|
+
async place() {
|
|
18
|
+
await this.space.paintTemplate(this.selection.origin, this.template.toJSON());
|
|
19
|
+
}
|
|
20
|
+
async clear() {
|
|
21
|
+
await this.space.eraseTemplate(this.selection.origin, this.template.toJSON());
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { VoxelBuildSpace } from "../../VoxelBuildSpace";
|
|
2
|
+
import { BasicVoxelShapeTemplate } from "../../../Templates/Shapes/BasicVoxelShapeTemplate";
|
|
3
|
+
import { VoxelTemplateSelection } from "../../../Templates/Selection/VoxelTemplateSelection";
|
|
4
|
+
import { VoxelPickResult } from "../../../Voxels/Interaction/VoxelPickResult";
|
|
5
|
+
import { Vector3Like } from "@amodx/math";
|
|
6
|
+
import { PaintVoxelData } from "../../../Voxels";
|
|
7
|
+
import { BuilderToolBase } from "../BuilderToolBase";
|
|
8
|
+
export declare enum BrushPositionModes {
|
|
9
|
+
Start = "Start",
|
|
10
|
+
Center = "Center",
|
|
11
|
+
End = "End"
|
|
12
|
+
}
|
|
13
|
+
export declare enum BrushToolModes {
|
|
14
|
+
Fill = "Fill",
|
|
15
|
+
Extrude = "Extrude",
|
|
16
|
+
Remove = "Remove"
|
|
17
|
+
}
|
|
18
|
+
type BrushVoxelData = {
|
|
19
|
+
fill: PaintVoxelData;
|
|
20
|
+
face: PaintVoxelData;
|
|
21
|
+
edge: PaintVoxelData;
|
|
22
|
+
point: PaintVoxelData;
|
|
23
|
+
};
|
|
24
|
+
interface BrushToolEvents {
|
|
25
|
+
"shape-updated": null;
|
|
26
|
+
}
|
|
27
|
+
export declare class BrushTool extends BuilderToolBase<BrushToolEvents> {
|
|
28
|
+
space: VoxelBuildSpace;
|
|
29
|
+
static ToolId: string;
|
|
30
|
+
static ModeArray: BrushToolModes[];
|
|
31
|
+
static PositionModeArray: BrushPositionModes[];
|
|
32
|
+
static get ShapesArray(): string[];
|
|
33
|
+
static ShapeCreators: Record<string, () => BasicVoxelShapeTemplate<any, any, any>>;
|
|
34
|
+
shape: string;
|
|
35
|
+
axisXPositionMode: BrushPositionModes;
|
|
36
|
+
axisYPositionMode: BrushPositionModes;
|
|
37
|
+
axisZPositionMode: BrushPositionModes;
|
|
38
|
+
mode: BrushToolModes;
|
|
39
|
+
template: BasicVoxelShapeTemplate<any, any, any>;
|
|
40
|
+
selection: VoxelTemplateSelection;
|
|
41
|
+
protected _position: Vector3Like;
|
|
42
|
+
constructor(space: VoxelBuildSpace);
|
|
43
|
+
use(picked: VoxelPickResult, voxelData?: Partial<BrushVoxelData>, usePlacingStrategy?: boolean): Promise<true | undefined>;
|
|
44
|
+
protected getPlacePosition(picked: VoxelPickResult): Vector3Like;
|
|
45
|
+
updatePlacer(picked: VoxelPickResult): false | undefined;
|
|
46
|
+
updateShape(shape: string): void;
|
|
47
|
+
}
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { VoxelTemplateSelection } from "../../../Templates/Selection/VoxelTemplateSelection";
|
|
2
|
+
import { SphereVoxelTemplate } from "../../../Templates/Shapes/SphereVoxelTemplate";
|
|
3
|
+
import { BoxVoxelTemplate } from "../../../Templates/Shapes/BoxVoxelTemplate";
|
|
4
|
+
import { PyramidVoxelTemplate } from "../../../Templates/Shapes/PyramidVoxelTemplate";
|
|
5
|
+
import { Vector3Like } from "@amodx/math";
|
|
6
|
+
import { BuilderToolBase } from "../BuilderToolBase";
|
|
7
|
+
import { EllipsoidVoxelTemplate } from "../../../Templates/Shapes/EllipsoidVoxelTemplate";
|
|
8
|
+
export var BrushPositionModes;
|
|
9
|
+
(function (BrushPositionModes) {
|
|
10
|
+
BrushPositionModes["Start"] = "Start";
|
|
11
|
+
BrushPositionModes["Center"] = "Center";
|
|
12
|
+
BrushPositionModes["End"] = "End";
|
|
13
|
+
})(BrushPositionModes || (BrushPositionModes = {}));
|
|
14
|
+
export var BrushToolModes;
|
|
15
|
+
(function (BrushToolModes) {
|
|
16
|
+
BrushToolModes["Fill"] = "Fill";
|
|
17
|
+
BrushToolModes["Extrude"] = "Extrude";
|
|
18
|
+
BrushToolModes["Remove"] = "Remove";
|
|
19
|
+
})(BrushToolModes || (BrushToolModes = {}));
|
|
20
|
+
export class BrushTool extends BuilderToolBase {
|
|
21
|
+
space;
|
|
22
|
+
static ToolId = "Brush";
|
|
23
|
+
static ModeArray = [
|
|
24
|
+
BrushToolModes.Fill,
|
|
25
|
+
BrushToolModes.Extrude,
|
|
26
|
+
BrushToolModes.Remove,
|
|
27
|
+
];
|
|
28
|
+
static PositionModeArray = [
|
|
29
|
+
BrushPositionModes.Start,
|
|
30
|
+
BrushPositionModes.Center,
|
|
31
|
+
BrushPositionModes.End,
|
|
32
|
+
];
|
|
33
|
+
static get ShapesArray() {
|
|
34
|
+
return Object.keys(this.ShapeCreators);
|
|
35
|
+
}
|
|
36
|
+
static ShapeCreators = {
|
|
37
|
+
Sphere: () => {
|
|
38
|
+
return new SphereVoxelTemplate(SphereVoxelTemplate.CreateNew({}));
|
|
39
|
+
},
|
|
40
|
+
Box: () => {
|
|
41
|
+
return new BoxVoxelTemplate(BoxVoxelTemplate.CreateNew({}));
|
|
42
|
+
},
|
|
43
|
+
Pyramid: () => {
|
|
44
|
+
return new PyramidVoxelTemplate(PyramidVoxelTemplate.CreateNew({}));
|
|
45
|
+
},
|
|
46
|
+
Ellipsoid: () => {
|
|
47
|
+
return new EllipsoidVoxelTemplate(EllipsoidVoxelTemplate.CreateNew({}));
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
shape = "Sphere";
|
|
51
|
+
axisXPositionMode = BrushPositionModes.Center;
|
|
52
|
+
axisYPositionMode = BrushPositionModes.Center;
|
|
53
|
+
axisZPositionMode = BrushPositionModes.Center;
|
|
54
|
+
mode = BrushToolModes.Fill;
|
|
55
|
+
template;
|
|
56
|
+
selection;
|
|
57
|
+
_position = Vector3Like.Create();
|
|
58
|
+
constructor(space) {
|
|
59
|
+
super();
|
|
60
|
+
this.space = space;
|
|
61
|
+
this.selection = new VoxelTemplateSelection();
|
|
62
|
+
this.updateShape(this.shape);
|
|
63
|
+
}
|
|
64
|
+
async use(picked, voxelData = {}, usePlacingStrategy = true) {
|
|
65
|
+
if (usePlacingStrategy) {
|
|
66
|
+
if (voxelData.fill) {
|
|
67
|
+
const newData = this.space.getPlaceState(voxelData.fill, picked);
|
|
68
|
+
if (newData)
|
|
69
|
+
voxelData.fill = newData;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (this.mode == BrushToolModes.Fill && voxelData.fill) {
|
|
73
|
+
if (!this.space.bounds.intersectsPoint(picked.normalPosition))
|
|
74
|
+
return;
|
|
75
|
+
this.template.setVoxels(voxelData.fill);
|
|
76
|
+
const place = this.getPlacePosition(picked);
|
|
77
|
+
await this.space.paintTemplate([place.x, place.y, place.z], this.template.toJSON());
|
|
78
|
+
}
|
|
79
|
+
if (this.mode == BrushToolModes.Remove) {
|
|
80
|
+
if (!this.space.bounds.intersectsPoint(picked.position))
|
|
81
|
+
return;
|
|
82
|
+
const voxel = picked.voxel;
|
|
83
|
+
if (voxel && !voxel.isAir()) {
|
|
84
|
+
const place = this.getPlacePosition(picked);
|
|
85
|
+
await this.space.eraseTemplate([place.x, place.y, place.z], this.template.toJSON());
|
|
86
|
+
}
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
getPlacePosition(picked) {
|
|
91
|
+
//x
|
|
92
|
+
if (this.axisXPositionMode == BrushPositionModes.Center) {
|
|
93
|
+
this._position.x =
|
|
94
|
+
picked.normalPosition.x - Math.floor(this.template.bounds.size.x / 2);
|
|
95
|
+
}
|
|
96
|
+
if (this.axisXPositionMode == BrushPositionModes.Start) {
|
|
97
|
+
this._position.x = picked.normalPosition.x;
|
|
98
|
+
}
|
|
99
|
+
if (this.axisXPositionMode == BrushPositionModes.End) {
|
|
100
|
+
this._position.x = picked.normalPosition.x - this.template.bounds.size.x;
|
|
101
|
+
}
|
|
102
|
+
//y
|
|
103
|
+
if (this.axisYPositionMode == BrushPositionModes.Center) {
|
|
104
|
+
this._position.y =
|
|
105
|
+
picked.normalPosition.y - Math.floor(this.template.bounds.size.y / 2);
|
|
106
|
+
}
|
|
107
|
+
if (this.axisYPositionMode == BrushPositionModes.Start) {
|
|
108
|
+
this._position.y = picked.normalPosition.y;
|
|
109
|
+
}
|
|
110
|
+
if (this.axisYPositionMode == BrushPositionModes.End) {
|
|
111
|
+
this._position.y = picked.normalPosition.y - this.template.bounds.size.y;
|
|
112
|
+
}
|
|
113
|
+
//z
|
|
114
|
+
if (this.axisZPositionMode == BrushPositionModes.Center) {
|
|
115
|
+
this._position.z =
|
|
116
|
+
picked.normalPosition.z - Math.floor(this.template.bounds.size.z / 2);
|
|
117
|
+
}
|
|
118
|
+
if (this.axisZPositionMode == BrushPositionModes.Start) {
|
|
119
|
+
this._position.z = picked.normalPosition.z;
|
|
120
|
+
}
|
|
121
|
+
if (this.axisXPositionMode == BrushPositionModes.End) {
|
|
122
|
+
this._position.z = picked.normalPosition.z - this.template.bounds.size.z;
|
|
123
|
+
}
|
|
124
|
+
return this._position;
|
|
125
|
+
}
|
|
126
|
+
updatePlacer(picked) {
|
|
127
|
+
const place = this.getPlacePosition(picked);
|
|
128
|
+
if (!this.space.bounds.intersectsPoint(place))
|
|
129
|
+
return false;
|
|
130
|
+
this.selection.origin.x = place.x;
|
|
131
|
+
this.selection.origin.y = place.y;
|
|
132
|
+
this.selection.origin.z = place.z;
|
|
133
|
+
}
|
|
134
|
+
updateShape(shape) {
|
|
135
|
+
const shapeCreator = BrushTool.ShapeCreators[shape];
|
|
136
|
+
if (!shapeCreator)
|
|
137
|
+
throw new Error(`Shape with id ${shape} does not exist`);
|
|
138
|
+
this.shape = shape;
|
|
139
|
+
this.template = shapeCreator();
|
|
140
|
+
this.selection.setTemplate(this.template);
|
|
141
|
+
this.template.addEventListener("updated", () => {
|
|
142
|
+
this.selection.setTemplate(this.template);
|
|
143
|
+
this.dispatch("shape-updated", null);
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { VoxelPickResult } from "../../../Voxels/Interaction/VoxelPickResult";
|
|
2
|
+
import { VoxelBuildSpace } from "../../VoxelBuildSpace";
|
|
3
|
+
import { PaintVoxelData } from "../../../Voxels";
|
|
4
|
+
import { VoxelPointSelection } from "../../../Templates/Selection/VoxelPointSelection";
|
|
5
|
+
import { BuilderToolBase } from "../BuilderToolBase";
|
|
6
|
+
export declare enum HandToolModes {
|
|
7
|
+
Place = "Place",
|
|
8
|
+
Remove = "Remove"
|
|
9
|
+
}
|
|
10
|
+
interface HandToolEvents {
|
|
11
|
+
}
|
|
12
|
+
export declare class HandTool extends BuilderToolBase<HandToolEvents> {
|
|
13
|
+
space: VoxelBuildSpace;
|
|
14
|
+
static ToolId: string;
|
|
15
|
+
static ModeArray: HandToolModes[];
|
|
16
|
+
mode: HandToolModes;
|
|
17
|
+
selection: VoxelPointSelection;
|
|
18
|
+
constructor(space: VoxelBuildSpace);
|
|
19
|
+
updatePlacer(picked: VoxelPickResult): void;
|
|
20
|
+
use(picked: VoxelPickResult, voxelData: PaintVoxelData, usePlacingStrategy?: boolean): Promise<boolean | undefined>;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { VoxelPointSelection } from "../../../Templates/Selection/VoxelPointSelection";
|
|
2
|
+
import { BuilderToolBase } from "../BuilderToolBase";
|
|
3
|
+
export var HandToolModes;
|
|
4
|
+
(function (HandToolModes) {
|
|
5
|
+
HandToolModes["Place"] = "Place";
|
|
6
|
+
HandToolModes["Remove"] = "Remove";
|
|
7
|
+
})(HandToolModes || (HandToolModes = {}));
|
|
8
|
+
export class HandTool extends BuilderToolBase {
|
|
9
|
+
space;
|
|
10
|
+
static ToolId = "Hand";
|
|
11
|
+
static ModeArray = [
|
|
12
|
+
HandToolModes.Place,
|
|
13
|
+
HandToolModes.Remove,
|
|
14
|
+
];
|
|
15
|
+
mode = HandToolModes.Place;
|
|
16
|
+
selection = new VoxelPointSelection();
|
|
17
|
+
constructor(space) {
|
|
18
|
+
super();
|
|
19
|
+
this.space = space;
|
|
20
|
+
}
|
|
21
|
+
updatePlacer(picked) {
|
|
22
|
+
if (this.mode == HandToolModes.Place) {
|
|
23
|
+
this.selection.reConstruct(picked.normalPosition);
|
|
24
|
+
}
|
|
25
|
+
if (this.mode == HandToolModes.Remove) {
|
|
26
|
+
this.selection.reConstruct(picked.position);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async use(picked, voxelData, usePlacingStrategy = true) {
|
|
30
|
+
if (this.mode == HandToolModes.Place) {
|
|
31
|
+
if (!this.space.bounds.intersectsPoint(picked.normalPosition))
|
|
32
|
+
return false;
|
|
33
|
+
if (usePlacingStrategy) {
|
|
34
|
+
const newData = this.space.getPlaceState(voxelData, picked);
|
|
35
|
+
if (newData)
|
|
36
|
+
voxelData = newData;
|
|
37
|
+
}
|
|
38
|
+
await this.space.paintVoxel([
|
|
39
|
+
picked.normalPosition.x,
|
|
40
|
+
picked.normalPosition.y,
|
|
41
|
+
picked.normalPosition.z,
|
|
42
|
+
], voxelData);
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
if (this.mode == HandToolModes.Remove) {
|
|
46
|
+
if (!this.space.bounds.intersectsPoint(picked.position))
|
|
47
|
+
return false;
|
|
48
|
+
await this.space.eraseVoxel([
|
|
49
|
+
picked.position.x,
|
|
50
|
+
picked.position.y,
|
|
51
|
+
picked.position.z,
|
|
52
|
+
]);
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { VoxelBuildSpace } from "../../VoxelBuildSpace";
|
|
2
|
+
import { PaintVoxelData } from "../../../Voxels";
|
|
3
|
+
import { VoxelPointSelection } from "../../../Templates/Selection/VoxelPointSelection";
|
|
4
|
+
import { BuilderToolBase } from "../BuilderToolBase";
|
|
5
|
+
import { VoxelPath } from "../../../Templates/Path/VoxelPath";
|
|
6
|
+
export declare enum PathToolModes {
|
|
7
|
+
PlacePoints = "Place Points",
|
|
8
|
+
MovePoints = "Move Points",
|
|
9
|
+
RemovePoints = "Remove Points",
|
|
10
|
+
FillPath = "Fill Path",
|
|
11
|
+
RemovePath = "Remvoe Path"
|
|
12
|
+
}
|
|
13
|
+
interface PathToolEvents {
|
|
14
|
+
}
|
|
15
|
+
export declare class PathTool extends BuilderToolBase<PathToolEvents> {
|
|
16
|
+
space: VoxelBuildSpace;
|
|
17
|
+
static ToolId: string;
|
|
18
|
+
static ModeArray: PathToolModes[];
|
|
19
|
+
mode: PathToolModes;
|
|
20
|
+
selection: VoxelPointSelection;
|
|
21
|
+
path: VoxelPath;
|
|
22
|
+
distance: number;
|
|
23
|
+
private _placedSegment;
|
|
24
|
+
constructor(space: VoxelBuildSpace);
|
|
25
|
+
setMode(mode: PathToolModes): void;
|
|
26
|
+
updatePlacer(): void;
|
|
27
|
+
use(voxelData: PaintVoxelData, usePlacingStrategy?: boolean): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { VoxelPointSelection } from "../../../Templates/Selection/VoxelPointSelection";
|
|
2
|
+
import { BuilderToolBase } from "../BuilderToolBase";
|
|
3
|
+
import { VoxelPath, VoxelPathSegment } from "../../../Templates/Path/VoxelPath";
|
|
4
|
+
import { Vector3Like } from "@amodx/math";
|
|
5
|
+
export var PathToolModes;
|
|
6
|
+
(function (PathToolModes) {
|
|
7
|
+
PathToolModes["PlacePoints"] = "Place Points";
|
|
8
|
+
PathToolModes["MovePoints"] = "Move Points";
|
|
9
|
+
PathToolModes["RemovePoints"] = "Remove Points";
|
|
10
|
+
PathToolModes["FillPath"] = "Fill Path";
|
|
11
|
+
PathToolModes["RemovePath"] = "Remvoe Path";
|
|
12
|
+
})(PathToolModes || (PathToolModes = {}));
|
|
13
|
+
export class PathTool extends BuilderToolBase {
|
|
14
|
+
space;
|
|
15
|
+
static ToolId = "Path";
|
|
16
|
+
static ModeArray = [
|
|
17
|
+
PathToolModes.PlacePoints,
|
|
18
|
+
PathToolModes.MovePoints,
|
|
19
|
+
PathToolModes.RemovePoints,
|
|
20
|
+
PathToolModes.FillPath,
|
|
21
|
+
PathToolModes.RemovePath,
|
|
22
|
+
];
|
|
23
|
+
mode = PathToolModes.PlacePoints;
|
|
24
|
+
selection = new VoxelPointSelection();
|
|
25
|
+
path = new VoxelPath(VoxelPath.CreateNew({}));
|
|
26
|
+
distance = 10;
|
|
27
|
+
_placedSegment = false;
|
|
28
|
+
constructor(space) {
|
|
29
|
+
super();
|
|
30
|
+
this.space = space;
|
|
31
|
+
}
|
|
32
|
+
setMode(mode) {
|
|
33
|
+
const lastMode = this.mode;
|
|
34
|
+
this.mode = mode;
|
|
35
|
+
if (lastMode == PathToolModes.PlacePoints && this._placedSegment) {
|
|
36
|
+
this._placedSegment = false;
|
|
37
|
+
if (this.path.lastSegment())
|
|
38
|
+
this.path.removeSegment(this.path.lastSegment());
|
|
39
|
+
}
|
|
40
|
+
if (mode == PathToolModes.PlacePoints && this.path.segments.length) {
|
|
41
|
+
const point = this.path.lastSegment().getPoint(1);
|
|
42
|
+
this.path.addSegment(VoxelPathSegment.CreateNew({
|
|
43
|
+
transient: true,
|
|
44
|
+
start: [...point],
|
|
45
|
+
end: [
|
|
46
|
+
this.selection.origin.x,
|
|
47
|
+
this.selection.origin.y,
|
|
48
|
+
this.selection.origin.z,
|
|
49
|
+
],
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
updatePlacer() {
|
|
54
|
+
if (this.mode == PathToolModes.PlacePoints) {
|
|
55
|
+
const rayPosition = Vector3Like.FloorInPlace(Vector3Like.Add(this.space.rayProvider.origin, Vector3Like.MultiplyScalar(this.space.rayProvider.direction, this.distance)));
|
|
56
|
+
if (!this.space.bounds.intersectsPoint(rayPosition)) {
|
|
57
|
+
//get point ray intersects with the space bounding box and use that instead
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
this.selection.reConstruct(rayPosition);
|
|
61
|
+
}
|
|
62
|
+
const last = this.path.lastSegment();
|
|
63
|
+
if (last) {
|
|
64
|
+
last.setPoints(last.start, [
|
|
65
|
+
this.selection.origin.x,
|
|
66
|
+
this.selection.origin.y,
|
|
67
|
+
this.selection.origin.z,
|
|
68
|
+
]);
|
|
69
|
+
}
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
async use(voxelData, usePlacingStrategy = true) {
|
|
74
|
+
if (this.mode == PathToolModes.PlacePoints) {
|
|
75
|
+
this._placedSegment = true;
|
|
76
|
+
if (!this.path.totalSegments) {
|
|
77
|
+
this.path.addSegment(VoxelPathSegment.CreateNew({
|
|
78
|
+
transient: true,
|
|
79
|
+
start: [
|
|
80
|
+
this.selection.origin.x,
|
|
81
|
+
this.selection.origin.y,
|
|
82
|
+
this.selection.origin.z,
|
|
83
|
+
],
|
|
84
|
+
end: [
|
|
85
|
+
this.selection.origin.x,
|
|
86
|
+
this.selection.origin.y,
|
|
87
|
+
this.selection.origin.z,
|
|
88
|
+
],
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
const lastSegment = this.path.lastSegment();
|
|
93
|
+
lastSegment.transient = false;
|
|
94
|
+
this.path.addSegment(VoxelPathSegment.CreateNew({
|
|
95
|
+
transient: true,
|
|
96
|
+
start: [...lastSegment.end],
|
|
97
|
+
end: [
|
|
98
|
+
this.selection.origin.x,
|
|
99
|
+
this.selection.origin.y,
|
|
100
|
+
this.selection.origin.z,
|
|
101
|
+
],
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (this.mode == PathToolModes.FillPath) {
|
|
106
|
+
for (const segment of this.path.segments) {
|
|
107
|
+
segment.voxel = voxelData;
|
|
108
|
+
}
|
|
109
|
+
await this.space.paintPath([0, 0, 0], this.path.toJSON());
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (this.mode == PathToolModes.RemovePath) {
|
|
113
|
+
await this.space.erasePath([0, 0, 0], this.path.toJSON());
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { VoxelPickResult } from "../../../Voxels/Interaction/VoxelPickResult";
|
|
2
|
+
import { VoxelBuildSpace } from "../../VoxelBuildSpace";
|
|
3
|
+
import { PaintVoxelData } from "../../../Voxels/Types/PaintVoxelData";
|
|
4
|
+
import { VoxelSurfaceSelection } from "../../../Templates/Selection/VoxelSurfaceSelection";
|
|
5
|
+
import { VoxelBFSSelection } from "../../../Templates/Selection/VoxelBFSSelection";
|
|
6
|
+
import { BuilderToolBase } from "../BuilderToolBase";
|
|
7
|
+
export declare enum WandToolModes {
|
|
8
|
+
Place = "Place",
|
|
9
|
+
Extrude = "Extrude",
|
|
10
|
+
Remove = "Remove"
|
|
11
|
+
}
|
|
12
|
+
interface WandToolEvents {
|
|
13
|
+
}
|
|
14
|
+
export declare class WandTool extends BuilderToolBase<WandToolEvents> {
|
|
15
|
+
space: VoxelBuildSpace;
|
|
16
|
+
static ToolId: string;
|
|
17
|
+
static ModeArray: WandToolModes[];
|
|
18
|
+
mode: WandToolModes;
|
|
19
|
+
maxCount: number;
|
|
20
|
+
extrusion: number;
|
|
21
|
+
get selection(): VoxelSurfaceSelection | VoxelBFSSelection;
|
|
22
|
+
surfaceSelection: VoxelSurfaceSelection;
|
|
23
|
+
bfsSelection: VoxelBFSSelection;
|
|
24
|
+
constructor(space: VoxelBuildSpace);
|
|
25
|
+
updatePlacer(picked: VoxelPickResult): Promise<void>;
|
|
26
|
+
use(picked: VoxelPickResult, voxelData: PaintVoxelData, usePlacingStrategy?: boolean): Promise<boolean | undefined>;
|
|
27
|
+
}
|
|
28
|
+
export {};
|