]> _ Git - fluidbook-html5.git/commitdiff
wip #2315 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 26 Oct 2018 16:27:22 +0000 (18:27 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 26 Oct 2018 16:27:22 +0000 (18:27 +0200)
js/libs/fluidbook/fluidbook.3dflip.js

index 9fe4b2dbfc1ea7cdeebeab0e23a342307bb8323a..b648d84e27cc74f8f1873bfb70d2b377413b9540 100644 (file)
@@ -169,9 +169,12 @@ Fluidbook3DFlip.prototype = {
             this.scene.add(this.shadowPlane);
         }
 
-        var geometry = new THREE.PlaneGeometry(this.fluidbook.datas.width * this.geometryScale, this.fluidbook.datas.height * this.geometryScale, Math.round(this.triangles * 5), Math.round(this.triangles), true);
+        this.geometryWidth = this.fluidbook.datas.width * this.geometryScale;
+        this.geometryHeight = this.fluidbook.datas.height * this.geometryScale;
+
+        var geometry = new THREE.PlaneGeometry(this.geometryWidth, this.geometryHeight, Math.round(this.triangles * 5), Math.round(this.triangles), true);
         var geometry2 = geometry.clone();
-        var geometry3 = new THREE.PlaneGeometry(this.fluidbook.datas.width * this.geometryScale, this.fluidbook.datas.height * this.geometryScale, 1, 1, true);
+        var geometry3 = new THREE.PlaneGeometry(this.geometryWidth, this.geometryHeight, 1, 1, true);
         geometry.merge(geometry2, new THREE.Matrix4().makeRotationY(Math.PI), 1);
 
         var roughness = 0.8;
@@ -202,7 +205,23 @@ Fluidbook3DFlip.prototype = {
         this.scene.add(this.plane);
 
         this.modifier = new ModifierStack(this.plane);
-        this.bend = new Bend(0, 0.65, 250 * 0.0174533);
+
+        this.bendAngle = 250;
+        this.bendOffset = 0.65;
+        this.bendForceMultiplicator = 1;
+
+        var ratio = this.fluidbook.datas.width / this.fluidbook.datas.height;
+        if (ratio > 0.85) {
+            this.bendAngle = 30;
+            this.bendOffset = 0.5;
+            this.bendForceMultiplicator = 1.1;
+        } else if (ratio >= 1) {
+            this.bendAngle = 10;
+            this.bendOffset = 0.4;
+            this.bendForceMultiplicator = 1.2;
+        }
+        this.bend = new Bend(0, this.bendOffset, this.bendAngle * 0.0174533);
+
         this.bend.constraint = -1;
         this.modifier.reset();
         this.modifier.addModifier(this.bend);
@@ -231,16 +250,19 @@ Fluidbook3DFlip.prototype = {
         this.initAnimations();
     },
 
+    setBendAngle: function (a) {
+        this.bend.angle = a * 0.0174533;
+    },
+
     clean: function () {
         this.disposeTextures();
     },
 
     initAnimations: function () {
-        var force = 0.65;
+        var force = 0.65 * this.bendForceMultiplicator;
         var easeOut = Power0.easeOut;
         var easeIn = Power0.easeIn;
 
-
         this.tlright = new TimelineMax();
         this.tlright.add(TweenMax.fromTo(this.bend, .5, {force: 0}, {
             force: force * -1,