prepareTurn: function (turning, callback) {
var $this = this;
+ this.disposeTextures();
+
this.prepareTexture(turning.flip[1], function (t1) {
$this.prepareTexture(turning.flip[0], function (t2) {
$this.texturesLoaded(t1, t2, callback);
},
texturesLoaded: function (t1, t2, callback) {
- this.textures[0].map = t1;
- this.textures[1].map = t2;
+ if (t1 != null) {
+ this.textures[0].map = t1;
+ }
+ if (t2 != null) {
+ this.textures[1].map = t2;
+ }
this.textures[0].needsUpdate = true;
this.textures[1].needsUpdate = true;
}
},
- prepareTexture: function (page, callback) {
- this.disposeTextures();
+ // prepareTexture: function (page, callback) {
+ // this.disposeTextures();
+ //
+ // var $this = this;
+ // this.fluidbook.loader.loadTexture(page, function () {
+ // var texture = new THREE.Texture($this.fluidbook.loader.getTexture(page));
+ // texture.needsUpdate = true;
+ // callback(texture);
+ // });
+ // },
- var $this = this;
- this.fluidbook.loader.loadTexture(page, function () {
- var texture = new THREE.Texture($this.fluidbook.loader.getTexture(page));
- texture.needsUpdate = true;
- callback(texture);
- });
+ prepareTexture: function (page, callback) {
+ var texture = new THREE.Texture(this.fluidbook.loader.getTexture(page));
+ texture.needsUpdate = true;
+ callback(texture);
},
playTurn: function (dir, callback) {
this.initTheme();
this.initKeyboardShortcuts();
+ this.initLoading();
},
setMaxPage: function (p) {
} else {
$('html').addClass('menu-default');
}
-
- this.initLoading();
},
initLoading: function () {
$("#loader").append(getSpriteIcon('interface-loader'));
this.displayLoader();
+ var $this = this;
+ this.loader.preloadStart(function () {
+ console.log('preload done');
+ $this.ready();
+ });
},
reloadErrorImages: function () {
$('img').each(function () {
});
},
initKeyboardShortcuts: function () {
-
// General keyboard shortcuts
key('home', this.goFirstPage.bind(this));
key('end', this.goLastPage.bind(this));
}
$(this).trigger('fluidbook.splash.hide');
-
},
- onReady: function (callback) {
- if (this.isReady) {
- callback();
- } else {
- $(this).on('fluidbook.ready', function () {
- callback();
- });
- }
- },
ready: function () {
if (this.isReady) {
return;
}
this.isReady = true;
+
$("#main").css('display', 'block');
this.nav = new FluidbookNav(this);
this.interface = new FluidbookInterface(this);
this.slider = new FluidbookSlider(this);
this.help = new FluidbookHelp(this);
this.help.displayAtStartup();
+
+ // Trigger a resize
resize();
+
+ // Trigger ready event
$(this).trigger('fluidbookready');
$(this).trigger('fluidbook.ready');
+
+ // Initial address handling
+ this.changeAddress();
},
+
loadPlugins: function () {
$.each(this.datas.plugins, function (k, plugin) {
try {
this.links = [];
this.toPreload = [];
this.imagesErrors = [];
+ this.shadeLeft = null;
+ this.shadeRight = null;
+
+ this.init();
}
FluidbookLoader.prototype = {
+ init: function () {
+ this.shadeLeft = this.loadImage('images/shadows/pages/left.png');
+ this.shadeRight = this.loadImage('images/shadows/pages/right.png');
+ },
+
getVersionToLoad: function (page) {
if (this.fluidbook.vectorTexts) {
if (this.fluidbook.datas.vectorPages.indexOf(page) >= 0) {
return 'raster';
},
+ preloadStart: function (callback) {
+ this.toPreload = [1, 2, 3, 4, 5];
+ this.preloadPages(callback);
+ },
preloadPagesBeforeTransition: function (pages, callback) {
var $this = this;
return true;
},
- preloadPages: function () {
+ preloadPages: function (cb) {
+ if (cb === undefined) {
+ cb = function () {
+ };
+ }
if (this.toPreload.length == 0) {
+ cb();
return;
}
var $this = this;
this.fluidbook.executeWhenNetwork(function () {
+ var preloadingPage = $this.toPreload.shift();
var callback = function () {
- $this.preloadPages();
+ if ($this.toPreload.length === 0) {
+ cb();
+ } else {
+ $this.preloadPages(cb);
+ }
};
- var preloadingPage = $this.toPreload.shift();
+
$this._preloadPage(preloadingPage, callback);
- }, 0, 1000);
+ });
},
_preloadPage: function (page, callback) {
},
cleanPreloaded: function () {
for (var i = 1; i <= this.fluidbook.getMaxPage(); i++) {
- if (this.backgrounds[i] != undefined && this.toPreload.indexOf(i) == -1) {
+ if (this.backgrounds[i] !== undefined && this.toPreload.indexOf(i) === -1) {
this.deletePage(i);
}
}
return 'data/background/' + this.fluidbook.support.resolution + '/' + prefix + page + '.jpg';
},
- getTextureURL: function (page) {
- var prefix = 't';
- return 'data/background/150/' + prefix + page + '.jpg';
- },
-
getTextsURL: function (page) {
return 'data/contents/p' + page + '.svg';
},
callback();
return;
}
- var url = this.getTextureURL(page);
- if (url == false) {
+
+ var d = 1024;
+ var c = document.getElementById("pscanvas");
+ c.width = d;
+ c.height = d;
+ var ctx = c.getContext("2d");
+ ctx.clearRect(0, 0, d, d);
+
+ // Draw background
+ ctx.drawImage(this.backgrounds[page].get(0), 0, 0, d, d);
+ // Draw the texts if necessary
+ if (this.getVersionToLoad(page) === 'textasvector') {
+ ctx.drawImage(this.texts[page].get(0), 0, 0, d, d);
+ }
+
+ // Draw the shadow if necessary
+ if (this.fluidbook.datas.shadeAlpha > 0) {
+ var sw = 1024 / 3;
+ var s, x;
+ if (page % 2 === 0) {
+ // Left
+ s = this.shadeLeft;
+ x = 1024 - sw;
+ } else {
+ // Right
+ s = this.shadeRight;
+ x = 0;
+ }
+ ctx.globalAlpha = this.fluidbook.datas.shadeAlpha / 100;
+ ctx.drawImage(s.get(0), x, 0, sw, d);
+ ctx.globalAlpha = 1;
+ }
+
+ var i = new Image();
+ i.onload = function () {
callback();
- return false;
}
- this.textures[page] = this.loadImage(url, null, null, null, callback);
+ i.src = c.toDataURL("image/png");
+
+ this.textures[page] = i;
},
getTexture: function (page) {
- return this.textures[page].get(0);
+ return this.textures[page];
},
loadTexts: function (pageNr, callback) {
var PLATFORM = 'web';
var DEVICE_READY = false;
-
try {
$(function () {
JQUERY_READY = true;
$(window).on('GALBundleLoaded', function (e, info) {
console.log('Loaded :: ' + info.bundleName);
-
if (info.bundleName == 'content_4') {
fluidbook.changeAddress();
}
fluidbook.loader.retryErrorImages();
}
} catch (err) {
-
}
});
} else {
if (INITED == true) {
return;
}
-
INITED = true;
fluidbook = new Fluidbook(DATAS);
fluidbook.gal = gal;
}
fluidbook.loadPlugins();
- fluidbook.loader.preloadPages();
desktopScale = 1;
desktopScaleAmount = 1.5;
setTimeout(function () {
resize();
}, 1000);
-
- fluidbook.onReady(function() {
- if (!startAfterLoading) {
- fluidbook.changeAddress();
- }
- });
-
- //console.log('fluidbook.ready');
- setTimeout(function(){
- fluidbook.ready();
- }, 3000);
}
} catch (err) {
console.log(err);