mirror of
https://github.com/LucasDower/ObjToSchematic.git
synced 2024-12-27 03:18:59 +08:00
Minor changes to axes rendering
This commit is contained in:
parent
8e17342413
commit
4f6aa66d5c
@ -210,8 +210,8 @@ export class DebugGeometryTemplates {
|
||||
public static arrow(start: Vector3, end: Vector3, colour: RGB): AttributeData {
|
||||
const line = DebugGeometryTemplates.line(start, end, colour);
|
||||
const lineLength = Vector3.sub(end, start).magnitude();
|
||||
const coneHeight = 0.1 * lineLength;
|
||||
const coneRadius = 0.1 * coneHeight;
|
||||
const coneHeight = 0.15 * lineLength;
|
||||
const coneRadius = 0.15 * coneHeight;
|
||||
|
||||
const normal = Vector3.sub(end, start).normalise();
|
||||
const cone = DebugGeometryTemplates.cone(end, coneHeight, normal, coneRadius, colour, 1);
|
||||
@ -229,35 +229,6 @@ export class DebugGeometryTemplates {
|
||||
const gridColourMinor = new RGB(0.15, 0.15, 0.15);
|
||||
const gridColourMajor = new RGB(0.3, 0.3, 0.3);
|
||||
|
||||
if (axes) {
|
||||
buffer.add(DebugGeometryTemplates.line(
|
||||
new Vector3(-gridRadius, 0, 0),
|
||||
new Vector3(gridRadius, 0, 0),
|
||||
new RGB(0.44, 0.64, 0.11),
|
||||
));
|
||||
buffer.add(DebugGeometryTemplates.cone(
|
||||
new Vector3(gridRadius, 0, 0),
|
||||
0.5,
|
||||
new Vector3(1, 0, 0),
|
||||
0.1,
|
||||
new RGB(0.44, 0.64, 0.11),
|
||||
8,
|
||||
));
|
||||
buffer.add(DebugGeometryTemplates.line(
|
||||
new Vector3(0, 0, -gridRadius),
|
||||
new Vector3(0, 0, gridRadius),
|
||||
new RGB(0.96, 0.21, 0.32)),
|
||||
);
|
||||
buffer.add(DebugGeometryTemplates.cone(
|
||||
new Vector3(0, 0, gridRadius),
|
||||
0.5,
|
||||
new Vector3(0, 0, 1),
|
||||
0.1,
|
||||
new RGB(0.96, 0.21, 0.32),
|
||||
8,
|
||||
));
|
||||
}
|
||||
|
||||
if (bounds) {
|
||||
buffer.add(DebugGeometryTemplates.line(
|
||||
new Vector3(-gridRadius, 0, -gridRadius),
|
||||
|
@ -52,6 +52,7 @@ export class Renderer {
|
||||
public _voxelBufferRaw?: any;
|
||||
private _blockBuffer?: twgl.BufferInfo;
|
||||
private _debugBuffers: { [meshType: string]: { [bufferComponent: string]: RenderBuffer } };
|
||||
private _axisBuffer: RenderBuffer;
|
||||
|
||||
private _isGridComponentEnabled: { [bufferComponent: string]: boolean };
|
||||
|
||||
@ -78,6 +79,14 @@ export class Renderer {
|
||||
|
||||
this._isGridComponentEnabled = {};
|
||||
this._isGridComponentEnabled[EDebugBufferComponents.Grid] = false;
|
||||
|
||||
this._axisBuffer = new RenderBuffer([
|
||||
{ name: 'position', numComponents: 3 },
|
||||
{ name: 'colour', numComponents: 3 },
|
||||
]);
|
||||
this._axisBuffer.add(DebugGeometryTemplates.arrow(new Vector3(0, 0, 0), new Vector3(1, 0, 0), new RGB(0.96, 0.21, 0.32)));
|
||||
this._axisBuffer.add(DebugGeometryTemplates.arrow(new Vector3(0, 0, 0), new Vector3(0, 1, 0), new RGB(0.44, 0.64, 0.11)));
|
||||
this._axisBuffer.add(DebugGeometryTemplates.arrow(new Vector3(0, 0, 0), new Vector3(0, 0, 1), new RGB(0.18, 0.52, 0.89)));
|
||||
}
|
||||
|
||||
public update() {
|
||||
@ -202,7 +211,7 @@ export class Renderer {
|
||||
dimensions.z % 2 === 0 ? 0 : -0.5,
|
||||
);
|
||||
|
||||
this._debugBuffers[MeshType.VoxelMesh][EDebugBufferComponents.Grid] = DebugGeometryTemplates.grid(true, true, true, this._voxelSize);
|
||||
this._debugBuffers[MeshType.VoxelMesh][EDebugBufferComponents.Grid] = DebugGeometryTemplates.grid(true, true, true, this._voxelSize, this._gridOffset.x === 0, this._gridOffset.z === 0);
|
||||
this._debugBuffers[MeshType.VoxelMesh][EDebugBufferComponents.Wireframe] = DebugGeometryTemplates.voxelMeshWireframe(voxelMesh, new RGB(0.18, 0.52, 0.89), this._voxelSize);
|
||||
|
||||
this._modelsAvailable = 2;
|
||||
@ -223,7 +232,7 @@ export class Renderer {
|
||||
mag: this._gl.NEAREST,
|
||||
});
|
||||
|
||||
this._debugBuffers[MeshType.BlockMesh][EDebugBufferComponents.Grid] = DebugGeometryTemplates.grid(true, true, true, this._voxelSize);
|
||||
this._debugBuffers[MeshType.BlockMesh][EDebugBufferComponents.Grid] = DebugGeometryTemplates.grid(true, true, true, this._voxelSize, this._gridOffset.x === 0, this._gridOffset.z === 0);
|
||||
|
||||
this._modelsAvailable = 3;
|
||||
this.setModelToUse(MeshType.BlockMesh);
|
||||
@ -250,6 +259,12 @@ export class Renderer {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Draw axis
|
||||
this._gl.disable(this._gl.DEPTH_TEST);
|
||||
this._drawBuffer(this._gl.LINES, this._axisBuffer.getWebGLBuffer(), ShaderManager.Get.debugProgram, {
|
||||
u_worldViewProjection: ArcballCamera.Get.getWorldViewProjection(),
|
||||
});
|
||||
this._gl.enable(this._gl.DEPTH_TEST);
|
||||
}
|
||||
|
||||
private _drawMesh() {
|
||||
|
Loading…
Reference in New Issue
Block a user