three-render-objects 1.29.3 → 1.29.4

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.
@@ -1,4 +1,4 @@
1
- // Version 1.29.3 three-render-objects - https://github.com/vasturiano/three-render-objects
1
+ // Version 1.29.4 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) :
@@ -6,22 +6,16 @@
6
6
  })(this, (function (three$1) { 'use strict';
7
7
 
8
8
  function styleInject(css, ref) {
9
- if ( ref === void 0 ) ref = {};
10
- var insertAt = ref.insertAt;
9
+ ref = {};
10
+ ref.insertAt;
11
11
 
12
- if (!css || typeof document === 'undefined') { return; }
12
+ if (typeof document === 'undefined') { return; }
13
13
 
14
14
  var head = document.head || document.getElementsByTagName('head')[0];
15
15
  var style = document.createElement('style');
16
16
  style.type = 'text/css';
17
17
 
18
- if (insertAt === 'top') {
19
- if (head.firstChild) {
20
- head.insertBefore(style, head.firstChild);
21
- } else {
22
- head.appendChild(style);
23
- }
24
- } else {
18
+ {
25
19
  head.appendChild(style);
26
20
  }
27
21
 
@@ -46,10 +40,7 @@
46
40
  f = !0,
47
41
  o = !1;
48
42
  try {
49
- if (i = (t = t.call(r)).next, 0 === l) {
50
- if (Object(t) !== t) return;
51
- f = !1;
52
- } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
43
+ if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
53
44
  } catch (r) {
54
45
  o = !0, n = r;
55
46
  } finally {
@@ -62,22 +53,22 @@
62
53
  return a;
63
54
  }
64
55
  }
65
- function _toPrimitive$1(t, r) {
56
+ function _toPrimitive(t, r) {
66
57
  if ("object" != typeof t || !t) return t;
67
58
  var e = t[Symbol.toPrimitive];
68
59
  if (void 0 !== e) {
69
- var i = e.call(t, r || "default");
60
+ var i = e.call(t, r );
70
61
  if ("object" != typeof i) return i;
71
62
  throw new TypeError("@@toPrimitive must return a primitive value.");
72
63
  }
73
- return ("string" === r ? String : Number)(t);
64
+ return (String )(t);
74
65
  }
75
- function _toPropertyKey$1(t) {
76
- var i = _toPrimitive$1(t, "string");
77
- return "symbol" == typeof i ? i : String(i);
66
+ function _toPropertyKey(t) {
67
+ var i = _toPrimitive(t, "string");
68
+ return "symbol" == typeof i ? i : i + "";
78
69
  }
79
70
  function _defineProperty(obj, key, value) {
80
- key = _toPropertyKey$1(key);
71
+ key = _toPropertyKey(key);
81
72
  if (key in obj) {
82
73
  Object.defineProperty(obj, key, {
83
74
  value: value,
@@ -1193,6 +1184,7 @@
1193
1184
  scope.target.clampLength( scope.minTargetRadius, scope.maxTargetRadius );
1194
1185
  scope.target.add( scope.cursor );
1195
1186
 
1187
+ let zoomChanged = false;
1196
1188
  // adjust the camera position based on zoom only if we're not zooming to the cursor or if it's an ortho camera
1197
1189
  // we adjust zoom later in these cases
1198
1190
  if ( scope.zoomToCursor && performCursorZoom || scope.object.isOrthographicCamera ) {
@@ -1201,7 +1193,9 @@
1201
1193
 
1202
1194
  } else {
1203
1195
 
1196
+ const prevRadius = spherical.radius;
1204
1197
  spherical.radius = clampDistance( spherical.radius * scale );
1198
+ zoomChanged = prevRadius != spherical.radius;
1205
1199
 
1206
1200
  }
1207
1201
 
@@ -1230,7 +1224,6 @@
1230
1224
  }
1231
1225
 
1232
1226
  // adjust camera position
1233
- let zoomChanged = false;
1234
1227
  if ( scope.zoomToCursor && performCursorZoom ) {
1235
1228
 
1236
1229
  let newRadius = null;
@@ -1245,15 +1238,19 @@
1245
1238
  scope.object.position.addScaledVector( dollyDirection, radiusDelta );
1246
1239
  scope.object.updateMatrixWorld();
1247
1240
 
1241
+ zoomChanged = !! radiusDelta;
1242
+
1248
1243
  } else if ( scope.object.isOrthographicCamera ) {
1249
1244
 
1250
1245
  // adjust the ortho camera position based on zoom changes
1251
1246
  const mouseBefore = new three$1.Vector3( mouse.x, mouse.y, 0 );
1252
1247
  mouseBefore.unproject( scope.object );
1253
1248
 
1249
+ const prevZoom = scope.object.zoom;
1254
1250
  scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom / scale ) );
1255
1251
  scope.object.updateProjectionMatrix();
1256
- zoomChanged = true;
1252
+
1253
+ zoomChanged = prevZoom !== scope.object.zoom;
1257
1254
 
1258
1255
  const mouseAfter = new three$1.Vector3( mouse.x, mouse.y, 0 );
1259
1256
  mouseAfter.unproject( scope.object );
@@ -1306,12 +1303,13 @@
1306
1303
 
1307
1304
  } else if ( scope.object.isOrthographicCamera ) {
1308
1305
 
1309
- zoomChanged = scale !== 1;
1306
+ const prevZoom = scope.object.zoom;
1307
+ scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom / scale ) );
1310
1308
 
1311
- if ( zoomChanged ) {
1309
+ if ( prevZoom !== scope.object.zoom ) {
1312
1310
 
1313
- scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom / scale ) );
1314
1311
  scope.object.updateProjectionMatrix();
1312
+ zoomChanged = true;
1315
1313
 
1316
1314
  }
1317
1315
 
@@ -1327,7 +1325,7 @@
1327
1325
  if ( zoomChanged ||
1328
1326
  lastPosition.distanceToSquared( scope.object.position ) > EPS ||
1329
1327
  8 * ( 1 - lastQuaternion.dot( scope.object.quaternion ) ) > EPS ||
1330
- lastTargetPosition.distanceToSquared( scope.target ) > 0 ) {
1328
+ lastTargetPosition.distanceToSquared( scope.target ) > EPS ) {
1331
1329
 
1332
1330
  scope.dispatchEvent( _changeEvent$1 );
1333
1331
 
@@ -1356,6 +1354,9 @@
1356
1354
  scope.domElement.removeEventListener( 'pointermove', onPointerMove );
1357
1355
  scope.domElement.removeEventListener( 'pointerup', onPointerUp );
1358
1356
 
1357
+ const document = scope.domElement.getRootNode(); // offscreen canvas compatibility
1358
+
1359
+ document.removeEventListener( 'keydown', interceptControlDown, { capture: true } );
1359
1360
 
1360
1361
  if ( scope._domElementKeyEvents !== null ) {
1361
1362
 
@@ -1945,6 +1946,10 @@
1945
1946
 
1946
1947
  //
1947
1948
 
1949
+ if ( isTrackingPointer( event ) ) return;
1950
+
1951
+ //
1952
+
1948
1953
  addPointer( event );
1949
1954
 
1950
1955
  if ( event.pointerType === 'touch' ) {
@@ -2392,6 +2397,18 @@
2392
2397
 
2393
2398
  }
2394
2399
 
2400
+ function isTrackingPointer( event ) {
2401
+
2402
+ for ( let i = 0; i < pointers.length; i ++ ) {
2403
+
2404
+ if ( pointers[ i ] == event.pointerId ) return true;
2405
+
2406
+ }
2407
+
2408
+ return false;
2409
+
2410
+ }
2411
+
2395
2412
  function trackPointer( event ) {
2396
2413
 
2397
2414
  let position = pointerPositions[ event.pointerId ];
@@ -4069,7 +4086,7 @@
4069
4086
  */
4070
4087
  function hsla(value, saturation, lightness, alpha) {
4071
4088
  if (typeof value === 'number' && typeof saturation === 'number' && typeof lightness === 'number' && typeof alpha === 'number') {
4072
- return alpha >= 1 ? hslToHex(value, saturation, lightness) : "rgba(" + hslToRgb(value, saturation, lightness) + "," + alpha + ")";
4089
+ return "rgba(" + hslToRgb(value, saturation, lightness) + "," + alpha + ")";
4073
4090
  } else if (typeof value === 'object' && saturation === undefined && lightness === undefined && alpha === undefined) {
4074
4091
  return value.alpha >= 1 ? hslToHex(value.hue, value.saturation, value.lightness) : "rgba(" + hslToRgb(value.hue, value.saturation, value.lightness) + "," + value.alpha + ")";
4075
4092
  }
@@ -4147,7 +4164,7 @@
4147
4164
  var rgbValue = parseToRgb(firstValue);
4148
4165
  return "rgba(" + rgbValue.red + "," + rgbValue.green + "," + rgbValue.blue + "," + secondValue + ")";
4149
4166
  } else if (typeof firstValue === 'number' && typeof secondValue === 'number' && typeof thirdValue === 'number' && typeof fourthValue === 'number') {
4150
- return fourthValue >= 1 ? rgb(firstValue, secondValue, thirdValue) : "rgba(" + firstValue + "," + secondValue + "," + thirdValue + "," + fourthValue + ")";
4167
+ return "rgba(" + firstValue + "," + secondValue + "," + thirdValue + "," + fourthValue + ")";
4151
4168
  } else if (typeof firstValue === 'object' && secondValue === undefined && thirdValue === undefined && fourthValue === undefined) {
4152
4169
  return firstValue.alpha >= 1 ? rgb(firstValue.red, firstValue.green, firstValue.blue) : "rgba(" + firstValue.red + "," + firstValue.green + "," + firstValue.blue + "," + firstValue.alpha + ")";
4153
4170
  }
@@ -6055,10 +6072,7 @@
6055
6072
  f = !0,
6056
6073
  o = !1;
6057
6074
  try {
6058
- if (i = (t = t.call(r)).next, 0 === l) {
6059
- if (Object(t) !== t) return;
6060
- f = !1;
6061
- } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
6075
+ if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
6062
6076
  } catch (r) {
6063
6077
  o = !0, n = r;
6064
6078
  } finally {
@@ -6076,18 +6090,7 @@
6076
6090
  throw new TypeError("Cannot call a class as a function");
6077
6091
  }
6078
6092
  }
6079
- function _defineProperties(target, props) {
6080
- for (var i = 0; i < props.length; i++) {
6081
- var descriptor = props[i];
6082
- descriptor.enumerable = descriptor.enumerable || false;
6083
- descriptor.configurable = true;
6084
- if ("value" in descriptor) descriptor.writable = true;
6085
- Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
6086
- }
6087
- }
6088
6093
  function _createClass(Constructor, protoProps, staticProps) {
6089
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
6090
- if (staticProps) _defineProperties(Constructor, staticProps);
6091
6094
  Object.defineProperty(Constructor, "prototype", {
6092
6095
  writable: false
6093
6096
  });
@@ -6108,27 +6111,13 @@
6108
6111
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
6109
6112
  }
6110
6113
  function _arrayLikeToArray(arr, len) {
6111
- if (len == null || len > arr.length) len = arr.length;
6114
+ if (len > arr.length) len = arr.length;
6112
6115
  for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
6113
6116
  return arr2;
6114
6117
  }
6115
6118
  function _nonIterableRest() {
6116
6119
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
6117
6120
  }
6118
- function _toPrimitive(input, hint) {
6119
- if (typeof input !== "object" || input === null) return input;
6120
- var prim = input[Symbol.toPrimitive];
6121
- if (prim !== undefined) {
6122
- var res = prim.call(input, hint || "default");
6123
- if (typeof res !== "object") return res;
6124
- throw new TypeError("@@toPrimitive must return a primitive value.");
6125
- }
6126
- return (hint === "string" ? String : Number)(input);
6127
- }
6128
- function _toPropertyKey(arg) {
6129
- var key = _toPrimitive(arg, "string");
6130
- return typeof key === "symbol" ? key : String(key);
6131
- }
6132
6121
 
6133
6122
  var Prop = /*#__PURE__*/_createClass(function Prop(name, _ref) {
6134
6123
  var _ref$default = _ref["default"],
@@ -6365,7 +6354,7 @@
6365
6354
  methods: {
6366
6355
  tick: function tick(state) {
6367
6356
  if (state.initialised) {
6368
- state.controls.update && state.controls.update(state.clock.getDelta()); // timedelta is required for fly controls
6357
+ state.controls.update && state.controls.update(Math.min(1, state.clock.getDelta())); // timedelta is required for fly controls
6369
6358
 
6370
6359
  state.postProcessingComposer ? state.postProcessingComposer.render() // if using postprocessing, switch the output to it
6371
6360
  : state.renderer.render(state.scene, state.camera);