Really add the master project files this time

This commit is contained in:
Rob L 2016-07-07 11:18:02 -04:00
parent 4291c82b1a
commit 47da08343c
5 changed files with 1264 additions and 1 deletions

21
mapview/LICENSE Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 roblevesque
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

1062
mapview/js/empiredata.json Normal file

File diff suppressed because it is too large Load Diff

164
mapview/js/mapviewgl.js Normal file
View File

@ -0,0 +1,164 @@
// Load Data
var xmlhttp = new XMLHttpRequest();
var url = "empiredata.json";
var jsonEmpire;
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
jsonEmpire = JSON.parse(xmlhttp.responseText);
}
};
xmlhttp.open("GET", url, true);
xmlhttp.send();
if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
var camera, controls, scene, renderer;
var canvas_t=[];
var context_t=[];
var clock = new THREE.Clock();
var WIDTH = window.innerWidth , HEIGHT = window.innerHeight
init();
animate();
function init() {
scene = new THREE.Scene();
//scene.fog = new THREE.FogExp2( 0xcccccc, 0.002 );
renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
container = document.createElement( 'div' );
document.body.appendChild( container );
camera = new THREE.PerspectiveCamera(50, window.innerWidth / window.innerHeight, 1, 1e7);
/* controls = new THREE.TrackballControls( camera, renderer.domElement ); // I don't like how the Trackball controls work.
controls.rotateSpeed = 1.0;
controls.zoomSpeed = 1.2;
controls.panSpeed = 0.8;
controls.noZoom = false;
controls.noPan = true;
controls.staticMoving = true;
controls.dynamicDampingFactor = 0.3;
controls.keys = [ 65, 83, 68 ];
camera.position.set(-8500,50,550);
/* camera.target = new THREE.Vector3().addVectors(/*new line for readability*/
// new THREE.Vector3(-9800,200,0), camera.getWorldDirection()); */
//camera.target = new THREE.Vector3(-9197,0,0); // END Trackball controls
controls = new THREE.OrbitControls( camera, renderer.domElement );
controls.enableDamping = true;
controls.dampingFactor = 0.25;
controls.enableZoom = true;
camera.position.set(-9300,50,550);
controls.addEventListener( 'change', render );
var borders=[];
var geometry=[];
var material=[];
var planets=[];
var labels=[];
var bases=[];
var Text2D = THREE_Text.Text2D;
var SpriteText2D = THREE_Text.SpriteText2D;
var textAlign = THREE_Text.textAlign
var raycaster = new THREE.Raycaster();
var mouse = new THREE.Vector2();
for (var key in jsonEmpire) {
area=jsonEmpire[key];
// Border Generation. If it's not visible, don't generate it, dummy.
if( area.bordervis) {
geometry[key] = new THREE.SphereGeometry( area.rad, 10, 10 )
material[key] = new THREE.MeshBasicMaterial( { color: area.color, wireframe: true} );
borders[key]= new THREE.Mesh( geometry[key], material[key] );
borders[key].position.x=area.cenx;
borders[key].position.y=area.ceny;
borders[key].position.z=area.cenz;
scene.add( borders[key] );
}
// Planet Generation
for (var key in area["planets"]) {
var planet = area.planets[key];
geometry[key] = new THREE.SphereGeometry( 1, 10, 10 );
material[key] = new THREE.MeshBasicMaterial( { color: area.color, wireframe: false} );
planets[key]= new THREE.Mesh( geometry[key], material[key] );
planets[key].position.x=planet.X;
planets[key].position.y=planet.Y;
planets[key].position.z=planet.Z;
var text = new Text2D(key, { align: textAlign.right, font: '12px Arial', fillStyle: '#FFF' , antialias: false });
text.material.alphaTest = 0.0;
text.position.set(planet.X,planet.Y,planet.Z);
text.scale.set(0.25,0.25,0.25);
scene.add(text);
scene.add( planets[key] );
}
// Base Generation
for (var key in area["bases"]) {
var base = area.bases[key];
var TILE_SIZE = 0.5;
geometry[key] = new THREE.CylinderGeometry( 0.1, TILE_SIZE*3, TILE_SIZE*3, 4 );
material[key] = new THREE.MeshBasicMaterial( { color: area.color, wireframe: false} );
bases[key] = new THREE.Mesh( geometry[key], material[key] );
bases[key].position.x=base.X;
bases[key].position.y=base.Y;
bases[key].position.z=base.Z;
scene.add( bases[key] );
var text = new Text2D(key, { align: textAlign.left, font: '12px Arial', fillStyle: '#ABABAB' , antialias: false });
text.material.alphaTest = 0.0;
text.position.set(base.X,base.Y+3,base.Z);
text.scale.set(0.20,0.20,0.20);
scene.add(text);
}
}
// Initial Target spot. UFP for convinence.
controls.target.x = borders['UFP'].position.x;
controls.target.y = borders['UFP'].position.y;
controls.target.z = borders['UFP'].position.z;
}
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
controls.handleResize();
render();
}
function animate() {
var delta = clock.getDelta();
requestAnimationFrame( animate );
controls.update(delta);
}
function render () {
requestAnimationFrame( animate );
renderer.render( scene, camera );
}
render();

17
mapview/webviewgl.htm Normal file
View File

@ -0,0 +1,17 @@
<html>
<head>
<script src="//threejs.org/build/three.js"></script>
<script src="//threejs.org/examples/js/controls/OrbitControls.js"></script>
<script src="//gamestd.io/three-text2d/dist/three-text2d.js"></script>
<script src="//crival.net/3d/js/Detector.js"></script> <!-- Not sure if this is even needed anymore. -->
<script src="/js/mapviewgl.js"></script>
<style type="text/css">
body { margin: 0; }
canvas { width: 100%; height: 100% }
</style>
</head>
<body>
<div id="container"></div>
</body>
</html>

View File

@ -1 +0,0 @@
../../webglmapview/