three-render-objects 1.28.3 → 1.28.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.28.3 three-render-objects - https://github.com/vasturiano/three-render-objects
1
+ // Version 1.28.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) :
@@ -327,13 +327,13 @@
327
327
 
328
328
  } else if ( scope.object.isOrthographicCamera ) {
329
329
 
330
- scope.object.zoom = three$1.MathUtils.clamp( scope.object.zoom / factor, scope.minZoom, scope.maxZoom );
331
-
332
- if ( lastZoom !== scope.object.zoom ) {
330
+ scope.object.zoom = three$1.MathUtils.clamp( scope.object.zoom / factor, scope.minZoom, scope.maxZoom );
333
331
 
334
- scope.object.updateProjectionMatrix();
335
-
336
- }
332
+ if ( lastZoom !== scope.object.zoom ) {
333
+
334
+ scope.object.updateProjectionMatrix();
335
+
336
+ }
337
337
 
338
338
  } else {
339
339
 
@@ -354,11 +354,11 @@
354
354
  } else if ( scope.object.isOrthographicCamera ) {
355
355
 
356
356
  scope.object.zoom = three$1.MathUtils.clamp( scope.object.zoom / factor, scope.minZoom, scope.maxZoom );
357
-
357
+
358
358
  if ( lastZoom !== scope.object.zoom ) {
359
359
 
360
360
  scope.object.updateProjectionMatrix();
361
-
361
+
362
362
  }
363
363
 
364
364
  } else {
@@ -2762,10 +2762,11 @@
2762
2762
 
2763
2763
  this.renderer = renderer;
2764
2764
 
2765
+ this._pixelRatio = renderer.getPixelRatio();
2766
+
2765
2767
  if ( renderTarget === undefined ) {
2766
2768
 
2767
2769
  const size = renderer.getSize( new three$1.Vector2() );
2768
- this._pixelRatio = renderer.getPixelRatio();
2769
2770
  this._width = size.width;
2770
2771
  this._height = size.height;
2771
2772
 
@@ -2774,7 +2775,6 @@
2774
2775
 
2775
2776
  } else {
2776
2777
 
2777
- this._pixelRatio = 1;
2778
2778
  this._width = renderTarget.width;
2779
2779
  this._height = renderTarget.height;
2780
2780
 
@@ -4017,37 +4017,7 @@
4017
4017
  },
4018
4018
  });
4019
4019
 
4020
- var now$2;
4021
- // Include a performance.now polyfill.
4022
- // In node.js, use process.hrtime.
4023
- // eslint-disable-next-line
4024
- // @ts-ignore
4025
- if (typeof self === 'undefined' && typeof process !== 'undefined' && process.hrtime) {
4026
- now$2 = function () {
4027
- // eslint-disable-next-line
4028
- // @ts-ignore
4029
- var time = process.hrtime();
4030
- // Convert [seconds, nanoseconds] to milliseconds.
4031
- return time[0] * 1000 + time[1] / 1000000;
4032
- };
4033
- }
4034
- // In a browser, use self.performance.now if it is available.
4035
- else if (typeof self !== 'undefined' && self.performance !== undefined && self.performance.now !== undefined) {
4036
- // This must be bound, because directly assigning this function
4037
- // leads to an invocation exception in Chrome.
4038
- now$2 = self.performance.now.bind(self.performance);
4039
- }
4040
- // Use Date.now if it is available.
4041
- else if (Date.now !== undefined) {
4042
- now$2 = Date.now;
4043
- }
4044
- // Otherwise, use 'new Date().getTime()'.
4045
- else {
4046
- now$2 = function () {
4047
- return new Date().getTime();
4048
- };
4049
- }
4050
- var now$1$1 = now$2;
4020
+ var now$2 = function () { return performance.now(); };
4051
4021
 
