three-render-objects 1.27.8 → 1.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -18,11 +18,7 @@ All the renderer/scene/camera scaffolding is already included and any instance o
18
18
  ```js
19
19
  import ThreeRenderObjects from 'three-render-objects';
20
20
  ```
21
- or
22
- ```js
23
- const ThreeRenderObjects = require('three-render-objects');
24
- ```
25
- or even
21
+ or using a *script* tag
26
22
  ```html
27
23
  <script src="//unpkg.com/three-render-objects"></script>
28
24
  ```
@@ -1,4 +1,4 @@
1
- // Version 1.27.8 three-render-objects - https://github.com/vasturiano/three-render-objects
1
+ // Version 1.28.0 three-render-objects - https://github.com/vasturiano/three-render-objects
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('three')) :
4
4
  typeof define === 'function' && define.amd ? define(['three'], factory) :
@@ -63,7 +63,7 @@
63
63
  }
64
64
  }
65
65
  function _defineProperty(obj, key, value) {
66
- key = _toPropertyKey(key);
66
+ key = _toPropertyKey$1(key);
67
67
  if (key in obj) {
68
68
  Object.defineProperty(obj, key, {
69
69
  value: value,
@@ -110,7 +110,7 @@
110
110
  function _nonIterableRest$1() {
111
111
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
112
112
  }
113
- function _toPrimitive(input, hint) {
113
+ function _toPrimitive$1(input, hint) {
114
114
  if (typeof input !== "object" || input === null) return input;
115
115
  var prim = input[Symbol.toPrimitive];
116
116
  if (prim !== undefined) {
@@ -120,8 +120,8 @@
120
120
  }
121
121
  return (hint === "string" ? String : Number)(input);
122
122
  }
123
- function _toPropertyKey(arg) {
124
- var key = _toPrimitive(arg, "string");
123
+ function _toPropertyKey$1(arg) {
124
+ var key = _toPrimitive$1(arg, "string");
125
125
  return typeof key === "symbol" ? key : String(key);
126
126
  }
127
127
 
@@ -4666,22 +4666,47 @@
4666
4666
 
4667
4667
  var debounce_1 = debounce;
4668
4668
 
4669
+ function _iterableToArrayLimit(arr, i) {
4670
+ var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
4671
+ if (null != _i) {
4672
+ var _s,
4673
+ _e,
4674
+ _x,
4675
+ _r,
4676
+ _arr = [],
4677
+ _n = !0,
4678
+ _d = !1;
4679
+ try {
4680
+ if (_x = (_i = _i.call(arr)).next, 0 === i) {
4681
+ if (Object(_i) !== _i) return;
4682
+ _n = !1;
4683
+ } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
4684
+ } catch (err) {
4685
+ _d = !0, _e = err;
4686
+ } finally {
4687
+ try {
4688
+ if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
4689
+ } finally {
4690
+ if (_d) throw _e;
4691
+ }
4692
+ }
4693
+ return _arr;
4694
+ }
4695
+ }
4669
4696
  function _classCallCheck(instance, Constructor) {
4670
4697
  if (!(instance instanceof Constructor)) {
4671
4698
  throw new TypeError("Cannot call a class as a function");
4672
4699
  }
4673
4700
  }
4674
-
4675
4701
  function _defineProperties(target, props) {
4676
4702
  for (var i = 0; i < props.length; i++) {
4677
4703
  var descriptor = props[i];
4678
4704
  descriptor.enumerable = descriptor.enumerable || false;
4679
4705
  descriptor.configurable = true;
4680
4706
  if ("value" in descriptor) descriptor.writable = true;
4681
- Object.defineProperty(target, descriptor.key, descriptor);
4707
+ Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
4682
4708
  }
4683
4709
  }
4684
-
4685
4710
  function _createClass(Constructor, protoProps, staticProps) {
4686
4711
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
4687
4712
  if (staticProps) _defineProperties(Constructor, staticProps);
@@ -4690,45 +4715,12 @@
4690
4715
  });
4691
4716
  return Constructor;
4692
4717
  }
4693
-
4694
4718
  function _slicedToArray(arr, i) {
4695
4719
  return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
4696
4720
  }
4697
-
4698
4721
  function _arrayWithHoles(arr) {
4699
4722
  if (Array.isArray(arr)) return arr;
4700
4723
  }
4701
-
4702
- function _iterableToArrayLimit(arr, i) {
4703
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
4704
-
4705
- if (_i == null) return;
4706
- var _arr = [];
4707
- var _n = true;
4708
- var _d = false;
4709
-
4710
- var _s, _e;
4711
-
4712
- try {
4713
- for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
4714
- _arr.push(_s.value);
4715
-
4716
- if (i && _arr.length === i) break;
4717
- }
4718
- } catch (err) {
4719
- _d = true;
4720
- _e = err;
4721
- } finally {
4722
- try {
4723
- if (!_n && _i["return"] != null) _i["return"]();
4724
- } finally {
4725
- if (_d) throw _e;
4726
- }
4727
- }
4728
-
4729
- return _arr;
4730
- }
4731
-
4732
4724
  function _unsupportedIterableToArray(o, minLen) {
4733
4725
  if (!o) return;
4734
4726
  if (typeof o === "string") return _arrayLikeToArray(o, minLen);
@@ -4737,50 +4729,57 @@
4737
4729
  if (n === "Map" || n === "Set") return Array.from(o);
4738
4730
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
4739
4731
  }
4740
-
4741
4732
  function _arrayLikeToArray(arr, len) {
4742
4733
  if (len == null || len > arr.length) len = arr.length;
4743
-
4744
4734
  for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
4745
-
4746
4735
  return arr2;
4747
4736
  }
4748
-
4749
4737
  function _nonIterableRest() {
4750
4738
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
4751
4739
  }
4740
+ function _toPrimitive(input, hint) {
4741
+ if (typeof input !== "object" || input === null) return input;
4742
+ var prim = input[Symbol.toPrimitive];
4743
+ if (prim !== undefined) {
4744
+ var res = prim.call(input, hint || "default");
4745
+ if (typeof res !== "object") return res;
4746
+ throw new TypeError("@@toPrimitive must return a primitive value.");
4747
+ }
4748
+ return (hint === "string" ? String : Number)(input);
4749
+ }
4750
+ function _toPropertyKey(arg) {
4751
+ var key = _toPrimitive(arg, "string");
4752
+ return typeof key === "symbol" ? key : String(key);
4753
+ }
4752
4754
 
4753
4755
  var Prop = /*#__PURE__*/_createClass(function Prop(name, _ref) {
4754
4756
  var _ref$default = _ref["default"],
4755
- defaultVal = _ref$default === void 0 ? null : _ref$default,
4756
- _ref$triggerUpdate = _ref.triggerUpdate,
4757
- triggerUpdate = _ref$triggerUpdate === void 0 ? true : _ref$triggerUpdate,
4758
- _ref$onChange = _ref.onChange,
4759
- onChange = _ref$onChange === void 0 ? function (newVal, state) {} : _ref$onChange;
4760
-
4757
+ defaultVal = _ref$default === void 0 ? null : _ref$default,
4758
+ _ref$triggerUpdate = _ref.triggerUpdate,
4759
+ triggerUpdate = _ref$triggerUpdate === void 0 ? true : _ref$triggerUpdate,
4760
+ _ref$onChange = _ref.onChange,
4761
+ onChange = _ref$onChange === void 0 ? function (newVal, state) {} : _ref$onChange;
4761
4762
  _classCallCheck(this, Prop);
4762
-
4763
4763
  this.name = name;
4764
4764
  this.defaultVal = defaultVal;
4765
4765
  this.triggerUpdate = triggerUpdate;
4766
4766
  this.onChange = onChange;
4767
4767
  });
4768
-
4769
4768
  function index (_ref2) {
4770
4769
  var _ref2$stateInit = _ref2.stateInit,
4771
- stateInit = _ref2$stateInit === void 0 ? function () {
4772
- return {};
4773
- } : _ref2$stateInit,
4774
- _ref2$props = _ref2.props,
4775
- rawProps = _ref2$props === void 0 ? {} : _ref2$props,
4776
- _ref2$methods = _ref2.methods,
4777
- methods = _ref2$methods === void 0 ? {} : _ref2$methods,
4778
- _ref2$aliases = _ref2.aliases,
4779
- aliases = _ref2$aliases === void 0 ? {} : _ref2$aliases,
4780
- _ref2$init = _ref2.init,
4781
- initFn = _ref2$init === void 0 ? function () {} : _ref2$init,
4782
- _ref2$update = _ref2.update,
4783
- updateFn = _ref2$update === void 0 ? function () {} : _ref2$update;
4770
+ stateInit = _ref2$stateInit === void 0 ? function () {
4771
+ return {};
4772
+ } : _ref2$stateInit,
4773
+ _ref2$props = _ref2.props,
4774
+ rawProps = _ref2$props === void 0 ? {} : _ref2$props,
4775
+ _ref2$methods = _ref2.methods,
4776
+ methods = _ref2$methods === void 0 ? {} : _ref2$methods,
4777
+ _ref2$aliases = _ref2.aliases,
4778
+ aliases = _ref2$aliases === void 0 ? {} : _ref2$aliases,
4779
+ _ref2$init = _ref2.init,
4780
+ initFn = _ref2$init === void 0 ? function () {} : _ref2$init,
4781
+ _ref2$update = _ref2.update,
4782
+ updateFn = _ref2$update === void 0 ? function () {} : _ref2$update;
4784
4783
  // Parse props into Prop instances
4785
4784
  var props = Object.keys(rawProps).map(function (propName) {
4786
4785
  return new Prop(propName, rawProps[propName]);
@@ -4788,98 +4787,94 @@
4788
4787
  return function () {
4789
4788
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4790
4789
  // Holds component state
4791
- var state = Object.assign({}, stateInit instanceof Function ? stateInit(options) : stateInit, // Support plain objects for backwards compatibility
4790
+ var state = Object.assign({}, stateInit instanceof Function ? stateInit(options) : stateInit,
4791
+ // Support plain objects for backwards compatibility
4792
4792
  {
4793
4793
  initialised: false
4794
- }); // keeps track of which props triggered an update
4794
+ });
4795
4795
 
4796
- var changedProps = {}; // Component constructor
4796
+ // keeps track of which props triggered an update
4797
+ var changedProps = {};
4797
4798
 
4799
+ // Component constructor
4798
4800
  function comp(nodeElement) {
4799
4801
  initStatic(nodeElement, options);
4800
4802
  digest();
4801
4803
  return comp;
4802
4804
  }
4803
-
4804
4805
  var initStatic = function initStatic(nodeElement, options) {
4805
4806
  initFn.call(comp, nodeElement, state, options);
4806
4807
  state.initialised = true;
4807
4808
  };
4808
-
4809
4809
  var digest = debounce_1(function () {
4810
4810
  if (!state.initialised) {
4811
4811
  return;
4812
4812
  }
4813
-
4814
4813
  updateFn.call(comp, state, changedProps);
4815
4814
  changedProps = {};
4816
- }, 1); // Getter/setter methods
4815
+ }, 1);
4817
4816
 
4817
+ // Getter/setter methods
4818
4818
  props.forEach(function (prop) {
4819
4819
  comp[prop.name] = getSetProp(prop);
4820
-
4821
4820
  function getSetProp(_ref3) {
4822
4821
  var prop = _ref3.name,
4823
- _ref3$triggerUpdate = _ref3.triggerUpdate,
4824
- redigest = _ref3$triggerUpdate === void 0 ? false : _ref3$triggerUpdate,
4825
- _ref3$onChange = _ref3.onChange,
4826
- onChange = _ref3$onChange === void 0 ? function (newVal, state) {} : _ref3$onChange,
4827
- _ref3$defaultVal = _ref3.defaultVal,
4828
- defaultVal = _ref3$defaultVal === void 0 ? null : _ref3$defaultVal;
4822
+ _ref3$triggerUpdate = _ref3.triggerUpdate,
4823
+ redigest = _ref3$triggerUpdate === void 0 ? false : _ref3$triggerUpdate,
4824
+ _ref3$onChange = _ref3.onChange,
4825
+ onChange = _ref3$onChange === void 0 ? function (newVal, state) {} : _ref3$onChange,
4826
+ _ref3$defaultVal = _ref3.defaultVal,
4827
+ defaultVal = _ref3$defaultVal === void 0 ? null : _ref3$defaultVal;
4829
4828
  return function (_) {
4830
4829
  var curVal = state[prop];
4831
-
4832
4830
  if (!arguments.length) {
4833
4831
  return curVal;
4834
4832
  } // Getter mode
4835
4833
 
4836
-
4837
4834
  var val = _ === undefined ? defaultVal : _; // pick default if value passed is undefined
4838
-
4839
4835
  state[prop] = val;
4840
- onChange.call(comp, val, state, curVal); // track changed props
4836
+ onChange.call(comp, val, state, curVal);
4841
4837
 
4838
+ // track changed props
4842
4839
  !changedProps.hasOwnProperty(prop) && (changedProps[prop] = curVal);
4843
-
4844
4840
  if (redigest) {
4845
4841
  digest();
4846
4842
  }
4847
-
4848
4843
  return comp;
4849
4844
  };
4850
4845
  }
4851
- }); // Other methods
4846
+ });
4852
4847
 
4848
+ // Other methods
4853
4849
  Object.keys(methods).forEach(function (methodName) {
4854
4850
  comp[methodName] = function () {
4855
4851
  var _methods$methodName;
4856
-
4857
4852
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4858
4853
  args[_key] = arguments[_key];
4859
4854
  }
4860
-
4861
4855
  return (_methods$methodName = methods[methodName]).call.apply(_methods$methodName, [comp, state].concat(args));
4862
4856
  };
4863
- }); // Link aliases
4857
+ });
4864
4858
 
4859
+ // Link aliases
4865
4860
  Object.entries(aliases).forEach(function (_ref4) {
4866
4861
  var _ref5 = _slicedToArray(_ref4, 2),
4867
- alias = _ref5[0],
4868
- target = _ref5[1];
4869
-
4862
+ alias = _ref5[0],
4863
+ target = _ref5[1];
4870
4864
  return comp[alias] = comp[target];
4871
- }); // Reset all component props to their default value
4865
+ });
4872
4866
 
4867
+ // Reset all component props to their default value
4873
4868
  comp.resetProps = function () {
4874
4869
  props.forEach(function (prop) {
4875
4870
  comp[prop.name](prop.defaultVal);
4876
4871
  });
4877
4872
  return comp;
4878
- }; //
4873
+ };
4879
4874
 
4875
+ //
4880
4876
 
4881
4877
  comp.resetProps(); // Apply all prop defaults
4882
-
4883
4878
  state._rerender = digest; // Expose digest method
4884
4879
 
4885
4880
  return comp;