this.sizePlane = new THREE.Mesh(geometry3);
this.sizePlane.castShadow = this.sizePlane.receiveShadow = false;
- this.sizePlane.visible=false;
+ this.sizePlane.visible = false;
this.scene.add(this.sizePlane);
this.scene.add(this.plane);
},
prepareTurn: function (turning, callback) {
-
var $this = this;
this.prepareTexture(turning.flip[1], function (t1) {
$this.prepareTexture(turning.flip[0], function (t2) {
callback();
},
+ disposeTextures: function () {
+ if (this.textures[0].map !== null) {
+ this.textures[0].map.dispose();
+ }
+ if (this.textures[1].map !== null) {
+ this.textures[1].map.dispose();
+ }
+ },
+
prepareTexture: function (page, callback) {
- 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);
- var img = new Image();
- img.src = "data/background/150/t" + page + ".jpg";
- img.onload = function () {
- ctx.drawImage(img, 0, 0, d, d);
- var i = new Image();
- var texture = new THREE.Texture(i);
- i.onload = function () {
- texture.needsUpdate = true;
- callback(texture);
- }
- i.src = c.toDataURL("image/png");
- };
+ 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);
+ });
},
playTurn: function (dir, callback) {
ease: Power0.easeIn,
onComplete: function () {
$this.turnRunning = false;
+ $this.disposeTextures();
this.tlname = '';
callback();
}
return 'raster';
},
+
preloadPagesBeforeTransition: function (pages, callback) {
var $this = this;
var $pages = pages.slice(0);
},
_preloadPage: function (page, callback) {
+ if (page == undefined || page == 'undefined' || page > this.fluidbook.getMaxPage() || page < 1) {
+ callback();
+ return;
+ }
+
var $this = this;
if (this.backgrounds[page] != undefined) {
callback();
if (this.fluidbook.support.transitions3dacc) {
$_callback = function () {
- $this._loadTexture(page, callback);
+ $this.loadTexture(page, callback);
};
} else {
$_callback = callback;
}
this.backgrounds[page] = this.loadImage(url, null, null, null, callback);
},
- _loadTexture: function (page, callback) {
+ loadTexture: function (page, callback) {
if (page <= 0 || page > this.fluidbook.datas.pages) {
callback();
return;
if (this.textures[page] != undefined) {
callback();
} else {
- this.__loadTexture(page, callback);
+ this._loadTexture(page, callback);
}
},
- __loadTexture: function (page, callback) {
+ _loadTexture: function (page, callback) {
if (page <= 0 || page > this.fluidbook.datas.pages) {
callback();
return;
this.textures[page] = this.loadImage(url, null, null, null, callback);
},
+ getTexture: function (page) {
+ return this.textures[page].get(0);
+ },
+
loadTexts: function (pageNr, callback) {
if (pageNr <= 0 || pageNr > this.fluidbook.datas.pages) {
callback();