4052
4022
  /**
4053
4023
  * Controlling groups of tweens
@@ -4078,7 +4048,7 @@
4078
4048
  delete this._tweensAddedDuringUpdate[tween.getId()];
4079
4049
  };
4080
4050
  Group.prototype.update = function (time, preserve) {
4081
- if (time === void 0) { time = now$1$1(); }
4051
+ if (time === void 0) { time = now$2(); }
4082
4052
  if (preserve === void 0) { preserve = false; }
4083
4053
  var tweenIds = Object.keys(this._tweens);
4084
4054
  if (tweenIds.length === 0) {
@@ -4219,6 +4189,7 @@
4219
4189
  this._valuesEnd = {};
4220
4190
  this._valuesStartRepeat = {};
4221
4191
  this._duration = 1000;
4192
+ this._isDynamic = false;
4222
4193
  this._initialRepeat = 0;
4223
4194
  this._repeat = 0;
4224
4195
  this._yoyo = false;
@@ -4234,6 +4205,7 @@
4234
4205
  this._onEveryStartCallbackFired = false;
4235
4206
  this._id = Sequence.nextId();
4236
4207
  this._isChainStopped = false;
4208
+ this._propertiesAreSetUp = false;
4237
4209
  this._goToEnd = false;
4238
4210
  }
4239
4211
  Tween.prototype.getId = function () {
@@ -4245,24 +4217,27 @@
4245
4217
  Tween.prototype.isPaused = function () {
4246
4218
  return this._isPaused;
4247
4219
  };
4248
- Tween.prototype.to = function (properties, duration) {
4249
- // TODO? restore this, then update the 07_dynamic_to example to set fox
4250
- // tween's to on each update. That way the behavior is opt-in (there's
4251
- // currently no opt-out).
4252
- // for (const prop in properties) this._valuesEnd[prop] = properties[prop]
4253
- this._valuesEnd = Object.create(properties);
4254
- if (duration !== undefined) {
4255
- this._duration = duration;
4256
- }
4220
+ Tween.prototype.to = function (target, duration) {
4221
+ if (duration === void 0) { duration = 1000; }
4222
+ if (this._isPlaying)
4223
+ throw new Error('Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.');
4224
+ this._valuesEnd = target;
4225
+ this._propertiesAreSetUp = false;
4226
+ this._duration = duration;
4227
+ return this;
4228
+ };
4229
+ Tween.prototype.duration = function (duration) {
4230
+ if (duration === void 0) { duration = 1000; }
4231
+ this._duration = duration;
4257
4232
  return this;
4258
4233
  };
4259
- Tween.prototype.duration = function (d) {
4260
- if (d === void 0) { d = 1000; }
4261
- this._duration = d;
4234
+ Tween.prototype.dynamic = function (dynamic) {
4235
+ if (dynamic === void 0) { dynamic = false; }
4236
+ this._isDynamic = dynamic;
4262
4237
  return this;
4263
4238
  };
4264
4239
  Tween.prototype.start = function (time, overrideStartingValues) {
4265
- if (time === void 0) { time = now$1$1(); }
4240
+ if (time === void 0) { time = now$2(); }
4266
4241
  if (overrideStartingValues === void 0) { overrideStartingValues = false; }
4267
4242
  if (this._isPlaying) {
4268
4243
  return this;
@@ -4286,7 +4261,17 @@
4286
4261
  this._isChainStopped = false;
4287
4262
  this._startTime = time;
4288
4263
  this._startTime += this._delayTime;
4289
- this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat, overrideStartingValues);
4264
+ if (!this._propertiesAreSetUp || overrideStartingValues) {
4265
+ this._propertiesAreSetUp = true;
4266
+ // If dynamic is not enabled, clone the end values instead of using the passed-in end values.
4267
+ if (!this._isDynamic) {
4268
+ var tmp = {};
4269
+ for (var prop in this._valuesEnd)
4270
+ tmp[prop] = this._valuesEnd[prop];
4271
+ this._valuesEnd = tmp;
4272
+ }
4273
+ this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat, overrideStartingValues);
4274
+ }
4290
4275
  return this;
4291
4276
  };
4292
4277
  Tween.prototype.startFromCurrentValues = function (time) {
@@ -4309,26 +4294,42 @@
4309
4294
  if (endValues.length === 0) {
4310
4295
  continue;
4311
4296
  }
4312
- // handle an array of relative values
4313
- endValues = endValues.map(this._handleRelativeValue.bind(this, startValue));
4314
- // Create a local copy of the Array with the start value at the front
4315
- if (_valuesStart[property] === undefined) {
4316
- _valuesEnd[property] = [startValue].concat(endValues);
4297
+ // Handle an array of relative values.
4298
+ // Creates a local copy of the Array with the start value at the front
4299
+ var temp = [startValue];
4300
+ for (var i = 0, l = endValues.length; i < l; i += 1) {
4301
+ var value = this._handleRelativeValue(startValue, endValues[i]);
4302
+ if (isNaN(value)) {
4303
+ isInterpolationList = false;
4304
+ console.warn('Found invalid interpolation list. Skipping.');
4305
+ break;
4306
+ }
4307
+ temp.push(value);
4308
+ }
4309
+ if (isInterpolationList) {
4310
+ // if (_valuesStart[property] === undefined) { // handle end values only the first time. NOT NEEDED? setupProperties is now guarded by _propertiesAreSetUp.
4311
+ _valuesEnd[property] = temp;
4312
+ // }
4317
4313
  }
4318
4314
  }
4319
4315
  // handle the deepness of the values
4320
4316
  if ((propType === 'object' || startValueIsArray) && startValue && !isInterpolationList) {
4321
4317
  _valuesStart[property] = startValueIsArray ? [] : {};
4322
- // eslint-disable-next-line
4323
- for (var prop in startValue) {
4324
- // eslint-disable-next-line
4325
- // @ts-ignore FIXME?
4326
- _valuesStart[property][prop] = startValue[prop];
4318
+ var nestedObject = startValue;
4319
+ for (var prop in nestedObject) {
4320
+ _valuesStart[property][prop] = nestedObject[prop];
4327
4321
  }
4328
- _valuesStartRepeat[property] = startValueIsArray ? [] : {}; // TODO? repeat nested values? And yoyo? And array values?
4329
- // eslint-disable-next-line
4330
- // @ts-ignore FIXME?
4331
- this._setupProperties(startValue, _valuesStart[property], _valuesEnd[property], _valuesStartRepeat[property], overrideStartingValues);
4322
+ // TODO? repeat nested values? And yoyo? And array values?
4323
+ _valuesStartRepeat[property] = startValueIsArray ? [] : {};
4324
+ var endValues = _valuesEnd[property];
4325
+ // If dynamic is not enabled, clone the end values instead of using the passed-in end values.
4326
+ if (!this._isDynamic) {
4327
+ var tmp = {};
4328
+ for (var prop in endValues)
4329
+ tmp[prop] = endValues[prop];
4330
+ _valuesEnd[property] = endValues = tmp;
4331
+ }
4332
+ this._setupProperties(nestedObject, _valuesStart[property], endValues, _valuesStartRepeat[property], overrideStartingValues);
4332
4333
  }
4333
4334
  else {
4334
4335
  // Save the starting value, but only once unless override is requested.
@@ -4374,7 +4375,7 @@
4374
4375
  return this;
4375
4376
  };
4376
4377
  Tween.prototype.pause = function (time) {
4377
- if (time === void 0) { time = now$1$1(); }
4378
+ if (time === void 0) { time = now$2(); }
4378
4379
  if (this._isPaused || !this._isPlaying) {
4379
4380
  return this;
4380
4381
  }
@@ -4385,7 +4386,7 @@
4385
4386
  return this;
4386
4387
  };
4387
4388
  Tween.prototype.resume = function (time) {
4388
- if (time === void 0) { time = now$1$1(); }
4389
+ if (time === void 0) { time = now$2(); }
4389
4390
  if (!this._isPaused || !this._isPlaying) {
4390
4391
  return this;
4391
4392
  }
@@ -4476,7 +4477,7 @@
4476
4477
  * it is still playing, just paused).
4477
4478
  */
