Do some more refactoring

This commit is contained in:
schmelczerandras 2020-07-30 20:59:37 +02:00
parent c892ca2d01
commit 24cc572e47
29 changed files with 191 additions and 152 deletions

View file

@ -18,7 +18,6 @@ A good-looking 2D adventure.
- subtract cameraPosition - subtract cameraPosition
- cross browser testing - cross browser testing
- nginx log monitor - nginx log monitor
- pass befejezése
- lightweight object storage - lightweight object storage
- local dev env - local dev env
- CI pipeline: - CI pipeline:

View file

@ -1,5 +1,5 @@
import { Command } from '../command'; import { Command } from '../../commands/command';
import { IRenderer } from '../../drawing/i-renderer'; import { IRenderer } from '../i-renderer';
export class BeforeRenderCommand extends Command { export class BeforeRenderCommand extends Command {
public constructor(public readonly renderer?: IRenderer) { public constructor(public readonly renderer?: IRenderer) {

View file

@ -1,5 +1,5 @@
import { Command } from '../command';
import { IRenderer } from '../../drawing/i-renderer'; import { IRenderer } from '../../drawing/i-renderer';
import { Command } from '../../commands/command';
export class RenderCommand extends Command { export class RenderCommand extends Command {
public constructor(public readonly renderer?: IRenderer) { public constructor(public readonly renderer?: IRenderer) {

View file

@ -5,8 +5,8 @@ import { IDrawableDescriptor } from '../i-drawable-descriptor';
export class CircleLight implements ILight { export class CircleLight implements ILight {
public static descriptor: IDrawableDescriptor = { public static descriptor: IDrawableDescriptor = {
uniformName: 'lights', uniformName: 'circleLights',
countMacroName: 'lightCount', countMacroName: 'circleLightCount',
shaderCombinationSteps: settings.shaderCombinations.circleLightSteps, shaderCombinationSteps: settings.shaderCombinations.circleLightSteps,
}; };
@ -17,15 +17,15 @@ export class CircleLight implements ILight {
public lightness: number public lightness: number
) {} ) {}
distance(target: vec2): number { public distance(target: vec2): number {
return 0; return 0;
} }
minimumDistance(target: vec2): number { public minimumDistance(target: vec2): number {
return 0; return 0;
} }
serializeToUniforms(uniforms: any): void { public serializeToUniforms(uniforms: any): void {
const listName = CircleLight.descriptor.uniformName; const listName = CircleLight.descriptor.uniformName;
if (!uniforms.hasOwnProperty(listName)) { if (!uniforms.hasOwnProperty(listName)) {
@ -39,7 +39,7 @@ export class CircleLight implements ILight {
}); });
} }
get value(): vec3 { public get value(): vec3 {
return vec3.scale( return vec3.scale(
vec3.create(), vec3.create(),
vec3.normalize(this.color, this.color), vec3.normalize(this.color, this.color),

View file

@ -1,23 +1,32 @@
import { ILight } from './i-light'; import { ILight } from './i-light';
import { vec2, vec3 } from 'gl-matrix'; import { vec2, vec3 } from 'gl-matrix';
import { IDrawableDescriptor } from '../i-drawable-descriptor';
import { settings } from '../../settings';
export class PointLight implements ILight { export class PointLight implements ILight {
public static uniformName = 'lights'; public static descriptor: IDrawableDescriptor = {
uniformName: 'pointLights',
countMacroName: 'pointLightCount',
shaderCombinationSteps: settings.shaderCombinations.pointLightSteps,
};
constructor( constructor(
public center: vec2, public center: vec2,
public radius: number,
public color: vec3, public color: vec3,
public lightness: number public lightness: number
) {} ) {}
distance(target: vec2): number {
throw new Error('Method not implemented.'); public distance(target: vec2): number {
} return vec2.distance(this.center, target) - this.radius;
minimumDistance(target: vec2): number {
throw new Error('Method not implemented.');
} }
serializeToUniforms(uniforms: any): void { public minimumDistance(target: vec2): number {
const listName = PointLight.uniformName; return vec2.distance(this.center, target) - this.radius;
}
public serializeToUniforms(uniforms: any): void {
const listName = PointLight.descriptor.uniformName;
if (!uniforms.hasOwnProperty(listName)) { if (!uniforms.hasOwnProperty(listName)) {
uniforms[listName] = []; uniforms[listName] = [];
@ -25,12 +34,12 @@ export class PointLight implements ILight {
uniforms[listName].push({ uniforms[listName].push({
center: this.center, center: this.center,
radius: 0, radius: this.radius,
value: this.value, value: this.value,
}); });
} }
get value(): vec3 { public get value(): vec3 {
return vec3.scale(vec3.create(), this.color, this.lightness); return vec3.scale(vec3.create(), this.color, this.lightness);
} }
} }

View file

@ -25,7 +25,6 @@ export class TunnelShape implements IPrimitive {
public readonly toRadius: number public readonly toRadius: number
) { ) {
this.toFromDelta = vec2.subtract(vec2.create(), to, from); this.toFromDelta = vec2.subtract(vec2.create(), to, from);
this.toFromDeltaLength = vec2.length(this.toFromDelta);
this.boundingCircle = new Circle( this.boundingCircle = new Circle(
vec2.fromValues(from.x / 2 + to.x / 2, from.y / 2 + to.y / 2), vec2.fromValues(from.x / 2 + to.x / 2, from.y / 2 + to.y / 2),
@ -50,8 +49,7 @@ export class TunnelShape implements IPrimitive {
const targetFromDelta = vec2.subtract(vec2.create(), target, this.from); const targetFromDelta = vec2.subtract(vec2.create(), target, this.from);
const h = clamp01( const h = clamp01(
vec2.dot(targetFromDelta, this.toFromDelta) / vec2.dot(targetFromDelta, this.toFromDelta) /
this.toFromDeltaLength / vec2.dot(this.toFromDelta, this.toFromDelta)
this.toFromDeltaLength
); );
return ( return (
vec2.distance( vec2.distance(

View file

@ -1,4 +1,4 @@
import { mat2d, vec2 } from 'gl-matrix'; import { mat2d, vec2, vec3 } from 'gl-matrix';
import caveFragmentShader from '../shaders/cave-distance-fs.glsl'; import caveFragmentShader from '../shaders/cave-distance-fs.glsl';
import lightsFragmentShader from '../shaders/lights-shading-fs.glsl'; import lightsFragmentShader from '../shaders/lights-shading-fs.glsl';
import caveVertexShader from '../shaders/passthrough-distance-vs.glsl'; import caveVertexShader from '../shaders/passthrough-distance-vs.glsl';
@ -20,6 +20,7 @@ import { getWebGl2Context } from '../graphics-library/helper/get-webgl2-context'
import { RenderingPass } from './rendering-pass'; import { RenderingPass } from './rendering-pass';
import { TunnelShape } from '../drawables/primitives/tunnel-shape'; import { TunnelShape } from '../drawables/primitives/tunnel-shape';
import { CircleLight } from '../drawables/lights/circle-light'; import { CircleLight } from '../drawables/lights/circle-light';
import { PointLight } from '../drawables/lights/point-light';
export class WebGl2Renderer implements IRenderer { export class WebGl2Renderer implements IRenderer {
private gl: WebGL2RenderingContext; private gl: WebGL2RenderingContext;
@ -53,7 +54,7 @@ export class WebGl2Renderer implements IRenderer {
this.lightingPass = new RenderingPass( this.lightingPass = new RenderingPass(
this.gl, this.gl,
[lightsVertexShader, lightsFragmentShader], [lightsVertexShader, lightsFragmentShader],
[CircleLight.descriptor], [CircleLight.descriptor, PointLight.descriptor],
this.lightingFrameBuffer this.lightingFrameBuffer
); );
@ -85,6 +86,9 @@ export class WebGl2Renderer implements IRenderer {
public finishFrame() { public finishFrame() {
const uniforms = this.calculateOwnUniforms(); const uniforms = this.calculateOwnUniforms();
this.lightingPass.addDrawable(
new PointLight(uniforms.cursorPosition, 200, vec3.fromValues(1, 1, 0), 1)
);
this.distancePass.render(uniforms, this.viewCircle); this.distancePass.render(uniforms, this.viewCircle);
this.lightingPass.render( this.lightingPass.render(
uniforms, uniforms,

View file

@ -22,10 +22,12 @@ export const settings = {
tileMultiplier: 5, tileMultiplier: 5,
shaderMacros: { shaderMacros: {
distanceScale: 64, distanceScale: 64,
distanceOffset: 0.15,
edgeSmoothing: 10, edgeSmoothing: 10,
}, },
shaderCombinations: { shaderCombinations: {
lineSteps: [0, 1, 2, 3, 4, 8, 16, 32], lineSteps: [0, 1, 2, 3, 4, 8, 16, 32],
circleLightSteps: [0, 1, 2, 3], circleLightSteps: [0, 1, 2, 3],
pointLightSteps: [0, 1, 2, 3],
}, },
}; };

View file

@ -6,7 +6,7 @@ precision mediump float;
#define CAVE_COLOR vec3(0.36, 0.38, 0.76) #define CAVE_COLOR vec3(0.36, 0.38, 0.76)
#define AIR_COLOR vec3(0.7) #define AIR_COLOR vec3(0.7)
#define DISTANCE_SCALE {distanceScale} #define DISTANCE_SCALE {distanceScale}
#define EDGE_SMOOTHING {edgeSmoothing} #define DISTANCE_OFFSET {distanceOffset}
uniform float maxMinDistance; uniform float maxMinDistance;
@ -23,28 +23,25 @@ in vec2 worldCoordinates;
out vec4 fragmentColor; out vec4 fragmentColor;
void main() { void main() {
float realDistance = 0.0;
#if LINE_COUNT > 0 #if LINE_COUNT > 0
float minDistance = maxMinDistance; float minDistance = maxMinDistance;
for (int i = 0; i < LINE_COUNT; i++) { for (int i = 0; i < LINE_COUNT; i++) {
Line line = lines[i]; vec2 pa = worldCoordinates - lines[i].from;
vec2 pa = worldCoordinates - line.from; vec2 ba = lines[i].toFromDelta;
vec2 ba = line.toFromDelta; float h = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0);
float baLength = length(ba); float lineDistance = distance(pa, ba * h) - mix(lines[i].fromRadius, lines[i].toRadius, h);
// todo: do we really want this dot(pa / baLength, ba / baLength)
float h = clamp(dot(pa / baLength, ba / baLength), 0.0, 1.0);
float lineDistance = distance(pa, ba * h) - mix(line.fromRadius, line.toRadius, h);
minDistance = min(minDistance, lineDistance); minDistance = min(minDistance, lineDistance);
} }
float distance = -minDistance; realDistance = -minDistance;
fragmentColor = vec4(
mix(CAVE_COLOR, AIR_COLOR, clamp(distance, -EDGE_SMOOTHING, 0.0) / EDGE_SMOOTHING + 1.0),
distance / DISTANCE_SCALE
);
#else
fragmentColor = vec4(AIR_COLOR, maxMinDistance / DISTANCE_SCALE);
#endif #endif
fragmentColor = vec4(
mix(CAVE_COLOR, AIR_COLOR, clamp(realDistance, 0.0, 1.0)),
(realDistance + DISTANCE_OFFSET) / DISTANCE_SCALE - 1.0/255.0
);
} }

View file

@ -7,58 +7,43 @@ precision mediump float;
#define MIN_STEP 1.0 #define MIN_STEP 1.0
#define AMBIENT_LIGHT vec3(0.15) #define AMBIENT_LIGHT vec3(0.15)
#define LIGHT_COUNT {lightCount} #define CIRCLE_LIGHT_COUNT {circleLightCount}
#define POINT_LIGHT_COUNT {pointLightCount}
#define DISTANCE_SCALE {distanceScale} #define DISTANCE_SCALE {distanceScale}
#define DISTANCE_OFFSET {distanceOffset}
#define EDGE_SMOOTHING {edgeSmoothing} #define EDGE_SMOOTHING {edgeSmoothing}
#if LIGHT_COUNT > 0
uniform struct Light {
vec2 center;
float radius;
vec3 value;
}[LIGHT_COUNT] lights;
uniform sampler2D distanceTexture; uniform sampler2D distanceTexture;
uniform vec2 viewBoxSize; uniform vec2 viewBoxSize;
in vec2[LIGHT_COUNT] directions;
float getDistance(in vec2 target, out vec3 color) { float getDistance(in vec2 target, out vec3 color) {
vec4 values = texture(distanceTexture, target); vec4 values = texture(distanceTexture, target);
color = values.rgb; color = values.rgb;
return values.w * DISTANCE_SCALE; return (values.w - DISTANCE_OFFSET) * DISTANCE_SCALE;
} }
float getDistance(in vec2 target) { float getDistance(in vec2 target) {
return texture(distanceTexture, target).w * DISTANCE_SCALE; return (texture(distanceTexture, target).w - DISTANCE_OFFSET) * DISTANCE_SCALE;
} }
float getFractionOfLightArriving( #if CIRCLE_LIGHT_COUNT > 0
in vec2 target, uniform struct CircleLight {
in vec2 direction, vec2 center;
in float startingDistance, float radius;
in float lightDistance, vec3 value;
in float lightRadius }[CIRCLE_LIGHT_COUNT] circleLights;
) {
float q = 1.0;
float rayLength = startingDistance;
float movingAverageMeanDistance = startingDistance;
direction /= viewBoxSize; in vec2[CIRCLE_LIGHT_COUNT] circleLightDirections;
#endif
for (int j = 0; j < 48; j++) { #if POINT_LIGHT_COUNT > 0
float minDistance = getDistance(target + direction * rayLength); uniform struct PointLight {
movingAverageMeanDistance = movingAverageMeanDistance / 2.0 + minDistance / 2.0; vec2 center;
q = min(q, movingAverageMeanDistance / rayLength); float radius;
vec3 value;
}[POINT_LIGHT_COUNT] pointLights;
rayLength += max(MIN_STEP, minDistance); in vec2[POINT_LIGHT_COUNT] pointLightDirections;
if (rayLength > lightDistance) {
return clamp(q * (lightDistance + lightRadius) / lightRadius, 0.0, 1.0);
}
}
return 0.0;
}
#endif #endif
in vec2 worldCoordinates; in vec2 worldCoordinates;
@ -66,35 +51,65 @@ in vec2 uvCoordinates;
out vec4 fragmentColor; out vec4 fragmentColor;
void main() { void main() {
#if LIGHT_COUNT > 0
vec3 colorAtPosition; vec3 colorAtPosition;
float startingDistance = getDistance(uvCoordinates, colorAtPosition); float startingDistance = getDistance(uvCoordinates, colorAtPosition);
vec3 ligthing = AMBIENT_LIGHT;
vec3 ligthing = vec3(0.0); #if CIRCLE_LIGHT_COUNT > 0
for (int i = 0; i < CIRCLE_LIGHT_COUNT; i++) {
float lightCenterDistance = distance(circleLights[i].center, worldCoordinates);
vec3 lightColorAtPosition = circleLights[i].value / pow(lightCenterDistance / LIGHT_DROP + 1.0, 2.0);
for (int i = 0; i < LIGHT_COUNT; i++) { float q = INFINITY;
Light light = lights[i]; float rayLength = startingDistance;
float lightDistance = distance(light.center, worldCoordinates); float exponentialDecayDistance = rayLength;
vec2 direction = normalize(circleLightDirections[i]) / viewBoxSize;
float r = (lightDistance + light.radius) / LIGHT_DROP + 1.0; for (int j = 0; j < 48; j++) {
vec3 lightColorAtPosition = light.value / (r * r); if (rayLength > lightCenterDistance) {
ligthing += lightColorAtPosition * clamp(
float fractionOfLightArriving = getFractionOfLightArriving( q / circleLights[i].radius * (lightCenterDistance + 1.0), 0.0, 1.0
uvCoordinates, normalize(directions[i]), startingDistance, ) * step(circleLights[i].radius, getDistance(uvCoordinates + direction * lightCenterDistance));
lightDistance, light.radius break;
);
ligthing += lightColorAtPosition * fractionOfLightArriving;
} }
fragmentColor = vec4( float minDistance = getDistance(uvCoordinates + direction * rayLength);
colorAtPosition * (AMBIENT_LIGHT + exponentialDecayDistance = (exponentialDecayDistance + minDistance) / 2.0;
step(EDGE_SMOOTHING / 2.0, clamp(startingDistance, 0.0, EDGE_SMOOTHING)) * ligthing), q = min(q, exponentialDecayDistance / rayLength);
1.0 rayLength += max(MIN_STEP, minDistance);
); }
}
#else
fragmentColor = vec4(1.0);
#endif #endif
#if POINT_LIGHT_COUNT > 0
for (int i = 0; i < POINT_LIGHT_COUNT; i++) {
float lightDistance = distance(pointLights[i].center, worldCoordinates);
vec3 lightColorAtPosition = mix(
pointLights[i].value,
vec3(0.0),
sqrt(clamp(lightDistance / pointLights[i].radius, 0.0, 1.0))
);
float q = INFINITY;
float rayLength = startingDistance;
float exponentialDecayDistance = startingDistance;
vec2 direction = normalize(pointLightDirections[i]) / viewBoxSize;
for (int j = 0; j < 48; j++) {
if (rayLength > lightDistance) {
ligthing += lightColorAtPosition * step(0.0, q);
break;
}
float minDistance = getDistance(uvCoordinates + direction * rayLength);
exponentialDecayDistance = (exponentialDecayDistance + minDistance) / 2.0;
q = min(q, exponentialDecayDistance);
rayLength += max(MIN_STEP, minDistance);
}
}
#endif
fragmentColor = vec4(colorAtPosition * ligthing * clamp(startingDistance, 0.0, 1.0), 1.0);
} }

View file

@ -2,7 +2,8 @@
precision mediump float; precision mediump float;
#define LIGHT_COUNT {lightCount} #define CIRCLE_LIGHT_COUNT {circleLightCount}
#define POINT_LIGHT_COUNT {pointLightCount}
uniform mat3 modelTransform; uniform mat3 modelTransform;
uniform mat3 ndcToUv; uniform mat3 ndcToUv;
@ -13,14 +14,24 @@ in vec4 vertexPosition;
out vec2 worldCoordinates; out vec2 worldCoordinates;
out vec2 uvCoordinates; out vec2 uvCoordinates;
#if LIGHT_COUNT > 0 #if CIRCLE_LIGHT_COUNT > 0
uniform struct Light { uniform struct CircleLight {
vec2 center; vec2 center;
float radius; float radius;
vec3 value; vec3 value;
}[LIGHT_COUNT] lights; }[CIRCLE_LIGHT_COUNT] circleLights;
out vec2[LIGHT_COUNT] directions; out vec2[CIRCLE_LIGHT_COUNT] circleLightDirections;
#endif
#if POINT_LIGHT_COUNT > 0
uniform struct PointLight {
vec2 center;
float radius;
vec3 value;
}[POINT_LIGHT_COUNT] pointLights;
out vec2[POINT_LIGHT_COUNT] pointLightDirections;
#endif #endif
void main() { void main() {
@ -29,9 +40,15 @@ void main() {
worldCoordinates = (uvCoordinates1 * uvToWorld).xy; worldCoordinates = (uvCoordinates1 * uvToWorld).xy;
uvCoordinates = (uvCoordinates1).xy; uvCoordinates = (uvCoordinates1).xy;
#if LIGHT_COUNT > 0 #if CIRCLE_LIGHT_COUNT > 0
for (int i = 0; i < LIGHT_COUNT; i++) { for (int i = 0; i < CIRCLE_LIGHT_COUNT; i++) {
directions[i] = lights[i].center - worldCoordinates; circleLightDirections[i] = circleLights[i].center - worldCoordinates;
}
#endif
#if POINT_LIGHT_COUNT > 0
for (int i = 0; i < POINT_LIGHT_COUNT; i++) {
pointLightDirections[i] = pointLights[i].center - worldCoordinates;
} }
#endif #endif

View file

@ -1,7 +1,6 @@
import { CommandBroadcaster } from './commands/command-broadcaster'; import { CommandBroadcaster } from './commands/command-broadcaster';
import { BeforeRenderCommand } from './commands/types/before-render'; import { BeforeRenderCommand } from './drawing/commands/before-render';
import { RenderCommand } from './commands/types/draw'; import { StepCommand } from './physics/commands/step';
import { StepCommand } from './commands/types/step';
import { WebGl2Renderer } from './drawing/rendering/webgl2-renderer'; import { WebGl2Renderer } from './drawing/rendering/webgl2-renderer';
import { timeIt } from './helper/timing'; import { timeIt } from './helper/timing';
import { KeyboardListener } from './input/keyboard-listener'; import { KeyboardListener } from './input/keyboard-listener';
@ -11,6 +10,7 @@ import { ObjectContainer } from './objects/object-container';
import { InfoText } from './objects/types/info-text'; import { InfoText } from './objects/types/info-text';
import { createCharacter } from './objects/world/create-character'; import { createCharacter } from './objects/world/create-character';
import { createDungeon } from './objects/world/create-dungeon'; import { createDungeon } from './objects/world/create-dungeon';
import { RenderCommand } from './drawing/commands/render';
export class Game { export class Game {
private previousTime?: DOMHighResTimeStamp = null; private previousTime?: DOMHighResTimeStamp = null;

View file

@ -1,4 +1,4 @@
import { Command } from '../command'; import { Command } from '../../commands/command';
import { vec2 } from 'gl-matrix'; import { vec2 } from 'gl-matrix';
export class CursorMoveCommand extends Command { export class CursorMoveCommand extends Command {

View file

@ -1,4 +1,4 @@
import { Command } from '../command'; import { Command } from '../../commands/command';
export class KeyDownCommand extends Command { export class KeyDownCommand extends Command {
public constructor(public readonly key?: string) { public constructor(public readonly key?: string) {

View file

@ -1,4 +1,4 @@
import { Command } from '../command'; import { Command } from '../../commands/command';
export class KeyUpCommand extends Command { export class KeyUpCommand extends Command {
public constructor(public readonly key?: string) { public constructor(public readonly key?: string) {

View file

@ -1,5 +1,5 @@
import { Command } from '../command';
import { vec2 } from 'gl-matrix'; import { vec2 } from 'gl-matrix';
import { Command } from '../../commands/command';
export class PrimaryActionCommand extends Command { export class PrimaryActionCommand extends Command {
public constructor(public readonly position?: vec2) { public constructor(public readonly position?: vec2) {

View file

@ -1,5 +1,5 @@
import { Command } from '../command';
import { vec2 } from 'gl-matrix'; import { vec2 } from 'gl-matrix';
import { Command } from '../../commands/command';
export class SecondaryActionCommand extends Command { export class SecondaryActionCommand extends Command {
public constructor(public readonly position?: vec2) { public constructor(public readonly position?: vec2) {

View file

@ -1,5 +1,5 @@
import { Command } from '../command';
import { vec2 } from 'gl-matrix'; import { vec2 } from 'gl-matrix';
import { Command } from '../../commands/command';
export class SwipeCommand extends Command { export class SwipeCommand extends Command {
public constructor(public readonly delta?: vec2) { public constructor(public readonly delta?: vec2) {

View file

@ -1,4 +1,4 @@
import { Command } from '../command'; import { Command } from '../../commands/command';
export class ZoomCommand extends Command { export class ZoomCommand extends Command {
public constructor(public readonly factor?: number) { public constructor(public readonly factor?: number) {

View file

@ -1,6 +1,6 @@
import { CommandGenerator } from '../commands/command-generator'; import { CommandGenerator } from '../commands/command-generator';
import { KeyDownCommand } from '../commands/types/key-down'; import { KeyDownCommand } from './commands/key-down';
import { KeyUpCommand } from '../commands/types/key-up'; import { KeyUpCommand } from './commands/key-up';
export class KeyboardListener extends CommandGenerator { export class KeyboardListener extends CommandGenerator {
constructor(target: Element) { constructor(target: Element) {

View file

@ -1,11 +1,11 @@
import { CommandGenerator } from '../commands/command-generator'; import { CommandGenerator } from '../commands/command-generator';
import { PrimaryActionCommand } from '../commands/types/primary-action';
import { SecondaryActionCommand } from '../commands/types/secondary-action';
import { SwipeCommand } from '../commands/types/swipe';
import { ZoomCommand } from '../commands/types/zoom';
import { vec2 } from 'gl-matrix'; import { vec2 } from 'gl-matrix';
import { clamp01 } from '../helper/clamp'; import { clamp01 } from '../helper/clamp';
import { CursorMoveCommand } from '../commands/types/cursor-move-command'; import { CursorMoveCommand } from './commands/cursor-move-command';
import { PrimaryActionCommand } from './commands/primary-action';
import { SwipeCommand } from './commands/swipe';
import { SecondaryActionCommand } from './commands/secondary-action';
import { ZoomCommand } from './commands/zoom';
export class MouseListener extends CommandGenerator { export class MouseListener extends CommandGenerator {
private previousPosition = vec2.create(); private previousPosition = vec2.create();

View file

@ -1,9 +1,9 @@
import { CommandGenerator } from '../commands/command-generator'; import { CommandGenerator } from '../commands/command-generator';
import { PrimaryActionCommand } from '../commands/types/primary-action';
import { SecondaryActionCommand } from '../commands/types/secondary-action';
import { SwipeCommand } from '../commands/types/swipe';
import { vec2 } from 'gl-matrix'; import { vec2 } from 'gl-matrix';
import { clamp01 } from '../helper/clamp'; import { clamp01 } from '../helper/clamp';
import { PrimaryActionCommand } from './commands/primary-action';
import { SecondaryActionCommand } from './commands/secondary-action';
import { SwipeCommand } from './commands/swipe';
export class TouchListener extends CommandGenerator { export class TouchListener extends CommandGenerator {
private previousPosition = vec2.create(); private previousPosition = vec2.create();

View file

@ -1,10 +1,10 @@
import { vec2 } from 'gl-matrix'; import { vec2 } from 'gl-matrix';
import { BeforeRenderCommand } from '../../commands/types/before-render'; import { BeforeRenderCommand } from '../../drawing/commands/before-render';
import { CursorMoveCommand } from '../../commands/types/cursor-move-command'; import { CursorMoveCommand } from '../../input/commands/cursor-move-command';
import { MoveToCommand } from '../../commands/types/move-to';
import { ZoomCommand } from '../../commands/types/zoom';
import { GameObject } from '../game-object'; import { GameObject } from '../game-object';
import { Lamp } from './lamp'; import { Lamp } from './lamp';
import { ZoomCommand } from '../../input/commands/zoom';
import { MoveToCommand } from '../../physics/commands/move-to';
export class Camera extends GameObject { export class Camera extends GameObject {
private inViewArea = 1920 * 1080 * 5; private inViewArea = 1920 * 1080 * 5;

View file

@ -1,11 +1,11 @@
import { vec2 } from 'gl-matrix'; import { vec2 } from 'gl-matrix';
import { KeyDownCommand } from '../../commands/types/key-down';
import { KeyUpCommand } from '../../commands/types/key-up';
import { MoveToCommand } from '../../commands/types/move-to';
import { StepCommand } from '../../commands/types/step';
import { SwipeCommand } from '../../commands/types/swipe';
import { GameObject } from '../game-object'; import { GameObject } from '../game-object';
import { Camera } from './camera'; import { Camera } from './camera';
import { StepCommand } from '../../physics/commands/step';
import { KeyDownCommand } from '../../input/commands/key-down';
import { KeyUpCommand } from '../../input/commands/key-up';
import { SwipeCommand } from '../../input/commands/swipe';
import { MoveToCommand } from '../../physics/commands/move-to';
export class Character extends GameObject { export class Character extends GameObject {
private keysDown: Set<string> = new Set(); private keysDown: Set<string> = new Set();

View file

@ -1,5 +1,5 @@
import { RenderCommand } from '../../commands/types/draw';
import { GameObject } from '../game-object'; import { GameObject } from '../game-object';
import { RenderCommand } from '../../drawing/commands/render';
export class InfoText extends GameObject { export class InfoText extends GameObject {
constructor() { constructor() {

View file

@ -1,10 +1,8 @@
import { vec2, vec3 } from 'gl-matrix'; import { vec2, vec3 } from 'gl-matrix';
import { RenderCommand } from '../../commands/types/draw';
import { MoveToCommand } from '../../commands/types/move-to';
import { GameObject } from '../game-object'; import { GameObject } from '../game-object';
import { CircleLight } from '../../drawing/drawables/lights/circle-light'; import { CircleLight } from '../../drawing/drawables/lights/circle-light';
import { RenderCommand } from '../../drawing/commands/render';
const range = 2000; import { MoveToCommand } from '../../physics/commands/move-to';
export class Lamp extends GameObject { export class Lamp extends GameObject {
private light: CircleLight; private light: CircleLight;

View file

@ -1,7 +1,7 @@
import { vec2 } from 'gl-matrix'; import { vec2 } from 'gl-matrix';
import { RenderCommand } from '../../commands/types/draw';
import { TunnelShape } from '../../drawing/drawables/primitives/tunnel-shape'; import { TunnelShape } from '../../drawing/drawables/primitives/tunnel-shape';
import { GameObject } from '../game-object'; import { GameObject } from '../game-object';
import { RenderCommand } from '../../drawing/commands/render';
export interface Line {} export interface Line {}

View file

@ -1,5 +1,5 @@
import { Command } from '../command';
import { vec2 } from 'gl-matrix'; import { vec2 } from 'gl-matrix';
import { Command } from '../../commands/command';
export class MoveToCommand extends Command { export class MoveToCommand extends Command {
public constructor(public readonly position?: vec2) { public constructor(public readonly position?: vec2) {

View file

@ -1,4 +1,4 @@
import { Command } from '../command'; import { Command } from '../../commands/command';
export class StepCommand extends Command { export class StepCommand extends Command {
public constructor( public constructor(