Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/Tour-360/tour-player into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
BorodinDK committed Oct 26, 2018
2 parents 3c793ca + d7c4491 commit 3d39ad9
Show file tree
Hide file tree
Showing 14 changed files with 61 additions and 49 deletions.
3 changes: 2 additions & 1 deletion example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ <h1>Lana Del Rey — Ultraviolence</h1>
<script>
Tour.init(false, {
controlPanel: true,
gallery: true
gallery: true,
galleryVisible: false
});
Tour.on('load', function(data) {
this.controls.autoRotate()
Expand Down
8 changes: 4 additions & 4 deletions example/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"lon": -90,
"lat": 16,
"icon": "info",
"title": "<a href=\"https://ru.wikipedia.org/wiki/Linkin_Park\" target=\"_blank\">Linkin Park</a> — A Thousand Suns",
"title": "<a href=\"https://ru.wikipedia.org/wiki/Linkin_Park\" target=\"_blank\">Linkin Park</a> — A Thousand Suns",
"action": {
"type": "url",
"href": "https://ru.wikipedia.org/wiki/Linkin_Park"
Expand Down Expand Up @@ -65,7 +65,7 @@
"lon": 280,
"lat": 13.73,
"icon": "info",
"title": "Lana Del Rey — Born To Die: Paradise Edition",
"title": "Lana Del Rey — Born To Die: Paradise Edition",
"action": {
"type": "popup",
"id": "lana-del-rey-born-to-die"
Expand All @@ -74,7 +74,7 @@
"lon": 292,
"lat": 3,
"icon": "info",
"title": "Lana Del Rey — Ultraviolence",
"title": "Lana Del Rey — Ultraviolence",
"action": {
"type": "popup",
"id": "lana-del-rey-ultraviolence"
Expand Down Expand Up @@ -108,4 +108,4 @@
]
}
]
}
}
2 changes: 1 addition & 1 deletion src/css/gallery.styl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
margin 0
background linear-gradient(to top,rgba(0,0,0,0.5) 40%, transparent)
color white
padding 2em .8em .5em
padding 24px 10px 8px
white-space nowrap
overflow hidden
text-overflow ellipsis
Expand Down
2 changes: 1 addition & 1 deletion src/js/Tour.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var Tour = {};

// Версия плеера
Tour.version = [0, 5, 0];
Tour.version = [2, 0, 0];
10 changes: 10 additions & 0 deletions src/js/Tour/getPanorama.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* globals Tour */

/**
* Простая утилита для получения конкретной панорамы из масива
*/
Tour.getPanorama = function(key) {
return (Tour.data.panorams || []).filter(function(pano) {
return pano.id == (key || 0);
})[0] || Tour.data.panorams[0];
};
2 changes: 1 addition & 1 deletion src/js/Tour/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Tour.history = {};
*/
Tour.history.set = function(push) {
var title = [Lang.translate(Tour.data.title) || Lang.get('virtual-tour'),
Lang.translate(Tour.data.panorams[Tour.view.id || 0].title)];
Lang.translate(Tour.getPanorama(Tour.view.id).title)];

title = title.join(title[1] ? ' – ' : '');

Expand Down
2 changes: 1 addition & 1 deletion src/js/Tour/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Tour.init = function(data, options) {
var query = Tour.query.get();
query.id = query.id || data.start || 0;
this.view.set(query, true);
this.setGallery(data);
this.setGallery(data, options.galleryVisible);
this.addEventListeners();
this.animate();
}.bind(this));
Expand Down
2 changes: 1 addition & 1 deletion src/js/Tour/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Tour.render = function() {
Tour.emmit('render');
this.needsUpdate = false;
}

this.previousCamera = (new THREE.Vector4()).copy(this.camera.rotation);
this.previousCamera.w = this.camera.fov;

