Skip to content

Commit

Permalink
add model for core
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffomatic committed Dec 25, 2020
1 parent 3169d03 commit deea153
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 22 deletions.
17 changes: 3 additions & 14 deletions src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,20 +182,9 @@ export class Client {
const gridModel = loadGrid()
this.renderer3d.loadModel('grid', gridModel, 'standard')

const wallModel = getModel('wall')
this.renderer3d.loadModel('wall', wallModel, 'standard')

const tankModel = getModel('tank')
this.renderer3d.loadModel('tank', tankModel, 'standard')

const turretModel = getModel('turret')
this.renderer3d.loadModel('turret', turretModel, 'standard')

const treeModel = getModel('tree')
this.renderer3d.loadModel('tree', treeModel, 'standard')

const bulletModel = getModel('bullet')
this.renderer3d.loadModel('bullet', bulletModel, 'standard')
for (const m of ['bullet', 'core', 'tank', 'tree', 'turret', 'wall']) {
this.renderer3d.loadModel(m, getModel(m), 'standard')
}

this.camera2d.minWorldPos = this.terrainLayer.minWorldPos()
this.camera2d.worldDimensions = this.terrainLayer.dimensions()
Expand Down
2 changes: 1 addition & 1 deletion src/entities/pickups/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ export const makeCorePickup = (): EntityComponents => {
offset: vec2.fromValues(-TILE_SIZE * 0.5, -TILE_SIZE * 0.5),
dimensions: vec2.fromValues(TILE_SIZE, TILE_SIZE),
}
e.renderable = 'not a real model'
e.renderable = 'core'
return e
}
40 changes: 40 additions & 0 deletions src/models/core.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { vec3 } from 'gl-matrix'

const obj = `
mtllib cube.mtl
o Cube
v 1 -1 -1
v 1 -1 1
v -1 -1 1
v -1 -1 -1
v 1 1 -1
v 1 1 1
v -1 1 1
v -1 1 -1
vn 0 -1 0
vn 0 1 0
vn 1 0 0
vn -0 0 1
vn -1 -0 -0
vn 0 0 -1
usemtl core
s off
f 2/1/1 3/2/1 4/3/1
f 8/1/2 7/4/2 6/5/2
f 5/6/3 6/7/3 2/8/3
f 6/8/4 7/5/4 3/4/4
f 3/9/5 7/10/5 8/11/5
f 1/12/6 4/13/6 8/11/6
f 1/4/1 2/1/1 4/3/1
f 5/14/2 8/1/2 6/5/2
f 1/12/3 5/6/3 2/8/3
f 2/12/4 6/8/4 3/4/4
f 4/13/5 3/9/5 8/11/5
f 5/6/6 1/12/6 8/11/6
`

export const model = {
scale: 0.25,
translate: vec3.fromValues(0, 0.5, 0),
obj,
}
17 changes: 10 additions & 7 deletions src/models/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { vec3 } from 'gl-matrix'

import { model as bullet } from './bullet'
import { model as core } from './core'
import { model as tank } from './tank'
import { model as tree } from './tree'
import { model as turret } from './turret'
Expand All @@ -15,20 +16,22 @@ const models: {
translate?: vec3
}
} = {
wall: wall,
bullet: bullet,
core: core,
tank: tank,
turret: turret,
tree: tree,
bullet: bullet,
turret: turret,
wall: wall,
}

const materials: { [key: string]: [number, number, number, number] } = {
tree: [0, 100 / 255, 0, 1.0],
tank: [0, 0, 0, 1.0],
bullet: [1.0, 0, 0, 1.0],
wall: [169 / 255, 169 / 255, 169 / 255, 1.0],
turret: [1.0, 250 / 255, 205 / 255, 1.0],
core: [1.0, 0.5, 0, 1.0],
debug: [0, 1.0, 1.0, 1.0],
tank: [0, 0, 0, 1.0],
tree: [0, 100 / 255, 0, 1.0],
turret: [1.0, 250 / 255, 205 / 255, 1.0],
wall: [169 / 255, 169 / 255, 169 / 255, 1.0],
}

type ModelTypes = keyof typeof models
Expand Down

0 comments on commit deea153

Please sign in to comment.