UNPKG

react-three

Version:

Construct three.js scenes using React

1,560 lines (1,241 loc) 625 kB
module.exports = /******/ (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] = { /******/ exports: {}, /******/ id: moduleId, /******/ loaded: false /******/ }; /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ // Flag the module as loaded /******/ module.loaded = 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; /******/ // __webpack_public_path__ /******/ __webpack_require__.p = "/build/"; /******/ // Load entry module and return exports /******/ return __webpack_require__(0); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; var _reactDom = __webpack_require__(1); var _reactDom2 = _interopRequireDefault(_reactDom); var _ReactTHREEMonkeyPatch = __webpack_require__(2); var _ReactTHREEMonkeyPatch2 = _interopRequireDefault(_ReactTHREEMonkeyPatch); var _THREERenderer = __webpack_require__(35); var _THREERenderer2 = _interopRequireDefault(_THREERenderer); var _THREEScene = __webpack_require__(97); var _THREEScene2 = _interopRequireDefault(_THREEScene); var _THREEPerspectiveCamera = __webpack_require__(107); var _THREEPerspectiveCamera2 = _interopRequireDefault(_THREEPerspectiveCamera); var _THREEOrthographicCamera = __webpack_require__(108); var _THREEOrthographicCamera2 = _interopRequireDefault(_THREEOrthographicCamera); var _THREEAxisHelper = __webpack_require__(109); var _THREEAxisHelper2 = _interopRequireDefault(_THREEAxisHelper); var _THREELine = __webpack_require__(110); var _THREELine2 = _interopRequireDefault(_THREELine); var _THREELineSegments = __webpack_require__(111); var _THREELineSegments2 = _interopRequireDefault(_THREELineSegments); var _THREEPointCloud = __webpack_require__(112); var _THREEPointCloud2 = _interopRequireDefault(_THREEPointCloud); var _THREEObject3D = __webpack_require__(113); var _THREEObject3D2 = _interopRequireDefault(_THREEObject3D); var _THREEMesh = __webpack_require__(114); var _THREEMesh2 = _interopRequireDefault(_THREEMesh); var _THREESkinnedMesh = __webpack_require__(115); var _THREESkinnedMesh2 = _interopRequireDefault(_THREESkinnedMesh); var _THREESprite = __webpack_require__(116); var _THREESprite2 = _interopRequireDefault(_THREESprite); var _THREEAmbientLight = __webpack_require__(117); var _THREEAmbientLight2 = _interopRequireDefault(_THREEAmbientLight); var _THREEPointLight = __webpack_require__(119); var _THREEPointLight2 = _interopRequireDefault(_THREEPointLight); var _THREEAreaLight = __webpack_require__(120); var _THREEAreaLight2 = _interopRequireDefault(_THREEAreaLight); var _THREEDirectionalLight = __webpack_require__(121); var _THREEDirectionalLight2 = _interopRequireDefault(_THREEDirectionalLight); var _THREEHemisphereLight = __webpack_require__(123); var _THREEHemisphereLight2 = _interopRequireDefault(_THREEHemisphereLight); var _THREESpotLight = __webpack_require__(124); var _THREESpotLight2 = _interopRequireDefault(_THREESpotLight); var _THREEDecoratorHelper = __webpack_require__(125); var _THREEDecoratorHelper2 = _interopRequireDefault(_THREEDecoratorHelper); var _Constants = __webpack_require__(128); var _Constants2 = _interopRequireDefault(_Constants); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /* * Copyright (c) 2014 Gary Haussmann * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // // Lots of code here is based on react-art: https://github.com/facebook/react-art // (0, _ReactTHREEMonkeyPatch2.default)(); // monkey patch to workaround some assumptions that we're working with the DOM module.exports = { Renderer: _THREERenderer2.default, Scene: _THREEScene2.default, PerspectiveCamera: _THREEPerspectiveCamera2.default, OrthographicCamera: _THREEOrthographicCamera2.default, AxisHelper: _THREEAxisHelper2.default, Line: _THREELine2.default, LineSegments: _THREELineSegments2.default, PointCloud: _THREEPointCloud2.default, Object3D: _THREEObject3D2.default, Mesh: _THREEMesh2.default, SkinnedMesh: _THREESkinnedMesh2.default, Sprite: _THREESprite2.default, AmbientLight: _THREEAmbientLight2.default, PointLight: _THREEPointLight2.default, AreaLight: _THREEAreaLight2.default, DirectionalLight: _THREEDirectionalLight2.default, HemisphereLight: _THREEHemisphereLight2.default, SpotLight: _THREESpotLight2.default, Helper: _THREEDecoratorHelper2.default, Constants: _Constants2.default, render: _reactDom2.default.render, unmountComponentAtNode: _reactDom2.default.unmountComponentAtNode }; /***/ }, /* 1 */ /***/ function(module, exports) { module.exports = require("react-dom"); /***/ }, /* 2 */ /***/ function(module, exports, __webpack_require__) { // // time to monkey-patch React! // // a subtle bug happens when ReactCompositeComponent updates something in-place by // modifying HTML markup; since THREE objects don't exist as markup the whole thing bombs. // we try to fix this by monkey-patching ReactCompositeComponent // "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _getPrototypeOf = __webpack_require__(3); var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf); var _ReactCompositeComponent = __webpack_require__(29); var _ReactCompositeComponent2 = _interopRequireDefault(_ReactCompositeComponent); var _ReactReconciler = __webpack_require__(30); var _ReactReconciler2 = _interopRequireDefault(_ReactReconciler); var _shouldUpdateReactComponent = __webpack_require__(31); var _shouldUpdateReactComponent2 = _interopRequireDefault(_shouldUpdateReactComponent); var _warning = __webpack_require__(32); var _warning2 = _interopRequireDefault(_warning); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } // // Composite components don't have an Object3D. So we have to do some work to find // the proper Object3D sometimes. // function findObject3DChild(componentinstance) { // walk downwards via _renderedComponent to find something with a displayObject var componentwalker = componentinstance; while (typeof componentwalker !== 'undefined') { // no displayObject? then fail if (typeof componentwalker._THREEObject3D !== 'undefined') { return componentwalker._THREEObject3D; } componentwalker = componentwalker._renderedComponent; } // we walked all the way down and found no Object3D return undefined; } // // This modified version of updateRenderedComponent will // manage Object3D nodes instead of HTML markup // var old_updateRenderedComponent = _ReactCompositeComponent2.default._updateRenderedComponent; var ReactTHREE_updateRenderedComponent = function ReactTHREE_updateRenderedComponent(transaction, context) { var prevComponentInstance = this._renderedComponent; // Find the first actual rendered (non-Composite) component. // If that component is a THREE node we use the special code here. // If not, we call back to the original version of updateComponent // which should handle all non-THREE nodes. var prevObject3D = findObject3DChild(prevComponentInstance); if (!prevObject3D) { // not a THREE node, use the original DOM-style version old_updateRenderedComponent.call(this, transaction, context); return; } // This is a THREE node, do a special THREE version of updateComponent var prevRenderedElement = prevComponentInstance._currentElement; var nextRenderedElement = this._renderValidatedComponent(); if ((0, _shouldUpdateReactComponent2.default)(prevRenderedElement, nextRenderedElement)) { _ReactReconciler2.default.receiveComponent(prevComponentInstance, nextRenderedElement, transaction, this._processChildContext(context)); } else { // We can't just update the current component. // So we nuke the current instantiated component and put a new component in // the same place based on the new props. var thisID = this._rootNodeID; var object3DParent = prevObject3D.parent; // unmounting doesn't disconnect the child from the parent node, // but later on we'll simply overwrite the proper element in the 'children' data member var object3DIndex = object3DParent.children.indexOf(prevObject3D); _ReactReconciler2.default.unmountComponent(prevComponentInstance); // create the new object and stuff it into the place vacated by the old object this._renderedComponent = this._instantiateReactComponent(nextRenderedElement, this._currentElement.type); var nextObject3D = _ReactReconciler2.default.mountComponent(this._renderedComponent, thisID, transaction, this._processChildContext(context)); this._renderedComponent._THREEObject3D = nextObject3D; // fixup _mountImage as well this._mountImage = nextObject3D; // overwrite the old child object3DParent.children[object3DIndex] = nextObject3D; } }; // // This generates a patched version of ReactReconciler.receiveComponent to check the type of the // component and patch it if it's an unpatched version of ReactCompositeComponentWrapper // var buildPatchedReceiveComponent = function buildPatchedReceiveComponent(oldReceiveComponent) { var newReceiveComponent = function newReceiveComponent(internalInstance, nextElement, transaction, context) { // if the instance is a ReactCompositeComponentWrapper, fixed it if needed var ComponentPrototype = (0, _getPrototypeOf2.default)(internalInstance); // if this is a composite component it wil have _updateRenderedComponent defined if (typeof ComponentPrototype._updateRenderedComponent !== 'undefined') { // check first to make sure we don't patch it twice if (ComponentPrototype._updateRenderedComponent !== ReactTHREE_updateRenderedComponent) { ComponentPrototype._updateRenderedComponent = ReactTHREE_updateRenderedComponent; } } oldReceiveComponent.call(this, internalInstance, nextElement, transaction, context); }; return newReceiveComponent; }; var ReactTHREEMonkeyPatch = function ReactTHREEMonkeyPatch() { // in order version we patched ReactCompositeComponentMixin, but in 0.13 the // prototype is wrapped in a ReactCompositeComponentWrapper so monkey-patching // ReactCompositeComponentMixin won't actually have any effect. // // Really we want to patch ReactCompositeComponentWrapper but it's hidden inside // the instantiateReactComponent module. urgh. // // So what we have to do is patch ReactReconciler to detect the first time an // instance of ReactCompositeComponentWrapper is used, and patch it THEN // // urk. var old_ReactReconciler_receiveComponent = _ReactReconciler2.default.receiveComponent; // check to see if we already patched it, so we don't patch again if (typeof old_ReactReconciler_receiveComponent._ReactTHREEPatched === 'undefined') { (0, _warning2.default)(false, "patching react to work with react-three"); _ReactReconciler2.default.receiveComponent = buildPatchedReceiveComponent(old_ReactReconciler_receiveComponent); _ReactReconciler2.default.receiveComponent._ReactTHREEPatched = true; } }; exports.default = ReactTHREEMonkeyPatch; /***/ }, /* 3 */ /***/ function(module, exports, __webpack_require__) { module.exports = { "default": __webpack_require__(4), __esModule: true }; /***/ }, /* 4 */ /***/ function(module, exports, __webpack_require__) { __webpack_require__(5); module.exports = __webpack_require__(16).Object.getPrototypeOf; /***/ }, /* 5 */ /***/ function(module, exports, __webpack_require__) { // 19.1.2.9 Object.getPrototypeOf(O) var toObject = __webpack_require__(6) , $getPrototypeOf = __webpack_require__(8); __webpack_require__(14)('getPrototypeOf', function(){ return function getPrototypeOf(it){ return $getPrototypeOf(toObject(it)); }; }); /***/ }, /* 6 */ /***/ function(module, exports, __webpack_require__) { // 7.1.13 ToObject(argument) var defined = __webpack_require__(7); module.exports = function(it){ return Object(defined(it)); }; /***/ }, /* 7 */ /***/ function(module, exports) { // 7.2.1 RequireObjectCoercible(argument) module.exports = function(it){ if(it == undefined)throw TypeError("Can't call method on " + it); return it; }; /***/ }, /* 8 */ /***/ function(module, exports, __webpack_require__) { // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O) var has = __webpack_require__(9) , toObject = __webpack_require__(6) , IE_PROTO = __webpack_require__(10)('IE_PROTO') , ObjectProto = Object.prototype; module.exports = Object.getPrototypeOf || function(O){ O = toObject(O); if(has(O, IE_PROTO))return O[IE_PROTO]; if(typeof O.constructor == 'function' && O instanceof O.constructor){ return O.constructor.prototype; } return O instanceof Object ? ObjectProto : null; }; /***/ }, /* 9 */ /***/ function(module, exports) { var hasOwnProperty = {}.hasOwnProperty; module.exports = function(it, key){ return hasOwnProperty.call(it, key); }; /***/ }, /* 10 */ /***/ function(module, exports, __webpack_require__) { var shared = __webpack_require__(11)('keys') , uid = __webpack_require__(13); module.exports = function(key){ return shared[key] || (shared[key] = uid(key)); }; /***/ }, /* 11 */ /***/ function(module, exports, __webpack_require__) { var global = __webpack_require__(12) , SHARED = '__core-js_shared__' , store = global[SHARED] || (global[SHARED] = {}); module.exports = function(key){ return store[key] || (store[key] = {}); }; /***/ }, /* 12 */ /***/ function(module, exports) { // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 var global = module.exports = typeof window != 'undefined' && window.Math == Math ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')(); if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef /***/ }, /* 13 */ /***/ function(module, exports) { var id = 0 , px = Math.random(); module.exports = function(key){ return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); }; /***/ }, /* 14 */ /***/ function(module, exports, __webpack_require__) { // most Object methods by ES6 should accept primitives var $export = __webpack_require__(15) , core = __webpack_require__(16) , fails = __webpack_require__(25); module.exports = function(KEY, exec){ var fn = (core.Object || {})[KEY] || Object[KEY] , exp = {}; exp[KEY] = exec(fn); $export($export.S + $export.F * fails(function(){ fn(1); }), 'Object', exp); }; /***/ }, /* 15 */ /***/ function(module, exports, __webpack_require__) { var global = __webpack_require__(12) , core = __webpack_require__(16) , ctx = __webpack_require__(17) , hide = __webpack_require__(19) , PROTOTYPE = 'prototype'; var $export = function(type, name, source){ var IS_FORCED = type & $export.F , IS_GLOBAL = type & $export.G , IS_STATIC = type & $export.S , IS_PROTO = type & $export.P , IS_BIND = type & $export.B , IS_WRAP = type & $export.W , exports = IS_GLOBAL ? core : core[name] || (core[name] = {}) , expProto = exports[PROTOTYPE] , target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE] , key, own, out; if(IS_GLOBAL)source = name; for(key in source){ // contains in native own = !IS_FORCED && target && target[key] !== undefined; if(own && key in exports)continue; // export native or passed out = own ? target[key] : source[key]; // prevent global pollution for namespaces exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key] // bind timers to global for call from export context : IS_BIND && own ? ctx(out, global) // wrap global constructors for prevent change them in library : IS_WRAP && target[key] == out ? (function(C){ var F = function(a, b, c){ if(this instanceof C){ switch(arguments.length){ case 0: return new C; case 1: return new C(a); case 2: return new C(a, b); } return new C(a, b, c); } return C.apply(this, arguments); }; F[PROTOTYPE] = C[PROTOTYPE]; return F; // make static versions for prototype methods })(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out; // export proto methods to core.%CONSTRUCTOR%.methods.%NAME% if(IS_PROTO){ (exports.virtual || (exports.virtual = {}))[key] = out; // export proto methods to core.%CONSTRUCTOR%.prototype.%NAME% if(type & $export.R && expProto && !expProto[key])hide(expProto, key, out); } } }; // type bitmap $export.F = 1; // forced $export.G = 2; // global $export.S = 4; // static $export.P = 8; // proto $export.B = 16; // bind $export.W = 32; // wrap $export.U = 64; // safe $export.R = 128; // real proto method for `library` module.exports = $export; /***/ }, /* 16 */ /***/ function(module, exports) { var core = module.exports = {version: '2.4.0'}; if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef /***/ }, /* 17 */ /***/ function(module, exports, __webpack_require__) { // optional / simple context binding var aFunction = __webpack_require__(18); module.exports = function(fn, that, length){ aFunction(fn); if(that === undefined)return fn; switch(length){ case 1: return function(a){ return fn.call(that, a); }; case 2: return function(a, b){ return fn.call(that, a, b); }; case 3: return function(a, b, c){ return fn.call(that, a, b, c); }; } return function(/* ...args */){ return fn.apply(that, arguments); }; }; /***/ }, /* 18 */ /***/ function(module, exports) { module.exports = function(it){ if(typeof it != 'function')throw TypeError(it + ' is not a function!'); return it; }; /***/ }, /* 19 */ /***/ function(module, exports, __webpack_require__) { var dP = __webpack_require__(20) , createDesc = __webpack_require__(28); module.exports = __webpack_require__(24) ? function(object, key, value){ return dP.f(object, key, createDesc(1, value)); } : function(object, key, value){ object[key] = value; return object; }; /***/ }, /* 20 */ /***/ function(module, exports, __webpack_require__) { var anObject = __webpack_require__(21) , IE8_DOM_DEFINE = __webpack_require__(23) , toPrimitive = __webpack_require__(27) , dP = Object.defineProperty; exports.f = __webpack_require__(24) ? Object.defineProperty : function defineProperty(O, P, Attributes){ anObject(O); P = toPrimitive(P, true); anObject(Attributes); if(IE8_DOM_DEFINE)try { return dP(O, P, Attributes); } catch(e){ /* empty */ } if('get' in Attributes || 'set' in Attributes)throw TypeError('Accessors not supported!'); if('value' in Attributes)O[P] = Attributes.value; return O; }; /***/ }, /* 21 */ /***/ function(module, exports, __webpack_require__) { var isObject = __webpack_require__(22); module.exports = function(it){ if(!isObject(it))throw TypeError(it + ' is not an object!'); return it; }; /***/ }, /* 22 */ /***/ function(module, exports) { module.exports = function(it){ return typeof it === 'object' ? it !== null : typeof it === 'function'; }; /***/ }, /* 23 */ /***/ function(module, exports, __webpack_require__) { module.exports = !__webpack_require__(24) && !__webpack_require__(25)(function(){ return Object.defineProperty(__webpack_require__(26)('div'), 'a', {get: function(){ return 7; }}).a != 7; }); /***/ }, /* 24 */ /***/ function(module, exports, __webpack_require__) { // Thank's IE8 for his funny defineProperty module.exports = !__webpack_require__(25)(function(){ return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7; }); /***/ }, /* 25 */ /***/ function(module, exports) { module.exports = function(exec){ try { return !!exec(); } catch(e){ return true; } }; /***/ }, /* 26 */ /***/ function(module, exports, __webpack_require__) { var isObject = __webpack_require__(22) , document = __webpack_require__(12).document // in old IE typeof document.createElement is 'object' , is = isObject(document) && isObject(document.createElement); module.exports = function(it){ return is ? document.createElement(it) : {}; }; /***/ }, /* 27 */ /***/ function(module, exports, __webpack_require__) { // 7.1.1 ToPrimitive(input [, PreferredType]) var isObject = __webpack_require__(22); // instead of the ES6 spec version, we didn't implement @@toPrimitive case // and the second argument - flag - preferred type is a string module.exports = function(it, S){ if(!isObject(it))return it; var fn, val; if(S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val; if(typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it)))return val; if(!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val; throw TypeError("Can't convert object to primitive value"); }; /***/ }, /* 28 */ /***/ function(module, exports) { module.exports = function(bitmap, value){ return { enumerable : !(bitmap & 1), configurable: !(bitmap & 2), writable : !(bitmap & 4), value : value }; }; /***/ }, /* 29 */ /***/ function(module, exports) { module.exports = require("react-dom/lib/ReactCompositeComponent"); /***/ }, /* 30 */ /***/ function(module, exports) { module.exports = require("react-dom/lib/ReactReconciler"); /***/ }, /* 31 */ /***/ function(module, exports) { module.exports = require("react-dom/lib/shouldUpdateReactComponent"); /***/ }, /* 32 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {/** * Copyright 2014-2015, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * */ 'use strict'; var emptyFunction = __webpack_require__(34); /** * Similar to invariant but only logs a warning if the condition is not met. * This can be used to log issues in development environments in critical * paths. Removing the logging code for production environments will keep the * same logic and follow the same code paths. */ var warning = emptyFunction; if (process.env.NODE_ENV !== 'production') { (function () { var printWarning = function printWarning(format) { for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { args[_key - 1] = arguments[_key]; } var argIndex = 0; var message = 'Warning: ' + format.replace(/%s/g, function () { return args[argIndex++]; }); if (typeof console !== 'undefined') { console.error(message); } try { // --- Welcome to debugging React --- // This error was thrown as a convenience so that you can use this stack // to find the callsite that caused this warning to fire. throw new Error(message); } catch (x) {} }; warning = function warning(condition, format) { if (format === undefined) { throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument'); } if (format.indexOf('Failed Composite propType: ') === 0) { return; // Ignore CompositeComponent proptype check. } if (!condition) { for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { args[_key2 - 2] = arguments[_key2]; } printWarning.apply(undefined, [format].concat(args)); } }; })(); } module.exports = warning; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(33))) /***/ }, /* 33 */ /***/ function(module, exports) { // shim for using process in browser var process = module.exports = {}; // cached from whatever global is present so that test runners that stub it // don't break things. But we need to wrap it in a try catch in case it is // wrapped in strict mode code which doesn't define any globals. It's inside a // function because try/catches deoptimize in certain engines. var cachedSetTimeout; var cachedClearTimeout; function defaultSetTimout() { throw new Error('setTimeout has not been defined'); } function defaultClearTimeout () { throw new Error('clearTimeout has not been defined'); } (function () { try { if (typeof setTimeout === 'function') { cachedSetTimeout = setTimeout; } else { cachedSetTimeout = defaultSetTimout; } } catch (e) { cachedSetTimeout = defaultSetTimout; } try { if (typeof clearTimeout === 'function') { cachedClearTimeout = clearTimeout; } else { cachedClearTimeout = defaultClearTimeout; } } catch (e) { cachedClearTimeout = defaultClearTimeout; } } ()) function runTimeout(fun) { if (cachedSetTimeout === setTimeout) { //normal enviroments in sane situations return setTimeout(fun, 0); } // if setTimeout wasn't available but was latter defined if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { cachedSetTimeout = setTimeout; return setTimeout(fun, 0); } try { // when when somebody has screwed with setTimeout but no I.E. maddness return cachedSetTimeout(fun, 0); } catch(e){ try { // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally return cachedSetTimeout.call(null, fun, 0); } catch(e){ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error return cachedSetTimeout.call(this, fun, 0); } } } function runClearTimeout(marker) { if (cachedClearTimeout === clearTimeout) { //normal enviroments in sane situations return clearTimeout(marker); } // if clearTimeout wasn't available but was latter defined if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { cachedClearTimeout = clearTimeout; return clearTimeout(marker); } try { // when when somebody has screwed with setTimeout but no I.E. maddness return cachedClearTimeout(marker); } catch (e){ try { // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally return cachedClearTimeout.call(null, marker); } catch (e){ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. // Some versions of I.E. have different rules for clearTimeout vs setTimeout return cachedClearTimeout.call(this, marker); } } } var queue = []; var draining = false; var currentQueue; var queueIndex = -1; function cleanUpNextTick() { if (!draining || !currentQueue) { return; } draining = false; if (currentQueue.length) { queue = currentQueue.concat(queue); } else { queueIndex = -1; } if (queue.length) { drainQueue(); } } function drainQueue() { if (draining) { return; } var timeout = runTimeout(cleanUpNextTick); draining = true; var len = queue.length; while(len) { currentQueue = queue; queue = []; while (++queueIndex < len) { if (currentQueue) { currentQueue[queueIndex].run(); } } queueIndex = -1; len = queue.length; } currentQueue = null; draining = false; runClearTimeout(timeout); } process.nextTick = function (fun) { var args = new Array(arguments.length - 1); if (arguments.length > 1) { for (var i = 1; i < arguments.length; i++) { args[i - 1] = arguments[i]; } } queue.push(new Item(fun, args)); if (queue.length === 1 && !draining) { runTimeout(drainQueue); } }; // v8 likes predictible objects function Item(fun, array) { this.fun = fun; this.array = array; } Item.prototype.run = function () { this.fun.apply(null, this.array); }; process.title = 'browser'; process.browser = true; process.env = {}; process.argv = []; process.version = ''; // empty string to avoid regexp issues process.versions = {}; function noop() {} process.on = noop; process.addListener = noop; process.once = noop; process.off = noop; process.removeListener = noop; process.removeAllListeners = noop; process.emit = noop; process.binding = function (name) { throw new Error('process.binding is not supported'); }; process.cwd = function () { return '/' }; process.chdir = function (dir) { throw new Error('process.chdir is not supported'); }; process.umask = function() { return 0; }; /***/ }, /* 34 */ /***/ function(module, exports) { "use strict"; /** * Copyright (c) 2013-present, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * * */ function makeEmptyFunction(arg) { return function () { return arg; }; } /** * This function accepts and discards inputs; it has no side effects. This is * primarily useful idiomatically for overridable function endpoints which * always need to be callable, since JS lacks a null-call idiom ala Cocoa. */ var emptyFunction = function emptyFunction() {}; emptyFunction.thatReturns = makeEmptyFunction; emptyFunction.thatReturnsFalse = makeEmptyFunction(false); emptyFunction.thatReturnsTrue = makeEmptyFunction(true); emptyFunction.thatReturnsNull = makeEmptyFunction(null); emptyFunction.thatReturnsThis = function () { return this; }; emptyFunction.thatReturnsArgument = function (arg) { return arg; }; module.exports = emptyFunction; /***/ }, /* 35 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _keys = __webpack_require__(36); var _keys2 = _interopRequireDefault(_keys); var _typeof2 = __webpack_require__(49); var _typeof3 = _interopRequireDefault(_typeof2); var _extends2 = __webpack_require__(85); var _extends3 = _interopRequireDefault(_extends2); var _react = __webpack_require__(90); var _react2 = _interopRequireDefault(_react); var _reactDom = __webpack_require__(1); var _reactDom2 = _interopRequireDefault(_reactDom); var _ReactUpdates = __webpack_require__(91); var _ReactUpdates2 = _interopRequireDefault(_ReactUpdates); var _warning = __webpack_require__(32); var _warning2 = _interopRequireDefault(_warning); var _three = __webpack_require__(92); var THREE = _interopRequireWildcard(_three); var _THREEContainerMixin = __webpack_require__(93); var _THREEContainerMixin2 = _interopRequireDefault(_THREEContainerMixin); var _EventPluginHub = __webpack_require__(96); var _EventPluginHub2 = _interopRequireDefault(_EventPluginHub); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } // // The 'Scene' component includes both the three.js scene and // the canvas DOM element that three.js renders onto. // var THREERenderer = _react2.default.createClass({ displayName: 'THREERenderer', mixins: [_THREEContainerMixin2.default], propTypes: { enableRapidRender: _react2.default.PropTypes.bool, pixelRatio: _react2.default.PropTypes.number, pointerEvents: _react2.default.PropTypes.arrayOf(_react2.default.PropTypes.string), transparent: _react2.default.PropTypes.bool, disableHotLoader: _react2.default.PropTypes.bool, customRender: _react2.default.PropTypes.func, style: _react2.default.PropTypes.object }, getDefaultProps: function getDefaultProps() { return { enableRapidRender: true, pixelRatio: 1, transparent: false, disableHotLoader: false, style: {}, rendererProps: {} }; }, componentDidMount: function componentDidMount() { var _this = this; var renderelement = this.props.canvas || _reactDom2.default.findDOMNode(this); var props = this.props; var context = this._reactInternalInstance._context; // manually mounting things in a 'createClass' component messes up react internals // need to fix up some fields this._rootNodeID = ""; this._customRender = this.props.customRender; this._THREErenderer = new THREE.WebGLRenderer((0, _extends3.default)({ alpha: this.props.transparent, canvas: renderelement, antialias: props.antialias === undefined ? true : props.antialias }, this.props.rendererProps)); this._THREErenderer.shadowMap.enabled = props.shadowMapEnabled !== undefined ? props.shadowMapEnabled : false; if (props.shadowMapType !== undefined) { this._THREErenderer.shadowMap.type = props.shadowMapType; } this._THREErenderer.setPixelRatio(props.pixelRatio); this._THREErenderer.setSize(+props.width, +props.height); this._debugID = this._reactInternalInstance._debugID; var transaction = _ReactUpdates2.default.ReactReconcileTransaction.getPooled(); transaction.perform(this.mountAndAddChildren, this, props.children, transaction, context); _ReactUpdates2.default.ReactReconcileTransaction.release(transaction); // THREEScene binds the pointer events and orbit camera but needs a canvas/DOM element to bind to. // The canvas is stored in the renderer, though, so we have to get the canvas here in the renderer and // then bind pointer events/orbit controls in child scenes var renderedComponent = this._reactInternalInstance._renderedComponent; var renderedChildren = this._renderedChildren; if (renderedChildren) { for (var childkey in renderedChildren) { if (renderedChildren.hasOwnProperty(childkey)) { var child = renderedChildren[childkey]; child.bindOrbitControls(renderedComponent, renderelement, child._currentElement.props); child.bindPointerEvents(renderedComponent, renderelement, child._currentElement.props); } } } // hack for react-hot-loader if (!this.props.disableHotLoader && renderedComponent._currentElement !== null) { renderedComponent._renderedChildren = this._renderedChildren; } var backgroundtype = (0, _typeof3.default)(props.background); if (backgroundtype !== 'undefined') { // background color should be a number, check it (0, _warning2.default)(backgroundtype === 'number', "The background property of " + "the Renderer component must be a number, not " + backgroundtype); this._THREErenderer.setClearColor(props.background, this.props.transparent ? 0 : 1); } this.renderScene(); // The canvas gets re-rendered every frame even if no props/state changed. // This is because some three.js items like skinned meshes need redrawing // every frame even if nothing changed in React props/state. // // See https://github.com/Izzimach/react-three/issues/28 if (this.props.enableRapidRender) { (function () { var rapidrender = function rapidrender(timestamp) { _this._timestamp = timestamp; if (typeof _this._rAFID !== 'undefined') { _this._rAFID = window.requestAnimationFrame(rapidrender); } // render the stage _this.renderScene(); }; _this._rAFID = window.requestAnimationFrame(rapidrender); })(); } // warn users of the old listenToClick prop (0, _warning2.default)(typeof props.listenToClick === 'undefined', "the `listenToClick` prop has been replaced with `pointerEvents`"); renderelement.onselectstart = function () { return false; }; }, componentDidUpdate: function componentDidUpdate(oldProps) { var props = this.props; var context = this._reactInternalInstance._context; if (props.pixelRatio !== oldProps.pixelRatio) { this._THREErenderer.setPixelRatio(props.pixelRatio); } if (props.width !== oldProps.width || props.height !== oldProps.height || props.pixelRatio !== oldProps.pixelRatio) { this._THREErenderer.setSize(+props.width, +props.height); } var backgroundtype = (0, _typeof3.default)(props.background); if (backgroundtype !== 'undefined') { // background color should be a number, check it (0, _warning2.default)(backgroundtype === 'number', "The background property of " + "the scene component must be a number, not " + backgroundtype); this._THREErenderer.setClearColor(props.background, this.props.transparent ? 0 : 1); } var transaction = _ReactUpdates2.default.ReactReconcileTransaction.getPooled(); transaction.perform(this.updateChildren, this, this.props.children, transaction, context); _ReactUpdates2.default.ReactReconcileTransaction.release(transaction); // hack for react-hot-loader var renderedComponent = this._reactInternalInstance._renderedComponent; if (!this.props.disableHotLoader && renderedComponent._currentElement !== null) { renderedComponent._renderedChildren = this._renderedChildren; } this.renderScene(); }, componentWillUnmount: function componentWillUnmount() { // hack for react-hot-loader var renderedComponent = this._reactInternalInstance._renderedComponent; if (!this.props.disableHotLoader && renderedComponent._currentElement !== null) { renderedComponent._renderedChildren = null; } _EventPluginHub2.default.deleteAllListeners(this._reactInternalInstance); if (typeof this._rAFID !== 'undefined') { window.cancelAnimationFrame(this._rAFID); delete this._rAFID; } }, renderScene: function renderScene() { var _this2 = this; if (!this.props.children) return; var children = this._renderedChildren; this._THREErenderer.autoClear = false; this._THREErenderer.clear(); (0, _keys2.default)(children).forEach(function (key) { var scene = children[key]; if (scene._THREEObject3D && scene._THREEMetaData.camera !== null) { if (_this2._customRender) { _this2._customRender(_this2._THREErenderer, scene._THREEObject3D, scene._THREEMetaData.camera); } else { _this2._THREErenderer.render(scene._THREEObject3D, scene._THREEMetaData.camera); } } }); }, render: function render() { if (this.props.canvas) return null; // the three.js renderer will get applied to this canvas element return _react2.default.createElement("canvas", { style: this.props.style }); } }); exports.default = THREERenderer; /***/ }, /* 36 */ /***/ function(module, exports, __webpack_require__) { module.exports = { "default": __webpack_require__(37), __esModule: true }; /***/ }, /* 37 */ /***/ function(module, exports, __webpack_require__) { __webpack_require__(38); module.exports = __webpack_require__(16).Object.keys; /***/ }, /* 38 */ /***/ function(module, exports, __webpack_require__) { // 19.1.2.14 Object.keys(O) var toObject = __webpack_require__(6) , $keys = __webpack_require__(39); __webpack_require__(14)('keys', function(){ return function keys(it){ return $keys(toObject(it)); }; }); /***/ }, /* 39 */ /***/ function(module, exports, __webpack_require__) { // 19.1.2.14 / 15.2.3.14 Object.keys(O) var $keys = __webpack_require__(40) , enumBugKeys = __webpack_require__(48); module.exports = Object.keys || function keys(O){ return $keys(O, enumBugKeys); }; /***/ }, /* 40 */ /***/ function(module, exports, __webpack_require__) { var has = __webpack_require__(9) , toIObject = __webpack_require__(41) , arrayIndexOf = __webpack_require__(44)(false) , IE_PROTO = __webpack_require__(10)('IE_PROTO'); module.exports = function(object, names){ var O = toIObject(object) , i = 0 , result = [] , key; for(key in O)if(key != IE_PROTO)has(O, key) && result.push(key); // Don't enum bug & hidden keys while(names.length > i)if(has(O, key = names[i++])){ ~arrayIndexOf(result, key) || result.push(key); } return result; }; /***/ }, /* 41 */ /***/ function(module, exports, __webpack_require__) { // to indexed object, toObject with fallback for non-array-like ES3 strings var IObject = __webpack_require__(42) , defined = __webpack_require__(7); module.exports = function(it){ return IObject(defined(it)); }; /***/ }, /* 42 */ /***/ function(module, exports, __webpack_require__) { // fallback for non-array-like ES3 and non-enumerable old V8 strings var cof = __webpack_require__(43); module.exports = Object('z').propertyIsEnumerable(0) ? Object : function(it){ return cof(it) == 'String' ? it.split('') : Object(it); }; /***/ }, /* 43 */ /***/ function(module, exports) { var toString = {}.toString; module.exports = function(it){ return toString.call(it).slice(8, -1); }; /***/ }, /* 44 */ /***/ function(module, exports, __webpack_require__) { // false -> Array#indexOf // true -> Array#includes var toIObject = __webpack_require__(41) , toLength = __webpack_require__(45) , toIndex = __webpack_require__(47); module.exports = function(IS_INCLUDES){ return function($this, el, fromIndex){ var O = toIObject($this) , length = toLength(O.length) , index = toIndex(fromIndex, length) , value; // Array#includes uses SameValueZero equality algorithm if(IS_INCLUDES && el != el)while(length > index){ value = O[index++]; if(value != value)return true; // Array#toIndex ignores holes, Array#includes - not } else for(;length > index; index++)if(IS_INCLUDES || index in O){ if(O[index] === el)return IS_INCLUDES || index || 0; } return !IS_INCLUDES && -1; }; }; /***/ }, /* 45 */ /***/ function(module, exports, __webpack_require__) { // 7.1.15 ToLength var toInteger = __webpack_require__(46) , min = Math.min; module.exports = function(it){ return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 }; /***/ }, /* 46 */ /***/ function(module, exports) { // 7.1.4 ToInteger var ceil = Math.ceil , floor = Math.floor; module.exports = function(it){ return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); }; /***/ }, /* 47 */ /***/ function(module, exports, __webpack_require__) { var toInteger = __webpack_require__(46) , max = Math.max , min = Math.min; module.exports = function(index, length){ index = toInteger(index); return index < 0 ? max(index + length, 0) : min(index, length); }; /***/ }, /* 48 */ /***/ function(module, exports) { // IE 8- don't enum bug keys module.exports = ( 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf' ).split(','); /***/ }, /* 49 */ /***/ function(module, exports, __webpack_require__) { "use strict"; exports.__esModule = true; var _iterator = __webpack_require__(50); var _iterator2 = _interopRequireDefault(_iterator); var _symbol = __webpack_require__(69); var _symbol2 = _interopRequireDefault(_symbol); var _typeof = typeof _symbol2.default === "function" && typeof _iterator2.default === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj; }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } exports.default = typeof _symbol2.default === "function" && _typeof(_iterator2.default) === "symbol" ? function (obj) { return typeof obj === "undefined" ? "undefined" : _typeof(obj); } : function (obj) { return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof(obj); }; /***/ }, /* 50 */ /***/ function(module, exports, __webpack_require__) { module.exports = { "default": __webpack_require__(51), __esModule: true }; /***/ }, /* 51 */ /***/ function(module, exports, __webpack_require__) { __webpack_require__(52); __webpack_require__(64); module.exports = __webpack_require__(68).f('iterator'); /***/ }, /* 52 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; var $at = __webpack_require__(53)(true); // 21.1.3.27 String.prototype[@@iterator]() __webpack_require__(54)(String, 'String', function(iterated){ this._t = String(iterated); // target this._i = 0; // next index // 21.1.5.2.1 %StringIteratorPrototype%.next() }, function(){ var O = this._t , index = this._i , point; if(index >= O.length)return {value: undefined, done: true}; point = $at(O, index); this._i += point.length; return {value: point, done: false}; }); /***/ }, /* 53 */ /***/ function(module, exports, __webpack_require__) { var toInteger = __webpack_require__(46) , defined = __webpack_require__(7); // true -> String#at // false -> String#codePointAt module.exports = function(TO_STRING){ return function(that, pos){ var s = String(defined(that)) , i = toInteger(pos) , l = s.length , a, b; if(i < 0 || i >= l)return TO_STRING ? '' : undefined; a = s.charCodeAt(i); return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff ? TO_STRING ? s.charAt(i) : a : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000; }; }; /***/ }, /* 54 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; var LIBRARY = __webpack_require__(55) , $export = __webpack_require__(15) , redefine = __webpack_require__(56) , hide = __webpack_require__(19) , has = __webpack_require__(9) , Iterators = __webpack_require__(57) , $iterCreate = __webpack_require__(58) , setToStringTag = __webpack_require__(62) , getPrototypeOf = __webpack_require__(8) , ITERATOR = __webpack_require__(63)('iterator') , BUGGY = !([].keys && 'next' in [].keys()) // Safari has buggy iterators w/o `next` , FF_ITERATOR = '@@iterator' , KEYS = 'keys' , VALUES = 'values'; var returnThis = function(){ return this; }; module.exports = function(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED){ $iterCreate(Constructor, NAME, next); var getMethod = function(kind){ if(!BUGGY && kind in proto)return proto[kind]; switch(kind){ case KEYS: return function keys(){ return new Constructor(this, kind); }; case VALUES: return function values(){ return new Constructor(this, kind); }; } return function entries(){ return new Constructor(this, kind); };