Stub a shader for objects in the 3D demo
This commit is contained in:
parent
4ab917b79b
commit
a9dd33d479
|
@ -148,8 +148,8 @@ class ThreeDView extends PathfinderDemoView {
|
|||
this.canvas.width / this.canvas.height,
|
||||
NEAR_CLIP_PLANE,
|
||||
FAR_CLIP_PLANE);
|
||||
glmatrix.mat4.translate(transform, transform, this.camera.translation);
|
||||
glmatrix.mat4.mul(transform, transform, this.camera.rotationMatrix);
|
||||
glmatrix.mat4.translate(transform, transform, this.camera.translation);
|
||||
return transform;
|
||||
}
|
||||
|
||||
|
|
|
@ -101,23 +101,28 @@ export class PerspectiveCamera extends Camera {
|
|||
return;
|
||||
}
|
||||
|
||||
this.movementDelta = glmatrix.vec3.fromValues(PERSPECTIVE_MOVEMENT_SPEED, 0.0, 0.0);
|
||||
this.movementDelta = glmatrix.vec3.fromValues(0.0, 0.0, PERSPECTIVE_MOVEMENT_SPEED);
|
||||
if (event.button !== 1)
|
||||
this.movementDelta[0] = -this.movementDelta[0];
|
||||
|
||||
if (this.movementInterval == null)
|
||||
this.movementInterval = window.setInterval(() => this.move(), MOVEMENT_INTERVAL_DELAY);
|
||||
}
|
||||
|
||||
private onMouseUp(event: MouseEvent): void {
|
||||
if (this.movementInterval != null) {
|
||||
window.clearInterval(this.movementInterval);
|
||||
this.movementInterval = null;
|
||||
this.movementDelta = glmatrix.vec3.create();
|
||||
}
|
||||
}
|
||||
|
||||
private move() {
|
||||
const invRotationMatrix = glmatrix.mat4.create();
|
||||
glmatrix.mat4.invert(invRotationMatrix, this.rotationMatrix);
|
||||
|
||||
const delta = glmatrix.vec3.clone(this.movementDelta);
|
||||
glmatrix.vec3.transformMat4(delta, delta, this.rotationMatrix);
|
||||
glmatrix.vec3.transformMat4(delta, delta, invRotationMatrix);
|
||||
glmatrix.vec3.add(this.translation, this.translation, delta);
|
||||
|
||||
if (this.onChange != null)
|
||||
|
|
|
@ -28,6 +28,7 @@ export const SHADER_NAMES: Array<keyof ShaderMap<void>> = [
|
|||
'ecaaCurve',
|
||||
'ecaaMonoResolve',
|
||||
'ecaaMultiResolve',
|
||||
'demo3DMonument',
|
||||
];
|
||||
|
||||
const SHADER_URLS: ShaderMap<ShaderProgramURLs> = {
|
||||
|
@ -67,6 +68,10 @@ const SHADER_URLS: ShaderMap<ShaderProgramURLs> = {
|
|||
vertex: "/glsl/gles2/ecaa-multi-resolve.vs.glsl",
|
||||
fragment: "/glsl/gles2/ecaa-multi-resolve.fs.glsl",
|
||||
},
|
||||
demo3DMonument: {
|
||||
vertex: "/glsl/gles2/demo-3d-monument.vs.glsl",
|
||||
fragment: "/glsl/gles2/demo-3d-monument.fs.glsl",
|
||||
},
|
||||
};
|
||||
|
||||
export interface ShaderMap<T> {
|
||||
|
@ -79,6 +84,7 @@ export interface ShaderMap<T> {
|
|||
ecaaCurve: T;
|
||||
ecaaMonoResolve: T;
|
||||
ecaaMultiResolve: T;
|
||||
demo3DMonument: T;
|
||||
}
|
||||
|
||||
export interface ShaderProgramSource {
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
// pathfinder/shaders/gles2/blit.vs.glsl
|
||||
//
|
||||
// Copyright (c) 2017 Mozilla Foundation
|
||||
// Copyright (c) 2017 The Pathfinder Project Developers.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
precision mediump float;
|
||||
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
// pathfinder/shaders/gles2/demo-3d-monument.fs.glsl
|
||||
//
|
||||
// Copyright (c) 2017 The Pathfinder Project Developers.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
precision mediump float;
|
||||
|
||||
uniform vec4 uColor;
|
||||
|
||||
void main() {
|
||||
// TODO(pcwalton): Lighting.
|
||||
gl_FragColor = uColor;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
// pathfinder/shaders/gles2/demo-3d-monument.vs.glsl
|
||||
//
|
||||
// Copyright (c) 2017 The Pathfinder Project Developers.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
precision mediump float;
|
||||
|
||||
uniform mat4 uTransform;
|
||||
|
||||
attribute vec3 aPosition;
|
||||
|
||||
void main() {
|
||||
gl_Position = uTransform * vec4(aPosition, 1.0);
|
||||
}
|
Loading…
Reference in New Issue