Skip to content

Commit b2af56e

Browse files
Olli Etuahophemavax
authored andcommitted
Clean up dead and commented out code from Aquarium
This includes removing the g_drawOnce option. It's not useful, since during the first frame the assets haven't yet loaded. The skybox was never being drawn, so it's not needed.
1 parent b11a491 commit b2af56e

File tree

4 files changed

+5
-311
lines changed

4 files changed

+5
-311
lines changed

aquarium-vr/aquarium-vr.html

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -140,30 +140,6 @@
140140
</div>
141141
<div id="msgContainer"></div>
142142
</body>
143-
<!--
144-
<script id="constVertexShader" type="text/something-not-javascript">
145-
attribute vec4 position;
146-
//attribute vec3 normal;
147-
//attribute vec2 texCoord;
148-
//varying vec2 v_texCoord;
149-
//varying vec3 v_normal;
150-
uniform mat4 worldViewProjection;
151-
void main() {
152-
//v_texCoord = texCoord;
153-
//v_normal = normal;
154-
gl_Position = (worldViewProjection * position);
155-
}
156-
</script>
157-
<script id="constFragmentShader" type="text/something-not-javascript">
158-
precision mediump float;
159-
//varying vec2 v_texCoord;
160-
//varying vec3 v_normal;
161-
void main() {
162-
// gl_FragColor = vec4(vec3(v_texCoord, 1) + v_normal, 1);
163-
gl_FragColor = vec4(1, 1, 0, 1);
164-
}
165-
</script>
166-
-->
167143
<script id="texVertexShader" type="text/something-not-javascript">
168144
attribute vec4 position;
169145
attribute vec2 texCoord;
@@ -870,36 +846,6 @@
870846
((r + 0.3) * (reflection.r))).rgb, 1.0 - r);
871847
}
872848
</script>
873-
<!-- ===[ SkyBox ]============================================== -->
874-
<script id="refractSkyboxVertexShader" type="text/something-not-javascript">
875-
attribute vec4 position;
876-
varying vec4 v_position;
877-
878-
void main() {
879-
v_position = position;
880-
gl_Position = position;
881-
}
882-
</script>
883-
<script id="skyboxVertexShader" type="text/something-not-javascript">
884-
attribute vec4 position;
885-
varying vec4 v_position;
886-
void main() {
887-
v_position = position;
888-
gl_Position = position;
889-
}
890-
</script>
891-
<script id="skyboxFragmentShader" type="text/something-not-javascript">
892-
precision mediump float;
893-
uniform samplerCube skybox;
894-
uniform mat4 viewDirectionProjectionInverse;
895-
varying vec4 v_position;
896-
void main() {
897-
vec4 t = viewDirectionProjectionInverse * v_position;
898-
gl_FragColor = textureCube(
899-
skybox,
900-
normalize(t.xyz));
901-
}
902-
</script>
903849
</html>
904850

905851

aquarium-vr/aquarium-vr.js

Lines changed: 3 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,8 @@ var fast; // the fast math lib.
2424
var g_fpsTimer; // object to measure frames per second;
2525
var g_logGLCalls = true // whether or not to log webgl calls
2626
var g_debug = false; // whether or not to debug.
27-
var g_drawOnce = false;
2827
var g_setSettingElements = [];
2928
var g_numSettingElements = {};
30-
var g_sharkWorldMats = [];
31-
var g_beamWorldMats = [];
3229
var g_scenes = {}; // each of the models
3330
var g_sceneGroups = {}; // the placement of the models
3431
var g_fog = true;
@@ -39,19 +36,10 @@ var g_vrDisplay;
3936
var g_vrUi;
4037

4138
//g_debug = true;
42-
//g_drawOnce = true;
4339

44-
var g_numSharks = 0;
4540
var g_tailOffsetMult = 1;
46-
var g_endOfDome = Math.PI / 8;
4741
var g_tankRadius = 74;
4842
var g_tankHeight = 36;
49-
var g_standHeight = 25;
50-
var g_sharkSpeed = 0.3;
51-
var g_sharkClockOffset = 17;
52-
var g_sharkXClock = 1;
53-
var g_sharkYClock = 0.17;
54-
var g_sharkZClock = 1;
5543
var g_numBubbleSets = 10;
5644
var g_laserEta = 1.2;
5745
var g_laserLenFudge = 1;
@@ -761,40 +749,11 @@ function setupBubbles(particleSystem) {
761749
accelerationRange: [0,0.02,0],
762750
velocityRange: [0.05,0,0.05],
763751
colorMult: [0.7,0.8,1,1]});
764-
//function(index, parameters) {
765-
// var speed = Math.random() * 0.6 + 0.2;
766-
// var speed2 = Math.random() * 0.2 + 0.1;
767-
// var angle = Math.random() * 2 * Math.PI;
768-
// parameters.velocity = math.matrix4.transformPoint(
769-
// math.matrix4.rotationZ(angle), [speed, speed2, 0]);
770-
//}
771-
//);
772752
for (var ii = 0; ii < g_numBubbleSets; ++ii) {
773753
g_bubbleSets[ii] = emitter.createOneShot();
774754
}
775755
}
776756

