Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added grid helper, and changed three.js refrence path #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 24 additions & 5 deletions index.html
Expand Up @@ -4,28 +4,47 @@
body { margin: 0; }
canvas { width: 100%; height: 100% }
</style>
<script src="/node_modules/three.js/node_modules/three/three.min.js"></script>
<script src="/node_modules/three/three.min.js"></script>
<script>

function init() {
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );
var camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 0.1, 1000 );

var renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );

var geometry = new THREE.BoxGeometry( 1, 1, 1 );
var material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
var material = new THREE.MeshLambertMaterial( { color: 0x00ff00 } );
var cube = new THREE.Mesh( geometry, material );
scene.add( cube );

var grid = new THREE.GridHelper(100, 10);
scene.add(grid);

camera.position.z = 5;
camera.position.z = 10;
camera.position.y = 5;
camera.rotation.x = -30 * Math.PI / 180;

var makelight = function(x,y,z,strength) {
var directionalLight = new THREE.DirectionalLight( 0xffffff, strength );
directionalLight.position.set( x, y, z );
scene.add( directionalLight );
};

makelight(-.5,1,.5, 1);
makelight(.5,1,.5, .5);
makelight(0,-1,0, .5);

var point=0;
function render() {
requestAnimationFrame( render );

cube.rotation.x += 0.1;
point += .001;

camera.rotation.y = Math.sin(point); //1 * Math.PI / 180;
cube.rotation.x += 0.01;
cube.rotation.y += 0.1;
renderer.render( scene, camera );
}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -5,6 +5,7 @@
},
"devDependencies": {
"connect": "^3.4.1",
"serve-static": "^1.10.2"
"serve-static": "^1.10.2",
"typescript": "^1.8.10"
}
}
1 change: 1 addition & 0 deletions src/main.ts
@@ -0,0 +1 @@
console.log("sup");
7 changes: 7 additions & 0 deletions tsconfig.json
@@ -0,0 +1,7 @@
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"sourceMap": true
}
}