this.ready = false;
this.animationTime = 1.2;
+ this.lowPerf = this.fluidbook.support.android || this.fluidbook.support.iOS || this.fluidbook.support.IE > 0;
+
this.jcontainer = $("#flip3dcontainer");
this.pw = this.fluidbook.resize.ww;
var far = 24000;
var near = 1000;
- this.enableShadow = true;
+ this.enableShadow = false && !this.lowPerf;
this.camera = new THREE.PerspectiveCamera(20, 1, near, far);
this.camera.zoom = 1;
// this.scene.add(light);
if (this.enableShadow) {
- var geometry = new THREE.PlaneGeometry(this.fluidbook.datas.width * this.geometryScale * 2, this.fluidbook.datas.height * this.geometryScale, 10, 10, true);
+ var geometry = new THREE.PlaneGeometry(this.fluidbook.datas.width * this.geometryScale * 2, this.fluidbook.datas.height * this.geometryScale, 3, 3, true);
var shadowTexture = new THREE.ShadowMaterial({
color: 0x000000,
side: THREE.FrontSide,
texturesLoaded: function (t1, t2) {
var $this = this;
+ var triangles = 10;
+ if (this.lowPerf) {
+ triangles = 3;
+ }
- var geometry = new THREE.PlaneGeometry(this.fluidbook.datas.width * this.geometryScale, this.fluidbook.datas.height * this.geometryScale, 50, 10, true);
+ var geometry = new THREE.PlaneGeometry(this.fluidbook.datas.width * this.geometryScale, this.fluidbook.datas.height * this.geometryScale, triangles * 5, triangles, true);
var geometry2 = geometry.clone();
geometry.merge(geometry2, new THREE.Matrix4().makeRotationY(Math.PI), 1);
var roughness = 0.8;
var textures = [
- //new THREE.MeshPhongMaterial({color: 0xff00ff, side: THREE.FrontSide, overdraw: 0.5}),
- //new THREE.MeshPhongMaterial({color: 0x00ff00, side: THREE.FrontSide, overdraw: 0.5}),
new THREE.MeshStandardMaterial({map: t1, side: THREE.FrontSide, overdraw: 0.5, roughness: roughness}),
new THREE.MeshStandardMaterial({map: t2, side: THREE.FrontSide, overdraw: 0.5, roughness: roughness}),
];
this.plane.castShadow = this.enableShadow;
this.plane.receiveShadow = false;
-
this.scene.add(this.plane);
this.modifier = new ModifierStack(this.plane);
this.modifier.reset();
this.modifier.addModifier(this.bend);
- this.renderer = new THREE.WebGLRenderer({antialias: true, alpha: true});
+ this.renderer = new THREE.WebGLRenderer({antialias: !this.lowPerf, alpha: true});
if (this.enableShadow) {
this.renderer.shadowMap.enabled = true;
this.renderer.shadowMap.type = THREE.PCFSoftShadowMap;
}
+
+ var qualityRatio = 2;
+ if (this.lowPerf) {
+ qualityRatio = 1.5;
+ }
+
this.renderer.setClearColor(0x000000, 0);
- this.renderer.setPixelRatio(window.devicePixelRatio);
+ this.renderer.setPixelRatio(window.devicePixelRatio * qualityRatio);
this.renderer.setSize(this.pw, this.ph);
this.container.appendChild(this.renderer.domElement);
},
prepareTexture: function (page, callback) {
- var d = 4096;
+ var d = 2048;
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/300/t" + page + ".jpg";
+ img.src = "data/background/150/t" + page + ".jpg";
img.onload = function () {
ctx.drawImage(img, 0, 0, d, d);
var i = new Image();
play: function () {
this.guessCameraZoom();
-
this.playAnimation();
-
},
playAnimation: function () {
var bookBox = $("#currentDoublePage").get(0).getBoundingClientRect();
var s = (bookBox.width / 2) / rect.width;
+ console.log(s);
this.plane.scale.x *= s;
this.plane.scale.y *= s;
this.plane.rotateX(0);
this.shadowPlane.scale.y = this.plane.scale.y;
}
-
- for (i = 0; i < 40; i++) {
+ for (var i = 0; i < 40; i++) {
bbox = new THREE.Box3().setFromObject(this.plane);
min = this.to2D(bbox.min);
max = this.to2D(bbox.max);
height: Math.abs(min.y - max.y)
};
- this.plane.translateY(rect.y - bookBox.y);
+ console.log(rect.y);
+ console.log(bookBox.y);
+
+ this.plane.translateY(rect.y - bookBox.top);
}
if (this.enableShadow) {
this.shadowPlane.position.y = this.plane.position.y;