UNPKG

3d-flip-book

Version:

3D FlipBook allows to browse images, PDFs or HTMLs as a flipping book. It helps to attract user attention and make more impression on him.

1,547 lines (1,287 loc) 1.35 MB
/******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) /******/ return installedModules[moduleId].exports; /******/ /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // identity function for calling harmony imports with the correct context /******/ __webpack_require__.i = function(value) { return value; }; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { /******/ configurable: false, /******/ enumerable: true, /******/ get: getter /******/ }); /******/ } /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 72); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ function(module, exports, __webpack_require__) { "use strict"; 'use strict'; exports.__esModule = true; var _$ = true ? window.jQuery : require('jquery'), _html2canvas = true ? window.html2canvas : require('html2canvas'), _THREE = true ? window.THREE : require('three'), _React = true ? window.React : require('react'), _ReactDOM = true ? window.ReactDOM : require('react-dom'), _PDFJS = true ? window.PDFJS : require('pdfjs'), _tr = function _tr(s) { return (window.iberezansky || {}).tr && window.iberezansky.tr(s) || s; }; exports.$ = _$; exports.html2canvas = _html2canvas; exports.THREE = _THREE; exports.React = _React; exports.ReactDOM = _ReactDOM; exports.PDFJS = _PDFJS; exports.tr = _tr; /***/ }, /* 1 */ /***/ function(module, exports, __webpack_require__) { "use strict"; 'use strict'; exports.__esModule = true; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _$ = true ? window.jQuery : require('jquery'), _html2canvas = true ? window.html2canvas : require('html2canvas'), _THREE = true ? window.THREE : require('three'), _PDFJS = true ? window.PDFJS : require('pdfjs'), _tr = function _tr(s) { return (window.iberezansky || {}).tr && window.iberezansky.tr(s) || s; }; if (window.FB3D_LOCALE) { window.iberezansky = _extends({}, window.iberezansky, { tr: function tr(s) { return (FB3D_LOCALE.dictionary || {})[s] || s; } }); } exports.$ = _$; exports.html2canvas = _html2canvas; exports.THREE = _THREE; exports.PDFJS = _PDFJS; exports.tr = _tr; /***/ }, /* 2 */ /***/ function(module, exports) { "use strict"; 'use strict'; exports.__esModule = true; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var BaseMathUtils = function () { function BaseMathUtils() { _classCallCheck(this, BaseMathUtils); } BaseMathUtils.sum1 = function sum1(ka, a, kb, b) { return [ka * a[0] + kb * b[0]]; }; BaseMathUtils.sum2 = function sum2(ka, a, kb, b) { return [ka * a[0] + kb * b[0], ka * a[1] + kb * b[1]]; }; BaseMathUtils.sum3 = function sum3(ka, a, kb, b) { return [ka * a[0] + kb * b[0], ka * a[1] + kb * b[1], ka * a[2] + kb * b[2]]; }; BaseMathUtils.sum4 = function sum4(ka, a, kb, b) { return [ka * a[0] + kb * b[0], ka * a[1] + kb * b[1], ka * a[2] + kb * b[2], ka * a[3] + kb * b[3]]; }; BaseMathUtils.rk4 = function rk4(dy, t, dt, y) { var sum = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : BaseMathUtils.sum[y.length - 1]; var k1 = dy(t, y), k2 = dy(t + dt / 2, sum(1, y, dt / 2, k1)), k3 = dy(t + dt / 2, sum(1, y, dt / 2, k2)), k4 = dy(t + dt, sum(1, y, dt, k3)); return sum(1, y, dt / 6, sum(1, sum(1, k1, 2, k2), 1, sum(2, k3, 1, k4))); }; BaseMathUtils.extrapolateLinear = function extrapolateLinear(x, y, xi) { return y[0] + (y[1] - y[0]) / (x[1] - x[0]) * (xi - x[0]); }; BaseMathUtils.interpolateLinear = function interpolateLinear(x, y, xi) { var yi = void 0; if (x[0] > x[1]) { x = x.reverse(); y = y.reverse(); } if (xi < x[0]) { yi = y[0]; } else if (xi > x[1]) { yi = y[1]; } else { yi = BaseMathUtils.extrapolateLinear(x, y, xi); } return yi; }; BaseMathUtils.calcScale = function calcScale(srcW, srcH, dstW, dstH) { return Math.min(dstW / srcW, dstH / srcH); }; BaseMathUtils.mulM = function mulM(a, b) { var r = []; for (var i = 0; i < a.length; ++i) { r.push([]); for (var j = 0; j < b[0].length; ++j) { r[i][j] = 0; for (var k = 0; k < b.length; ++k) { r[i][j] += a[i][k] * b[k][j]; } } } return r; }; BaseMathUtils.transM = function transM(m) { var r = []; for (var i = 0; i < m.length; ++i) { for (var j = 0; j < m[0].length; ++j) { if (!r[j]) { r[j] = []; } r[j][i] = m[i][j]; } } return r; }; BaseMathUtils.mat = function mat(data) { var s = 0; for (var _iterator = data, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { var _ref; if (_isArray) { if (_i >= _iterator.length) break; _ref = _iterator[_i++]; } else { _i = _iterator.next(); if (_i.done) break; _ref = _i.value; } var x = _ref; s += x; } return s / data.length; }; BaseMathUtils.disp = function disp(data) { var M = BaseMathUtils.mat(data); var s = 0; for (var _iterator2 = data, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) { var _ref2; if (_isArray2) { if (_i2 >= _iterator2.length) break; _ref2 = _iterator2[_i2++]; } else { _i2 = _iterator2.next(); if (_i2.done) break; _ref2 = _i2.value; } var x = _ref2; s += (x - M) * (x - M); } return s / data.length; }; BaseMathUtils.predict = function predict(data, num) { var r = [], l = data.length, D = BaseMathUtils.disp(data); if (D < l && l > 1) { var am = [], bm = []; for (var i = 0; i < l; ++i) { am.push([i, 1]); bm.push([data[i]]); } var ta = BaseMathUtils.transM(am), a = BaseMathUtils.mulM(ta, am), b = BaseMathUtils.mulM(ta, bm), d = a[0][0] * a[1][1] - a[1][0] * a[0][1], p = [-(a[0][1] * b[1][0] - b[0][0] * a[1][1]) / d, (a[0][0] * b[1][0] - a[1][0] * b[0][0]) / d]; for (var _i3 = 0; _i3 < num; ++_i3) { var v = Math.round(p[0] * (_i3 + l) + p[1]); if (r.indexOf(v) === -1) { r.push(v); } } } return r; }; BaseMathUtils.getUnique = function getUnique() { return Math.ceil(1e9 * Math.random()); }; BaseMathUtils.setSplinePoints = function setSplinePoints(spline, ps) { if (spline.points.length !== ps.x.length) { console.warn('setSplinePoints: bad points'); } for (var i = 0; i < spline.points.length; ++i) { spline.points[i].set(ps.x[i], ps.y[i], ps.z ? ps.z[i] : 0); } }; BaseMathUtils.mapl2L = function mapl2L(ls, len, n, f) { var dL = len / (n - 1); var L = 0; for (var i = 0, d = ls[0]; i < ls.length - 1 && L < len + 0.1 * dL; ++i, d += ls[i]) { if (Math.abs(L - d) < Math.abs(L - d - ls[i + 1])) { f(i, L); L += dL; } } if (L < len + 0.1 * dL) { console.warn('mapl2L: ls is not enought'); } }; BaseMathUtils.det2 = function det2(a, b, c, d) { return a * d - b * c; }; BaseMathUtils.solve2Lin = function solve2Lin(a1, b1, a2, b2) { var res = void 0; var d = BaseMathUtils.det2(a1[0], a1[1], a2[0], a2[1]); if (Math.abs(d) > BaseMathUtils.eps) { var dx = BaseMathUtils.det2(b1, a1[1], b2, a2[1]), dy = BaseMathUtils.det2(a1[0], b1, a2[0], b2); res = { x: dx / d, y: dy / d }; } return res; }; BaseMathUtils.isInsidePoly = function isInsidePoly(ps, p) { var done = false, ct = void 0; for (var i = 0; i < ps.length; ++i) { if (BaseMathUtils.v2dist(p, ps[i]) < BaseMathUtils.eps) { ct = 1; done = true; break; } } while (!done) { done = true; ct = 0; var np = { x: p.x + Math.random() - 0.5, y: p.y + Math.random() - 0.5 }, rn = { x: np.x - p.x, y: np.y - p.y }, a1 = [rn.y, -rn.x], b1 = p.x * rn.y - p.y * rn.x; for (var _i4 = 0; _i4 < ps.length; ++_i4) { var p0 = ps[_i4], p1 = ps[(_i4 + 1) % ps.length], n = { x: p1.x - p0.x, y: p1.y - p0.y }, a2 = [n.y, -n.x], b2 = p0.x * n.y - p0.y * n.x, ip = BaseMathUtils.solve2Lin(a1, b1, a2, b2); if (ip) { if (BaseMathUtils.v2dist(ip, p0) < BaseMathUtils.eps || BaseMathUtils.v2dist(ip, p1) < BaseMathUtils.eps) { done = false; break; } else if (ip.x > Math.min(p0.x, p1.x) - BaseMathUtils.eps && ip.x < Math.max(p0.x, p1.x) + BaseMathUtils.eps && ip.y > Math.min(p0.y, p1.y) - BaseMathUtils.eps && ip.y < Math.max(p0.y, p1.y) + BaseMathUtils.eps) { if (BaseMathUtils.v2dist(ip, p) < BaseMathUtils.eps) { ct = 1; break; } else { var tn = { x: ip.x - p.x, y: ip.y - p.y }; ct += tn.x * rn.x + tn.y * rn.y > 0; } } } } } return ct % 2; }; BaseMathUtils.isInsideConvPoly = function isInsideConvPoly(ps, p) { var sg = [0, 0]; for (var i = 0; i < ps.length; ++i) { var p0 = ps[i], p1 = ps[(i + 1) % ps.length], a = { x: p0.x - p.x, y: p0.y - p.y }, b = { x: p1.x - p.x, y: p1.y - p.y }; ++sg[(a.x * b.y - a.y * b.x < 0) + 0]; } return ~sg.indexOf(ps.length); }; BaseMathUtils.v2len = function v2len(v2) { return Math.sqrt(v2.x * v2.x + v2.y * v2.y); }; BaseMathUtils.v2dist = function v2dist(v21, v22) { return BaseMathUtils.v2len({ x: v22.x - v21.x, y: v22.y - v21.y }); }; BaseMathUtils.computeSquare = function computeSquare(ps) { var a = []; var p = 0; for (var i = 0; i < ps.length; ++i) { a.push(BaseMathUtils.v2dist(ps[i], ps[(i + 1) % ps.length])); p += 0.5 * a[i]; } return Math.sqrt(p * (p - a[0]) * (p - a[1]) * (p - a[2])); }; BaseMathUtils.computeInterpCoefs = function computeInterpCoefs(tri, p) { var s = BaseMathUtils.computeSquare(tri), coefs = [], l = tri.length; for (var i = 0; i < l; ++i) { coefs[i] = BaseMathUtils.computeSquare([p, tri[(i + 1) % l], tri[(i + 2) % l]]) / s; } return coefs; }; return BaseMathUtils; }(); BaseMathUtils.sum = [BaseMathUtils.sum1, BaseMathUtils.sum2, BaseMathUtils.sum3, BaseMathUtils.sum4]; BaseMathUtils.eps = 1e-4; exports.default = BaseMathUtils; /***/ }, /* 3 */ /***/ function(module, exports, __webpack_require__) { "use strict"; 'use strict'; exports.__esModule = true; var _libs = __webpack_require__(0); var _BaseMathUtils2 = __webpack_require__(2); var _BaseMathUtils3 = _interopRequireDefault(_BaseMathUtils2); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var MathUtils = function (_BaseMathUtils) { _inherits(MathUtils, _BaseMathUtils); function MathUtils() { _classCallCheck(this, MathUtils); return _possibleConstructorReturn(this, _BaseMathUtils.apply(this, arguments)); } MathUtils.splitSpline = function splitSpline(spline, N) { var o = { len: 0, ls: [0] }, dl = 1 / N; for (var i = 0; i <= N; ++i) { var p = spline.getPoint(i * dl); if (i) { var d = MathUtils.v1.distanceTo(p); o.len += d; o.ls.push(d); } MathUtils.v1.copy(p); } return o; }; MathUtils.getLinearIndeces = function getLinearIndeces(spline, n) { var del = 5000, dDel = 1 / del; var ls = [0]; var l = 0; for (var i = 0; i <= del; ++i) { var p = spline.getPoint(i * dDel); if (i) { var d = MathUtils.v1.distanceTo(p); l += d; ls.push(d); } MathUtils.v1.copy(p); } ls.push(1e7); var res = [], dl = l / (n - 1); for (var _i = 0, L = 0, _d = ls[0]; _i < ls.length - 1; ++_i, _d += ls[_i]) { if (Math.abs(L - _d) < Math.abs(L - _d - ls[_i + 1])) { res.push(_i * dDel); L += dl; } } return res; }; MathUtils.refinePoly = function refinePoly(poly, maxDl) { var res = []; for (var i = 0; i < poly.length; ++i) { var p0 = poly[i], p1 = poly[(i + 1) % poly.length], l = _BaseMathUtils3.default.v2dist(p0, p1), n = Math.ceil(l / maxDl), dl = l / n; res.push(p0); for (var j = 1; j < n; ++j) { res.push(new _libs.THREE.Vector2(p0.x + j * dl * (p1.x - p0.x) / l, p0.y + j * dl * (p1.y - p0.y) / l)); } } return res; }; return MathUtils; }(_BaseMathUtils3.default); MathUtils.v1 = new _libs.THREE.Vector3(); exports.default = MathUtils; /***/ }, /* 4 */ /***/ function(module, exports) { "use strict"; 'use strict'; exports.__esModule = true; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var Utils = function () { function Utils() { _classCallCheck(this, Utils); } Utils.normalizeUrl = function normalizeUrl(url) { function split(s) { return s.replace(/\\/g, '/').split('/'); } var base = split(window.location.href); url = split(url); if (base[2] === url[2]) { url[0] = base[0]; } return url.join('/'); }; Utils.extends = function _extends(der, base) { for (var name in base) { if (!der.hasOwnProperty(name)) { der[name] = base[name]; } } }; Utils.defaultCmp = function defaultCmp(a, b) { return a - b; }; Utils.lowerBound = function lowerBound(a, x, cmp) { cmp = cmp || Utils.defaultCmp; var l = 0, h = a.length - 1; while (h - l > 1) { var mid = Math.floor((l + h) / 2); if (cmp(x, a[mid]) < 0) { h = mid; } else { l = mid; } } return cmp(x, a[h]) >= 0 ? h : l; }; return Utils; }(); exports.default = Utils; /***/ }, /* 5 */ /***/ function(module, exports, __webpack_require__) { "use strict"; 'use strict'; exports.__esModule = true; var _libs = __webpack_require__(0); var _GraphUtils = __webpack_require__(7); var _GraphUtils2 = _interopRequireDefault(_GraphUtils); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var ImageBase = function () { function ImageBase(context, width, height, color) { _classCallCheck(this, ImageBase); this.context = context; this.wnd = context.wnd; this.doc = context.doc; this.element = context.element || context.doc.body; this.c = context.renderCanvas || ImageBase.renderCanvas; this.ctx = context.renderCanvasCtx || ImageBase.renderCanvasCtx; this.resW = this.width = width; this.resH = this.height = height; this.color = color; } ImageBase.prototype.setResolution = function setResolution(res) { this.resW = res.width; this.resH = res.height; }; ImageBase.prototype.dispose = function dispose() {}; ImageBase.prototype.renderBlankPage = function renderBlankPage() { this.ctx.beginPath(); this.ctx.fillStyle = _GraphUtils2.default.color2Rgba(this.color, 1); this.ctx.rect(0, 0, this.c.width, this.c.height); this.ctx.fill(); }; ImageBase.prototype.renderImage = function renderImage(image) { this.pushCtx(); this.ctx.drawImage(image, 0, 0); this.popCtx(); }; ImageBase.prototype.normToConv = function normToConv(p) { return { x: p.x * this.c.width, y: (1 - p.y) * this.c.height }; }; ImageBase.prototype.renderHit = function renderHit(poly) { var ctx = this.ctx; ctx.fillStyle = 'rgba(255,255,0,0.4)'; ctx.beginPath(); var p = this.normToConv(poly[0]); ctx.moveTo(p.x, p.y); for (var i = 1; i < poly.length; ++i) { p = this.normToConv(poly[i]); ctx.lineTo(p.x, p.y); } ctx.closePath(); ctx.fill(); }; ImageBase.prototype.pushCtx = function pushCtx() { if (this.resW != this.c.width) { this.c.width = this.resW; } if (this.resH != this.c.height) { this.c.height = this.resH; } this.ctx.save(); this.ctx.scale(this.c.width / this.width, this.c.height / this.height); return this.ctx; }; ImageBase.prototype.popCtx = function popCtx() { this.ctx.restore(); }; ImageBase.prototype.renderNotFoundPage = function renderNotFoundPage() { this.renderBlankPage(); }; ImageBase.prototype.finishRender = function finishRender() { if (this.onChange) { this.onChange(this.c); } }; ImageBase.prototype.finishLoad = function finishLoad() { if (this.onLoad) { this.onLoad(); } else { this.startRender(); } }; ImageBase.prototype.getSimulatedDoc = function getSimulatedDoc() { return undefined; }; return ImageBase; }(); ImageBase.renderCanvas = (0, _libs.$)('<canvas>')[0]; ImageBase.renderCanvasCtx = ImageBase.renderCanvas.getContext('2d'); exports.default = ImageBase; /***/ }, /* 6 */ /***/ function(module, exports, __webpack_require__) { "use strict"; 'use strict'; exports.__esModule = true; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _libs = __webpack_require__(0); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var EventConverter = function () { // virtuals // getObject(e, data); // getCallback(object); // test(object1, object1); function EventConverter(wnd, doc) { _classCallCheck(this, EventConverter); this.wnd = wnd; this.doc = doc; this.enabled = true; } EventConverter.prototype.setEnable = function setEnable(vl) { if (!vl) { if (this.mCapObject) { this.notify(this.mCapObject, _libs.$.Event('mouseup'), 'mouseup'); this.mCapObject = undefined; } if (this.mHovObject) { this.notify(this.mHovObject, _libs.$.Event('mouseout'), 'mouseout'); this.mHovObject = undefined; } } this.enabled = vl; }; EventConverter.prototype.getCallback = function getCallback(object) { return undefined; }; EventConverter.prototype.notify = function notify(object, e, type) { var callback = this.getCallback(object); if (callback) { var props = _extends({}, e, { type: type, view: this.wnd }); var jE = _libs.$.Event(type, props); callback(jE, object); } }; EventConverter.prototype.convert = function convert(e, data) { if (!this.enabled) return; if (this.filter) { e = this.filter(this.element, e); } var object = this.getObject(e, data), notify = ~e.type.indexOf('touch') ? this.convertTouch(e, data, object) : this.convertMouse(e, data, object); if (notify && object) { this.notify(object, e, e.type); } }; EventConverter.prototype.convertTouch = function convertTouch(e, data, object) { var notify = true; switch (e.type) { case 'touchstart': { if (this.tCapObject) { this.notify(this.tCapObject, e, 'touchend'); } this.tCapObject = object; break; } case 'touchend': { if (this.tCapObject && !this.test(this.tCapObject, object)) { this.notify(this.tCapObject, e, 'touchend'); notify = false; } else if (object && this.test(this.tCapObject, object)) { this.notify(object, e, 'touchtap'); } this.tCapObject = undefined; break; } case 'touchtap': { notify = false; break; } } return notify; }; EventConverter.prototype.convertMouse = function convertMouse(e, data, object) { var notify = true; switch (e.type) { case 'mousedown': { if (this.mCapObject) { this.notify(this.mCapObject, e, 'mouseup'); } this.mCapObject = object; break; } case 'mouseup': { if (this.mCapObject && !this.test(this.mCapObject, object)) { this.notify(this.mCapObject, e, 'mouseup'); notify = false; } break; } case 'click': { notify = this.test(this.mCapObject, object); this.mCapObject = undefined; break; } case 'mouseenter': case 'mouseover': case 'mousemove': { if (!this.test(this.mHovObject, object) && this.mHovObject) { this.notify(this.mHovObject, e, 'mouseout'); this.mHovObject = undefined; } if (!this.mHovObject && object) { this.notify(object, e, 'mouseover'); this.mHovObject = object; } notify = e.type === 'mousemove'; break; } case 'mouseleave': case 'mouseout': { if (this.mHovObject) { this.notify(this.mHovObject, e, 'mouseout'); this.mHovObject = undefined; } notify = false; break; } } return notify; }; return EventConverter; }(); exports.default = EventConverter; /***/ }, /* 7 */ /***/ function(module, exports) { "use strict"; 'use strict'; exports.__esModule = true; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var GraphUtils = function () { function GraphUtils() { _classCallCheck(this, GraphUtils); } GraphUtils.extrapolateLinear = function extrapolateLinear(x, y, xi) { return y[0] + (y[1] - y[0]) / (x[1] - x[0]) * (xi - x[0]); }; GraphUtils.interpolate01 = function interpolate01(y1, y2, t) { return GraphUtils.extrapolateLinear([0, 1], [y1, y2], t); }; GraphUtils.getColorBytes = function getColorBytes(color) { return [color >> 16 & 0xFF, color >> 8 & 0xFF, color & 0xFF]; }; GraphUtils.inverseColor = function inverseColor(color) { var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; var bs = GraphUtils.getColorBytes(color), ibs = [0xFF - bs[0], 0xFF - bs[1], 0xFF - bs[2]], nbs = [Math.round(GraphUtils.interpolate01(bs[0], ibs[0], t)), Math.round(GraphUtils.interpolate01(bs[1], ibs[1], t)), Math.round(GraphUtils.interpolate01(bs[2], ibs[2], t))]; return GraphUtils.bytes2Color(nbs); }; GraphUtils.color2Rgba = function color2Rgba(color, a) { return GraphUtils.bytes2Rgba(GraphUtils.getColorBytes(color), a); }; GraphUtils.bytes2Rgba = function bytes2Rgba(bs, a) { return 'rgba(' + bs.join(',') + ',' + a + ')'; }; GraphUtils.bytes2Color = function bytes2Color(bs) { return bs[2] | bs[1] << 8 | bs[0] << 16; }; return GraphUtils; }(); exports.default = GraphUtils; /***/ }, /* 8 */ /***/ function(module, exports, __webpack_require__) { "use strict"; 'use strict'; exports.__esModule = true; var _Cache = __webpack_require__(14); var _Cache2 = _interopRequireDefault(_Cache); var _BlankImage = __webpack_require__(43); var _BlankImage2 = _interopRequireDefault(_BlankImage); var _StaticImage = __webpack_require__(59); var _StaticImage2 = _interopRequireDefault(_StaticImage); var _PdfImage = __webpack_require__(57); var _PdfImage2 = _interopRequireDefault(_PdfImage); var _InteractiveImage = __webpack_require__(51); var _InteractiveImage2 = _interopRequireDefault(_InteractiveImage); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var ImageFactory = function () { function ImageFactory(context, cache) { _classCallCheck(this, ImageFactory); this.context = context; this.cache = cache || new _Cache2.default(); } ImageFactory.prototype.build = function build(info) { var n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; var widthTexels = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 210; var heightTexels = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 297; var color = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0xFFFFFF; var injector = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : undefined; var image = void 0; switch (info.type) { case 'html': { image = new _InteractiveImage2.default(this.context, widthTexels, heightTexels, color, info.src, this.cache, injector); break; } case 'image': { image = new _StaticImage2.default(this.context, widthTexels, heightTexels, color, info.src); break; } case 'pdf': { image = new _PdfImage2.default(this.context, widthTexels, heightTexels, color, info.src, n); break; } case 'blank': default: { image = new _BlankImage2.default(this.context, widthTexels, heightTexels, color); break; } } return image; }; return ImageFactory; }(); exports.default = ImageFactory; /***/ }, /* 9 */ /***/ function(module, exports, __webpack_require__) { "use strict"; 'use strict'; exports.__esModule = true; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _book = __webpack_require__(11); var _BaseMathUtils = __webpack_require__(2); var _BaseMathUtils2 = _interopRequireDefault(_BaseMathUtils); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var BookPropsBuilder = function () { function BookPropsBuilder(onReady) { _classCallCheck(this, BookPropsBuilder); this.onReady = onReady; this.defaults = (0, _book.props)(); } BookPropsBuilder.prototype.dispose = function dispose() {}; BookPropsBuilder.prototype.calcSize = function calcSize(width, height) { var scale = _BaseMathUtils2.default.calcScale(width, height, this.defaults.width, this.defaults.height); return { width: scale * width, height: scale * height }; }; BookPropsBuilder.prototype.calcTexels = function calcTexels(width, height) { var sheet = this.defaults.sheet, scale = _BaseMathUtils2.default.calcScale(width, height, sheet.widthTexels, sheet.heightTexels); return { widthTexels: scale * width, heightTexels: scale * height }; }; BookPropsBuilder.prototype.calcProps = function calcProps(width, height) { this.props = _extends({}, this.defaults, this.calcSize(width, height), { sheet: _extends({}, this.defaults.sheet, this.calcTexels(width, height)), cover: _extends({}, this.defaults.cover), page: _extends({}, this.defaults.page) }); }; BookPropsBuilder.prototype.calcSheets = function calcSheets(pages) { return this.sheets = Math.ceil(Math.max(0, pages - 4) / 2); }; BookPropsBuilder.prototype.getSheets = function getSheets() { return this.sheets; }; BookPropsBuilder.prototype.getProps = function getProps() { return this.props; }; BookPropsBuilder.prototype.getPageCallback = function getPageCallback() { return this.binds.pageCallback; }; BookPropsBuilder.prototype.ready = function ready() { if (this.onReady) { this.onReady(this.getProps(), this.getSheets(), this.getPageCallback()); } }; return BookPropsBuilder; }(); exports.default = BookPropsBuilder; /***/ }, /* 10 */ /***/ function(module, exports, __webpack_require__) { "use strict"; 'use strict'; exports.__esModule = true; var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _libs = __webpack_require__(1); var _sheetBlock = __webpack_require__(41); var _sheetBlock2 = _interopRequireDefault(_sheetBlock); var _MathUtils = __webpack_require__(3); var _MathUtils2 = _interopRequireDefault(_MathUtils); var _ThreeUtils = __webpack_require__(20); var _ThreeUtils2 = _interopRequireDefault(_ThreeUtils); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } // import ThreeMarkup from './ThreeMarkup'; var SheetBlock = function () { function SheetBlock(visual, p, first, last) { var angle = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0; var _this = this; var state = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 'closed'; var height = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 0; _classCallCheck(this, SheetBlock); this.visual = visual; this.p = _extends({}, p, { first: first, last: last }); var props = this.getProps(); var loadedPoints = this.loadPoints(); Object.keys(loadedPoints).map(function (k) { _this[k] = loadedPoints[k][props.shape] || loadedPoints[k][0]; }); this.pSpline = new _libs.THREE.Spline([]); for (var i = 0; i < this.interpolationPoints.x[0].length; ++i) { this.pSpline.points.push(new _libs.THREE.Vector3()); } this.iSpline = new _libs.THREE.Spline([]); for (var _i = 0; _i < _sheetBlock2.default.resX; ++_i) { this.iSpline.points.push(new _libs.THREE.Vector3()); } this.aSplines = []; //this.three = new THREE.Object3D(); this.geometry = _sheetBlock2.default.geometry.clone(); this.p.sideFaces = [{ first: 0, last: _sheetBlock2.default.faces[0] }, { first: _sheetBlock2.default.faces[0], last: _sheetBlock2.default.faces[1] }]; this.sideTexture = new _libs.THREE.Texture(); this.sideTexture.wrapT = _libs.THREE.RepeatWrapping; this.sideTexture.repeat.set(0, last - first); this.sideTexture.image = props.sideTexture; this.sideTexture.needsUpdate = true; this.materials = [new _libs.THREE.MeshPhongMaterial(), new _libs.THREE.MeshPhongMaterial(), new _libs.THREE.MeshPhongMaterial({ map: this.sideTexture }), new _libs.THREE.MeshPhongMaterial({ map: this.sideTexture }), new _libs.THREE.MeshPhongMaterial({ map: this.sideTexture }), new _libs.THREE.MeshPhongMaterial({ map: this.sideTexture })]; this.p.setTexture(this.materials[0], 2 * first); this.p.setTexture(this.materials[1], 2 * last - 1); this.mesh = new _libs.THREE.Mesh(this.geometry, new _libs.THREE.MeshFaceMaterial(this.materials)); this.mesh.castShadow = false; this.mesh.receiveShadow = false; // this.mesh.frustumCulled = true; //this.three.add(this.mesh); this.three = this.mesh; this.three.userData.self = this; this.markers = []; if (this.p.marker.use) { var l = this.geometry.vertices.length; var is = void 0; // is = [0, sheetBlock.resX-1, (sheetBlock.resZ-1)*sheetBlock.resX, sheetBlock.resZ*sheetBlock.resX-1]; is = Array.apply(0, Array(l)).map(function (_, i) { return i; }); for (var _iterator = is, _isArray = Array.isArray(_iterator), _i2 = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { var _ref; if (_isArray) { if (_i2 >= _iterator.length) break; _ref = _iterator[_i2++]; } else { _i2 = _iterator.next(); if (_i2.done) break; _ref = _i2.value; } var _i3 = _ref; var marker = _ThreeUtils2.default.createMarker(this.geometry.vertices[_i3], _i3 < l / 2 ? 0xFF0000 : 0x00FF00, this.p.marker.size); this.markers.push({ marker: marker, vertex: _i3 }); this.three.add(marker); } } this.corner = { use: true, height: 0, maxDistance: 0, points: [], OZ: new _libs.THREE.Vector3(0, 0, 1), axis: new _libs.THREE.Vector3() }; this.set(0, 'closed', height, first, last); // calculate corner points this.set(angle, state, height, first, last); // init position // if(!SheetBlock.markup) { // SheetBlock.markup=true; // this.markup = new ThreeMarkup(this, 0, [{ // x: 0, // y: 0, // }, { // x: 0.5, // y: 1 // }, { // x: 1, // y: 0 // }].map((p)=>new THREE.Vector2(p.x, p.y)), {}); // } } SheetBlock.prototype.dispose = function dispose() { for (var _iterator2 = this.materials, _isArray2 = Array.isArray(_iterator2), _i4 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) { var _ref2; if (_isArray2) { if (_i4 >= _iterator2.length) break; _ref2 = _iterator2[_i4++]; } else { _i4 = _iterator2.next(); if (_i4.done) break; _ref2 = _i4.value; } var m = _ref2; if (m.map) { m.map = null; m.needsUpdate = true; } m.dispose(); } delete this.materials; this.geometry.dispose(); }; SheetBlock.prototype.getSize = function getSize() { return this.p.last - this.p.first; }; SheetBlock.prototype.getProps = function getProps() { return _extends({}, this.p.page, { sheets: this.p.sheets }); }; SheetBlock.prototype.getTopCerners = function getTopCerners() { var off = this.angle > Math.PI / 2 ? this.geometry.vertices.length / 2 : 0; return [this.geometry.vertices[off], this.geometry.vertices[_sheetBlock2.default.resX - 1 + off], this.geometry.vertices[(_sheetBlock2.default.resZ - 1) * _sheetBlock2.default.resX + off], this.geometry.vertices[_sheetBlock2.default.resZ * _sheetBlock2.default.resX - 1 + off]]; }; SheetBlock.prototype.getTopSize = function getTopSize() { // const l=this.geometry.vertices.length, off = this.angle>Math.PI/2? l/2: 0, // v0 = this.geometry.vertices[off], v1 = this.geometry.vertices[sheetBlock.resZ*sheetBlock.resX-1+off]; // // is = [0, sheetBlock.resX-1, (sheetBlock.resZ-1)*sheetBlock.resX, sheetBlock.resZ*sheetBlock.resX-1]; // return { // width: Math.abs(v1.x-v0.x), // height: Math.abs(v1.z-v0.z) // }; var vs = this.getTopCerners(); return { width: vs[0].distanceTo(vs[1]), height: vs[0].distanceTo(vs[2]) }; }; SheetBlock.prototype.getTopWorldRotation = function getTopWorldRotation(q) { q.x = -Math.PI / 2; return q; }; SheetBlock.prototype.getTopWorldPosition = function getTopWorldPosition(v) { var l = this.geometry.vertices.length, off = this.angle > Math.PI / 2 ? l / 2 : 0, vs = [this.geometry.vertices[off], this.geometry.vertices[_sheetBlock2.default.resX - 1 + off], this.geometry.vertices[(_sheetBlock2.default.resZ - 1) * _sheetBlock2.default.resX + off], this.geometry.vertices[_sheetBlock2.default.resZ * _sheetBlock2.default.resX - 1 + off]]; v.set(0, 0, 0); for (var _iterator3 = vs, _isArray3 = Array.isArray(_iterator3), _i5 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) { var _ref3; if (_isArray3) { if (_i5 >= _iterator3.length) break; _ref3 = _iterator3[_i5++]; } else { _i5 = _iterator3.next(); if (_i5.done) break; _ref3 = _i5.value; } var vi = _ref3; v.x += 0.25 * vi.x; v.y += 0.25 * vi.y; v.z += 0.25 * vi.z; } this.three.localToWorld(v); return v; }; SheetBlock.prototype.getInterpolationPoints = function getInterpolationPoints(inds, mod) { var ps = { x: [], y: [] }, K = this.getProps().wave; for (var _iterator4 = inds, _isArray4 = Array.isArray(_iterator4), _i6 = 0, _iterator4 = _isArray4 ? _iterator4 : _iterator4[Symbol.iterator]();;) { var _ref4; if (_isArray4) { if (_i6 >= _iterator4.length) break; _ref4 = _iterator4[_i6++]; } else { _i6 = _iterator4.next(); if (_i6.done) break; _ref4 = _i6.value; } var i = _ref4; ps.x.push([].concat(this.interpolationPoints.x[i])); ps.y.push(~mod.indexOf(i) ? this.interpolationPoints.y[i].map(function (n) { return K * n; }) : [].concat(this.interpolationPoints.y[i])); } return ps; }; SheetBlock.prototype.set = function set(angle) { var state = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.state; var height = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.corner.height; var first = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : this.p.first; var last = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.p.last; var PI = Math.PI; this.state = state; var closedAngle = void 0, binderTurn = void 0; if ((typeof angle === 'undefined' ? 'undefined' : _typeof(angle)) === 'object') { this.angle = angle.openedAngle; closedAngle = angle.closedAngle; binderTurn = angle.binderTurn > PI / 2 ? PI - angle.binderTurn : angle.binderTurn; } else { this.angle = angle; } this.corner.height = height; if (this.p.first !== first || this.p.last !== last) { this.sideTexture.repeat.set(0, last - first); this.sideTexture.needsUpdate = true; if (this.p.first !== first) { this.p.setTexture(this.materials[0], 2 * first); } if (this.p.last !== last) { this.p.setTexture(this.materials[1], 2 * last - 1); } } this.p.first = first; this.p.last = last; var points = void 0; var props = this.getProps(); if (this.state === 'closed') { points = this.getInterpolationPoints(this.closedInterpolationIndeces, this.closedInterpolationIndeces); } else if (this.state === 'opened') { if (closedAngle !== undefined && Math.abs(closedAngle - PI / 2) > 1e-2) { points = this.getInterpolationPoints(this.flatInterpolationIndeces, []); var ps = this.getPointsAtAngle(this.getInterpolationPoints(this.closedInterpolationIndeces, this.closedInterpolationIndeces), closedAngle > PI / 2 ? PI - closedAngle : closedAngle); points.x = [ps.x].concat(points.x); points.y = [ps.y].concat(points.y); // console.log(ps); } else { points = this.getInterpolationPoints(this.openedInterpolationIndeces, this.closedInterpolationIndeces); } } var hl = void 0, hr = void 0, offset = 0.5 * props.sheets * props.depth; if (this.state === 'closed') { offset -= 7e-6 * this.p.scale; } if (this.angle <= PI / 2) { hl = (props.sheets - first) * props.depth; hr = (props.sheets - last) * props.depth; } else { hl = first * props.depth; hr = last * props.depth; } var inAngle = this.angle > PI / 2 ? PI - this.angle : this.angle, hAngle = this.state === 'closed' ? inAngle : binderTurn === undefined ? PI / 2 : binderTurn; var _getPointsAtAngleAndH = this.getPointsAtAngleAndHs(points, inAngle, hAngle, [hl / props.width, hr / props.width]), left = _getPointsAtAngleAndH[0], right = _getPointsAtAngleAndH[1]; if (this.angle > PI / 2) { this.inverse(left); this.inverse(right); offset = -offset; } this.setPoints(left, right, offset); }; SheetBlock.prototype.setPoints = function setPoints(left, right, offset) { var _this2 = this; var p = this.getProps(); var i = 0; var ys = [right, left]; for (var y = 0; y < _sheetBlock2.default.resY; ++y) { for (var z = 0; z < _sheetBlock2.default.resZ; ++z) { for (var x = 0; x < _sheetBlock2.default.resX; ++x) { this.geometry.vertices[i++].set(ys[y].x[x] * p.width + offset, ys[y].y[x] * p.width, z * p.height / (_sheetBlock2.default.resZ - 1) - 0.5 * p.height); } } } if (i !== this.geometry.vertices.length) { console.warn('setPoints: bad mapping!'); } if (this.corner.use && !this.corner.points.length) { var plane = new _libs.THREE.Plane(), normal = plane.normal, planeOffset = (1 - this.getProps().flexibleCorner) * Math.min(p.width, p.height), proj = new _libs.THREE.Vector3(); plane.setFromNormalAndCoplanarPoint(new _libs.THREE.Vector3(-1, 0, -1).normalize(), new _libs.THREE.Vector3(planeOffset + offset, 0, 0.5 * p.height)); for (var _i7 = 0, l = this.geometry.vertices.length; _i7 < l; ++_i7) { plane.projectPoint(this.geometry.vertices[_i7], proj); proj.sub(this.geometry.vertices[_i7]); if (proj.x * normal.x + proj.y * normal.y + proj.z * normal.z > 0) { var d = proj.length() / planeOffset; this.corner.maxDistance = Math.max(this.corner.maxDistance, d); this.corner.points.push({ vertex: _i7, distance: d }); } } } if (this.corner.use && Math.abs(this.corner.height) > 1e-3) { var d2Angle = function d2Angle(d) { return p.cornerDeviation * _this2.corner.height / (1 + Math.exp(-p.bending * (d - 0.5 * _this2.corner.maxDistance))); }; this.corner.axis.set(-1, 0, 1).normalize(); this.corner.axis.applyAxisAngle(this.corner.OZ, this.angle); for (var _iterator5 = this.corner.points, _isArray5 = Array.isArray(_iterator5), _i8 = 0, _iterator5 = _isArray5 ? _iterator5 : _iterator5[Symbol.iterator]();;) { var _ref5; if (_isArray5) { if (_i8 >= _iterator5.length) break; _ref5 = _iterator5[_i8++]; } else { _i8 = _iterator5.next(); if (_i8.done) break; _ref5 = _i8.value; } var point = _ref5; this.geometry.vertices[point.vertex].applyAxisAngle(this.corner.axis, d2Angle(point.distance)); } } for (var _iterator6 = this.markers, _isArray6 = Array.isArray(_iterator6), _i9 = 0, _iterator6 = _isArray6 ? _iterator6 : _iterator6[Symbol.iterator]();;) { var _ref6; if (_isArray6) { if (_i9 >= _iterator6.length) break; _ref6 = _iterator6[_i9++]; } else { _i9 = _iterator6.next(); if (_i9.done) break; _ref6 = _i9.value; } var m = _ref6; m.marker.position.copy(this.geometry.vertices[m.vertex]); } this.geometry.computeVertexNormals(); //this.geometry.computeFaceNormals(); this.geometry.computeBoundingSphere(); //this.geometry.computeBoundingBox(); this.geometry.verticesNeedUpdate = true; if (this.markup) { this.markup.computeVertices(); } }; SheetBlock.prototype.inverse = function inverse(ps) { for (var i = 0; i < ps.x.length; ++i) { ps.x[i] = -ps.x[i]; } return ps; }; SheetBlock.prototype.getPointsAtHs = function getPointsAtHs(ps, angle, hs) { var _this3 = this; var N = 1000; _MathUtils2.default.setSplinePoints(this.pSpline, ps); var bl = _MathUtils2.default.splitSpline(this.pSpline, N), r = []; { var p1 = _extends({}, this.pSpline.getPoint((N - 1) / N)), p2 = _extends({}, this.pSpline.getPoint(1)), dp = { x: p2.x - p1.x, y: p2.y - p1.y }, ln = Math.sqrt(dp.x * dp.x + dp.y * dp.y), sp = this.pSpline.points[this.pSpline.points.length - 1]; sp.set(sp.x + 0.1 * dp.x / ln, sp.y + 0.1 * dp.y / ln, 0); bl = _MathUtils2.default.splitSpline(this.pSpline, N); } bl.ls.push(1e7); _MathUtils2.default.mapl2L(bl.ls, bl.len, _sheetBlock2.default.resX, function (i) { for (var j = 0; j < hs.length; ++j) { if (!i) { r[j] = { x: [-hs[j] * Math.sin(angle)], y: [hs[j] * Math.cos(angle)] }; } else { var p0 = _extends({}, _this3.pSpline.getPoint((i - 1) / N))