corrade-nucleus-nucleons – Blame information for rev 36

Subversion Repositories:
Rev:
Rev Author Line No. Line
36 office 1 <div id="compass">
2 <!-- Three.js -->
3 <script src="/compass/js/three/three.min.js" type="text/javascript"></script>
4 <!-- Helvetiker -->
5 <script src="/compass/js/three/helvetiker_regular.typeface.js" type="text/javascript"></script>
6 <!-- Orbit Controls -->
7 <script src="/compass/js/three/OrbitControls.min.js" type="text/javascript"></script>
8  
9 <div class="panel panel-default window-manager-window">
10 <div class="panel-heading">
11 <button type="button" class="close window-manager-close-button" data-target="compass"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
12 <h3 class="panel-title">Compass</h3>
13 </div>
14 <div class="panel-body">
15 <div id="container"></div>
16 </div>
17 </div>
18  
19 <!-- Terrain Vertex and Fragment Shaders -->
20 <!-- Vertex Shader -->
21 <script id="terrainVertex" type="x-shader/x-vertex">
22 uniform sampler2D bumpTexture;
23 uniform float bumpScale;
24  
25 varying vec2 vUV;
26  
27 void main() {
28 vUV = uv;
29 vec4 bumpData = texture2D(bumpTexture, uv);
30  
31 // move the position along the normal
32 vec3 newPosition =
33 position +
34 normal *
35 bumpScale *
36 bumpData.r; // use red channel (all equal in greyscale)
37  
38 gl_Position =
39 projectionMatrix *
40 modelViewMatrix *
41 vec4(newPosition, 1.0);
42 }
43 </script>
44 <!-- Fragment Shader / Pixel Shader -->
45 <script id="terrainFragment" type="x-shader/x-vertex">
46 uniform sampler2D mapTexture;
47 varying vec2 vUV;
48  
49 void main() {
50 vec4 map = texture2D(mapTexture, vUV);
51 gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0) + map; //, 1.0);
52 }
53 </script>
54 <!-- -->
55  
56 <script>
57  
58 /* The bounds of the plot. */
59 var plotBounds = {
60 'maxx' : 256,
61 'minx' : -256,
62 'maxy' : 256,
63 'miny' : -256,
64 'maxz' : 256,
65 'minz' : -256
66 };
67  
68 /* This represents the bounds of the data to plot.
69 * These values will be linearly mapped onto the
70 * bounds for the plot.
71 */
72 var dataBounds = {
73 'maxx' : 256,
74 'minx' : 0,
75 'maxy' : 256,
76 'miny' : 0,
77 'maxz' : 256, // Second Life maximum rez altitude
78 'minz' : 0
79 }
80  
81 /* Structure to be filled by the backend scripts. */
82 var csv =
83 {
84 'header' : [ "x", "y", "z" ],
85 'positions' : [],
86 'names' : [],
87 'colors' : []
88 };
89  
90 /* The size of the cursor for each avatar. */
91 var dotSize = 8;
92 /* The interval in milliseconds for updating the terrain. */
93 var mapFetchInterval = 60000;
94 /* The interval in milliseconds for avatar position updates. */
95 var avatarsFetchInterval = 1000;
96  
97 var container;
98 var camera, controls, scene, renderer;
99 var scatterPlot;
100 var points;
101 var avatarLabels = [];
102 var avatarProjections = [];
103 var mapImageData = null;
104 var mapBumpData = null;
105 var mapHeight;
106 var mapMesh;
107  
108 init();
109 animate();
110  
111 function init() {
112 /* Create the camera. */
113 camera = new THREE.PerspectiveCamera(
114 60,
115 window.innerWidth / window.innerHeight,
116 2,
117 10000
118 );
119 camera.position.z = plotBounds.maxz * 2;
120 camera.position.x = 0;
121 camera.position.y = plotBounds.maxy * 1.25;
122 controls = new THREE.OrbitControls(camera);
123 controls.damping = 0.2;
124 controls.addEventListener('change', render);
125  
126 /* Create the scene. */
127 scene = new THREE.Scene();
128  
129 /* Add the scatterplot to it. */
130 scatterPlot = new THREE.Object3D();
131 scene.add(scatterPlot);
132  
133 /* Draw axes. */
134 var xAxisGeo = new THREE.Geometry();
135 var yAxisGeo = new THREE.Geometry();
136 var zAxisGeo = new THREE.Geometry();
137  
138 xAxisGeo.vertices.push(
139 new THREE.Vector3(
140 plotBounds.minx/2,
141 plotBounds.miny/2,
142 plotBounds.minz/2
143 ),
144 new THREE.Vector3(
145 plotBounds.maxx/2,
146 plotBounds.miny/2,
147 plotBounds.minz/2
148 )
149 );
150 yAxisGeo.vertices.push(
151 new THREE.Vector3(
152 plotBounds.minx/2,
153 plotBounds.miny/2,
154 plotBounds.minz/2
155 ),
156 new THREE.Vector3(
157 plotBounds.minx/2,
158 plotBounds.maxy/2,
159 plotBounds.minz/2
160 )
161 );
162 zAxisGeo.vertices.push(
163 new THREE.Vector3(
164 plotBounds.minx/2,
165 plotBounds.miny/2,
166 plotBounds.minz/2
167 ),
168 new THREE.Vector3(
169 plotBounds.minx/2,
170 plotBounds.miny/2,
171 plotBounds.maxz/2
172 )
173 );
174  
175 var xAxisMat = new THREE.LineBasicMaterial(
176 {
177 color: 0xa60000,
178 lineWidth: 1
179 }
180 );
181 var xAxis = new THREE.Line(xAxisGeo, xAxisMat);
182 xAxis.type = THREE.Lines;
183 scatterPlot.add(xAxis);
184  
185 var yAxisMat = new THREE.LineBasicMaterial(
186 {
187 color: 0x0000a6,
188 lineWidth: 1
189 }
190 );
191 var yAxis = new THREE.Line(yAxisGeo, yAxisMat);
192 yAxis.type = THREE.Lines;
193 scatterPlot.add(yAxis);
194  
195 var zAxisMat = new THREE.LineBasicMaterial(
196 {
197 color: 0x00a600,
198 lineWidth: 1
199 }
200 );
201 var zAxis = new THREE.Line(zAxisGeo, zAxisMat);
202 zAxis.type = THREE.Lines;
203 scatterPlot.add(zAxis);
204  
205 /* Add axes text. */
206 var text3d = new THREE.TextGeometry("O", {
207 size: 8,
208 height: 2,
209 curveSegments: 2//,
210 //font: "cmutypewriter_regular"
211  
212 });
213 text3d.computeBoundingBox();
214 var centerOffset = -0.5 * (
215 text3d.boundingBox.max.x -
216 text3d.boundingBox.min.x
217 );
218 var textMaterial = new THREE.MeshBasicMaterial(
219 {
220 color: 0xa6a6a6,
221 overdraw: 0.5
222 }
223 );
224 text = new THREE.Mesh(text3d, textMaterial);
225 text.position.x = plotBounds.minx/2 + 2 * centerOffset;
226 text.position.y = plotBounds.minx/2 + 2 * centerOffset;
227 text.position.z = plotBounds.minx/2;
228 scatterPlot.add(text);
229  
230 text3d = new THREE.TextGeometry(
231 csv.header[0] +
232 " " +
233 "(" +
234 dataBounds.maxx +
235 "m)",
236 {
237 size: 8,
238 height: 2,
239 curveSegments: 2//,
240 //font: "cmutypewriter_regular"
241 }
242 );
243 text3d.computeBoundingBox();
244 centerOffset = -0.5 * (
245 text3d.boundingBox.max.x -
246 text3d.boundingBox.min.x
247 );
248 textMaterial = new THREE.MeshBasicMaterial(
249 {
250 color: 0xa60000,
251 overdraw: 0.5
252 }
253 );
254 text = new THREE.Mesh(text3d, textMaterial);
255 text.position.x = plotBounds.maxx/2 - centerOffset / 4;
256 text.position.y = plotBounds.miny/2 + centerOffset / 8;
257 text.position.z = plotBounds.minz/2;
258 scatterPlot.add(text);
259  
260 text3d = new THREE.TextGeometry(
261 csv.header[2] +
262 " " +
263 "(" +
264 dataBounds.maxz +
265 "m)",
266 {
267 size: 8,
268 height: 2,
269 curveSegments: 2//,
270 //font: "cmutypewriter_regular"
271 }
272 );
273 text3d.computeBoundingBox();
274 centerOffset = -0.5 * (
275 text3d.boundingBox.max.x -
276 text3d.boundingBox.min.x
277 );
278 textMaterial = new THREE.MeshBasicMaterial(
279 {
280 color: 0x0000a6,
281 overdraw: 0.5
282 }
283 );
284 text = new THREE.Mesh( text3d, textMaterial );
285 text.position.x = plotBounds.minx/2 + centerOffset;
286 text.position.y = plotBounds.maxy/2 - centerOffset / 4;
287 text.position.z = plotBounds.minz/2;
288 scatterPlot.add(text);
289  
290 text3d = new THREE.TextGeometry(
291 csv.header[1] +
292 " " +
293 "(" +
294 dataBounds.maxy +
295 "m)",
296 {
297 size: 8,
298 height: 2,
299 curveSegments: 2//,
300 //font: "cmutypewriter_regular"
301 }
302 );
303 text3d.computeBoundingBox();
304 centerOffset = -0.5 * (
305 text3d.boundingBox.max.x -
306 text3d.boundingBox.min.x
307 );
308 textMaterial = new THREE.MeshBasicMaterial(
309 {
310 color: 0x00a600,
311 overdraw: 0.5
312 }
313 );
314 text = new THREE.Mesh(text3d, textMaterial);
315 text.position.x = plotBounds.minx/2 + centerOffset;
316 text.position.y = plotBounds.miny/2;
317 text.position.z = plotBounds.maxz/2 - centerOffset / 4;
318 scatterPlot.add(text);
319  
320 /* Add enclosing case. */
321 var enclosingCubeGeometry = enclosingCase(plotBounds.maxx);
322 enclosingCubeGeometry.computeLineDistances();
323 var enclosingCube =
324 new THREE.Line(
325 enclosingCubeGeometry,
326 new THREE.LineDashedMaterial(
327 {
328 color: 0xa6a6a6,
329 dashSize: 3,
330 gapSize: 1,
331 linewidth: 2
332 }
333 ),
334 THREE.LinePieces
335 );
336 scene.add(enclosingCube);
337  
338 // renderer
339 renderer = new THREE.WebGLRenderer(
340 {
341 antialias: true
342 }
343 );
344 renderer.setClearColor(0x1d475f, 1.0);
345 renderer.setPixelRatio(window.devicePixelRatio);
346 renderer.setSize(window.innerWidth, window.innerHeight);
347  
348 container = document.getElementById( 'container' );
349 container.appendChild( renderer.domElement );
350  
351 window.addEventListener('resize', onWindowResize, false );
352  
353 render();
354  
355 getAvatars();
356 getMapTexture();
357 getMapHeight();
358 getMapTerrain();
359 }
360  
361 function onWindowResize() {
362  
363 camera.aspect = window.innerWidth / window.innerHeight;
364 camera.updateProjectionMatrix();
365 renderer.setSize( window.innerWidth, window.innerHeight );
366 //controls.handleResize();
367 render();
368 }
369  
370 function animate() {
371 requestAnimationFrame(animate);
372 controls.update();
373 }
374  
375 function render() {
376 renderer.render(scene,camera);
377 }
378  
379 function enclosingCase(size) {
380 var h = size * 0.5;
381 var geometry = new THREE.Geometry();
382 geometry.vertices.push(
383 // Oz
384 //new THREE.Vector3( -h, -h, -h ),
385 //new THREE.Vector3( -h, h, -h ),
386  
387 new THREE.Vector3( -h, h, -h ),
388 new THREE.Vector3( h, h, -h ),
389  
390 new THREE.Vector3( h, h, -h ),
391 new THREE.Vector3( h, -h, -h ),
392  
393 // Ox
394 //new THREE.Vector3( h, -h, -h ),
395 //new THREE.Vector3( -h, -h, -h ),
396  
397 new THREE.Vector3( -h, -h, h ),
398 new THREE.Vector3( -h, h, h ),
399  
400 new THREE.Vector3( -h, h, h ),
401 new THREE.Vector3( h, h, h ),
402  
403 new THREE.Vector3( h, h, h ),
404 new THREE.Vector3( h, -h, h ),
405  
406 new THREE.Vector3( h, -h, h ),
407 new THREE.Vector3( -h, -h, h ),
408  
409 // Oy
410 //new THREE.Vector3( -h, -h, -h ),
411 //new THREE.Vector3( -h, -h, h ),
412  
413 new THREE.Vector3( -h, h, -h ),
414 new THREE.Vector3( -h, h, h ),
415  
416 new THREE.Vector3( h, h, -h ),
417 new THREE.Vector3( h, h, h ),
418  
419 new THREE.Vector3( h, -h, -h ),
420 new THREE.Vector3( h, -h, h )
421 );
422 return geometry;
423 }
424  
425 function makeTextSprite(message, parameters) {
426 if ( parameters === undefined ) parameters = {};
427  
428 var fontface = parameters.hasOwnProperty("fontface") ?
429 parameters["fontface"] :
430 "Helvetiker";
431  
432 var fontsize = parameters.hasOwnProperty("fontsize") ?
433 parameters["fontsize"] :
434 18;
435  
436 var borderThickness =
437 parameters.hasOwnProperty("borderThickness") ?
438 parameters["borderThickness"] :
439 4;
440  
441 var borderColor =
442 parameters.hasOwnProperty("borderColor") ?
443 parameters["borderColor"] :
444 { r:0, g:0, b:0, a:1.0 };
445  
446 var backgroundColor =
447 parameters.hasOwnProperty("backgroundColor") ?
448 parameters["backgroundColor"] :
449 { r:255, g:255, b:255, a:1.0 };
450  
451 var canvas = document.createElement('canvas');
452 canvas.width = 162;
453 canvas.height = 64;
454 var context = canvas.getContext('2d');
455 context.font = "Bold " + fontsize + "px " + fontface;
456 context.imageSmoothingEnabled = true;
457  
458 // determine the longest line
459 var textLines = message.split("\n");
460 var longestLine = textLines[0].length;
461 var longestIndex = 0;
462 for(var i = 1; i <textLines.length; ++i) {
463 if(textLines[i].length > longestLine) {
464 longestLine = textLines[i].length;
465 longestIndex = i;
466 }
467 }
468  
469 // get size data (height depends only on font size)
470 var metrics = context.measureText(textLines[longestIndex]);
471 var textWidth = metrics.width;
472  
473 // background color
474 context.fillStyle =
475 "rgba(" +
476 backgroundColor.r +
477 "," +
478 backgroundColor.g +
479 "," +
480 backgroundColor.b +
481 "," +
482 backgroundColor.a +
483 ")";
484 // border color
485 context.strokeStyle =
486 "rgba(" +
487 borderColor.r +
488 "," +
489 borderColor.g +
490 "," +
491 borderColor.b +
492 "," +
493 borderColor.a +
494 ")";
495  
496 context.lineWidth = borderThickness;
497 roundRect(
498 context,
499 borderThickness/2,
500 borderThickness/2,
501 textWidth + borderThickness,
502 // 1.2 is extra height factor for text below baseline
503 textLines.length * fontsize * 1.2 + borderThickness,
504 6
505 );
506  
507 // add the text color
508 context.fillStyle =
509 "rgba(" +
510 borderColor.r +
511 "," +
512 borderColor.g +
513 "," +
514 borderColor.b +
515 "," +
516 borderColor.a +
517 ")";
518  
519 // add all the requested lines whist increasing lines
520 for(var i = 0; i< textLines.length; ++ i) {
521 context.fillText(
522 textLines[i],
523 borderThickness,
524 fontsize
525 );
526 fontsize += fontsize;
527 }
528  
529 // canvas contents will be used for a texture
530 var spriteTexture = new THREE.Texture(canvas,
531 THREE.UVMapping, // mapping
532 THREE.ClampToEdgeWrapping, // wrapS
533 THREE.ClampToEdgeWrapping, // wrapT
534 THREE.NearestFilter, // magfilter
535 THREE.NearestFilter, //minfilter,
536 THREE.RGBAFormat, // format
537 THREE.UnsignedByteType // type
538 )
539 spriteTexture.anisotropy = renderer.getMaxAnisotropy();
540 spriteTexture.needsUpdate = true;
541 var spriteMaterial = new THREE.SpriteMaterial(
542 {
543 map: spriteTexture,
544 useScreenCoordinates: false,
545 overdraw: false,
546 side:THREE.DoubleSide
547 }
548 );
549 var sprite = new THREE.Sprite(spriteMaterial);
550 sprite.scale.set(64,32, 1.0);
551 return sprite;
552 }
553  
554 // function for drawing rounded rectangles
555 function roundRect(ctx, x, y, w, h, r)
556 {
557 ctx.beginPath();
558 ctx.moveTo(x+r, y);
559 ctx.lineTo(x+w-r, y);
560 ctx.quadraticCurveTo(x+w, y, x+w, y+r);
561 ctx.lineTo(x+w, y+h-r);
562 ctx.quadraticCurveTo(x+w, y+h, x+w-r, y+h);
563 ctx.lineTo(x+r, y+h);
564 ctx.quadraticCurveTo(x, y+h, x, y+h-r);
565 ctx.lineTo(x, y+r);
566 ctx.quadraticCurveTo(x, y, x+r, y);
567 ctx.closePath();
568 ctx.fill();
569 ctx.stroke();
570 }
571  
572 /*************************************************************************/
573 /* Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 */
574 /*************************************************************************/
575 function wasMapValueToRange(value, xMin, xMax, yMin, yMax) {
576 return yMin + (
577 ( yMax - yMin ) * ( value - xMin ) / ( xMax - xMin )
578 );
579 }
580  
581 function updatePoints() {
582 /* Remove points. */
583 scatterPlot.remove(points);
584 /* Remove labels. */
585 for(i=0; i
586
587
588 * Remove projections. */
589 for(i=0; i
590
591
592  
593
594
595
596  
597
598
599
600
601 * For SecondLife the z and y axes must be swapped
602 in order to attain
603 for threejs.
604 /
605 var x = wasMapValueToRange(
606 csv.positions[i][1],
607 dataBounds.minx,
608 dataBounds.maxx,
609 plotBounds.minx/2,
610 /2
611 );
612 var y = wasMapValueToRange(
613 csv.positions[i][j],
614 dataBounds.minz,
615 dataBounds.maxz,
616 plotBounds.minz/2,
617 /2
618 );
619 var z = wasMapValueToRange(
620 csv.positions[i][0],
621 dataBounds.miny,
622 dataBounds.maxy,
623 plotBounds.miny/2,
624 /2
625 );
626  
627 // Add the points
628 pointGeo.vertices.push(
629 new THREE.Vector3(
630 x,
631 y + dotSize/4,
632
633
634
635  
636 // Add the color for the point.
637 var pointColor = new THREE.Color().setRGB(
638
639
640
641
642
643  
644 // Add the projection in plane xOy
645 var lineMaterial = new THREE.LineDashedMaterial(
646
647
648
649
650
651
652 var lineGeometry = new THREE.Geometry();
653
654 new THREE.Vector3(
655
656
657
658
659
660
661 new THREE.Vector3(
662
663 /2,
664 z
665 )
666 );
667 lineGeometry.computeLineDistances();
668 var xOyProjection = new THREE.Line(
669 lineGeometry,
670 lineMaterial,
671 THREE.LineStrip
672 );
673 avatarProjections.push(xOyProjection)
674 scatterPlot.add(xOyProjection);
675  
676 // Generate the label.
677 var sprite = makeTextSprite(
678 " " +
679 csv.names[i] +
680 " " +
681 "\n" +
682 " " +
683 "@" +
684 "<" +
685 <" + csv.positions[i][0] +
686 <" + "," +
687 <" + csv.positions[i][1] +
688 <" + "," +
689 <" + csv.positions[i][j] +
690 <" + ">" +
691 <" + " ",
692 <" + {
693 <" + "fontsize": 9,
694 <" + "backgroundColor":
695 <" + {r:255, g:255, b:255, a:1},
696 <" + "borderColor":
697 <" + {
698 <" + r:Math.round(wasMapValueToRange(
699 <" + csv.colors[i][0],
700 <" + 0,
701 <" + 1,
702 <" + 0,
703 <" + 255
704 <" + )),
705 <" + g:Math.round(wasMapValueToRange(
706 <" + csv.colors[i][1],
707 <" + 0,
708 <" + 1,
709 <" + 0,
710 <" + 255
711 <" + )),
712 <" + b:Math.round(wasMapValueToRange(
713 <" + csv.colors[i][2],
714 <" + 0,
715 <" + 1,
716 <" + 0,
717 <" + 255
718 <" + )),
719 <" + a:1
720 <" + },
721 <" + "borderThickness": 1
722 <" + }
723 <" + );
724  
725 <" + sprite.position.x = pointGeo.vertices[i].x;
726 <" + sprite.position.y = pointGeo.vertices[i].y;
727 <" + sprite.position.z = pointGeo.vertices[i].z;
728  
729 <" + avatarLabels.push(sprite);
730 <" + scatterPlot.add(sprite);
731  
732 <" + }
733 <" + }
734 <" + var pointCloudTexture = THREE.ImageUtils.loadTexture(
735 <" + "images/triangle.gif"
736 );
737 pointCloudTexture.anisotropy = renderer.getMaxAnisotropy();
738 var pointCloudMaterial = new THREE.PointCloudMaterial(
739 {
740 size: dotSize,
741 map: pointCloudTexture,
742 blending: THREE.NormalBlending, // required
743 depthTest: true, // required
744 transparent: true,
745 opacity: 1,
746 vertexColors: true // optional
747 });
748 //pointCloudTexture.needsUpdate = true;
749 points = new THREE.PointCloud(
750 pointGeo,
751 pointCloudMaterial
752 );
753 scatterPlot.add(points);
754 scatterPlot.needsUpdate = true;
755 }
756  
757 function updateMap() {
758 if(mapBumpData == null || mapImageData == null) return;
759  
760 scatterPlot.remove(mapMesh);
761 // texture used to generate "bumpiness"
762 var bumpTexture = new THREE.ImageUtils.loadTexture(
763 'data:image/png;base64,' + mapBumpData
764 );
765 bumpTexture.wrapS =
766 bumpTexture.wrapT =
767 THREE.RepeatWrapping;
768 bumpTexture.anisotropy = renderer.getMaxAnisotropy();
769 // magnitude of normal displacement
770 var bumpScale = mapHeight;
771  
772 var mapTexture = new THREE.ImageUtils.loadTexture(
773 'data:image/png;base64,' + mapImageData
774 );
775 mapTexture.anisotropy = renderer.getMaxAnisotropy();
776 mapTexture.wrapS = mapTexture.wrapT;
777  
778 // Create the uniforms.
779 this.customUniforms = {
780 bumpTexture: {
781 type: "t",
782 value: bumpTexture
783 },
784 bumpScale: {
785 type: "f",
786 value: bumpScale
787 },
788 mapTexture: {
789 type: "t",
790 value: mapTexture
791 },
792 };
793  
794 // create custom material from the shader code above
795 // that is within specially labelled script tags
796 var customMaterial =
797 new THREE.ShaderMaterial(
798 {
799 uniforms: customUniforms,
800 vertexShader: document.getElementById(
801 'terrainVertex'
802 ).textContent,
803 fragmentShader: document.getElementById(
804 'terrainFragment'
805 ).textContent,
806 side: THREE.DoubleSide
807 }
808 );
809  
810 var planeGeo = new THREE.PlaneBufferGeometry(
811 plotBounds.maxx,
812 plotBounds.maxy,
813 100,
814 100
815 );
816  
817 mapMesh = new THREE.Mesh(
818 planeGeo,
819 customMaterial
820 );
821 mapMesh.rotation.x = - Math.PI / 2;
822 mapMesh.rotation.z = - Math.PI / 2;
823 mapMesh.position.y = -plotBounds.maxy/2;
824 scatterPlot.add(mapMesh);
825 scatterPlot.needsUpdate = true;
826 }
827  
828 function getAvatars() {
829 $.ajax({
830 /*type: 'POST',
831 url: "getAvatars.php",
832 cache: false,
833 timeout: 60000*/
834 type: 'POST',
835 url: '/',
836 data: {
837 command: 'getavatarpositions',
838 entity: 'region'
839 },
840 dataType: 'json'
841 }).done(function(response) {
842 /*switch(data != null && data != "") {
843 case false:
844 setTimeout(getAvatars, 1000);
845 return;
846 }
847 var json = jQuery.parseJSON(data);
848 switch(JSON.stringify(json) != JSON.stringify(csv)) {
849 case true:
850 csv = json;
851 updatePoints();
852 render();
853 break;
854 }
855 setTimeout(getAvatars, avatarsFetchInterval);*/
856 csv['names']
857 .concat($.stride(wasCSVToArray(response.data), 3));
858 csv['positions']
859 .concat($.stride(wasCSVToArray(response.data).slice(2), 3));
860 csv['colors']
861 .concat([255, 0, 0]);
862 }).error(function() {
863 setTimeout(getAvatars, 1000);
864 });
865 }
866  
867 function getMapTerrain() {
868 $.ajax({
869 type: 'POST',
870 url: "generateTerrainHeightMap.php",
871 cache: false,
872 timeout: 60000
873 }).done(function(data) {
874 // Only update if the data changed.
875 switch(data != null && data != '') {
876 case false:
877 setTimeout(getMapTerrain, 1000);
878 return;
879 }
880 switch(data != mapHeight) {
881 case true:
882 mapBumpData = data;
883 updateMap();
884 render();
885 break;
886 }
887 setTimeout(getMapTerrain, mapFetchInterval);
888 }).error(function() {
889 setTimeout(getMapTerrain, 1000);
890 });
891 }
892  
893 function getMapTexture() {
894 $.ajax({
895 type: 'POST',
896 url: "getMapTexture.php",
897 cache: false,
898 timeout: 60000
899 }).done(function(data) {
900 // Only update if the data changed.
901 switch(data != null && data != '') {
902 case false:
903 setTimeout(getMapTexture, 1000);
904 return;
905 }
906 switch(data != mapHeight) {
907 case true:
908 mapImageData = data;
909 updateMap();
910 render();
911 break;
912 }
913 setTimeout(getMapTexture, mapFetchInterval);
914 }).error(function() {
915 setTimeout(getMapTexture, 1000);
916 });
917 }
918  
919 function getMapHeight() {
920 $.ajax({
921 type: 'POST',
922 url: "getMapHeight.php",
923 cache: false,
924 timeout: 60000
925 }).done(function(data) {
926 // Only update if the data changed.
927 switch(data != null && data != '') {
928 case false:
929 setTimeout(getMapHeight, 1000);
930 return;
931 }
932 switch(data != mapHeight) {
933 case true:
934 mapHeight = data;
935 updateMap();
936 render();
937 break;
938 }
939 setTimeout(getMapHeight, mapFetchInterval);
940 }).error(function() {
941 setTimeout(getMapHeight, 1000);
942 });
943 }
944  
945 </script>
946 </div>