html
html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<!-- Created by Aditya -->
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://badasstechie.github.io/lib/three/112.1/three.min.js"></script>
<script src="https://badasstechie.github.io/lib/three/112.1/GLTFLoader.min.js"></script>
<script src="https://badasstechie.github.io/lib/three/112.1/BufferGeometryUtils.min.js"></script>
</head>
<body onload="init()">
�
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://badasstechie.github.io/lib/stats/stats.min.js"></script>
<script src="https://badasstechie.github.io/lib/sweetalert/sweetalert.min.js"></script>
<!--Shader. Makes objects glow-->
<script id="vertexShader" type="x-shader/x-vertex">
uniform vec3 viewVector;
varying float intensity;
void main(){
gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.0);
vec3 actual_normal = vec3(modelMatrix * vec4(normal, 0.0));
intensity = pow(dot(normalize(viewVector), actual_normal), 6.0);
}
</script>
<script id="fragmentShader" type="x-shader/x-fragment">
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* Created by Aditya */
body{
margin: 0;
}
canvas{
height: 100%;
width: 100%;
}
.swal-overlay {
background-color: rgba(25, 25, 255, 0.55);
}
.swal-modal {
background-color: rgba(64, 255, 119, 0.67);
}
.swal-title {
color: #ffffff;
font-size: 26px;
margin: 0px;
padding: 0px;
padding-bottom: 16px;
}
.swal-text {
padding: 0px;
text-align: center;
color: #ffffff;
Enter to Rename, Shift+Enter to Preview
js
js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Created by Aditya
alert("It may take some time to load")
alert("don't forget to upvote")
alert("comment also")
"use strict";
let sceneWidth, sceneHeight, camera, scene, renderer, orbitControl, stats, quality = 0.6;
let ground, groundAttributes = {width: 10, height: 10, widthSegments: 64, heightSegments: 64}, glow, heightMap, heightScale = 0.67; //ground
let parrot, flyingAnimation, acceleration = -0.2,
orgTilt, tilt = THREE.Math.degToRad(-30), minTilt = -30, maxTilt = 30, maxHeight, jumpTimeout, tiltTimeout; //parrot
let up, down, front, planes = [], z, dZ = 0, yMax, zMax = 0.4, dRot, collided = false; //collision
let landscape, landscapePool = [], meshes = [], materials = [], pole1, pole2, gap = 0.14; //object groups
let cameraTarget = new THREE.Vector3(0, 0, 3); //camera
let clock = new THREE.Clock(), delta = 0, speed = 2, mixer; //timing
let score = 0, highScore = 0, scoreLabel, gameOver = false; //score
let flapSound, hitSound, metalSound, scoreSound, laugh; //sound effects
const loader = new THREE.GLTFLoader();
//initializes the scene
function init() {
stats = new Stats();
stats.showPanel(0);
//document.body.appendChild(stats.dom);
sceneWidth = window.innerWidth;
sceneHeight = window.innerHeight;
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run