Expand Down
2 changes: 1 addition & 1 deletion src/js/Tour/resize.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ Tour.resize = function() {
if (this.renderer.setPixelRatio) {
this.renderer.setPixelRatio(window.devicePixelRatio);
}
this.needUpdate = true;
this.needsUpdate = true;
};
35 changes: 13 additions & 22 deletions src/js/Tour/setGallery.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,24 @@
/* globals UI, Tour, Lang */
Tour.setGallery = function(data) {
Tour.setGallery = function(data, visible) {
if (this.options.gallery) {
UI.gallery.init();
UI.gallery.init(visible);

var panorams = data.panorams.map(function(n){
n.listNumber = n.listNumber===undefined ? Infinity : n.listNumber;
return n;
}).sort(function(a, b){
return a.listNumber - b.listNumber || a.id - b.id;
})

for(var i=0; i<panorams.length; i++){
var pano = panorams[i];
if(pano.listNumber !== 0){
data.panorams.map(function(pano){
if (pano.listNumber !== 0) {
UI.gallery.addItem({
id: pano.id,
image: 'panorams/'+pano.id+'/thumbnail/mini.jpg',
title: Lang.translate(panorams[i].title),
onclick: function(pano){
this.view.set({
id: pano.id,
lat: data.panorams[pano.id].lat || 0,
lon: data.panorams[pano.id].lon || 0,
fov: data.panorams[pano.id].fov || Tour.options.fov
})
}.bind(this, pano)
})
title: Lang.translate(pano.title),
onclick: function(){
Tour.view.set(pano);
}
});
}
}
});


UI.gallery.setActive(Tour.view.id);

Tour.on('changeView', function(view){
UI.gallery.setActive(view.id)
Expand Down
6 changes: 4 additions & 2 deletions src/js/Tour/setMarkers.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Tour.setMarkers = function(id) {
}

this.markers = [];
var markers = this.data.panorams && this.data.panorams[id] && this.data.panorams[id].markers;
var pano = this.getPanorama(id);
var markers = pano && pano.markers;

if (markers) {
/* Типы действий
Expand All @@ -32,6 +33,7 @@ Tour.setMarkers = function(id) {
for(var k in this.planes) {
var planeId = this.planes[k][this.click % this.planes[k].length];
var imgeURL = Tour.options.path + id + '/' + Tour.options.imageType + '/' + planeId+ '.jpg';

Tour.setPlane(k, imgeURL, manager);
}
}
Expand All @@ -41,7 +43,7 @@ Tour.setMarkers = function(id) {
var marker = new this.Marker(markers[i].lat, markers[i].lon, action.bind(markers[i].action));

var title = markers[i].title ||
(markers[i].action.type == 'panorama' && this.data.panorams[markers[i].action.id].title);
(markers[i].action.type == 'panorama' && this.getPanorama(markers[i].action.id).title);

marker.setTitle(Lang.translate(title));
marker.setIcon(markers[i].icon || (markers[i].action && markers[i].action.type == 'panorama' ? 'up' : 'info'));
Expand Down
9 changes: 5 additions & 4 deletions src/js/Tour/setPanorama.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ Tour.setPanorama = function(id) {
var change = function(id) {
this.setTexture(id);
this.setMarkers(id);
this.view.rotation.auto = this.data.panorams[id].autorotation !== false &&
(this.data.panorams[id].autorotation || this.data.autorotation);
var panorama = this.getPanorama(id);
this.view.rotation.auto = panorama.autorotation !== false &&
(panorama.autorotation || this.data.autorotation);
};


if (this.options.rendererType != 'css' && this.options.transition) {

Expand All @@ -24,7 +25,7 @@ Tour.setPanorama = function(id) {
imageUrl,
this.data.backgroundColor,
function() {
Tour.mesh.rotation.set(0, Math.PI/2-((this.data.panorams[id].heading || 0) / 180 * Math.PI), 0);
Tour.mesh.rotation.set(0, Math.PI/2-((this.getPanorama(id).heading || 0) / 180 * Math.PI), 0);
this.data.backgroundImage = false;
document.body.classList.add('transition');
change.call(this, id);
Expand Down
19 changes: 12 additions & 7 deletions src/js/Tour/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
Tour.view = {};

Tour.view.set = function(options, replaceHistory) {

options = options || {};

this.fov = new Tour.Transition(options.fov || this.fov || Tour.options.fov, Tour.options.limit.fov);
Expand All @@ -25,13 +26,17 @@ Tour.view.set = function(options, replaceHistory) {
}
Tour.history.set(!replaceHistory);

for (var k in this) {if (k != 'id') {
this[k].setOptions(
(Tour.data.panorams[this.id] && Tour.data.panorams[this.id].limit && Tour.data.panorams[this.id].limit[k]) ||
(Tour.data.limit && Tour.data.limit[k]) ||
Tour.options.limit[k]
);
}}
var panorama;
for (var k in this) {
if (k != 'id') {
panorama = Tour.getPanorama(this.id);
this[k].setOptions(
(panorama && panorama.limit && panorama.limit[k]) ||
(Tour.data.limit && Tour.data.limit[k]) ||
Tour.options.limit[k]
);
}
}
Tour.emmit('changeView', Tour.view.get());
};

Expand Down
8 changes: 5 additions & 3 deletions src/js/UI/Gallery.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/* globals UI */

UI.gallery = {
init: function() {
this.visible = false;
borderHoverSize: 5,
init: function(visible) {
this.visible = visible;
this.domElement = document.createElement('div');
this.domElement.id = 'gallery';
this.ul = document.createElement('ul');
Expand All @@ -15,7 +16,7 @@ UI.gallery = {

this.items = [];

this.display(true);
this.display(visible);
},
toggle: function(){
this.display(!this.visible);
Expand Down Expand Up @@ -50,6 +51,7 @@ UI.gallery = {
item.classList.remove('active');
});
this.items[id].classList.add('active');
this.ul.scrollTo(0, this.ul.scrollTop + this.items[id].getBoundingClientRect().y - this.borderHoverSize);
},
setVisible: function(type) {

Expand Down

0 comments on commit 3d39ad9

Please sign in to comment.