Add more options
This commit is contained in:
parent
d0b53678e2
commit
2481cfc3e6
1 changed files with 102 additions and 117 deletions
|
|
@ -1,6 +1,8 @@
|
|||
import { mat2d, vec2 } from 'gl-matrix';
|
||||
import { mat2d, vec2, vec3 } from 'gl-matrix';
|
||||
|
||||
export class UniformsProvider {
|
||||
public ambientLight = vec3.fromValues(0.25, 0.15, 0.25);
|
||||
|
||||
private scaleWorldLengthToNDC = 1;
|
||||
private transformWorldToNDC = mat2d.create();
|
||||
|
||||
|
|
@ -8,17 +10,15 @@ export class UniformsProvider {
|
|||
private worldAreaInView = vec2.create();
|
||||
private squareToAspectRatio = vec2.create();
|
||||
private uvToWorld = mat2d.create();
|
||||
private cursorPosition = vec2.create();
|
||||
|
||||
public softShadowsEnabled?: boolean;
|
||||
|
||||
public constructor(private gl: WebGL2RenderingContext) {}
|
||||
|
||||
public getUniforms(uniforms: any): any {
|
||||
const cursorPosition = this.uvToWorldCoordinate(this.cursorPosition);
|
||||
return {
|
||||
...uniforms,
|
||||
cursorPosition,
|
||||
ambientLight: this.ambientLight,
|
||||
uvToWorld: this.uvToWorld,
|
||||
worldAreaInView: this.worldAreaInView,
|
||||
squareToAspectRatio: this.squareToAspectRatio,
|
||||
|
|
@ -51,6 +51,10 @@ export class UniformsProvider {
|
|||
);
|
||||
}
|
||||
|
||||
public getViewArea(): vec2 {
|
||||
return this.worldAreaInView;
|
||||
}
|
||||
|
||||
public setViewArea(topLeft: vec2, size: vec2) {
|
||||
this.worldAreaInView = size;
|
||||
|
||||
|
|
@ -87,8 +91,4 @@ export class UniformsProvider {
|
|||
this.uvToWorld = mat2d.fromTranslation(mat2d.create(), this.viewAreaBottomLeft);
|
||||
mat2d.scale(this.uvToWorld, this.uvToWorld, this.worldAreaInView);
|
||||
}
|
||||
|
||||
public setCursorPosition(position: vec2): void {
|
||||
this.cursorPosition = position;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue