aca
This commit is contained in:
parent
9356bb1560
commit
acff70d414
@ -93,4 +93,5 @@ function loadShader(gl, type, source)
|
|||||||
return shader;
|
return shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export let shaderInfos = null;
|
||||||
export { initShaderProgram };
|
export { initShaderProgram };
|
||||||
|
@ -40,10 +40,18 @@ class Segment
|
|||||||
* @param {CanvasRenderingContext2D} ctx
|
* @param {CanvasRenderingContext2D} ctx
|
||||||
*/
|
*/
|
||||||
draw(ctx)
|
draw(ctx)
|
||||||
|
{
|
||||||
|
if(this.gl instanceof CanvasRenderingContext2D)
|
||||||
{
|
{
|
||||||
ctx.moveTo(this.start.x, this.start.y);
|
ctx.moveTo(this.start.x, this.start.y);
|
||||||
ctx.lineTo(this.stop.x, this.stop.y);
|
ctx.lineTo(this.stop.x, this.stop.y);
|
||||||
}
|
}
|
||||||
|
else if(this.gl instanceof WebGLRenderingContext)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else
|
||||||
|
alert('Unknown rendering context type');
|
||||||
|
}
|
||||||
|
|
||||||
from_json(data)
|
from_json(data)
|
||||||
{
|
{
|
||||||
@ -54,4 +62,4 @@ class Segment
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { Segment };
|
export { Segment }
|
||||||
|
@ -5,8 +5,8 @@ import Search from "./views/Search.js";
|
|||||||
import HomeView from "./views/HomeView.js";
|
import HomeView from "./views/HomeView.js";
|
||||||
import LogoutView from "./views/accounts/LogoutView.js";
|
import LogoutView from "./views/accounts/LogoutView.js";
|
||||||
import GameOfflineView from "./views/GameOfflineView.js";
|
import GameOfflineView from "./views/GameOfflineView.js";
|
||||||
import GameView from "./views/GameView.js";
|
//import GameView from "./views/GameView.js";
|
||||||
//import GameView from "./views/GameView3D.js";
|
import GameView from "./views/GameView3D.js";
|
||||||
|
|
||||||
import PageNotFoundView from './views/PageNotFoundView.js' ;
|
import PageNotFoundView from './views/PageNotFoundView.js' ;
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ import { client } from "../index.js";
|
|||||||
import { Game } from "../api/game/Game.js";
|
import { Game } from "../api/game/Game.js";
|
||||||
import AbstractView from "./abstracts/AbstractView.js";
|
import AbstractView from "./abstracts/AbstractView.js";
|
||||||
import { initShaderProgram } from "../3D/shaders.js"
|
import { initShaderProgram } from "../3D/shaders.js"
|
||||||
|
import shaderInfos from "../3D/shaders.js"
|
||||||
import { initBuffers } from "../3D/buffers.js"
|
import { initBuffers } from "../3D/buffers.js"
|
||||||
import "../3D/maths/gl-matrix-min.js"
|
import "../3D/maths/gl-matrix-min.js"
|
||||||
|
|
||||||
@ -16,7 +17,6 @@ export default class extends AbstractView
|
|||||||
this.gl = null;
|
this.gl = null;
|
||||||
this.shader_prog = null;
|
this.shader_prog = null;
|
||||||
this.buffers = null;
|
this.buffers = null;
|
||||||
this.programInfo = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
initGL()
|
initGL()
|
||||||
@ -33,7 +33,7 @@ export default class extends AbstractView
|
|||||||
this.shader_prog = initShaderProgram(this.gl);
|
this.shader_prog = initShaderProgram(this.gl);
|
||||||
this.buffers = initBuffers(this.gl);
|
this.buffers = initBuffers(this.gl);
|
||||||
|
|
||||||
this.programInfo = {
|
shaderInfos = {
|
||||||
program: this.shader_prog,
|
program: this.shader_prog,
|
||||||
attribLocations: {
|
attribLocations: {
|
||||||
vertexPosition: this.gl.getAttribLocation(this.shader_prog, "aPos"),
|
vertexPosition: this.gl.getAttribLocation(this.shader_prog, "aPos"),
|
||||||
@ -90,16 +90,16 @@ export default class extends AbstractView
|
|||||||
this.setPositionAttribute();
|
this.setPositionAttribute();
|
||||||
this.setNormalAttribute();
|
this.setNormalAttribute();
|
||||||
|
|
||||||
this.gl.useProgram(this.programInfo.program);
|
this.gl.useProgram(shaderInfos.program);
|
||||||
|
|
||||||
this.gl.uniformMatrix4fv(
|
this.gl.uniformMatrix4fv(
|
||||||
this.programInfo.uniformLocations.projectionMatrix,
|
shaderInfos.uniformLocations.projectionMatrix,
|
||||||
false,
|
false,
|
||||||
projectionMatrix
|
projectionMatrix
|
||||||
);
|
);
|
||||||
|
|
||||||
// rendering player bar
|
//this.game.draw(this.gl);
|
||||||
this.renderCube(0.0, -5.0, -8.0, 0.0, 5);
|
//this.renderCube(1, 0, -15);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderCube(x, y, z, angle = 0, sx = 1, sy = 1, sz = 1)
|
renderCube(x, y, z, angle = 0, sx = 1, sy = 1, sz = 1)
|
||||||
@ -130,12 +130,12 @@ export default class extends AbstractView
|
|||||||
mat4.transpose(normalMatrix, normalMatrix);
|
mat4.transpose(normalMatrix, normalMatrix);
|
||||||
|
|
||||||
this.gl.uniformMatrix4fv(
|
this.gl.uniformMatrix4fv(
|
||||||
this.programInfo.uniformLocations.modelViewMatrix,
|
shaderInfos.uniformLocations.modelViewMatrix,
|
||||||
false,
|
false,
|
||||||
modelViewMatrix
|
modelViewMatrix
|
||||||
);
|
);
|
||||||
this.gl.uniformMatrix4fv(
|
this.gl.uniformMatrix4fv(
|
||||||
this.programInfo.uniformLocations.normalMatrix,
|
shaderInfos.uniformLocations.normalMatrix,
|
||||||
false,
|
false,
|
||||||
normalMatrix,
|
normalMatrix,
|
||||||
);
|
);
|
||||||
@ -155,17 +155,17 @@ export default class extends AbstractView
|
|||||||
const offset = 0;
|
const offset = 0;
|
||||||
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.buffers.normal);
|
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.buffers.normal);
|
||||||
this.gl.vertexAttribPointer(
|
this.gl.vertexAttribPointer(
|
||||||
this.programInfo.attribLocations.vertexNormal,
|
shaderInfos.attribLocations.vertexNormal,
|
||||||
numComponents,
|
numComponents,
|
||||||
type,
|
type,
|
||||||
normalize,
|
normalize,
|
||||||
stride,
|
stride,
|
||||||
offset,
|
offset,
|
||||||
);
|
);
|
||||||
this.gl.enableVertexAttribArray(this.programInfo.attribLocations.vertexNormal);
|
this.gl.enableVertexAttribArray(shaderInfos.attribLocations.vertexNormal);
|
||||||
}
|
}
|
||||||
|
|
||||||
setPositionAttribute(programInfo)
|
setPositionAttribute()
|
||||||
{
|
{
|
||||||
const numComponents = 3;
|
const numComponents = 3;
|
||||||
const type = this.gl.FLOAT;
|
const type = this.gl.FLOAT;
|
||||||
@ -175,14 +175,14 @@ export default class extends AbstractView
|
|||||||
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.buffers.vertex);
|
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.buffers.vertex);
|
||||||
this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.buffers.index);
|
this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.buffers.index);
|
||||||
this.gl.vertexAttribPointer(
|
this.gl.vertexAttribPointer(
|
||||||
this.programInfo.attribLocations.vertexPosition,
|
shaderInfos.attribLocations.vertexPosition,
|
||||||
numComponents,
|
numComponents,
|
||||||
type,
|
type,
|
||||||
normalize,
|
normalize,
|
||||||
stride,
|
stride,
|
||||||
offset
|
offset
|
||||||
);
|
);
|
||||||
this.gl.enableVertexAttribArray(this.programInfo.attribLocations.vertexPosition);
|
this.gl.enableVertexAttribArray(shaderInfos.attribLocations.vertexPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
render_game()
|
render_game()
|
||||||
|
Loading…
Reference in New Issue
Block a user