Skip to content

Commit

Permalink
Moving code to Three.js r75
Browse files Browse the repository at this point in the history
  • Loading branch information
gbiobob committed Apr 7, 2016
1 parent 209ea45 commit 65836ce
Show file tree
Hide file tree
Showing 18 changed files with 1,231 additions and 788 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
minify/
minify/
demo_planet.html
demo_edsm.html
js/ed3dplanet.js
json_samples/eddb.json
json_samples/edsm.json
21 changes: 10 additions & 11 deletions data/milkyway.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,52 +45,52 @@
{"x":-7265, "z":4226, "rotate":-35},
{"x":6858, "z":-576, "rotate":0}
],
"The outer arm vacuus" : [
"The outer Arm vacuus" : [
{"x":10, "z":-14500, "rotate":0}
],
"The Sagittarius arm" : [
"The Sagittarius Arm" : [
{"x":5379, "z":4768, "rotate":0}
],
"The Carina-Sagittarius arm" : [
"The Carina-Sagittarius Arm" : [
{"x":22458, "z":10237, "rotate":45},
{"x":29632, "z":25285, "rotate":82},
{"x":28962, "z":40634, "rotate":105},
{"x":17446, "z":58185, "rotate":-40}
],
"The new outer arm" : [
"The new outer Arm" : [
{"x":-31158, "z":16529, "rotate":90},
{"x":-28281, "z":3070, "rotate":112},
{"x":-18972, "z":-8546, "rotate":-35}

],
"The Perseus arm" : [
"The Perseus Arm" : [
{"x":-19961, "z":30870, "rotate":60 },
{"x":-22778, "z":10633, "rotate":110 },
{"x":-7525, "z":-3597, "rotate":-25 },
{"x":8039, "z":-7019, "rotate":0 },
{"x":32905, "z":4565, "rotate":45 }
],
"The Norma arm" : [
"The Norma Arm" : [
{"x":7944, "z":17960, "rotate":40 },
{"x":13524, "z":29918, "rotate":90 },
{"x":7498, "z":40348, "rotate":-35 }
],
"The Cygnus arm" : [
"The Cygnus Arm" : [
{"x":-7724, "z":43523, "rotate":0 },
{"x":-22353, "z":37643, "rotate":38 }
],
"The Scutum-Centaurus arm" : [
"The Scutum-Centaurus Arm" : [
{"x":-33364, "z":46016, "rotate":45 },
{"x":-15742, "z":54759, "rotate":0 },
{"x":-334, "z":53331, "rotate":-14 },
{"x":14300, "z":46140, "rotate":-38 },
{"x":19815, "z":31418, "rotate":90 },
{"x":16637, "z":17458, "rotate":48 }
],
"The near 3KPC arm" : [
"The near 3 KPC Arm" : [
{"x":5765, "z":22639, "rotate":45 }
],
"The far 3KPC arm" : [
"The far 3 KPC Arm" : [
{"x":-4906 ,"z":28535, "rotate":45 }
]
},
Expand Down Expand Up @@ -134,5 +134,4 @@
]

}

}
3 changes: 1 addition & 2 deletions demo_galnet.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
<!-- jQuery -->
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<!-- Three.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r73/three.min.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r75/three.min.js"></script>

<!-- Launch ED3Dmap -->
<link href="css/styles.css" rel="stylesheet" type="text/css" />
Expand Down
2 changes: 1 addition & 1 deletion demo_infos.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ <h1>Milky Way</h1>
<!-- jQuery -->
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<!-- Three.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r73/three.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r75/three.min.js"></script>

<!-- Launch ED3Dmap -->
<link href="css/styles.css" rel="stylesheet" type="text/css" />
Expand Down
2 changes: 1 addition & 1 deletion demo_no_jsonfile.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ <h1>NO JSon file test</h1>
<!-- jQuery -->
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<!-- Three.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r73/three.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r75/three.min.js"></script>

<!-- JSon inside a container -->
<div id="json_data">
Expand Down
2 changes: 1 addition & 1 deletion demo_routes.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ <h1>Milky Way</h1>
<!-- jQuery -->
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<!-- Three.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r73/three.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r75/three.min.js"></script>

<!-- Launch ED3Dmap -->
<link href="css/styles.css" rel="stylesheet" type="text/css" />
Expand Down
10 changes: 5 additions & 5 deletions js/components/action.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ var Action = {
mx: Ed3d.playerPos[0], my: Ed3d.playerPos[1] , mz: -Ed3d.playerPos[2]
};
camera.position.set(moveTo.x, moveTo.y, moveTo.z);
controls.center.set(moveTo.mx, moveTo.my, moveTo.mz);
controls.target.set(moveTo.mx, moveTo.my, moveTo.mz);

},

Expand All @@ -281,7 +281,7 @@ var Action = {

var moveFrom = {
x: camera.position.x, y: camera.position.y , z: camera.position.z,
mx: controls.center.x, my: controls.center.y , mz: controls.center.z
mx: controls.target.x, my: controls.target.y , mz: controls.target.z
};

//-- Move to player position if defined, else move to Sol
Expand All @@ -307,7 +307,7 @@ var Action = {
.start()
.onUpdate(function () {
camera.position.set(moveFrom.x, moveFrom.y, moveFrom.z);
controls.center.set(moveFrom.mx, moveFrom.my, moveFrom.mz);
controls.target.set(moveFrom.mx, moveFrom.my, moveFrom.mz);
})
.onComplete(function () {
controls.enabled = true;
Expand Down Expand Up @@ -348,7 +348,7 @@ var Action = {

var moveFrom = {
x: camera.position.x, y: camera.position.y , z: camera.position.z,
mx: controls.center.x, my: controls.center.y , mz: controls.center.z
mx: controls.target.x, my: controls.target.y , mz: controls.target.z
};
var moveCoords = {
x: goX, y: goY + 15, z: goZ + 15,
Expand All @@ -359,7 +359,7 @@ var Action = {
.start()
.onUpdate(function () {
camera.position.set(moveFrom.x, moveFrom.y, moveFrom.z);
controls.center.set(moveFrom.mx, moveFrom.my, moveFrom.mz);
controls.target.set(moveFrom.mx, moveFrom.my, moveFrom.mz);
})
.onComplete(function () {
controls.update();
Expand Down
4 changes: 2 additions & 2 deletions js/components/grid.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ var Grid = {

}

this.obj = new THREE.Line( geometry, material, THREE.LinePieces );
this.obj = new THREE.LineSegments( geometry, material );
this.obj.position.set(0,0,-20000);

//-- Add quadrant
Expand All @@ -85,7 +85,7 @@ var Grid = {

quadrant.vertices.push( new THREE.Vector3( 0, 0, - size ) );
quadrant.vertices.push( new THREE.Vector3( 0, 0, size ) );
var quadrantL = new THREE.Line( quadrant, material, THREE.LinePieces );
var quadrantL = new THREE.LineSegments( quadrant, material );


this.obj.add(quadrantL);
Expand Down
4 changes: 2 additions & 2 deletions js/components/hud.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ var HUD = {
case 'top':
Ed3d.isTopView = true;
var moveFrom = {x: camera.position.x, y: camera.position.y , z: camera.position.z};
var moveCoords = {x: controls.center.x, y: controls.center.y+500, z: controls.center.z};
var moveCoords = {x: controls.target.x, y: controls.target.y+500, z: controls.target.z};
HUD.moveCamera(moveFrom,moveCoords);
break;

case '3d':
Ed3d.isTopView = false;
var moveFrom = {x: camera.position.x, y: camera.position.y , z: camera.position.z};
var moveCoords = {x: controls.center.x-100, y: controls.center.y+500, z: controls.center.z+500};
var moveCoords = {x: controls.target.x-100, y: controls.target.y+500, z: controls.target.z+500};
HUD.moveCamera(moveFrom,moveCoords);
break;

Expand Down
22 changes: 12 additions & 10 deletions js/ed3dmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ var Ed3d = {
});
Ed3d.material.glow_2 = new THREE.SpriteMaterial({

map: Ed3d.textures.flare_white, transparent: true, size: 15,
vertexColors: THREE.VertexColors,
map: Ed3d.textures.flare_white,
transparent: true,
blending: THREE.AdditiveBlending,
depthWrite: false,
opacity: 0.5
Expand Down Expand Up @@ -334,11 +334,11 @@ var Ed3d = {

//controls
controls = new THREE.OrbitControls(camera, container);
controls.rotateSpeed = 1.0;
controls.zoomSpeed = 3.0;
controls.rotateSpeed = 0.6;
controls.zoomSpeed = 2.0;
controls.panSpeed = 0.8;
controls.maxDistance = 60000;
controls.noZoom=!1;controls.noPan=!1;controls.staticMoving=!0;controls.dynamicDampingFactor=.3;
controls.enableZoom=1;controls.enablePan=1;controls.enableDamping=!0;controls.dampingFactor=.3;


// Add Fog
Expand Down Expand Up @@ -516,6 +516,8 @@ var Ed3d = {

function animate(time) {

//rendererStats.update(renderer);

if(scene.visible == false) {
requestAnimationFrame( animate );
return;
Expand All @@ -534,16 +536,16 @@ function animate(time) {
//-- If 2D top view, lock camera pos
if(Ed3d.isTopView) {
camera.rotation.set(-Math.PI/2,0,0);
camera.position.x = controls.center.x;
camera.position.z = controls.center.z;
camera.position.x = controls.target.x;
camera.position.z = controls.target.z;
}


renderer.render(scene, camera);

$('#cx').html(Math.round(controls.center.x));
$('#cy').html(Math.round(controls.center.y));
$('#cz').html(Math.round(-controls.center.z)); // Reverse z coord
$('#cx').html(Math.round(controls.target.x));
$('#cy').html(Math.round(controls.target.y));
$('#cz').html(Math.round(-controls.target.z)); // Reverse z coord

$('#distsol').html(Ed3d.calcDistSol(controls.target));

Expand Down
2 changes: 1 addition & 1 deletion js/ed3dmap.min.js

Large diffs are not rendered by default.

51 changes: 51 additions & 0 deletions vendor/renderstats/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
threex.rendererstats
====================

It is a three.js extension to display realtime informations about ```THREE.WebGLRenderer```.
Here is a [basic example](http://jeromeetienne.github.io/threex.rendererstats/examples/basic.html). It is widely inpired from @mrdoob [stats.js](https://github.com/mrdoob/stats.js/).
It is released under MIT license.

## How To install it

You can install it manually or with
[bower](http://bower.io/).
for the manual version, first include ```threex.rendererstats.js``` with the usual

```html
<script src='threex.rendererstats.js'></script>
```

or with
[bower](http://bower.io/)
you type the following to install the package.

```bash
bower install -s threex.rendererstats=https://github.com/jeromeetienne/threex.rendererstats/archive/master.zip
```

then you add that in your html

```html
<script src="bower_components/threex.rendererstats/threex.rendererstats.js"></script>
```

## How To Use It

```
var rendererStats = new THREEx.RendererStats()
```

position it on the page with css with something along this line

```
rendererStats.domElement.style.position = 'absolute'
rendererStats.domElement.style.left = '0px'
rendererStats.domElement.style.bottom = '0px'
document.body.appendChild( rendererStats.domElement )
```

finally update it at every frame

```
rendererStats.update(renderer);
```
66 changes: 66 additions & 0 deletions vendor/renderstats/threex.rendererstats.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/**
* @author mrdoob / http://mrdoob.com/
* @author jetienne / http://jetienne.com/
*/
/** @namespace */
var THREEx = THREEx || {}

/**
* provide info on THREE.WebGLRenderer
*
* @param {Object} renderer the renderer to update
* @param {Object} Camera the camera to update
*/
THREEx.RendererStats = function (){

var msMin = 100;
var msMax = 0;

var container = document.createElement( 'div' );
container.style.cssText = 'width:80px;opacity:0.9;cursor:pointer';

var msDiv = document.createElement( 'div' );
msDiv.style.cssText = 'padding:0 0 3px 3px;text-align:left;background-color:#200;';
container.appendChild( msDiv );

var msText = document.createElement( 'div' );
msText.style.cssText = 'color:#f00;font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px';
msText.innerHTML= 'WebGLRenderer';
msDiv.appendChild( msText );

var msTexts = [];
var nLines = 9;
for(var i = 0; i < nLines; i++){
msTexts[i] = document.createElement( 'div' );
msTexts[i].style.cssText = 'color:#f00;background-color:#311;font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px';
msDiv.appendChild( msTexts[i] );
msTexts[i].innerHTML= '-';
}


var lastTime = Date.now();
return {
domElement: container,

update: function(webGLRenderer){
// sanity check
console.assert(webGLRenderer instanceof THREE.WebGLRenderer)

// refresh only 30time per second
if( Date.now() - lastTime < 1000/30 ) return;
lastTime = Date.now()

var i = 0;
msTexts[i++].textContent = "== Memory =====";
msTexts[i++].textContent = "Programs: " + webGLRenderer.info.memory.programs;
msTexts[i++].textContent = "Geometries: "+webGLRenderer.info.memory.geometries;
msTexts[i++].textContent = "Textures: " + webGLRenderer.info.memory.textures;

msTexts[i++].textContent = "== Render =====";
msTexts[i++].textContent = "Calls: " + webGLRenderer.info.render.calls;
msTexts[i++].textContent = "Vertices: " + webGLRenderer.info.render.vertices;
msTexts[i++].textContent = "Faces: " + webGLRenderer.info.render.faces;
msTexts[i++].textContent = "Points: " + webGLRenderer.info.render.points;
}
}
};
Loading

0 comments on commit 65836ce

Please sign in to comment.