three-render-objects 1.29.4 → 1.29.5

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.
@@ -5,20 +5,26 @@ import { FlyControls } from 'three/examples/jsm/controls/FlyControls.js';
5
5
  import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer.js';
6
6
  import { RenderPass } from 'three/examples/jsm/postprocessing/RenderPass.js';
7
7
  import { parseToRgb, opacify } from 'polished';
8
- import * as TWEEN from '@tweenjs/tween.js';
8
+ import { Tween, Easing, Group } from '@tweenjs/tween.js';
9
9
  import accessorFn from 'accessor-fn';
10
10
  import Kapsule from 'kapsule';
11
11
 
12
12
  function styleInject(css, ref) {
13
- ref = {};
14
- ref.insertAt;
13
+ if (ref === void 0) ref = {};
14
+ var insertAt = ref.insertAt;
15
15
  if (typeof document === 'undefined') {
16
16
  return;
17
17
  }
18
18
  var head = document.head || document.getElementsByTagName('head')[0];
19
19
  var style = document.createElement('style');
20
20
  style.type = 'text/css';
21
- {
21
+ if (insertAt === 'top') {
22
+ if (head.firstChild) {
23
+ head.insertBefore(style, head.firstChild);
24
+ } else {
25
+ head.appendChild(style);
26
+ }
27
+ } else {
22
28
  head.appendChild(style);
23
29
  }
24
30
  if (style.styleSheet) {
@@ -31,6 +37,28 @@ function styleInject(css, ref) {
31
37
  var css_248z = ".scene-nav-info {\n bottom: 5px;\n width: 100%;\n text-align: center;\n color: slategrey;\n opacity: 0.7;\n font-size: 10px;\n}\n\n.scene-tooltip {\n top: 0;\n color: lavender;\n font-size: 15px;\n}\n\n.scene-nav-info, .scene-tooltip {\n position: absolute;\n font-family: sans-serif;\n pointer-events: none;\n user-select: none;\n}\n\n.scene-container canvas:focus {\n outline: none;\n}";
32
38
  styleInject(css_248z);
33
39
 
40
+ function _arrayLikeToArray(r, a) {
41
+ (null == a || a > r.length) && (a = r.length);
42
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
43
+ return n;
44
+ }
45
+ function _arrayWithHoles(r) {
46
+ if (Array.isArray(r)) return r;
47
+ }
48
+ function _arrayWithoutHoles(r) {
49
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
50
+ }
51
+ function _defineProperty(e, r, t) {
52
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
53
+ value: t,
54
+ enumerable: !0,
55
+ configurable: !0,
56
+ writable: !0
57
+ }) : e[r] = t, e;
58
+ }
59
+ function _iterableToArray(r) {
60
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
61
+ }
34
62
  function _iterableToArrayLimit(r, l) {
35
63
  var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
36
64
  if (null != t) {
@@ -55,67 +83,38 @@ function _iterableToArrayLimit(r, l) {
55
83
  return a;
56
84
  }
57
85
  }
86
+ function _nonIterableRest() {
87
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
88
+ }
89
+ function _nonIterableSpread() {
90
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
91
+ }
92
+ function _slicedToArray(r, e) {
93
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
94
+ }
95
+ function _toConsumableArray(r) {
96
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
97
+ }
58
98
  function _toPrimitive(t, r) {
59
99
  if ("object" != typeof t || !t) return t;
60
100
  var e = t[Symbol.toPrimitive];
61
101
  if (void 0 !== e) {
62
- var i = e.call(t, r );
102
+ var i = e.call(t, r || "default");
63
103
  if ("object" != typeof i) return i;
64
104
  throw new TypeError("@@toPrimitive must return a primitive value.");
65
105
  }
66
- return (String )(t);
106
+ return ("string" === r ? String : Number)(t);
67
107
  }
68
108
  function _toPropertyKey(t) {
69
109
  var i = _toPrimitive(t, "string");
70
110
  return "symbol" == typeof i ? i : i + "";
71
111
  }
72
- function _defineProperty(obj, key, value) {
73
- key = _toPropertyKey(key);
74
- if (key in obj) {
75
- Object.defineProperty(obj, key, {
76
- value: value,
77
- enumerable: true,
78
- configurable: true,
79
- writable: true
80
- });
81
- } else {
82
- obj[key] = value;
112
+ function _unsupportedIterableToArray(r, a) {
113
+ if (r) {
114
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
115
+ var t = {}.toString.call(r).slice(8, -1);
116
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
83
117
  }
84
- return obj;
85
- }
86
- function _slicedToArray(arr, i) {
87
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
88
- }
89
- function _toConsumableArray(arr) {
90
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
91
- }
92
- function _arrayWithoutHoles(arr) {
93
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
94
- }
95
- function _arrayWithHoles(arr) {
96
- if (Array.isArray(arr)) return arr;
97
- }
98
- function _iterableToArray(iter) {
99
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
100
- }
101
- function _unsupportedIterableToArray(o, minLen) {
102
- if (!o) return;
103
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
104
- var n = Object.prototype.toString.call(o).slice(8, -1);
105
- if (n === "Object" && o.constructor) n = o.constructor.name;
106
- if (n === "Map" || n === "Set") return Array.from(o);
107
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
108
- }
109
- function _arrayLikeToArray(arr, len) {
110
- if (len == null || len > arr.length) len = arr.length;
111
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
112
- return arr2;
113
- }
114
- function _nonIterableSpread() {
115
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
116
- }
117
- function _nonIterableRest() {
118
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
119
118
  }
120
119
 
121
120
  var three = window.THREE ? window.THREE // Prefer consumption from global THREE, if exists
@@ -250,7 +249,7 @@ var threeRenderObjects = Kapsule({
250
249
  state.hoverObj = topObject;
251
250
  }
252
251
  }
253
- TWEEN.update(); // update camera animation tweens
252
+ state.tweenGroup.update(); // update camera animation tweens
254
253
  }
255
254
  return this;
256
255
  },
@@ -281,10 +280,10 @@ var threeRenderObjects = Kapsule({
281
280
  } else {
282
281
  var camPos = Object.assign({}, camera.position);
283
282
  var camLookAt = getLookAt();
284
- new TWEEN.Tween(camPos).to(finalPos, transitionDuration).easing(TWEEN.Easing.Quadratic.Out).onUpdate(setCameraPos).start();
283
+ state.tweenGroup.add(new Tween(camPos).to(finalPos, transitionDuration).easing(Easing.Quadratic.Out).onUpdate(setCameraPos).start());
285
284
 
286
285
  // Face direction in 1/3rd of time
287
- new TWEEN.Tween(camLookAt).to(finalLookAt, transitionDuration / 3).easing(TWEEN.Easing.Quadratic.Out).onUpdate(setLookAt).start();
286
+ state.tweenGroup.add(new Tween(camLookAt).to(finalLookAt, transitionDuration / 3).easing(Easing.Quadratic.Out).onUpdate(setLookAt).start());
288
287
  }
289
288
  return this;
290
289
  }
@@ -415,7 +414,8 @@ var threeRenderObjects = Kapsule({
415
414
  return {
416
415
  scene: new three.Scene(),
417
416
  camera: new three.PerspectiveCamera(),
418
- clock: new three.Clock()
417
+ clock: new three.Clock(),
418
+ tweenGroup: new Group()
419
419
  };
420
420
  },
421
421
  init: function init(domNode, state) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "three-render-objects",
3
- "version": "1.29.4",
3
+ "version": "1.29.5",
4
4
  "description": "Easy way to render ThreeJS objects with built-in interaction defaults",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -45,7 +45,7 @@
45
45
  "prepare": "npm run build"
46
46
  },
47
47
  "dependencies": {
48
- "@tweenjs/tween.js": "18 - 23",
48
+ "@tweenjs/tween.js": "18 - 25",
49
49
  "accessor-fn": "1",
50
50
  "kapsule": "1",
51
51
  "polished": "4"
@@ -54,19 +54,19 @@
54
54
  "three": "*"
55
55
  },
56
56
  "devDependencies": {
57
- "@babel/core": "^7.24.4",
58
- "@babel/preset-env": "^7.24.4",
57
+ "@babel/core": "^7.25.2",
58
+ "@babel/preset-env": "^7.25.4",
59
59
  "@rollup/plugin-babel": "^6.0.4",
60
- "@rollup/plugin-commonjs": "^25.0.7",
61
- "@rollup/plugin-node-resolve": "^15.2.3",
60
+ "@rollup/plugin-commonjs": "^28.0.0",
61
+ "@rollup/plugin-node-resolve": "^15.3.0",
62
62
  "@rollup/plugin-terser": "^0.4.4",
63
- "postcss": "^8.4.38",
64
- "rimraf": "^5.0.5",
65
- "rollup": "^4.16.1",
66
- "rollup-plugin-dts": "^6.1.0",
63
+ "postcss": "^8.4.47",
64
+ "rimraf": "^6.0.1",
65
+ "rollup": "^4.22.4",
66
+ "rollup-plugin-dts": "^6.1.1",
67
67
  "rollup-plugin-postcss": "^4.0.2",
68
- "three": "^0.163.0",
69
- "typescript": "^5.4.5"
68
+ "three": "^0.168.0",
69
+ "typescript": "^5.6.2"
70
70
  },
71
71
  "engines": {
72
72
  "node": ">=12"