777-
/**
778-
* Sets up the Skybox
779-
*/
780-
function setupSkybox() {
781-
var textures = {
782-
skybox: tdl.textures.loadTexture(g_skyBoxUrls)};
783-
var program;
784-
program = createProgramFromTags(
785-
'skyboxVertexShader',
786-
'skyboxFragmentShader');
787-
var arrays = tdl.primitives.createPlane(2, 2, 1, 1);
788-
delete arrays['normal'];
789-
delete arrays['texCoord'];
790-
tdl.primitives.reorient(arrays,
791-
[1, 0, 0, 0,
792-
0, 0, 1, 0,
793-
0,-1, 0, 0,
794-
0, 0, 0.99, 1]);
795-
return new tdl.models.Model(program, arrays, textures);
796-
}
797-
798757
function setViewSettings(index) {
799758
function setGlobal(name, value) {
800759
$(g_uiWidgets.globals[name]).slider("value", value * 1000);
@@ -886,13 +845,10 @@ function initialize() {
886845
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
887846

888847
loadPlacement();
889-
Log("--Setup Skybox---------------------------------------");
890-
var skybox = setupSkybox();
891848
loadScenes();
892849
Log("--Setup Laser----------------------------------------");
893850
var laser = setupLaser();
894851

895-
var num = [1, 100, 500, 1000, 5000, 10000, 15000, 20000, 25000, 30000];
896852
var changeViewElem = document.getElementById("setSettingChangeView");
897853
var parentElem = changeViewElem.parentNode;
898854
g_numFish.forEach((numFish, ndx) => {
@@ -955,9 +911,6 @@ function initialize() {
955911
var viewProjection = new Float32Array(16);
956912
var worldViewProjection = new Float32Array(16);
957913
var viewInverse = new Float32Array(16);
958-
var skyView = new Float32Array(16);
959-
var skyViewProjection = new Float32Array(16);
960-
var skyViewProjectionInverse = new Float32Array(16);
961914
var eyePosition = new Float32Array(3);
962915
var target = new Float32Array(3);
963916
var up = new Float32Array([0,1,0]);
@@ -974,10 +927,6 @@ function initialize() {
974927
var ambient = new Float32Array(4);
975928
var fogColor = new Float32Array([1,1,1,1]);
976929

977-
// Sky uniforms.
978-
var skyConst = {viewProjectionInverse: skyViewProjectionInverse};
979-
var skyPer = {};
980-
981930
// Generic uniforms.
982931
var genericConst = {
983932
viewInverse: viewInverse,
@@ -1231,42 +1180,21 @@ function initialize() {
12311180
fast.matrix4.inverse(view, viewInverse);
12321181
fast.matrix4.mul(viewProjection, view, projection);
12331182

1234-
fast.matrix4.copy(skyView, view);
1235-
skyView[12] = 0;
1236-
skyView[13] = 0;
1237-
skyView[14] = 0;
1238-
fast.matrix4.mul(skyViewProjection, skyView, projection);
1239-
fast.matrix4.inverse(skyViewProjectionInverse, skyViewProjection);
1240-
12411183
fast.matrix4.getAxis(v3t0, viewInverse, 0); // x
12421184
fast.matrix4.getAxis(v3t1, viewInverse, 1); // y;
12431185
fast.mulScalarVector(v3t0, 20, v3t0);
12441186
fast.mulScalarVector(v3t1, 30, v3t1);
12451187
fast.addVector(lightWorldPos, eyePosition, v3t0);
12461188
fast.addVector(lightWorldPos, lightWorldPos, v3t1);
12471189

1248-
// view: view,
1249-
// projection: projection,
1250-
// viewProjection: viewProjection,
1251-
12521190
gl.disable(gl.BLEND);
12531191
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
12541192
gl.blendEquation(gl.FUNC_ADD);
12551193
gl.enable(gl.CULL_FACE);
12561194

12571195
math.resetPseudoRandom();
12581196
var pseudoRandom = math.pseudoRandom;
1259-
//var pseudoRandom = function() {
1260-
// return 0.5;
1261-
//};
1262-
1263-
// Draw Skybox
1264-
//Log("--Draw Sky---------------------------------------");
1265-
//if (g.options.skybox.enabled) {
1266-
// gl.depthMask(false);
1267-
// skybox.drawPrep(skyConst);
1268-
// skybox.draw(skyPer);
1269-
//}
1197+
12701198
gl.depthMask(true);
12711199

12721200
if (g_fog) {
@@ -1353,13 +1281,6 @@ function initialize() {
13531281
fishNextPosition[2] = Math.cos(zClock - 0.04) * zRadius;
13541282
fishPer.scale = scale;
13551283

1356-
// matMul(world,
1357-
// matScaling(m4t0, [scale, scale, scale]),
1358-
// matCameraLookAt(
1359-
// m4t1, [x, y, z], [nextX, nextY, nextZ], [0, 1, 0]));
1360-
// matMul(worldViewProjection, world, viewProjection);
1361-
// matInverse(worldInverse, world);
1362-
// matTranspose(worldInverseTranspose, worldInverse);
13631284
fishPer.time =
13641285
((clock + ii * g_tailOffsetMult) * fishTailSpeed * speed) %
13651286
(Math.PI * 2);
@@ -1565,21 +1486,6 @@ function initialize() {
15651486
up));
15661487
fast.matrix4.mul(worldViewProjection, world, viewProjection);
15671488
laser.draw(laserPer);
1568-
//for (var jj = 0; jj < 3; ++jj) {
1569-
// fast.matrix4.mul(
1570-
// world,
1571-
// fast.matrix4.axisRotation(
1572-
// m4t0,
1573-
// math.normalize([
1574-
// Math.random() - 0.5,
1575-
// Math.random() - 0.5,
1576-
// Math.random() - 0.5]),
1577-
// Math.random() * Math.PI * 2),
1578-
// fast.matrix4.translation(m4t1, laserInfo.position));
1579-
// fast.matrix4.mul(
1580-
// worldViewProjection, world, viewProjection);
1581-
// laser.draw(laserPer);
1582-
//}
15831489
}
15841490
}
15851491
}
@@ -1601,12 +1507,6 @@ function initialize() {
16011507

16021508
// turn off logging after 1 frame.
16031509
g_logGLCalls = false;
1604-
1605-
/*
1606-
if (!g_drawOnce) {
1607-
g_requestId = tdl.webgl.requestAnimationFrame(render, canvas);
1608-
}
1609-
*/
16101510
}
16111511

16121512
function onAnimationFrame() {
@@ -1664,9 +1564,7 @@ function initialize() {
16641564
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT);
16651565

16661566
if (g_vrDisplay) {
1667-
if (!g_drawOnce) {
1668-
g_requestId = g_vrDisplay.requestAnimationFrame(onAnimationFrame);
1669-
}
1567+
g_requestId = g_vrDisplay.requestAnimationFrame(onAnimationFrame);
16701568
g_vrDisplay.getFrameData(g_frameData);
16711569
if (g_vrDisplay.isPresenting) {
16721570

@@ -1719,9 +1617,7 @@ function initialize() {
17191617
render();
17201618
}
17211619
} else {
1722-
if (!g_drawOnce) {
1723-
g_requestId = tdl.webgl.requestAnimationFrame(onAnimationFrame, canvas);
1724-
}
1620+
g_requestId = tdl.webgl.requestAnimationFrame(onAnimationFrame, canvas);
17251621
gl.viewport(0, 0, canvas.width, canvas.height);
17261622
render();
17271623
}

aquarium/aquarium.html

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -270,30 +270,6 @@
270270
</div>
271271
<div id="msgContainer"></div>
272272
</body>
273-
<!--
274-
<script id="constVertexShader" type="text/something-not-javascript">
275-
attribute vec4 position;
276-
//attribute vec3 normal;
277-
//attribute vec2 texCoord;
278-
//varying vec2 v_texCoord;
279-
//varying vec3 v_normal;
280-
uniform mat4 worldViewProjection;
281-
void main() {
282-
//v_texCoord = texCoord;
283-
//v_normal = normal;
284-
gl_Position = (worldViewProjection * position);
285-
}
286-
</script>
287-
<script id="constFragmentShader" type="text/something-not-javascript">
288-
precision mediump float;
289-
//varying vec2 v_texCoord;
290-
//varying vec3 v_normal;
291-
void main() {
292-
// gl_FragColor = vec4(vec3(v_texCoord, 1) + v_normal, 1);
293-
gl_FragColor = vec4(1, 1, 0, 1);
294-
}
295-
</script>
296-
-->
297273
<script id="texVertexShader" type="text/something-not-javascript">
298274
attribute vec4 position;
299275
attribute vec2 texCoord;
@@ -1000,36 +976,6 @@
1000976
((r + 0.3) * (reflection.r))).rgb, 1.0 - r);
1001977
}
1002978
</script>
1003-
<!-- ===[ SkyBox ]============================================== -->
1004-
<script id="refractSkyboxVertexShader" type="text/something-not-javascript">
1005-
attribute vec4 position;
1006-
varying vec4 v_position;
1007-
1008-
void main() {
1009-
v_position = position;
1010-
gl_Position = position;
1011-
}
1012-
</script>
1013-
<script id="skyboxVertexShader" type="text/something-not-javascript">
1014-
attribute vec4 position;
1015-
varying vec4 v_position;
1016-
void main() {
1017-
v_position = position;
1018-
gl_Position = position;
1019-
}
1020-
</script>
1021-
<script id="skyboxFragmentShader" type="text/something-not-javascript">
1022-
precision mediump float;
1023-
uniform samplerCube skybox;
1024-
uniform mat4 viewDirectionProjectionInverse;
1025-
varying vec4 v_position;
1026-
void main() {
1027-
vec4 t = viewDirectionProjectionInverse * v_position;
1028-
gl_FragColor = textureCube(
1029-
skybox,
1030-
normalize(t.xyz));
1031-
}
1032-
</script>
1033979
</html>
1034980

1035981

0 commit comments

Comments
 (0)