Skip to content

Commit

Permalink
slightly saner renderer import hierarchy
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffomatic committed Dec 25, 2020
1 parent b6eacb7 commit cf80bd6
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 162 deletions.
2 changes: 1 addition & 1 deletion src/ClientSim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import { ClientMessage, ClientMessageType } from '~/network/ClientMessage'
import { IServerConnection } from '~/network/ServerConnection'
import { ServerMessage, ServerMessageType } from '~/network/ServerMessage'
import { ParticleEmitter } from '~/particles/ParticleEmitter'
import { IModelLoader } from '~/renderer/ModelLoader'
import { Primitive2d, Renderable2d, TextAlign } from '~/renderer/Renderer2d'
import { IModelLoader } from '~/renderer/Renderer3d'
import { simulate } from '~/simulate'
import * as systems from '~/systems'
import { CursorMode } from '~/systems/client/playerInput'
Expand Down
3 changes: 2 additions & 1 deletion src/ClientView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { mat2d } from 'gl-matrix'
import { vec2 } from 'gl-matrix'

import { IDebugDrawReader, IDebugDrawWriter } from '~/DebugDraw'
import { IModelLoader } from '~/renderer/ModelLoader'
import { Renderer2d } from '~/renderer/Renderer2d'
import { IModelLoader, Renderer3d } from '~/renderer/Renderer3d'
import { Renderer3d } from '~/renderer/Renderer3d'
import { Immutable } from '~/types/immutable'
import { RunningAverage } from '~/util/RunningAverage'
import * as time from '~/util/time'
Expand Down
14 changes: 2 additions & 12 deletions src/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ import { model as tank } from '~/models/tank'
import { model as tree } from '~/models/tree'
import { model as turret } from '~/models/turret'
import { model as wall } from '~/models/wall'

export enum ModelPrimitive {
Lines,
Triangles,
}
import { ModelDef, ModelPrimitive } from '~/renderer/common'

const models: {
[key: string]: {
Expand Down Expand Up @@ -38,16 +34,10 @@ const materials: { [key: string]: [number, number, number, number] } = {
}

type ModelTypes = keyof typeof models
export type Model = {
primitive: ModelPrimitive
positions: Float32Array
colors?: Float32Array
normals?: Float32Array
}

const defaultColor = [1.0, 0, 1.0, 1.0]

export const getModel: (modelType: ModelTypes) => Model = (modelType) => {
export const getModel: (modelType: ModelTypes) => ModelDef = (modelType) => {
const obj = models[modelType]

const vertices: number[] = []
Expand Down
11 changes: 11 additions & 0 deletions src/renderer/ModelLoader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { ModelDef } from '~/renderer/common'

export interface IModelLoader {
loadModel: (modelName: string, model: ModelDef, shaderName: string) => void
}

export class StubModelLoader implements IModelLoader {
loadModel(_modelName: string, _model: ModelDef, _shaderName: string): void {
/* do nothing */
}
}
Loading

0 comments on commit cf80bd6

Please sign in to comment.