UNPKG

whs-cube-spheres

Version:

This plugin has a container with multiple spheres.

1,302 lines (981 loc) 332 kB
/*! WhitestormJS Framework v2.0.0-beta.8 */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(require("three")); else if(typeof define === 'function' && define.amd) define(["three"], factory); else if(typeof exports === 'object') exports["WHS"] = factory(require("three")); else root["WHS"] = factory(root["THREE"]); })(this, function(__WEBPACK_EXTERNAL_MODULE_0__) { return /******/ (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 = 86); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports) { module.exports = __WEBPACK_EXTERNAL_MODULE_0__; /***/ }), /* 1 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_three__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_three___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_three__); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Component__ = __webpack_require__(5); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__prototype_attributes__ = __webpack_require__(9); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__errors__ = __webpack_require__(3); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return MeshComponent; }); 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 _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _dec, _class, _class2, _temp; 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 MeshComponent = (_dec = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__prototype_attributes__["a" /* attributes */])(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__prototype_attributes__["b" /* copy */])('position', 'rotation', 'quaternion', 'scale'), __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__prototype_attributes__["c" /* mirror */])('material', 'geometry')), _dec(_class = (_temp = _class2 = function (_Component) { _inherits(MeshComponent, _Component); _createClass(MeshComponent, null, [{ key: 'custom', // CUSTOM GEOMETRY HANDLING value: function custom(geom) { var constructor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : __WEBPACK_IMPORTED_MODULE_0_three__["Mesh"]; return function (_MeshComponent) { _inherits(_class3, _MeshComponent); function _class3() { _classCallCheck(this, _class3); return _possibleConstructorReturn(this, (_class3.__proto__ || Object.getPrototypeOf(_class3)).apply(this, arguments)); } _createClass(_class3, [{ key: 'build', value: function build() { var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.params; var _applyBridge = this.applyBridge({ geometry: geom, material: params.material }), geometry = _applyBridge.geometry, material = _applyBridge.material; return this.applyBridge({ mesh: new constructor(geometry, material) }).mesh; } }]); return _class3; }(MeshComponent); } }, { key: 'create', value: function create(geom, params, constructor) { return new (MeshComponent.custom(geom, constructor))(params); } }]); function MeshComponent(params) { var defaults = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : MeshComponent.defaults; var instructions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : MeshComponent.instructions; _classCallCheck(this, MeshComponent); var _this = _possibleConstructorReturn(this, (MeshComponent.__proto__ || Object.getPrototypeOf(MeshComponent)).call(this, params, defaults, instructions)); if (_this.params.build) { var build = _this.build(_this.params); if (!build) { throw new __WEBPACK_IMPORTED_MODULE_3__errors__["a" /* CompositionError */]('MeshComponent', '.build() method should return a THREE.Object3D or a Promise resolved with THREE.Object3D.', _this); } if (build instanceof Promise) { build.then(function (native) { _this.native = native; _this.wrap(); }); } else { _this.native = build; _this.wrap(); } } return _this; } // BUILDING & WRAPPING _createClass(MeshComponent, [{ key: 'build', value: function build() { throw new __WEBPACK_IMPORTED_MODULE_3__errors__["a" /* CompositionError */]('MeshComponent', 'Instance should have it\'s own .build().', this); } }, { key: 'wrap', value: function wrap() { var _this3 = this; return new Promise(function (resolve) { _this3.defer(function () { var _params = _this3.params, position = _params.position, rotation = _params.rotation, scale = _params.scale, shadow = _params.shadow; _this3.position.set(position.x, position.y, position.z); _this3.rotation.set(rotation.x, rotation.y, rotation.z); _this3.scale.set(scale.x, scale.y, scale.z); _this3.native.castShadow = shadow.cast; _this3.native.receiveShadow = shadow.receive; _this3.applyBridge({ onWrap: 1 }); resolve(_this3); }); }); } // COPYING & CLONING }, { key: 'copy', value: function copy(source) { var _this4 = this; return _get(MeshComponent.prototype.__proto__ || Object.getPrototypeOf(MeshComponent.prototype), 'copy', this).call(this, source, function () { _this4.position.copy(source.position); _this4.rotation.copy(source.rotation); _this4.quaternion.copy(source.quaternion); }); } }, { key: 'clone', value: function clone(geometry, material) { var dest = new this.constructor({ build: false }).copy(this); if (geometry) dest.geometry = dest.geometry.clone(); if (material) dest.material = dest.material.clone(); return dest; } }]); return MeshComponent; }(__WEBPACK_IMPORTED_MODULE_1__Component__["a" /* Component */]), _class2.defaults = _extends({}, __WEBPACK_IMPORTED_MODULE_1__Component__["a" /* Component */].defaults, { build: true, geometry: {}, material: false, shadow: { cast: true, receive: true }, position: { x: 0, y: 0, z: 0 }, rotation: { x: 0, y: 0, z: 0 }, scale: { x: 1, y: 1, z: 1 } }), _class2.instructions = { position: ['x', 'y', 'z'], rotation: ['x', 'y', 'z'], scale: ['x', 'y', 'z'] }, _temp)) || _class); /***/ }), /* 2 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Component__ = __webpack_require__(5); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__prototype_attributes__ = __webpack_require__(9); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__errors__ = __webpack_require__(3); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return LightComponent; }); 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 _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; var _dec, _class, _class2, _temp; 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 LightComponent = (_dec = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__prototype_attributes__["a" /* attributes */])(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__prototype_attributes__["b" /* copy */])('position', 'rotation', 'quaternion', 'target')), _dec(_class = (_temp = _class2 = function (_Component) { _inherits(LightComponent, _Component); function LightComponent(params) { var defaults = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : LightComponent.defaults; var instructions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : LightComponent.instructions; _classCallCheck(this, LightComponent); var _this = _possibleConstructorReturn(this, (LightComponent.__proto__ || Object.getPrototypeOf(LightComponent)).call(this, params, defaults, instructions)); if (_this.params.build) { var build = _this.build(_this.params); if (!build) { throw new __WEBPACK_IMPORTED_MODULE_2__errors__["a" /* CompositionError */]('LightComponent', '.build() method should return a THREE.Object3D or a Promise resolved with THREE.Object3D.', _this); } if (build instanceof Promise) { build.then(function (native) { _this.native = native; }); } else _this.native = build; _this.wrap(); } return _this; } // BUILDING & WRAPPING _createClass(LightComponent, [{ key: 'build', value: function build() { throw new __WEBPACK_IMPORTED_MODULE_2__errors__["a" /* CompositionError */]('MeshComponent', 'Instance should have it\'s own .build().', this); } }, { key: 'wrap', value: function wrap() { var _this2 = this; return new Promise(function (resolve) { _this2.defer(function () { var _params = _this2.params, position = _params.position, rotation = _params.rotation; _this2.position.set(position.x, position.y, position.z); _this2.rotation.set(rotation.x, rotation.y, rotation.z); _this2.applyBridge({ onWrap: 1 }); resolve(_this2); }); }); } }, { key: 'wrapShadow', value: function wrapShadow() { var native = this.native, shadow = this.params.shadow; native.castShadow = shadow.cast; native.shadow.mapSize.width = shadow.mapSize.width; native.shadow.mapSize.height = shadow.mapSize.height; native.shadow.bias = shadow.bias; native.shadow.radius = shadow.radius; var shadowCamera = native.shadow.camera; var camera = shadow.camera; shadowCamera.near = camera.near; shadowCamera.far = camera.far; shadowCamera.fov = camera.fov; shadowCamera.left = camera.left; shadowCamera.right = camera.right; shadowCamera.top = camera.top; shadowCamera.bottom = camera.bottom; } // COPYING & CLONING }, { key: 'copy', value: function copy(source) { var _this3 = this; return _get(LightComponent.prototype.__proto__ || Object.getPrototypeOf(LightComponent.prototype), 'copy', this).call(this, source, function () { if (_this3.target) _this3.target.copy(source.target()); _this3.position.copy(source.position); _this3.rotation.copy(source.rotation); _this3.quaternion.copy(source.quaternion); }); } }, { key: 'clone', value: function clone() { return new this.constructor({ build: false }).copy(this); } }]); return LightComponent; }(__WEBPACK_IMPORTED_MODULE_0__Component__["a" /* Component */]), _class2.defaults = _extends({}, __WEBPACK_IMPORTED_MODULE_0__Component__["a" /* Component */].defaults, { build: true, shadow: { cast: true, bias: 0, radius: 1, mapSize: { width: 1024, height: 1024 }, camera: { near: true, far: 400, fov: 90, top: 200, bottom: -200, left: -200, right: 200 } }, position: { x: 0, y: 0, z: 0 }, rotation: { x: 0, y: 0, z: 0 } }), _class2.instructions = { position: ['x', 'y', 'z'], rotation: ['x', 'y', 'z'], scale: ['x', 'y', 'z'] }, _temp)) || _class); /***/ }), /* 3 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* WEBPACK VAR INJECTION */(function(process) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return CompositionError; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return DependencyError; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return ManagerError; }); 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 CompositionError = function (_Error) { _inherits(CompositionError, _Error); function CompositionError(classInstance, message, component) { _classCallCheck(this, CompositionError); var _this = _possibleConstructorReturn(this, (CompositionError.__proto__ || Object.getPrototypeOf(CompositionError)).call(this)); var stackArray = _this.stack.split('\n'); stackArray.splice(1, 2); _this.stack = stackArray.join('\n'); if (!process) console.error('Component:', component); _this.name = 'CompositionError'; _this.message = '@' + classInstance + ': ' + message; return _this; } return CompositionError; }(Error); var DependencyError = function (_Error2) { _inherits(DependencyError, _Error2); function DependencyError(classInstance, message, activeModule) { var dependencyModule = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; _classCallCheck(this, DependencyError); var _this2 = _possibleConstructorReturn(this, (DependencyError.__proto__ || Object.getPrototypeOf(DependencyError)).call(this)); var stackArray = _this2.stack.split('\n'); stackArray.splice(1, 2); _this2.stack = stackArray.join('\n'); if (!process) console.error('Active module:', activeModule); if (!process && dependencyModule) console.error('Dependency published by module:', dependencyModule); _this2.name = 'DependencyError'; _this2.message = '@' + classInstance + ': ' + message; return _this2; } return DependencyError; }(Error); var ManagerError = function (_Error3) { _inherits(ManagerError, _Error3); function ManagerError(classInstance, message, component) { var activeModule = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; _classCallCheck(this, ManagerError); var _this3 = _possibleConstructorReturn(this, (ManagerError.__proto__ || Object.getPrototypeOf(ManagerError)).call(this)); var stackArray = _this3.stack.split('\n'); stackArray.splice(1, 2); _this3.stack = stackArray.join('\n'); if (!process) console.error('Component:', dependencyModule); if (!process && activeModule) console.error('Active module:', activeModule); _this3.name = 'DependencyError'; _this3.message = '@' + classInstance + ': ' + message; return _this3; } return ManagerError; }(Error); /* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(85))) /***/ }), /* 4 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Pass; }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var Pass = function () { function Pass(name) { _classCallCheck(this, Pass); this.uniqName = name === undefined ? 'pass_' + ((1 + Math.random()) * 0x10000 | 0).toString(16).substring(1) : name; // if set to true, the pass is processed by the composer this.enabled = true; // if set to true, the pass indicates to swap read and write buffer after rendering this.needsSwap = true; // if set to true, the pass clears its buffer before rendering this.clear = false; // if set to true, the result of the pass is rendered to screen this.renderToScreen = false; } /** * Resize a pass. * @param {Number} width : in pixels. * @param {Number} height : in pixels. */ _createClass(Pass, [{ key: "setSize", value: function setSize(width, height) {} /** * Render a pass * @param {THREE.WebGLRenderer} renderer : The renderer used to render the pass objects. * @param {THREE.WebGLRenderTarget.Buffer} writeBuffer : The write buffer used to do buffer swapping. * @param {THREE.WebGLRenderTarget.Buffer} readBuffer : The read buffer used to do buffer swapping. * @param {Number} delta : The delta time since the previous frame. * @param {Boolean} maskActive : Flag indicating the Composer that this pass use masking. */ }, { key: "render", value: function render(renderer, writeBuffer, readBuffer, delta, maskActive) { console.error("Pass: .render() must be implemented in derived pass."); } /** * Get the name of the pass * @return {String} Unique name */ }, { key: "name", get: function get() { return this.uniqName; } }]); return Pass; }(); /***/ }), /* 5 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__utils_index__ = __webpack_require__(25); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__ModuleSystem__ = __webpack_require__(20); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__ModuleManager__ = __webpack_require__(8); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__errors__ = __webpack_require__(3); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Component; }); 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 _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _class, _temp; 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 Component = (_temp = _class = function (_ModuleSystem) { _inherits(Component, _ModuleSystem); // For keeping children components; // Collection of promises; function Component() { var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var defaults = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Component.defaults; var instructions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Component.instructions; _classCallCheck(this, Component); // Apply polyfilled parameters to .params; var _this = _possibleConstructorReturn(this, (Component.__proto__ || Object.getPrototypeOf(Component)).call(this)); _this._wait = []; _this.modules = []; _this.children = []; _this.params = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__utils_index__["a" /* extend */])(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__utils_index__["c" /* transformData */])(params, instructions), defaults); if (_this.params.manager) _this.manager = new __WEBPACK_IMPORTED_MODULE_2__ModuleManager__["a" /* ModuleManager */](); _this.modules = _this.params.modules; _this.integrateModules(); return _this; } // PROMISES (Asynchronous code) // FIXME: possible use of Promise.all(this._wait) only in .defer(); // Collection of modules; _createClass(Component, [{ key: 'wait', value: function wait(promise) { if (promise) this._wait.push(promise); return Promise.all(this._wait); } }, { key: 'defer', value: function defer(func) { var _this2 = this; if (this.isDeffered) this.wait().then(function () { return func(_this2); });else func(this); } // PARAMETERS }, { key: 'updateParams', value: function updateParams() { var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; this.params = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__utils_index__["a" /* extend */])(params, this.params); return this.params; } // COPYING & CLONING }, { key: 'clone', value: function clone() { return new this.constructor(this.params).copy(this); } }, { key: 'copy', value: function copy(source, customize) { this.params = _extends({}, source.params); if (source.native) this.native = source.native.clone(source.params); if (customize) customize(); this.integrateModules(source); return this; } // ADD }, { key: 'add', value: function add(object) { var _this3 = this; object.parent = this; return new Promise(function (resolve, reject) { _this3.defer(function () { var native = object.native; if (!native) reject(); var addPromise = _this3.applyBridge({ onAdd: object }).onAdd; var resolver = function resolver() { _this3.native.add(native); _this3.children.push(object); resolve(object); }; if (addPromise instanceof Promise) addPromise.then(resolver);else resolver(); }); }); } }, { key: 'remove', value: function remove(object) { object.parent = null; this.native.remove(object.native); } }, { key: 'addTo', value: function addTo(object) { return object.add(this); } // GETTERS & SETTERS }, { key: 'isDeffered', get: function get() { return this._wait.length > 0; } // .manager }, { key: 'manager', get: function get() { if (this._manager) return this._manager; throw new __WEBPACK_IMPORTED_MODULE_3__errors__["b" /* ManagerError */]('Component', 'ModuleManager is not used in this component. \'manager\' parameter should be set as \'true\'', this); }, set: function set(manager) { this._manager = manager; } // .native }, { key: 'native', get: function get() { return this._native; }, set: function set(mesh) { this._native = mesh; this._native.component = this; return this._native; } }]); return Component; }(__WEBPACK_IMPORTED_MODULE_1__ModuleSystem__["a" /* ModuleSystem */]), _class.defaults = { modules: [], manager: true }, _class.instructions = {}, _temp); /***/ }), /* 6 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Component__ = __webpack_require__(5); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__prototype_attributes__ = __webpack_require__(9); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__errors__ = __webpack_require__(3); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return CameraComponent; }); 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 _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; var _dec, _class, _class2, _temp; 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 CameraComponent = (_dec = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__prototype_attributes__["a" /* attributes */])(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__prototype_attributes__["b" /* copy */])('position', 'rotation', 'quaternion', 'target')), _dec(_class = (_temp = _class2 = function (_Component) { _inherits(CameraComponent, _Component); function CameraComponent(params) { var defaults = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : CameraComponent.defaults; var instructions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : CameraComponent.instructions; _classCallCheck(this, CameraComponent); var _this = _possibleConstructorReturn(this, (CameraComponent.__proto__ || Object.getPrototypeOf(CameraComponent)).call(this, params, defaults, instructions)); if (_this.params.build) { var build = _this.build(_this.params); if (!build) { throw new __WEBPACK_IMPORTED_MODULE_2__errors__["a" /* CompositionError */]('CameraComponent', '.build() method should return a THREE.Object3D or a Promise resolved with THREE.Object3D.', _this); } if (build instanceof Promise) { build.then(function (native) { _this.native = native; }); } else _this.native = build; _this.wrap(); } return _this; } // BUILDING & WRAPPING _createClass(CameraComponent, [{ key: 'build', value: function build() { throw new __WEBPACK_IMPORTED_MODULE_2__errors__["a" /* CompositionError */]('CameraComponent', 'Instance should have it\'s own .build().', this); } }, { key: 'wrap', value: function wrap() { var _this2 = this; return new Promise(function (resolve) { _this2.defer(function () { _this2.position.set(_this2.params.position.x, _this2.params.position.y, _this2.params.position.z); _this2.rotation.set(_this2.params.rotation.x, _this2.params.rotation.y, _this2.params.rotation.z); _this2.applyBridge({ onWrap: 1 }); resolve(_this2); }); }); } // COPYING & CLONING }, { key: 'copy', value: function copy(source) { var _this3 = this; return _get(CameraComponent.prototype.__proto__ || Object.getPrototypeOf(CameraComponent.prototype), 'copy', this).call(this, source, function () { if (_this3.target) _this3.target.copy(source.target()); _this3.position.copy(source.position); _this3.rotation.copy(source.rotation); _this3.quaternion.copy(source.quaternion); }); } }, { key: 'clone', value: function clone() { return new this.constructor({ build: false }).copy(this); } }]); return CameraComponent; }(__WEBPACK_IMPORTED_MODULE_0__Component__["a" /* Component */]), _class2.defaults = _extends({}, __WEBPACK_IMPORTED_MODULE_0__Component__["a" /* Component */].defaults, { build: true, position: { x: 0, y: 0, z: 0 }, rotation: { x: 0, y: 0, z: 0 } }), _class2.instructions = { position: ['x', 'y', 'z'], rotation: ['x', 'y', 'z'], scale: ['x', 'y', 'z'] }, _temp)) || _class); /***/ }), /* 7 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_three__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_three___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_three__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Loop; }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var Loop = function () { function Loop(func) { var useClock = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; _classCallCheck(this, Loop); this.func = func; this.clock = useClock ? new __WEBPACK_IMPORTED_MODULE_0_three__["Clock"]() : null; this.enabled = false; } // CONTROLS _createClass(Loop, [{ key: 'start', value: function start(world) { if (this.enabled) return; if (world) world.addLoop(this); if (this.clock) this.clock.start(); this.enabled = true; } }, { key: 'stop', value: function stop(world) { if (!this.enabled) return; if (this.clock) this.clock.stop(); this.enabled = false; if (world) world.removeLoop(this); } // EXECUTION }, { key: 'execute', value: function execute() { return this.func(this.clock); } }]); return Loop; }(); /***/ }), /* 8 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__errors__ = __webpack_require__(3); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ModuleManager; }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var ModuleManager = function () { function ModuleManager(object) { _classCallCheck(this, ModuleManager); this.handler = object; this.currentModule = null; this.store = {}; this.updateMap = {}; } // SETTING ACTIVE MODULE _createClass(ModuleManager, [{ key: 'active', value: function active(module) { this.currentModule = module; } }, { key: 'reset', value: function reset() { this.currentModule = null; } // DEPENDENCIES }, { key: 'update', value: function update() { var depsMap = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; for (var key in depsMap) { if (this.updateMap[key]) this.updateMap[key].push(depsMap[key]);else this.updateMap[key] = [depsMap[key]]; } } }, { key: 'add', value: function add(key, object) { var _this = this; var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; if (this.store[key] && this.store[key][2].immutable) { throw new __WEBPACK_IMPORTED_MODULE_0__errors__["c" /* DependencyError */]('ModuleManager', 'Dependency \'' + key + '\' is immutable and already used by another module', this.currentModule, this.store[key][1]); } this.store[key] = [object, this.currentModule, config]; if (config.alias) { Object.defineProperty(this.handler, config.alias, { get: function get() { return _this.store[key][0]; }, set: function set(value) { if (_this.store[key] && _this.store[key][2].immutable) { throw new __WEBPACK_IMPORTED_MODULE_0__errors__["c" /* DependencyError */]('ModuleManager', 'Dependency \'' + key + '\' is immutable and already used by another module', _this.currentModule, _this.store[key][1]); } _this.store[key][0] = value; if (_this.updateMap[key]) { for (var i = 0, max = _this.updateMap[key].length; i < max; i++) { _this.updateMap[key][i](value); } } }, enumerable: true, configurable: true }); } if (this.updateMap[key]) { for (var i = 0, max = this.updateMap[key].length; i < max; i++) { this.updateMap[key][i](object); } } } }, { key: 'remove', value: function remove(key) { this.store[key] = null; } }, { key: 'get', value: function get(key) { var getModule = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; if (!this.store[key]) { throw new __WEBPACK_IMPORTED_MODULE_0__errors__["c" /* DependencyError */]('ModuleManager', 'Module requires \'' + key + '\' dependency', this.currentModule); } return getModule ? this.store[key][1] : this.store[key][0]; } }, { key: 'has', value: function has(key) { return Boolean(this.store[key]); } // ALIAS METHODS }, { key: 'set', value: function set(key, value) { this.add(key, value, this.store[key][2] || {}); } }]); return ModuleManager; }(); /***/ }), /* 9 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (immutable) */ __webpack_exports__["a"] = attributes; /* harmony export (immutable) */ __webpack_exports__["b"] = copy; /* harmony export (immutable) */ __webpack_exports__["c"] = mirror; function attributes() { for (var _len = arguments.length, mappers = Array(_len), _key = 0; _key < _len; _key++) { mappers[_key] = arguments[_key]; } return function (target) { for (var i = 0; i < mappers.length; i++) { var mapper = mappers[i]; for (var k = 0; k < mapper.map.length; k++) { var attribute = mapper.map[k]; Object.defineProperty(target.prototype, attribute, { get: mapper.getter(attribute), set: mapper.setter(attribute), configurable: mapper.configurable, enumerable: mapper.enumerable }); } } }; } function copy() { for (var _len2 = arguments.length, map = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { map[_key2] = arguments[_key2]; } return { map: map, getter: function getter(name) { return function () { return this.native[name]; }; }, setter: function setter(name) { return function (value) { this.native[name].copy(value); }; }, configurable: true, enumerable: true }; } function mirror() { for (var _len3 = arguments.length, map = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { map[_key3] = arguments[_key3]; } return { map: map, getter: function getter(name) { return function () { return this.native[name]; }; }, setter: function setter(name) { return function (value) { this.native[name] = value; }; }, configurable: true, enumerable: true }; } /***/ }), /* 10 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return CopyShader; }); /** * @author alteredq / http://alteredqualia.com/ * * Full-screen textured quad shader */ var CopyShader = { uniforms: { tDiffuse: { value: null }, opacity: { value: 1.0 } }, vertexShader: "\n varying vec2 vUv;\n\n void main() {\n\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n", fragmentShader: "\n uniform float opacity;\n\n uniform sampler2D tDiffuse;\n\n varying vec2 vUv;\n\n void main() {\n\n vec4 texel = texture2D( tDiffuse, vUv );\n gl_FragColor = opacity * texel;\n\n }\n" }; /***/ }), /* 11 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__components_cameras_PerspectiveCamera__ = __webpack_require__(18); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return CameraModule; }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var CameraModule = function () { function CameraModule() { var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; _classCallCheck(this, CameraModule); this.params = Object.assign({ fov: 75, near: 1, far: 1000, position: { x: 0, y: 0, z: 0 } }, params); this.camera = new __WEBPACK_IMPORTED_MODULE_0__components_cameras_PerspectiveCamera__["a" /* PerspectiveCamera */]({ camera: { fov: this.params.fov, aspect: this.params.aspect, near: this.params.near, far: this.params.far }, modules: [], position: { x: this.params.position.x, y: this.params.position.y, z: this.params.position.z } }); } _createClass(CameraModule, [{ key: 'integrate', value: function integrate(self) { this.add(self.camera); } }, { key: 'manager', value: function manager(_manager) { _manager.add('camera', this.camera, { alias: '$camera' }); } }]); return CameraModule; }(); /***/ }), /* 12 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ElementModule; }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var ElementModule = function () { function ElementModule() { var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; _classCallCheck(this, ElementModule); this.params = Object.assign({ container: document.body }, params); this.element = window.document.createElement('div'); this.element.className = 'whs'; this.element.style.width = 'inherit'; this.element.style.height = 'inherit'; this.element.style.position = 'relative'; } _createClass(ElementModule, [{ key: 'manager', value: function manager(_manager) { _manager.add('element', this.element, { alias: '$element' }); _ma