Add opacity control for intersection plane

This commit is contained in:
Teriuihi 2025-06-22 23:24:06 +02:00
parent 9abd570b87
commit daf88ea437
3 changed files with 31 additions and 2 deletions

View File

@ -1,5 +1,11 @@
<div #rendererContainer class="renderer-container"> <div #rendererContainer class="renderer-container">
<div class="plane-controls-overlay"> <div class="plane-controls-overlay">
<div>
<mat-form-field appearance="outline" style="width: 10ch">
<mat-label>Opacity</mat-label>
<input matInput type="number" [(ngModel)]="opacity" min="0" max="1" step="0.01" placeholder="">
</mat-form-field>
</div>
<div class="button-row"> <div class="button-row">
<button mat-mini-fab color="primary" (click)="resetCamera()" <button mat-mini-fab color="primary" (click)="resetCamera()"
matTooltip="Reset camera"> matTooltip="Reset camera">

View File

@ -7,6 +7,8 @@ import {MatTooltip} from '@angular/material/tooltip';
import {RendererService} from '../../services/renderer.service'; import {RendererService} from '../../services/renderer.service';
import {PlayerModelService} from '../../services/player-model.service'; import {PlayerModelService} from '../../services/player-model.service';
import {InputHandlerService} from '../../services/input-handler.service'; import {InputHandlerService} from '../../services/input-handler.service';
import {FormsModule} from '@angular/forms';
import {MatFormField, MatInput, MatLabel} from '@angular/material/input';
@Component({ @Component({
selector: 'app-render-container', selector: 'app-render-container',
@ -14,7 +16,11 @@ import {InputHandlerService} from '../../services/input-handler.service';
MatIcon, MatIcon,
MatMiniFabButton, MatMiniFabButton,
MatTooltip, MatTooltip,
NgIf NgIf,
FormsModule,
MatInput,
MatFormField,
MatLabel
], ],
templateUrl: './render-container.component.html', templateUrl: './render-container.component.html',
styleUrl: './render-container.component.scss' styleUrl: './render-container.component.scss'
@ -74,6 +80,14 @@ export class RenderContainerComponent implements AfterViewInit, OnDestroy {
return this.intersectionPlaneService.isPlaneLocked(); return this.intersectionPlaneService.isPlaneLocked();
} }
public set opacity(opacity: number) {
this.intersectionPlaneService.currentOpacity = opacity;
}
public get opacity(): number {
return this.intersectionPlaneService.currentOpacity;
}
/** /**
* Toggle the plane locked state * Toggle the plane locked state
*/ */

View File

@ -25,6 +25,7 @@ export class IntersectionPlaneService {
private planePosition: number = 0; // Position in 1/16th of a block private planePosition: number = 0; // Position in 1/16th of a block
private currentOrientation: PlaneOrientation = PlaneOrientation.HORIZONTAL_FRONT; private currentOrientation: PlaneOrientation = PlaneOrientation.HORIZONTAL_FRONT;
private planeLocked: boolean = false; private planeLocked: boolean = false;
private opacity: number = 0.05;
constructor(private rendererService: RendererService) { constructor(private rendererService: RendererService) {
} }
@ -152,11 +153,19 @@ export class IntersectionPlaneService {
this.intersectionPlane.material = new THREE.MeshBasicMaterial({ this.intersectionPlane.material = new THREE.MeshBasicMaterial({
color: color, color: color,
transparent: true, transparent: true,
opacity: 0.05, opacity: this.opacity,
side: THREE.DoubleSide side: THREE.DoubleSide
}); });
} }
public set currentOpacity(opacity: number) {
this.opacity = opacity;
}
public get currentOpacity(): number {
return this.opacity;
}
/** /**
* Gets the intersection plane * Gets the intersection plane
*/ */