4478
4479
  Tween.prototype.update = function (time, autoStart) {
4479
- if (time === void 0) { time = now$1$1(); }
4480
+ if (time === void 0) { time = now$2(); }
4480
4481
  if (autoStart === void 0) { autoStart = true; }
4481
4482
  if (this._isPaused)
4482
4483
  return true;
@@ -4599,9 +4600,7 @@
4599
4600
  if (end.charAt(0) === '+' || end.charAt(0) === '-') {
4600
4601
  return start + parseFloat(end);
4601
4602
  }
4602
- else {
4603
- return parseFloat(end);
4604
- }
4603
+ return parseFloat(end);
4605
4604
  };
4606
4605
  Tween.prototype._swapEndStartRepeatValues = function (property) {
4607
4606
  var tmp = this._valuesStartRepeat[property];
@@ -4617,7 +4616,7 @@
4617
4616
  return Tween;
4618
4617
  }());
4619
4618
 
4620
- var VERSION = '19.0.0';
4619
+ var VERSION = '20.0.3';
4621
4620
 
4622
4621
  /**
4623
4622
  * Tween.js - Licensed under the MIT license
@@ -4648,7 +4647,7 @@
4648
4647
  Easing: Easing,
4649
4648
  Group: Group,
4650
4649
  Interpolation: Interpolation,
4651
- now: now$1$1,
4650
+ now: now$2,
4652
4651
  Sequence: Sequence,
4653
4652
  nextId: nextId,
4654
4653
  Tween: Tween,
@@ -5380,6 +5379,7 @@
5380
5379
  Scene: three$1.Scene,
5381
5380
  PerspectiveCamera: three$1.PerspectiveCamera,
5382
5381
  Raycaster: three$1.Raycaster,
5382
+ SRGBColorSpace: three$1.SRGBColorSpace,
5383
5383
  TextureLoader: three$1.TextureLoader,
5384
5384
  Vector2: three$1.Vector2,
5385
5385
  Vector3: three$1.Vector3,
@@ -5869,6 +5869,7 @@
5869
5869
  !state.loadComplete && finishLoad();
5870
5870
  } else {
5871
5871
  new three.TextureLoader().load(state.backgroundImageUrl, function (texture) {
5872
+ texture.colorSpace = three.SRGBColorSpace;
5872
5873
  state.skysphere.material = new three.MeshBasicMaterial({
5873
5874
  map: texture,
5874
5875
  side: three.BackSide