diff --git a/assets/models/stage.obj b/assets/models/stage.obj index a9f5160..bd1a414 100644 --- a/assets/models/stage.obj +++ b/assets/models/stage.obj @@ -1,6 +1,5 @@ # Blender v2.79 (sub 0) OBJ File: 'stage.blend' # www.blender.org -o 000_sky v 0.000000 0.000000 2500.000000 v -0.000224 0.000000 -2500.000000 v 0.000000 1767.767334 1767.766724 @@ -1011,7 +1010,6 @@ f 174/183 241/4 171/176 f 174/183 14/182 61/5 f 56/193 178/192 242/1 f 178/192 20/191 58/2 -o 000backglow v 25.250380 -68.634323 -67.805519 v -7.311297 -99.964310 -32.531570 v 44.684368 -90.595970 -33.472618 @@ -1093,7 +1091,6 @@ f 247/293 243/289 246/291 f 263/307 259/304 261/310 f 243/289 258/303 262/306 f 243/289 262/306 244/290 -o 010tunnel.001_tunnel.000 v -19.994535 0.145583 -32.841618 v -20.733458 0.242623 -32.561462 v -19.994535 0.145583 -33.207436 @@ -1150,7 +1147,6 @@ f 270/323 271/336 274/324 f 270/323 273/334 275/325 f 267/327 268/337 277/328 f 269/330 267/338 276/331 -o 015tunnelneon.001_tunnelneon.007 v 12.287717 7.337969 -32.869480 v 7.337968 12.287716 -32.869480 v 12.287717 7.337969 -33.090019 @@ -1184,7 +1180,6 @@ f 280/339 282/349 281/340 f 284/342 280/339 279/341 f 287/344 288/350 286/345 f 285/346 286/345 290/347 -o 030tunnel.002_tunnel.002 v -19.994535 0.145583 -26.381851 v -20.733458 0.242623 -26.101696 v -19.994535 0.145583 -26.747669 @@ -1241,7 +1236,6 @@ f 294/362 295/375 298/363 f 294/362 297/373 299/364 f 291/366 292/376 301/367 f 293/369 291/377 300/370 -o 035tunnelneon.002_tunnelneon.008 v 12.287717 7.337969 -26.429806 v 7.337968 12.287716 -26.429806 v 12.287717 7.337969 -26.650343 @@ -1275,7 +1269,6 @@ f 304/378 306/388 305/379 f 308/381 304/378 303/380 f 311/383 312/389 310/384 f 309/385 310/384 314/386 -o 050tunnel.003_tunnel.003 v -19.994535 0.145583 -19.922087 v -20.733458 0.242623 -19.641930 v -19.994535 0.145583 -20.287905 @@ -1332,7 +1325,6 @@ f 318/401 319/414 322/402 f 318/401 321/412 323/403 f 315/405 316/415 325/406 f 317/408 315/416 324/409 -o 055tunnelneon.003_tunnelneon.009 v 12.287717 7.337969 -19.990133 v 7.337968 12.287716 -19.990133 v 12.287717 7.337969 -20.210670 @@ -1366,7 +1358,6 @@ f 328/417 330/427 329/418 f 332/420 328/417 327/419 f 335/422 336/428 334/423 f 333/424 334/423 338/425 -o 070tunnel_tunnel.001 v -19.994535 0.145583 -13.462321 v -20.733458 0.242623 -13.182165 v -19.994535 0.145583 -13.828139 @@ -1423,7 +1414,6 @@ f 342/440 343/453 346/441 f 342/440 345/451 347/442 f 339/444 340/454 349/445 f 341/447 339/455 348/448 -o 075tunnelneon.0_tunnelneon.002 v 12.287717 7.337969 -13.550458 v 7.337968 12.287716 -13.550458 v 12.287717 7.337969 -13.770994 @@ -1457,7 +1447,6 @@ f 352/456 354/466 353/457 f 356/459 352/456 351/458 f 359/461 360/467 358/462 f 357/463 358/462 362/464 -o 085neon_Cube.002 v 4.475000 0.625000 18.000004 v 4.475000 0.675000 18.000004 v 4.475000 0.625000 -81.999992 @@ -1503,7 +1492,6 @@ f 366/471 364/484 367/472 f 371/474 372/485 370/475 f 373/477 374/486 376/478 f 374/480 370/487 372/481 -o 095neon.001_Cube.000 v 3.475000 0.625000 -6.999996 v 3.475000 0.675000 -6.999996 v 3.475000 0.625000 -56.999996 @@ -1549,7 +1537,6 @@ f 380/491 378/504 381/492 f 385/494 386/505 384/495 f 387/497 388/506 390/498 f 388/500 384/507 386/501 -o 100corridor_corridor v -2.050000 -0.150000 -6.850000 v -2.050000 0.150000 -6.850000 v -2.050000 0.150000 -56.849998 @@ -1569,7 +1556,6 @@ f 395/508 391/509 394/510 f 393/511 395/512 396/513 f 395/508 392/514 391/509 f 393/511 392/515 395/512 -o 105stairs_Cube.003 v -1.738699 0.120202 -7.350870 v -1.738699 0.172067 -7.350870 v -1.738699 0.120202 -7.569801 @@ -1871,7 +1857,6 @@ f 470/615 472/653 471/616 f 476/618 474/625 473/619 f 474/621 470/654 469/622 f 472/624 470/655 474/625 -o 110pillars_Cube.001 v 1.687466 -19.969999 -6.886095 v 1.687466 0.030000 -6.886095 v 1.687466 -19.969999 -7.186095 @@ -2017,7 +2002,6 @@ f 511/696 512/718 516/697 f 516/699 512/719 514/700 f 499/702 518/684 520/686 f 501/704 519/681 518/683 -o 150floorsymbols v -0.337820 0.003068 0.246305 v -0.337820 0.003068 -1.203815 v 0.325738 0.003068 0.246305 diff --git a/assets/models/stageadditive.obj b/assets/models/stageadditive.obj index c9d20fd..745a552 100644 --- a/assets/models/stageadditive.obj +++ b/assets/models/stageadditive.obj @@ -1,6 +1,5 @@ # Blender v2.79 (sub 0) OBJ File: 'stage.blend' # www.blender.org -o 000tunnelneonglow.002_tunnelneon.014 v 15.178578 1.075909 -33.904572 v 1.075902 15.178576 -33.904572 v 19.149137 5.046469 -33.587288 @@ -22,7 +21,6 @@ f 1/1 4/2 2/3 f 5/4 8/5 7/6 f 1/1 3/7 4/2 f 5/4 6/8 8/5 -o 000tunnelneonglow.005_tunnelneon.017 v 12.863472 5.606542 -33.581116 v 5.505581 12.964426 -33.581116 v 14.446635 7.189702 -33.454609 @@ -44,7 +42,6 @@ f 9/9 12/10 10/11 f 13/12 16/13 15/14 f 9/9 11/15 12/10 f 13/12 14/16 16/13 -o 020tunnelneonglow.003_tunnelneon.015 v 15.178578 1.075909 -27.463730 v 1.075902 15.178576 -27.463730 v 19.149137 5.046469 -27.146448 @@ -66,7 +63,6 @@ f 17/17 20/18 18/19 f 21/20 24/21 23/22 f 17/17 19/23 20/18 f 21/20 22/24 24/21 -o 020tunnelneonglow.006_tunnelneon.018 v 12.863472 5.606542 -27.129221 v 5.505581 12.964426 -27.129221 v 14.446635 7.189702 -27.002712 @@ -88,7 +84,6 @@ f 25/25 28/26 26/27 f 29/28 32/29 31/30 f 25/25 27/31 28/26 f 29/28 30/32 32/29 -o 040tunnelneonglow.004_tunnelneon.016 v 15.178578 1.075909 -21.022888 v 1.075902 15.178576 -21.022886 v 19.149137 5.046469 -20.705606 @@ -110,7 +105,6 @@ f 33/33 36/34 34/35 f 37/36 40/37 39/38 f 33/33 35/39 36/34 f 37/36 38/40 40/37 -o 040tunnelneonglow.007_tunnelneon.019 v 12.863472 5.606542 -20.677326 v 5.505581 12.964426 -20.677326 v 14.446635 7.189702 -20.550817 @@ -132,7 +126,6 @@ f 41/41 44/42 42/43 f 45/44 48/45 47/46 f 41/41 43/47 44/42 f 45/44 46/48 48/45 -o 060tunnelneonglow.001_tunnelneon.013 v 15.178578 1.075909 -14.582047 v 1.075902 15.178576 -14.582046 v 19.149137 5.046469 -14.264764 @@ -154,7 +147,6 @@ f 49/49 52/50 50/51 f 53/52 56/53 55/54 f 49/49 51/55 52/50 f 53/52 54/56 56/53 -o 060tunnelneonglow.002_tunnelneon v 12.863472 5.606542 -14.225430 v 5.505581 12.964426 -14.225430 v 14.446635 7.189702 -14.098923 @@ -176,7 +168,6 @@ f 57/57 60/58 58/59 f 61/60 64/61 63/62 f 57/57 59/63 60/58 f 61/60 62/64 64/61 -o 080neonglow_tunnelneon.001 v 4.693238 0.813037 19.789230 v 4.693230 0.813042 -82.453156 v 4.350243 0.470041 19.789230 @@ -198,7 +189,6 @@ f 65/65 66/66 68/67 f 69/68 71/69 72/70 f 65/65 68/67 67/71 f 69/68 72/70 70/72 -o 090neonglow.001_tunnelneon.006 v 3.762471 0.875742 -7.080121 v 3.762460 0.875749 -58.498669 v 3.277436 0.390707 -7.080121 @@ -232,7 +222,6 @@ f 78/73 74/75 76/83 f 75/76 77/74 78/73 f 80/78 84/80 82/84 f 83/79 81/82 84/80 -o 120floorglow_Plane.001 v 1.374993 -0.006546 -1.379147 v 1.595471 -0.006546 -1.599395 v -1.597251 -0.006546 1.593773 diff --git a/src/assets.html b/src/assets.html index 824028e..800abbc 100644 --- a/src/assets.html +++ b/src/assets.html @@ -25,6 +25,7 @@ + diff --git a/src/components/stage-colors.js b/src/components/stage-colors.js index 149df91..80b57b2 100644 --- a/src/components/stage-colors.js +++ b/src/components/stage-colors.js @@ -8,6 +8,7 @@ AFRAME.registerComponent('stage-colors', { }, init: function () { + /* this.neonRed = new THREE.Color(0xff9999); this.neonBlue = new THREE.Color(0x9999ff); this.defaultRed = new THREE.Color(0xff0000); @@ -52,26 +53,31 @@ AFRAME.registerComponent('stage-colors', { this.colorCodes = ['off', 'blue', 'blue', 'bluefade', '', 'red', 'red', 'redfade']; this.el.addEventListener('cleargame', this.resetColors.bind(this)); + */ }, update: function (oldData) { - this.updateColors(this.data.color); + // this.updateColors(this.data.color); }, setColor: function (target, code) { - const mesh = this.targets[target].getObject3D('mesh'); + /* const mesh = this.targets[target].getObject3D('mesh'); if (mesh) { mesh.material.opacity = 1; } this.targets[target].emit('color' + this.colorCodes[code], null, false); + */ }, resetColors: function () { + /* this.updateColors('blue'); for (let target in this.targets) { this.targets[target].emit('colorblue', null, false); } + */ }, updateColors: function (color) { + /* const red = color === 'red'; // Init or reset. @@ -95,4 +101,5 @@ AFRAME.registerComponent('stage-colors', { this.mineMaterial.envMap = this.mineEnvMap[red ? 'red' : 'blue']; this.mineMaterial.needsUpdate = true; } + */ }); diff --git a/src/components/twister.js b/src/components/twister.js index 3fc51f2..ff055e5 100644 --- a/src/components/twister.js +++ b/src/components/twister.js @@ -1,3 +1,5 @@ +const NUM_VALUES_PER_SEGMENT = 75; + AFRAME.registerComponent('twister', { schema: { enabled: {default: false}, @@ -12,47 +14,44 @@ AFRAME.registerComponent('twister', { init: function () { this.currentTwist = 0; this.animate = false; - this.zoomProgress = 0; + this.geometry = null; }, pulse: function (twist) { if (!this.data.enabled) { return; } + console.log('PULSE'); if (twist == 0) { twist = 0.03 + Math.random() * 0.25; } else twist = Math.min(twist * 0.4, 0.4); twist *= Math.random() < 0.5 ? -1 : 1; // random direction this.el.setAttribute('twister', {twist: twist}); }, - zoom: function () { - if (!this.data.enabled) { return; } - this.zoomProgress = 0.01; - this.animate = true; - }, - update: function (oldData) { var radius = 6; - var segment; - var lastSegment; + var segments = []; if (Math.abs(this.data.twist - this.currentTwist) > 0.001) { this.animate = true; return; } - this.clearSegments(); - lastSegment = this.el.object3D; + this.clear(); for (var i = 0; i < this.data.count; i++) { - segment = this.createSegment(radius); - segment.position.y = this.data.positionIncrement; - lastSegment.add(segment); - lastSegment = segment; + let segment = this.createSegment(radius); + segment.translate(0, this.data.positionIncrement * i, 0); + segments.push(segment); radius += this.data.radiusIncrement; } + this.geometry = THREE.BufferGeometryUtils.mergeBufferGeometries(segments); + var material = this.el.sceneEl.systems.materials.stageNormal; + var mesh = new THREE.Mesh(this.geometry, material); + this.el.object3D.add(mesh); }, createSegment: function (radius) { const R = this.data.thickness; + var geometry; var points = [ new THREE.Vector2(radius - R, R), new THREE.Vector2(radius - R, -R), @@ -60,40 +59,50 @@ AFRAME.registerComponent('twister', { new THREE.Vector2(radius + R, R), new THREE.Vector2(radius - R, R) ]; - var material = this.el.sceneEl.systems.materials.black; - var geometry = new THREE.LatheBufferGeometry(points, this.data.vertices); - var segment = new THREE.Mesh(geometry, material); - return segment; + geometry = new THREE.LatheBufferGeometry(points, this.data.vertices); + // move uvs to a specific point in atlas.png + for (let i = 0; i < geometry.attributes.uv.array.length; i += 2) { + geometry.attributes.uv.array[i] = 0.77; + geometry.attributes.uv.array[i + 1] = 0.001; + } + return geometry; }, - clearSegments: function () { + clear: function () { this.el.object3D.remove(this.el.object3D.children[0]); + if (this.geometry) this.geometry.dispose(); + this.geometry = new THREE.BufferGeometry(); }, tick: function (time, delta) { if (!this.animate) { return; } + + var posArray = this.geometry.attributes.position.array; + var rotation; + var x, y; + var sin, cos; + delta *= 0.001; + // TODO: FIX ROTATIONS!! (before they where absolute, now relative) this.currentTwist += (this.data.twist - this.currentTwist) * delta; + rotation = 0.01; - var child = this.el.object3D.children[0]; - var zoom = this.zoomProgress ? Math.sin(this.zoomProgress * Math.PI) * 0.4 : 0; - - while (child) { - child.rotation.y = this.currentTwist; - child.position.y = this.data.positionIncrement + zoom; - child = child.children[0]; - } - - if (this.zoomProgress > 0) { - this.zoomProgress += delta; - if (this.zoomProgress >= 1) { - this.zoomProgress = 0; + for (var s = 0; s < this.data.count; s++) { + for (var i = 0; i < NUM_VALUES_PER_SEGMENT; i += 3) { + cos = Math.cos(rotation); + sin = Math.sin(rotation); + x = posArray[s * NUM_VALUES_PER_SEGMENT + i]; + y = posArray[s * NUM_VALUES_PER_SEGMENT + i + 2]; + posArray[s * NUM_VALUES_PER_SEGMENT + i] = x * cos - y * sin; + posArray[s * NUM_VALUES_PER_SEGMENT + i + 2] = y * cos + x * sin; } + rotation *= 1.05; } - if (Math.abs(this.data.twist - this.currentTwist) < 0.001 && this.zoomProgress == 0){ + this.geometry.attributes.position.needsUpdate = true; + + if (Math.abs(this.data.twist - this.currentTwist) < 0.001){ this.animate = false; } - } }); diff --git a/src/state/index.js b/src/state/index.js index bbd7968..8e3c383 100644 --- a/src/state/index.js +++ b/src/state/index.js @@ -64,7 +64,7 @@ AFRAME.registerState({ leaderboardQualified: false, leaderboardNames: '', leaderboardScores: '', - menuActive: false, // Main menu active. + menuActive: true, // Main menu active. menuDifficulties: [], // List of strings of available difficulties for selected. menuSelectedChallenge: { // Currently selected challenge in the main menu. author: '', diff --git a/src/templates/stage.html b/src/templates/stage.html index a8b3dbf..4fc466b 100644 --- a/src/templates/stage.html +++ b/src/templates/stage.html @@ -22,6 +22,7 @@ animation__colorbluefade="property: components.fog.el.object3D.fog.color; type: color; from: #3398CA; to: #007cb9; dur: 500; easing: linear; startEvents: colorbluefade" animation__colorred="property: components.fog.el.object3D.fog.color; type: color; to: #b90000; dur: 5; easing: linear; startEvents: colorred" animation__colorredfade="property: components.fog.el.object3D.fog.color; type: color; from: #ff0000; to: #b90000; dur: 500; easing: linear; startEvents: colorredfade"> + - +