three-render-objects 1.28.3 → 1.28.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.
@@ -1,4 +1,4 @@
1
- // Version 1.28.3 three-render-objects - https://github.com/vasturiano/three-render-objects
1
+ // Version 1.28.5 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 {
@@ -1100,6 +1100,7 @@
1100
1100
 
1101
1101
  const lastPosition = new three$1.Vector3();
1102
1102
  const lastQuaternion = new three$1.Quaternion();
1103
+ const lastTargetPosition = new three$1.Vector3();
1103
1104
 
1104
1105
  const twoPI = 2 * Math.PI;
1105
1106
 
@@ -1213,12 +1214,15 @@
1213
1214
 
1214
1215
  if ( zoomChanged ||
1215
1216
  lastPosition.distanceToSquared( scope.object.position ) > EPS ||
1216
- 8 * ( 1 - lastQuaternion.dot( scope.object.quaternion ) ) > EPS ) {
1217
+ 8 * ( 1 - lastQuaternion.dot( scope.object.quaternion ) ) > EPS ||
1218
+ lastTargetPosition.distanceToSquared( scope.target ) > 0 ) {
1217
1219
 
1218
1220
  scope.dispatchEvent( _changeEvent$1 );
1219
1221
 
1220
1222
  lastPosition.copy( scope.object.position );
1221
1223
  lastQuaternion.copy( scope.object.quaternion );
1224
+ lastTargetPosition.copy( scope.target );
1225
+
1222
1226
  zoomChanged = false;
1223
1227
 
1224
1228
  return true;
@@ -2477,6 +2481,8 @@
2477
2481
 
2478
2482
  const CopyShader = {
2479
2483
 
2484
+ name: 'CopyShader',
2485
+
2480
2486
  uniforms: {
2481
2487
 
2482
2488
  'tDiffuse': { value: null },
@@ -2609,6 +2615,7 @@
2609
2615
 
2610
2616
  this.material = new three$1.ShaderMaterial( {
2611
2617
 
2618
+ name: ( shader.name !== undefined ) ? shader.name : 'unspecified',
2612
2619
  defines: Object.assign( {}, shader.defines ),
2613
2620
  uniforms: this.uniforms,
2614
2621
  vertexShader: shader.vertexShader,
@@ -2762,19 +2769,19 @@
2762
2769
 
2763
2770
  this.renderer = renderer;
2764
2771
 
2772
+ this._pixelRatio = renderer.getPixelRatio();
2773
+
2765
2774
  if ( renderTarget === undefined ) {
2766
2775
 
2767
2776
  const size = renderer.getSize( new three$1.Vector2() );
2768
- this._pixelRatio = renderer.getPixelRatio();
2769
2777
  this._width = size.width;
2770
2778
  this._height = size.height;
2771
2779
 
2772
- renderTarget = new three$1.WebGLRenderTarget( this._width * this._pixelRatio, this._height * this._pixelRatio );
2780
+ renderTarget = new three$1.WebGLRenderTarget( this._width * this._pixelRatio, this._height * this._pixelRatio, { type: three$1.HalfFloatType } );
2773
2781
  renderTarget.texture.name = 'EffectComposer.rt1';
2774
2782
 
2775
2783
  } else {
2776
2784
 
2777
- this._pixelRatio = 1;
2778
2785
  this._width = renderTarget.width;
2779
2786
  this._height = renderTarget.height;
2780
2787
 
@@ -4017,37 +4024,7 @@
4017
4024
  },
4018
4025
  });
4019
4026
 
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;
4027
+ var now$2 = function () { return performance.now(); };
4051
4028
 
4052
4029
  /**
4053
4030
  * Controlling groups of tweens
@@ -4078,7 +4055,7 @@
4078
4055
  delete this._tweensAddedDuringUpdate[tween.getId()];
4079
4056
  };
4080
4057
  Group.prototype.update = function (time, preserve) {
4081
- if (time === void 0) { time = now$1$1(); }
4058
+ if (time === void 0) { time = now$2(); }
4082
4059
  if (preserve === void 0) { preserve = false; }
4083
4060
  var tweenIds = Object.keys(this._tweens);
4084
4061
  if (tweenIds.length === 0) {
@@ -4219,6 +4196,7 @@
4219
4196
  this._valuesEnd = {};
4220
4197
  this._valuesStartRepeat = {};
4221
4198
  this._duration = 1000;
4199
+ this._isDynamic = false;
4222
4200
  this._initialRepeat = 0;
4223
4201
  this._repeat = 0;
4224
4202
  this._yoyo = false;
@@ -4234,6 +4212,7 @@
4234
4212
  this._onEveryStartCallbackFired = false;
4235
4213
  this._id = Sequence.nextId();
4236
4214
  this._isChainStopped = false;
4215
+ this._propertiesAreSetUp = false;
4237
4216
  this._goToEnd = false;
4238
4217
  }
4239
4218
  Tween.prototype.getId = function () {
@@ -4245,24 +4224,27 @@
4245
4224
  Tween.prototype.isPaused = function () {
4246
4225
  return this._isPaused;
4247
4226
  };
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
- }
4227
+ Tween.prototype.to = function (target, duration) {
4228
+ if (duration === void 0) { duration = 1000; }
4229
+ if (this._isPlaying)
4230
+ throw new Error('Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.');
4231
+ this._valuesEnd = target;
4232
+ this._propertiesAreSetUp = false;
4233
+ this._duration = duration;
4234
+ return this;
4235
+ };
4236
+ Tween.prototype.duration = function (duration) {
4237
+ if (duration === void 0) { duration = 1000; }
4238
+ this._duration = duration;
4257
4239
  return this;
4258
4240
  };
4259
- Tween.prototype.duration = function (d) {
4260
- if (d === void 0) { d = 1000; }
4261
- this._duration = d;
4241
+ Tween.prototype.dynamic = function (dynamic) {
4242
+ if (dynamic === void 0) { dynamic = false; }
4243
+ this._isDynamic = dynamic;
4262
4244
  return this;
4263
4245
  };
4264
4246
  Tween.prototype.start = function (time, overrideStartingValues) {
4265
- if (time === void 0) { time = now$1$1(); }
4247
+ if (time === void 0) { time = now$2(); }
4266
4248
  if (overrideStartingValues === void 0) { overrideStartingValues = false; }
4267
4249
  if (this._isPlaying) {
4268
4250
  return this;
@@ -4286,7 +4268,17 @@
4286
4268
  this._isChainStopped = false;
4287
4269
  this._startTime = time;
4288
4270
  this._startTime += this._delayTime;
4289
- this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat, overrideStartingValues);
4271
+ if (!this._propertiesAreSetUp || overrideStartingValues) {
4272
+ this._propertiesAreSetUp = true;
4273
+ // If dynamic is not enabled, clone the end values instead of using the passed-in end values.
4274
+ if (!this._isDynamic) {
4275
+ var tmp = {};
4276
+ for (var prop in this._valuesEnd)
4277
+ tmp[prop] = this._valuesEnd[prop];
4278
+ this._valuesEnd = tmp;
4279
+ }
4280
+ this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat, overrideStartingValues);
4281
+ }
4290
4282
  return this;
4291
4283
  };
4292
4284
  Tween.prototype.startFromCurrentValues = function (time) {
@@ -4309,26 +4301,42 @@
4309
4301
  if (endValues.length === 0) {
4310
4302
  continue;
4311
4303
  }
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);
4304
+ // Handle an array of relative values.
4305
+ // Creates a local copy of the Array with the start value at the front
4306
+ var temp = [startValue];
4307
+ for (var i = 0, l = endValues.length; i < l; i += 1) {
4308
+ var value = this._handleRelativeValue(startValue, endValues[i]);
4309
+ if (isNaN(value)) {
4310
+ isInterpolationList = false;
4311
+ console.warn('Found invalid interpolation list. Skipping.');
4312
+ break;
4313
+ }
4314
+ temp.push(value);
4315
+ }
4316
+ if (isInterpolationList) {
4317
+ // if (_valuesStart[property] === undefined) { // handle end values only the first time. NOT NEEDED? setupProperties is now guarded by _propertiesAreSetUp.
4318
+ _valuesEnd[property] = temp;
4319
+ // }
4317
4320
  }
4318
4321
  }
4319
4322
  // handle the deepness of the values
4320
4323
  if ((propType === 'object' || startValueIsArray) && startValue && !isInterpolationList) {
4321
4324
  _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];
4325
+ var nestedObject = startValue;
4326
+ for (var prop in nestedObject) {
4327
+ _valuesStart[property][prop] = nestedObject[prop];
4327
4328
  }
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);
4329
+ // TODO? repeat nested values? And yoyo? And array values?
4330
+ _valuesStartRepeat[property] = startValueIsArray ? [] : {};
4331
+ var endValues = _valuesEnd[property];
4332
+ // If dynamic is not enabled, clone the end values instead of using the passed-in end values.
4333
+ if (!this._isDynamic) {
4334
+ var tmp = {};
4335
+ for (var prop in endValues)
4336
+ tmp[prop] = endValues[prop];
4337
+ _valuesEnd[property] = endValues = tmp;
4338
+ }
4339
+ this._setupProperties(nestedObject, _valuesStart[property], endValues, _valuesStartRepeat[property], overrideStartingValues);
4332
4340
  }
4333
4341
  else {
4334
4342
  // Save the starting value, but only once unless override is requested.
@@ -4374,7 +4382,7 @@
4374
4382
  return this;
4375
4383
  };
4376
4384
  Tween.prototype.pause = function (time) {
4377
- if (time === void 0) { time = now$1$1(); }
4385
+ if (time === void 0) { time = now$2(); }
4378
4386
  if (this._isPaused || !this._isPlaying) {
4379
4387
  return this;
4380
4388
  }
@@ -4385,7 +4393,7 @@
4385
4393
  return this;
4386
4394
  };
4387
4395
  Tween.prototype.resume = function (time) {
4388
- if (time === void 0) { time = now$1$1(); }
4396
+ if (time === void 0) { time = now$2(); }
4389
4397
  if (!this._isPaused || !this._isPlaying) {
4390
4398
  return this;
4391
4399
  }
@@ -4476,7 +4484,7 @@
4476
4484
  * it is still playing, just paused).
4477
4485
  */
4478
4486
  Tween.prototype.update = function (time, autoStart) {
4479
- if (time === void 0) { time = now$1$1(); }
4487
+ if (time === void 0) { time = now$2(); }
4480
4488
  if (autoStart === void 0) { autoStart = true; }
4481
4489
  if (this._isPaused)
4482
4490
  return true;
@@ -4599,9 +4607,7 @@
4599
4607
  if (end.charAt(0) === '+' || end.charAt(0) === '-') {
4600
4608
  return start + parseFloat(end);
4601
4609
  }
4602
- else {
4603
- return parseFloat(end);
4604
- }
4610
+ return parseFloat(end);
4605
4611
  };
4606
4612
  Tween.prototype._swapEndStartRepeatValues = function (property) {
4607
4613
  var tmp = this._valuesStartRepeat[property];
@@ -4616,18 +4622,6 @@
4616
4622
  };
4617
4623
  return Tween;
4618
4624
  }());
4619
-
4620
- var VERSION = '19.0.0';
4621
-
4622
- /**
4623
- * Tween.js - Licensed under the MIT license
4624
- * https://github.com/tweenjs/tween.js
4625
- * ----------------------------------------------
4626
- *
4627
- * See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors.
4628
- * Thank you all, you're awesome!
4629
- */
4630
- var nextId = Sequence.nextId;
4631
4625
  /**
4632
4626
  * Controlling groups of tweens
4633
4627
  *
@@ -4639,29 +4633,14 @@
4639
4633
  // Modules and CommonJS, without build hacks, and so as not to break the
4640
4634
  // existing API.
4641
4635
  // https://github.com/rollup/rollup/issues/1961#issuecomment-423037881
4642
- var getAll = TWEEN.getAll.bind(TWEEN);
4643
- var removeAll = TWEEN.removeAll.bind(TWEEN);
4644
- var add = TWEEN.add.bind(TWEEN);
4645
- var remove = TWEEN.remove.bind(TWEEN);
4636
+ TWEEN.getAll.bind(TWEEN);
4637
+ TWEEN.removeAll.bind(TWEEN);
4638
+ TWEEN.add.bind(TWEEN);
4639
+ TWEEN.remove.bind(TWEEN);
4646
4640
  var update = TWEEN.update.bind(TWEEN);
4647
- var exports$1 = {
4648
- Easing: Easing,
4649
- Group: Group,
4650
- Interpolation: Interpolation,
4651
- now: now$1$1,
4652
- Sequence: Sequence,
4653
- nextId: nextId,
4654
- Tween: Tween,
4655
- VERSION: VERSION,
4656
- getAll: getAll,
4657
- removeAll: removeAll,
4658
- add: add,
4659
- remove: remove,
4660
- update: update,
4661
- };
4662
4641
 
4663
4642
  var index$1 = (function (p) {
4664
- return p instanceof Function ? p // fn
4643
+ return typeof p === 'function' ? p // fn
4665
4644
  : typeof p === 'string' ? function (obj) {
4666
4645
  return obj[p];
4667
4646
  } // property name
@@ -5380,6 +5359,7 @@
5380
5359
  Scene: three$1.Scene,
5381
5360
  PerspectiveCamera: three$1.PerspectiveCamera,
5382
5361
  Raycaster: three$1.Raycaster,
5362
+ SRGBColorSpace: three$1.SRGBColorSpace,
5383
5363
  TextureLoader: three$1.TextureLoader,
5384
5364
  Vector2: three$1.Vector2,
5385
5365
  Vector3: three$1.Vector3,
@@ -5502,7 +5482,7 @@
5502
5482
  state.hoverObj = topObject;
5503
5483
  }
5504
5484
  }
5505
- exports$1.update(); // update camera animation tweens
5485
+ update(); // update camera animation tweens
5506
5486
  }
5507
5487
 
5508
5488
  return this;
@@ -5534,10 +5514,10 @@
5534
5514
  } else {
5535
5515
  var camPos = Object.assign({}, camera.position);
5536
5516
  var camLookAt = getLookAt();
5537
- new exports$1.Tween(camPos).to(finalPos, transitionDuration).easing(exports$1.Easing.Quadratic.Out).onUpdate(setCameraPos).start();
5517
+ new Tween(camPos).to(finalPos, transitionDuration).easing(Easing.Quadratic.Out).onUpdate(setCameraPos).start();
5538
5518
 
5539
5519
  // Face direction in 1/3rd of time
5540
- new exports$1.Tween(camLookAt).to(finalLookAt, transitionDuration / 3).easing(exports$1.Easing.Quadratic.Out).onUpdate(setLookAt).start();
5520
+ new Tween(camLookAt).to(finalLookAt, transitionDuration / 3).easing(Easing.Quadratic.Out).onUpdate(setLookAt).start();
5541
5521
  }
5542
5522
  return this;
5543
5523
  }
@@ -5869,6 +5849,7 @@
5869
5849
  !state.loadComplete && finishLoad();
5870
5850
  } else {
5871
5851
  new three.TextureLoader().load(state.backgroundImageUrl, function (texture) {
5852
+ texture.colorSpace = three.SRGBColorSpace;
5872
5853
  state.skysphere.material = new three.MeshBasicMaterial({
5873
5854
  map: texture,
5874
5855
  side: three.BackSide