Version 0.3.2, rev351, Sidebar to display site infos an modify settings, Per-site upload/download bytes statistics, Deny different origin media requests, Allow 10sec to finish query modifications, Websocket display errors to client instead of disconnecting, Allow specify notification id to server-side messages, Track every command response time
This commit is contained in:
parent
b1c5b7d3a3
commit
b83d6ba2ff
43 changed files with 8104 additions and 39 deletions
60
plugins/Sidebar/media-globe/Detector.js
Normal file
60
plugins/Sidebar/media-globe/Detector.js
Normal file
|
@ -0,0 +1,60 @@
|
|||
/**
|
||||
* @author alteredq / http://alteredqualia.com/
|
||||
* @author mr.doob / http://mrdoob.com/
|
||||
*/
|
||||
|
||||
Detector = {
|
||||
|
||||
canvas : !! window.CanvasRenderingContext2D,
|
||||
webgl : ( function () { try { return !! window.WebGLRenderingContext && !! document.createElement( 'canvas' ).getContext( 'experimental-webgl' ); } catch( e ) { return false; } } )(),
|
||||
workers : !! window.Worker,
|
||||
fileapi : window.File && window.FileReader && window.FileList && window.Blob,
|
||||
|
||||
getWebGLErrorMessage : function () {
|
||||
|
||||
var domElement = document.createElement( 'div' );
|
||||
|
||||
domElement.style.fontFamily = 'monospace';
|
||||
domElement.style.fontSize = '13px';
|
||||
domElement.style.textAlign = 'center';
|
||||
domElement.style.background = '#eee';
|
||||
domElement.style.color = '#000';
|
||||
domElement.style.padding = '1em';
|
||||
domElement.style.width = '475px';
|
||||
domElement.style.margin = '5em auto 0';
|
||||
|
||||
if ( ! this.webgl ) {
|
||||
|
||||
domElement.innerHTML = window.WebGLRenderingContext ? [
|
||||
'Sorry, your graphics card doesn\'t support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation">WebGL</a>'
|
||||
].join( '\n' ) : [
|
||||
'Sorry, your browser doesn\'t support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation">WebGL</a><br/>',
|
||||
'Please try with',
|
||||
'<a href="http://www.google.com/chrome">Chrome</a>, ',
|
||||
'<a href="http://www.mozilla.com/en-US/firefox/new/">Firefox 4</a> or',
|
||||
'<a href="http://nightly.webkit.org/">Webkit Nightly (Mac)</a>'
|
||||
].join( '\n' );
|
||||
|
||||
}
|
||||
|
||||
return domElement;
|
||||
|
||||
},
|
||||
|
||||
addGetWebGLMessage : function ( parameters ) {
|
||||
|
||||
var parent, id, domElement;
|
||||
|
||||
parameters = parameters || {};
|
||||
|
||||
parent = parameters.parent !== undefined ? parameters.parent : document.body;
|
||||
id = parameters.id !== undefined ? parameters.id : 'oldie';
|
||||
|
||||
domElement = Detector.getWebGLErrorMessage();
|
||||
domElement.id = id;
|
||||
|
||||
parent.appendChild( domElement );
|
||||
|
||||
}
|
||||
|
||||
};
|
12
plugins/Sidebar/media-globe/Tween.js
Normal file
12
plugins/Sidebar/media-globe/Tween.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
// Tween.js - http://github.com/sole/tween.js
|
||||
var TWEEN=TWEEN||function(){var a,e,c,d,f=[];return{start:function(g){c=setInterval(this.update,1E3/(g||60))},stop:function(){clearInterval(c)},add:function(g){f.push(g)},remove:function(g){a=f.indexOf(g);a!==-1&&f.splice(a,1)},update:function(){a=0;e=f.length;for(d=(new Date).getTime();a<e;)if(f[a].update(d))a++;else{f.splice(a,1);e--}}}}();
|
||||
TWEEN.Tween=function(a){var e={},c={},d={},f=1E3,g=0,j=null,n=TWEEN.Easing.Linear.EaseNone,k=null,l=null,m=null;this.to=function(b,h){if(h!==null)f=h;for(var i in b)if(a[i]!==null)d[i]=b[i];return this};this.start=function(){TWEEN.add(this);j=(new Date).getTime()+g;for(var b in d)if(a[b]!==null){e[b]=a[b];c[b]=d[b]-a[b]}return this};this.stop=function(){TWEEN.remove(this);return this};this.delay=function(b){g=b;return this};this.easing=function(b){n=b;return this};this.chain=function(b){k=b};this.onUpdate=
|
||||
function(b){l=b;return this};this.onComplete=function(b){m=b;return this};this.update=function(b){var h,i;if(b<j)return true;b=(b-j)/f;b=b>1?1:b;i=n(b);for(h in c)a[h]=e[h]+c[h]*i;l!==null&&l.call(a,i);if(b==1){m!==null&&m.call(a);k!==null&&k.start();return false}return true}};TWEEN.Easing={Linear:{},Quadratic:{},Cubic:{},Quartic:{},Quintic:{},Sinusoidal:{},Exponential:{},Circular:{},Elastic:{},Back:{},Bounce:{}};TWEEN.Easing.Linear.EaseNone=function(a){return a};
|
||||
TWEEN.Easing.Quadratic.EaseIn=function(a){return a*a};TWEEN.Easing.Quadratic.EaseOut=function(a){return-a*(a-2)};TWEEN.Easing.Quadratic.EaseInOut=function(a){if((a*=2)<1)return 0.5*a*a;return-0.5*(--a*(a-2)-1)};TWEEN.Easing.Cubic.EaseIn=function(a){return a*a*a};TWEEN.Easing.Cubic.EaseOut=function(a){return--a*a*a+1};TWEEN.Easing.Cubic.EaseInOut=function(a){if((a*=2)<1)return 0.5*a*a*a;return 0.5*((a-=2)*a*a+2)};TWEEN.Easing.Quartic.EaseIn=function(a){return a*a*a*a};
|
||||
TWEEN.Easing.Quartic.EaseOut=function(a){return-(--a*a*a*a-1)};TWEEN.Easing.Quartic.EaseInOut=function(a){if((a*=2)<1)return 0.5*a*a*a*a;return-0.5*((a-=2)*a*a*a-2)};TWEEN.Easing.Quintic.EaseIn=function(a){return a*a*a*a*a};TWEEN.Easing.Quintic.EaseOut=function(a){return(a-=1)*a*a*a*a+1};TWEEN.Easing.Quintic.EaseInOut=function(a){if((a*=2)<1)return 0.5*a*a*a*a*a;return 0.5*((a-=2)*a*a*a*a+2)};TWEEN.Easing.Sinusoidal.EaseIn=function(a){return-Math.cos(a*Math.PI/2)+1};
|
||||
TWEEN.Easing.Sinusoidal.EaseOut=function(a){return Math.sin(a*Math.PI/2)};TWEEN.Easing.Sinusoidal.EaseInOut=function(a){return-0.5*(Math.cos(Math.PI*a)-1)};TWEEN.Easing.Exponential.EaseIn=function(a){return a==0?0:Math.pow(2,10*(a-1))};TWEEN.Easing.Exponential.EaseOut=function(a){return a==1?1:-Math.pow(2,-10*a)+1};TWEEN.Easing.Exponential.EaseInOut=function(a){if(a==0)return 0;if(a==1)return 1;if((a*=2)<1)return 0.5*Math.pow(2,10*(a-1));return 0.5*(-Math.pow(2,-10*(a-1))+2)};
|
||||
TWEEN.Easing.Circular.EaseIn=function(a){return-(Math.sqrt(1-a*a)-1)};TWEEN.Easing.Circular.EaseOut=function(a){return Math.sqrt(1- --a*a)};TWEEN.Easing.Circular.EaseInOut=function(a){if((a/=0.5)<1)return-0.5*(Math.sqrt(1-a*a)-1);return 0.5*(Math.sqrt(1-(a-=2)*a)+1)};TWEEN.Easing.Elastic.EaseIn=function(a){var e,c=0.1,d=0.4;if(a==0)return 0;if(a==1)return 1;d||(d=0.3);if(!c||c<1){c=1;e=d/4}else e=d/(2*Math.PI)*Math.asin(1/c);return-(c*Math.pow(2,10*(a-=1))*Math.sin((a-e)*2*Math.PI/d))};
|
||||
TWEEN.Easing.Elastic.EaseOut=function(a){var e,c=0.1,d=0.4;if(a==0)return 0;if(a==1)return 1;d||(d=0.3);if(!c||c<1){c=1;e=d/4}else e=d/(2*Math.PI)*Math.asin(1/c);return c*Math.pow(2,-10*a)*Math.sin((a-e)*2*Math.PI/d)+1};
|
||||
TWEEN.Easing.Elastic.EaseInOut=function(a){var e,c=0.1,d=0.4;if(a==0)return 0;if(a==1)return 1;d||(d=0.3);if(!c||c<1){c=1;e=d/4}else e=d/(2*Math.PI)*Math.asin(1/c);if((a*=2)<1)return-0.5*c*Math.pow(2,10*(a-=1))*Math.sin((a-e)*2*Math.PI/d);return c*Math.pow(2,-10*(a-=1))*Math.sin((a-e)*2*Math.PI/d)*0.5+1};TWEEN.Easing.Back.EaseIn=function(a){return a*a*(2.70158*a-1.70158)};TWEEN.Easing.Back.EaseOut=function(a){return(a-=1)*a*(2.70158*a+1.70158)+1};
|
||||
TWEEN.Easing.Back.EaseInOut=function(a){if((a*=2)<1)return 0.5*a*a*(3.5949095*a-2.5949095);return 0.5*((a-=2)*a*(3.5949095*a+2.5949095)+2)};TWEEN.Easing.Bounce.EaseIn=function(a){return 1-TWEEN.Easing.Bounce.EaseOut(1-a)};TWEEN.Easing.Bounce.EaseOut=function(a){return(a/=1)<1/2.75?7.5625*a*a:a<2/2.75?7.5625*(a-=1.5/2.75)*a+0.75:a<2.5/2.75?7.5625*(a-=2.25/2.75)*a+0.9375:7.5625*(a-=2.625/2.75)*a+0.984375};
|
||||
TWEEN.Easing.Bounce.EaseInOut=function(a){if(a<0.5)return TWEEN.Easing.Bounce.EaseIn(a*2)*0.5;return TWEEN.Easing.Bounce.EaseOut(a*2-1)*0.5+0.5};
|
1333
plugins/Sidebar/media-globe/all.js
Normal file
1333
plugins/Sidebar/media-globe/all.js
Normal file
File diff suppressed because one or more lines are too long
424
plugins/Sidebar/media-globe/globe.js
Normal file
424
plugins/Sidebar/media-globe/globe.js
Normal file
|
@ -0,0 +1,424 @@
|
|||
/**
|
||||
* dat.globe Javascript WebGL Globe Toolkit
|
||||
* http://dataarts.github.com/dat.globe
|
||||
*
|
||||
* Copyright 2011 Data Arts Team, Google Creative Lab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the 'License');
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
|
||||
var DAT = DAT || {};
|
||||
|
||||
DAT.Globe = function(container, opts) {
|
||||
opts = opts || {};
|
||||
|
||||
var colorFn = opts.colorFn || function(x) {
|
||||
var c = new THREE.Color();
|
||||
c.setHSL( ( 0.5 - (x * 2) ), Math.max(0.8, 1.0 - (x * 3)), 0.5 );
|
||||
return c;
|
||||
};
|
||||
var imgDir = opts.imgDir || '/globe/';
|
||||
|
||||
var Shaders = {
|
||||
'earth' : {
|
||||
uniforms: {
|
||||
'texture': { type: 't', value: null }
|
||||
},
|
||||
vertexShader: [
|
||||
'varying vec3 vNormal;',
|
||||
'varying vec2 vUv;',
|
||||
'void main() {',
|
||||
'gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );',
|
||||
'vNormal = normalize( normalMatrix * normal );',
|
||||
'vUv = uv;',
|
||||
'}'
|
||||
].join('\n'),
|
||||
fragmentShader: [
|
||||
'uniform sampler2D texture;',
|
||||
'varying vec3 vNormal;',
|
||||
'varying vec2 vUv;',
|
||||
'void main() {',
|
||||
'vec3 diffuse = texture2D( texture, vUv ).xyz;',
|
||||
'float intensity = 1.05 - dot( vNormal, vec3( 0.0, 0.0, 1.0 ) );',
|
||||
'vec3 atmosphere = vec3( 1.0, 1.0, 1.0 ) * pow( intensity, 3.0 );',
|
||||
'gl_FragColor = vec4( diffuse + atmosphere, 1.0 );',
|
||||
'}'
|
||||
].join('\n')
|
||||
},
|
||||
'atmosphere' : {
|
||||
uniforms: {},
|
||||
vertexShader: [
|
||||
'varying vec3 vNormal;',
|
||||
'void main() {',
|
||||
'vNormal = normalize( normalMatrix * normal );',
|
||||
'gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );',
|
||||
'}'
|
||||
].join('\n'),
|
||||
fragmentShader: [
|
||||
'varying vec3 vNormal;',
|
||||
'void main() {',
|
||||
'float intensity = pow( 0.8 - dot( vNormal, vec3( 0, 0, 1.0 ) ), 12.0 );',
|
||||
'gl_FragColor = vec4( 1.0, 1.0, 1.0, 1.0 ) * intensity;',
|
||||
'}'
|
||||
].join('\n')
|
||||
}
|
||||
};
|
||||
|
||||
var camera, scene, renderer, w, h;
|
||||
var mesh, atmosphere, point, running;
|
||||
|
||||
var overRenderer;
|
||||
var running = true;
|
||||
|
||||
var curZoomSpeed = 0;
|
||||
var zoomSpeed = 50;
|
||||
|
||||
var mouse = { x: 0, y: 0 }, mouseOnDown = { x: 0, y: 0 };
|
||||
var rotation = { x: 0, y: 0 },
|
||||
target = { x: Math.PI*3/2, y: Math.PI / 6.0 },
|
||||
targetOnDown = { x: 0, y: 0 };
|
||||
|
||||
var distance = 100000, distanceTarget = 100000;
|
||||
var padding = 10;
|
||||
var PI_HALF = Math.PI / 2;
|
||||
|
||||
function init() {
|
||||
|
||||
container.style.color = '#fff';
|
||||
container.style.font = '13px/20px Arial, sans-serif';
|
||||
|
||||
var shader, uniforms, material;
|
||||
w = container.offsetWidth || window.innerWidth;
|
||||
h = container.offsetHeight || window.innerHeight;
|
||||
|
||||
camera = new THREE.PerspectiveCamera(30, w / h, 1, 10000);
|
||||
camera.position.z = distance;
|
||||
|
||||
scene = new THREE.Scene();
|
||||
|
||||
var geometry = new THREE.SphereGeometry(200, 40, 30);
|
||||
|
||||
shader = Shaders['earth'];
|
||||
uniforms = THREE.UniformsUtils.clone(shader.uniforms);
|
||||
|
||||
uniforms['texture'].value = THREE.ImageUtils.loadTexture(imgDir+'world.jpg');
|
||||
|
||||
material = new THREE.ShaderMaterial({
|
||||
|
||||
uniforms: uniforms,
|
||||
vertexShader: shader.vertexShader,
|
||||
fragmentShader: shader.fragmentShader
|
||||
|
||||
});
|
||||
|
||||
mesh = new THREE.Mesh(geometry, material);
|
||||
mesh.rotation.y = Math.PI;
|
||||
scene.add(mesh);
|
||||
|
||||
shader = Shaders['atmosphere'];
|
||||
uniforms = THREE.UniformsUtils.clone(shader.uniforms);
|
||||
|
||||
material = new THREE.ShaderMaterial({
|
||||
|
||||
uniforms: uniforms,
|
||||
vertexShader: shader.vertexShader,
|
||||
fragmentShader: shader.fragmentShader,
|
||||
side: THREE.BackSide,
|
||||
blending: THREE.AdditiveBlending,
|
||||
transparent: true
|
||||
|
||||
});
|
||||
|
||||
mesh = new THREE.Mesh(geometry, material);
|
||||
mesh.scale.set( 1.1, 1.1, 1.1 );
|
||||
scene.add(mesh);
|
||||
|
||||
geometry = new THREE.BoxGeometry(2.75, 2.75, 1);
|
||||
geometry.applyMatrix(new THREE.Matrix4().makeTranslation(0,0,-0.5));
|
||||
|
||||
point = new THREE.Mesh(geometry);
|
||||
|
||||
renderer = new THREE.WebGLRenderer({antialias: true});
|
||||
renderer.setSize(w, h);
|
||||
renderer.setClearColor( 0x212121, 1 );
|
||||
|
||||
renderer.domElement.style.position = 'relative';
|
||||
|
||||
container.appendChild(renderer.domElement);
|
||||
|
||||
container.addEventListener('mousedown', onMouseDown, false);
|
||||
|
||||
container.addEventListener('mousewheel', onMouseWheel, false);
|
||||
|
||||
document.addEventListener('keydown', onDocumentKeyDown, false);
|
||||
|
||||
window.addEventListener('resize', onWindowResize, false);
|
||||
|
||||
container.addEventListener('mouseover', function() {
|
||||
overRenderer = true;
|
||||
}, false);
|
||||
|
||||
container.addEventListener('mouseout', function() {
|
||||
overRenderer = false;
|
||||
}, false);
|
||||
}
|
||||
|
||||
function addData(data, opts) {
|
||||
var lat, lng, size, color, i, step, colorFnWrapper;
|
||||
|
||||
opts.animated = opts.animated || false;
|
||||
this.is_animated = opts.animated;
|
||||
opts.format = opts.format || 'magnitude'; // other option is 'legend'
|
||||
if (opts.format === 'magnitude') {
|
||||
step = 3;
|
||||
colorFnWrapper = function(data, i) { return colorFn(data[i+2]); }
|
||||
} else if (opts.format === 'legend') {
|
||||
step = 4;
|
||||
colorFnWrapper = function(data, i) { return colorFn(data[i+3]); }
|
||||
} else if (opts.format === 'peer') {
|
||||
colorFnWrapper = function(data, i) { return colorFn(data[i+2]); }
|
||||
} else {
|
||||
throw('error: format not supported: '+opts.format);
|
||||
}
|
||||
|
||||
if (opts.animated) {
|
||||
if (this._baseGeometry === undefined) {
|
||||
this._baseGeometry = new THREE.Geometry();
|
||||
for (i = 0; i < data.length; i += step) {
|
||||
lat = data[i];
|
||||
lng = data[i + 1];
|
||||
// size = data[i + 2];
|
||||
color = colorFnWrapper(data,i);
|
||||
size = 0;
|
||||
addPoint(lat, lng, size, color, this._baseGeometry);
|
||||
}
|
||||
}
|
||||
if(this._morphTargetId === undefined) {
|
||||
this._morphTargetId = 0;
|
||||
} else {
|
||||
this._morphTargetId += 1;
|
||||
}
|
||||
opts.name = opts.name || 'morphTarget'+this._morphTargetId;
|
||||
}
|
||||
var subgeo = new THREE.Geometry();
|
||||
for (i = 0; i < data.length; i += step) {
|
||||
lat = data[i];
|
||||
lng = data[i + 1];
|
||||
color = colorFnWrapper(data,i);
|
||||
size = data[i + 2];
|
||||
size = size*200;
|
||||
addPoint(lat, lng, size, color, subgeo);
|
||||
}
|
||||
if (opts.animated) {
|
||||
this._baseGeometry.morphTargets.push({'name': opts.name, vertices: subgeo.vertices});
|
||||
} else {
|
||||
this._baseGeometry = subgeo;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
function createPoints() {
|
||||
if (this._baseGeometry !== undefined) {
|
||||
if (this.is_animated === false) {
|
||||
this.points = new THREE.Mesh(this._baseGeometry, new THREE.MeshBasicMaterial({
|
||||
color: 0xffffff,
|
||||
vertexColors: THREE.FaceColors,
|
||||
morphTargets: false
|
||||
}));
|
||||
} else {
|
||||
if (this._baseGeometry.morphTargets.length < 8) {
|
||||
console.log('t l',this._baseGeometry.morphTargets.length);
|
||||
var padding = 8-this._baseGeometry.morphTargets.length;
|
||||
console.log('padding', padding);
|
||||
for(var i=0; i<=padding; i++) {
|
||||
console.log('padding',i);
|
||||
this._baseGeometry.morphTargets.push({'name': 'morphPadding'+i, vertices: this._baseGeometry.vertices});
|
||||
}
|
||||
}
|
||||
this.points = new THREE.Mesh(this._baseGeometry, new THREE.MeshBasicMaterial({
|
||||
color: 0xffffff,
|
||||
vertexColors: THREE.FaceColors,
|
||||
morphTargets: true
|
||||
}));
|
||||
}
|
||||
scene.add(this.points);
|
||||
}
|
||||
}
|
||||
|
||||
function addPoint(lat, lng, size, color, subgeo) {
|
||||
|
||||
var phi = (90 - lat) * Math.PI / 180;
|
||||
var theta = (180 - lng) * Math.PI / 180;
|
||||
|
||||
point.position.x = 200 * Math.sin(phi) * Math.cos(theta);
|
||||
point.position.y = 200 * Math.cos(phi);
|
||||
point.position.z = 200 * Math.sin(phi) * Math.sin(theta);
|
||||
|
||||
point.lookAt(mesh.position);
|
||||
|
||||
point.scale.z = Math.max( size, 0.1 ); // avoid non-invertible matrix
|
||||
point.updateMatrix();
|
||||
|
||||
for (var i = 0; i < point.geometry.faces.length; i++) {
|
||||
|
||||
point.geometry.faces[i].color = color;
|
||||
|
||||
}
|
||||
if(point.matrixAutoUpdate){
|
||||
point.updateMatrix();
|
||||
}
|
||||
subgeo.merge(point.geometry, point.matrix);
|
||||
}
|
||||
|
||||
function onMouseDown(event) {
|
||||
event.preventDefault();
|
||||
|
||||
container.addEventListener('mousemove', onMouseMove, false);
|
||||
container.addEventListener('mouseup', onMouseUp, false);
|
||||
container.addEventListener('mouseout', onMouseOut, false);
|
||||
|
||||
mouseOnDown.x = - event.clientX;
|
||||
mouseOnDown.y = event.clientY;
|
||||
|
||||
targetOnDown.x = target.x;
|
||||
targetOnDown.y = target.y;
|
||||
|
||||
container.style.cursor = 'move';
|
||||
}
|
||||
|
||||
function onMouseMove(event) {
|
||||
mouse.x = - event.clientX;
|
||||
mouse.y = event.clientY;
|
||||
|
||||
var zoomDamp = distance/1000;
|
||||
|
||||
target.x = targetOnDown.x + (mouse.x - mouseOnDown.x) * 0.005 * zoomDamp;
|
||||
target.y = targetOnDown.y + (mouse.y - mouseOnDown.y) * 0.005 * zoomDamp;
|
||||
|
||||
target.y = target.y > PI_HALF ? PI_HALF : target.y;
|
||||
target.y = target.y < - PI_HALF ? - PI_HALF : target.y;
|
||||
}
|
||||
|
||||
function onMouseUp(event) {
|
||||
container.removeEventListener('mousemove', onMouseMove, false);
|
||||
container.removeEventListener('mouseup', onMouseUp, false);
|
||||
container.removeEventListener('mouseout', onMouseOut, false);
|
||||
container.style.cursor = 'auto';
|
||||
}
|
||||
|
||||
function onMouseOut(event) {
|
||||
container.removeEventListener('mousemove', onMouseMove, false);
|
||||
container.removeEventListener('mouseup', onMouseUp, false);
|
||||
container.removeEventListener('mouseout', onMouseOut, false);
|
||||
}
|
||||
|
||||
function onMouseWheel(event) {
|
||||
event.preventDefault();
|
||||
if (overRenderer) {
|
||||
zoom(event.wheelDeltaY * 0.3);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function onDocumentKeyDown(event) {
|
||||
switch (event.keyCode) {
|
||||
case 38:
|
||||
zoom(100);
|
||||
event.preventDefault();
|
||||
break;
|
||||
case 40:
|
||||
zoom(-100);
|
||||
event.preventDefault();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function onWindowResize( event ) {
|
||||
camera.aspect = container.offsetWidth / container.offsetHeight;
|
||||
camera.updateProjectionMatrix();
|
||||
renderer.setSize( container.offsetWidth, container.offsetHeight );
|
||||
}
|
||||
|
||||
function zoom(delta) {
|
||||
distanceTarget -= delta;
|
||||
distanceTarget = distanceTarget > 855 ? 855 : distanceTarget;
|
||||
distanceTarget = distanceTarget < 350 ? 350 : distanceTarget;
|
||||
}
|
||||
|
||||
function animate() {
|
||||
if (!running) return
|
||||
requestAnimationFrame(animate);
|
||||
render();
|
||||
}
|
||||
|
||||
function render() {
|
||||
zoom(curZoomSpeed);
|
||||
|
||||
rotation.x += (target.x - rotation.x) * 0.1;
|
||||
rotation.y += (target.y - rotation.y) * 0.1;
|
||||
distance += (distanceTarget - distance) * 0.3;
|
||||
|
||||
camera.position.x = distance * Math.sin(rotation.x) * Math.cos(rotation.y);
|
||||
camera.position.y = distance * Math.sin(rotation.y);
|
||||
camera.position.z = distance * Math.cos(rotation.x) * Math.cos(rotation.y);
|
||||
|
||||
camera.lookAt(mesh.position);
|
||||
|
||||
renderer.render(scene, camera);
|
||||
}
|
||||
|
||||
function unload() {
|
||||
running = false
|
||||
container.removeEventListener('mousedown', onMouseDown, false);
|
||||
container.removeEventListener('mousewheel', onMouseWheel, false);
|
||||
document.removeEventListener('keydown', onDocumentKeyDown, false);
|
||||
window.removeEventListener('resize', onWindowResize, false);
|
||||
|
||||
}
|
||||
|
||||
init();
|
||||
this.animate = animate;
|
||||
this.unload = unload;
|
||||
|
||||
|
||||
this.__defineGetter__('time', function() {
|
||||
return this._time || 0;
|
||||
});
|
||||
|
||||
this.__defineSetter__('time', function(t) {
|
||||
var validMorphs = [];
|
||||
var morphDict = this.points.morphTargetDictionary;
|
||||
for(var k in morphDict) {
|
||||
if(k.indexOf('morphPadding') < 0) {
|
||||
validMorphs.push(morphDict[k]);
|
||||
}
|
||||
}
|
||||
validMorphs.sort();
|
||||
var l = validMorphs.length-1;
|
||||
var scaledt = t*l+1;
|
||||
var index = Math.floor(scaledt);
|
||||
for (i=0;i<validMorphs.length;i++) {
|
||||
this.points.morphTargetInfluences[validMorphs[i]] = 0;
|
||||
}
|
||||
var lastIndex = index - 1;
|
||||
var leftover = scaledt - index;
|
||||
if (lastIndex >= 0) {
|
||||
this.points.morphTargetInfluences[lastIndex] = 1 - leftover;
|
||||
}
|
||||
this.points.morphTargetInfluences[index] = leftover;
|
||||
this._time = t;
|
||||
});
|
||||
|
||||
this.addData = addData;
|
||||
this.createPoints = createPoints;
|
||||
this.renderer = renderer;
|
||||
this.scene = scene;
|
||||
|
||||
return this;
|
||||
|
||||
};
|
||||
|
814
plugins/Sidebar/media-globe/three.min.js
vendored
Normal file
814
plugins/Sidebar/media-globe/three.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
plugins/Sidebar/media-globe/world.jpg
Normal file
BIN
plugins/Sidebar/media-globe/world.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 93 KiB |
Loading…
Add table
Add a link
Reference in a new issue