Skip to content

Commit

Permalink
added models and coder
Browse files Browse the repository at this point in the history
  • Loading branch information
jinpyojeon committed May 10, 2017
1 parent d928925 commit 7d45799
Show file tree
Hide file tree
Showing 19 changed files with 39,190 additions and 15 deletions.
3 changes: 3 additions & 0 deletions main.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
<!-- script type="text/javascript" src="src/loaders/LoadingManager.js"></script-->
<script type="text/javascript" src="src/loaders/OBJLoader.js"></script>
<script type="text/javascript" src="main.js"></script>
<script type="text/javascript" src='src/threex.grassground.js'></script>
</head>

<body>
<div id="score">0</div>
<div id="distance">0</div>
</body>

</html>
92 changes: 77 additions & 15 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,107 @@
var scene, camera, renderer;
var mousePos;

init();
var figure;
var sun;

var game;
var deltaTime = 0;
var newTime = new Date().getTime();
var oldTime = new Date().getTime();

var Colors = {
red: 0xf25346,
white: 0xd8d0d1,
brown: 0x59332e,
pink: 0xF5986E,
brownDark: 0x23190f,
blue: 0x68c3c0,
};

init();

function init() {
scene = new THREE.Scene();


camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 1, 10000);
camera.position.z = 1000;
camera.position.z = 10;
camera.position.y = 2;

var ambientLight = new THREE.AmbientLight(0x404040); // soft white light
scene.add(ambientLight);

var light = new THREE.DirectionalLight(0xffffff, 1, 100);
var geomSun = new THREE.BoxGeometry(1, 1, 1, 1, 1, 1);
var matSun = new THREE.MeshPhongMaterial({ color: Colors.red, shading: THREE.FlatShading })
sun = new THREE.Mesh(geomSun, matSun);
sun.position.set(5, 5, -1);
scene.add(sun);

var light = new THREE.DirectionalLight(Colors.red, 1, 10);
light.position.set(sun.position);
light.position.set(0, 1, 0); //default; light shining from top
scene.add(light);

renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColor(0xEEEEEE);
var listener = new THREE.AudioListener();
camera.add(listener);

// // create a global audio source
// var sound = new THREE.Audio(listener);

// var audioLoader = new THREE.AudioLoader();

// //Load a sound and set it as the Audio object's buffer
// audioLoader.load('sounds/ambient.ogg', function(buffer) {
// sound.setBuffer(buffer);
// sound.setLoop(true);
// sound.setVolume(0.5);
// sound.play();
// });

var loader = new THREE.TextureLoader();

// var manager = new THREE.LoadingManager();
// manager.onProgress = function(item, loaded, total) {
// console.log(item, loaded, total);
// };
// var groundMesh = new THREEx.GrassGround();
// scene.add(groundMesh);

renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
// renderer.setClearColor(0xEEEEEE);

var loader = new THREE.OBJLoader();


loader.load('models/Stick_Figure_by_Swp.OBJ',
function(object) {
object.position.set(0, 0, 0);
scene.add(object);
object.position.set(1, 1, 0);
object.rotation.set(1, 1, 180);
figure = object;
scene.add(figure);
}
);

window.onload = function() {
document.body.appendChild(renderer.domElement);
render();
}

render();
document.addEventListener("mousemove", handleMouseMove, false);
}

function render() {
requestAnimationFrame(render);
// camera.rotation.z -= 0.1;
// figure.position.z += 0.01;
if (sun) figure.position.z -= 0.01;
if (figure) figure.position.set(mousePos.x * 10, mousePos.y * 10, 1);
renderer.render(scene, camera);

requestAnimationFrame(render);
}

function handleMouseMove(event) {
var tx = -1 + (event.clientX / window.innerWidth) * 2;
var ty = 1 - (event.clientY / window.innerHeight) * 2;
mousePos = { x: tx, y: ty };
}

function procGenerateCubes() {

}
Binary file added models/tree 1a - 1b/bark1.tga
Binary file not shown.
Binary file added models/tree 1a - 1b/bark1_nmp.tga
Binary file not shown.
Binary file added models/tree 1a - 1b/leafs1.tga
Binary file not shown.
Loading

0 comments on commit 7d45799

Please sign in to comment.