Various review cleanups
This commit is contained in:
parent
3d223c1a4a
commit
8ed4e96ff9
|
@ -46,7 +46,10 @@
|
||||||
class="btn btn-outline-secondary pf-toolbar-button"
|
class="btn btn-outline-secondary pf-toolbar-button"
|
||||||
aria-expanded="false" aria-controls="#pf-vr"
|
aria-expanded="false" aria-controls="#pf-vr"
|
||||||
style="display: none">
|
style="display: none">
|
||||||
<span>VR</span>
|
<!-- https://materialdesignicons.com/icon/virtual-reality -->
|
||||||
|
<svg style="height: 18px" viewBox="0 0 24 24">
|
||||||
|
<path fill="#000000" d="M5,3C3.89,3 3,3.9 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5A2,2 0 0,0 19,3H5M6,9H7.5L8.5,12.43L9.5,9H11L9.25,15H7.75L6,9M13,9H16.5C17.35,9 18,9.65 18,10.5V11.5C18,12.1 17.6,12.65 17.1,12.9L18,15H16.5L15.65,13H14.5V15H13V9M14.5,10.5V11.5H16.5V10.5H14.5Z" />
|
||||||
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -383,44 +383,42 @@ class ThreeDView extends DemoView implements TextRenderContext {
|
||||||
newTimingsReceived(timings: Timings): void {}
|
newTimingsReceived(timings: Timings): void {}
|
||||||
|
|
||||||
vrSetup(): void {
|
vrSetup(): void {
|
||||||
if (navigator.getVRDisplays) {
|
if (!('getVRDisplays' in navigator)) {
|
||||||
navigator.getVRDisplays().then((displays) => {
|
return;
|
||||||
if (displays.length > 0) {
|
}
|
||||||
|
|
||||||
|
navigator.getVRDisplays().then(displays => {
|
||||||
|
if (displays.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.vrDisplay = displays[displays.length - 1];
|
this.vrDisplay = displays[displays.length - 1];
|
||||||
|
|
||||||
// It's heighly reccommended that you set the near and far planes to
|
// It's heighly recommended that you set the near and far planes to
|
||||||
// something appropriate for your scene so the projection matricies
|
// something appropriate for your scene so the projection matrices
|
||||||
// WebVR produces have a well scaled depth buffer.
|
// WebVR produces have a well scaled depth buffer.
|
||||||
this.renderer.setClipPlanes(this.vrDisplay);
|
this.renderer.setClipPlanes(this.vrDisplay);
|
||||||
unwrapNull(document.getElementById('pf-vr')).style.display = "initial";
|
unwrapNull(document.getElementById('pf-vr')).style.display = "initial";
|
||||||
} else {
|
|
||||||
// no vr displays
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
// no vr support
|
|
||||||
}
|
|
||||||
|
|
||||||
window.addEventListener('vrdisplaypresentchange', () => {
|
window.addEventListener('vrdisplaypresentchange', () => {
|
||||||
if (this.vrDisplay == null)
|
if (this.vrDisplay == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (this.vrDisplay.isPresenting) {
|
if (this.vrDisplay.isPresenting) {
|
||||||
const that = this;
|
|
||||||
const eye = this.vrDisplay.getEyeParameters("left");
|
const eye = this.vrDisplay.getEyeParameters("left");
|
||||||
|
|
||||||
this.vrDisplayHeight = eye.renderHeight;
|
this.vrDisplayHeight = eye.renderHeight;
|
||||||
this.vrDisplayWidth = eye.renderWidth * 2;
|
this.vrDisplayWidth = eye.renderWidth * 2;
|
||||||
this.resizeToFit(true);
|
this.resizeToFit(true);
|
||||||
function vrCallback(): void {
|
const vrCallback = () => {
|
||||||
if (that.vrDisplay == null || !that.renderer.inVR) {
|
if (this.vrDisplay == null || !this.renderer.inVR) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
that.vrDisplay.requestAnimationFrame(vrCallback);
|
this.vrDisplay.requestAnimationFrame(vrCallback);
|
||||||
that.inVRRAF = true;
|
this.inVRRAF = true;
|
||||||
that.redraw();
|
this.redraw();
|
||||||
that.inVRRAF = false;
|
this.inVRRAF = false;
|
||||||
}
|
};
|
||||||
this.vrDisplay.requestAnimationFrame(vrCallback);
|
this.vrDisplay.requestAnimationFrame(vrCallback);
|
||||||
} else {
|
} else {
|
||||||
this.renderer.inVR = false;
|
this.renderer.inVR = false;
|
||||||
|
@ -458,7 +456,7 @@ class ThreeDRenderer extends Renderer {
|
||||||
camera: PerspectiveCamera;
|
camera: PerspectiveCamera;
|
||||||
|
|
||||||
needsStencil: boolean = false;
|
needsStencil: boolean = false;
|
||||||
rightEye: boolean = false;
|
vrRightEye: boolean = false;
|
||||||
|
|
||||||
get isMulticolor(): boolean {
|
get isMulticolor(): boolean {
|
||||||
return false;
|
return false;
|
||||||
|
@ -532,6 +530,7 @@ class ThreeDRenderer extends Renderer {
|
||||||
|
|
||||||
this.distantGlyphVAO = null;
|
this.distantGlyphVAO = null;
|
||||||
this.vrProjectionMatrix = null;
|
this.vrProjectionMatrix = null;
|
||||||
|
|
||||||
this.camera = new PerspectiveCamera(renderContext.canvas, {
|
this.camera = new PerspectiveCamera(renderContext.canvas, {
|
||||||
innerCollisionExtent: MONUMENT_SCALE[0],
|
innerCollisionExtent: MONUMENT_SCALE[0],
|
||||||
});
|
});
|
||||||
|
@ -573,10 +572,10 @@ class ThreeDRenderer extends Renderer {
|
||||||
redrawVR(frame: VRFrameData): void {
|
redrawVR(frame: VRFrameData): void {
|
||||||
this.clearDestFramebuffer(true);
|
this.clearDestFramebuffer(true);
|
||||||
this.vrProjectionMatrix = frame.leftProjectionMatrix;
|
this.vrProjectionMatrix = frame.leftProjectionMatrix;
|
||||||
this.rightEye = false;
|
this.vrRightEye = false;
|
||||||
this.camera.setView(F32ArrayToMat4(frame.leftViewMatrix), frame.pose);
|
this.camera.setView(F32ArrayToMat4(frame.leftViewMatrix), frame.pose);
|
||||||
this.redraw();
|
this.redraw();
|
||||||
this.rightEye = true;
|
this.vrRightEye = true;
|
||||||
this.vrProjectionMatrix = frame.rightProjectionMatrix;
|
this.vrProjectionMatrix = frame.rightProjectionMatrix;
|
||||||
this.camera.setView(F32ArrayToMat4(frame.rightViewMatrix), frame.pose);
|
this.camera.setView(F32ArrayToMat4(frame.rightViewMatrix), frame.pose);
|
||||||
this.redraw();
|
this.redraw();
|
||||||
|
@ -584,7 +583,7 @@ class ThreeDRenderer extends Renderer {
|
||||||
|
|
||||||
setDrawViewport() {
|
setDrawViewport() {
|
||||||
let offset = 0;
|
let offset = 0;
|
||||||
if (this.rightEye) {
|
if (this.vrRightEye) {
|
||||||
offset = this.destAllocatedSize[0];
|
offset = this.destAllocatedSize[0];
|
||||||
}
|
}
|
||||||
const renderContext = this.renderContext;
|
const renderContext = this.renderContext;
|
||||||
|
@ -806,7 +805,7 @@ class ThreeDRenderer extends Renderer {
|
||||||
normal[0] / normal[3],
|
normal[0] / normal[3],
|
||||||
normal[1] / normal[3],
|
normal[1] / normal[3],
|
||||||
normal[2] / normal[3]);
|
normal[2] / normal[3]);
|
||||||
gl.uniform1f(monumentProgram.uniforms.uLightThings, this.inVR ? 0 : 1);
|
gl.uniform1f(monumentProgram.uniforms.uEnableLighting, this.inVR ? 0 : 1);
|
||||||
// Draw the face!
|
// Draw the face!
|
||||||
gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, face * 6 * UINT16_SIZE);
|
gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, face * 6 * UINT16_SIZE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -373,7 +373,7 @@ export class PerspectiveCamera extends Camera {
|
||||||
// TODO(pcwalton)
|
// TODO(pcwalton)
|
||||||
}
|
}
|
||||||
|
|
||||||
setView(rotation: glmatrix.mat4, pose: VRPose) {
|
setView(rotation: glmatrix.mat4, pose: VRPose): void {
|
||||||
this.vrRotationMatrix = rotation;
|
this.vrRotationMatrix = rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ uniform float uShininess;
|
||||||
/// The normal of these vertices.
|
/// The normal of these vertices.
|
||||||
uniform vec3 uNormal;
|
uniform vec3 uNormal;
|
||||||
|
|
||||||
uniform bool uLightThings;
|
uniform bool uEnableLighting;
|
||||||
|
|
||||||
varying vec3 vPosition;
|
varying vec3 vPosition;
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ void main() {
|
||||||
|
|
||||||
vec3 color = uAmbientColor;
|
vec3 color = uAmbientColor;
|
||||||
|
|
||||||
if (uLightThings) {
|
if (uEnableLighting) {
|
||||||
float lambertian = max(dot(lightDirection, normal), 0.0);
|
float lambertian = max(dot(lightDirection, normal), 0.0);
|
||||||
float specular = 0.0;
|
float specular = 0.0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue