super-three 0.164.0 → 0.165.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.
Files changed (124) hide show
  1. package/README.md +3 -3
  2. package/build/three.cjs +664 -217
  3. package/build/three.module.js +664 -217
  4. package/build/three.module.min.js +1 -1
  5. package/examples/jsm/controls/TransformControls.js +1 -1
  6. package/examples/jsm/environments/RoomEnvironment.js +1 -5
  7. package/examples/jsm/exporters/GLTFExporter.js +1 -1
  8. package/examples/jsm/exporters/USDZExporter.js +6 -4
  9. package/examples/jsm/helpers/ViewHelper.js +32 -67
  10. package/examples/jsm/libs/tween.module.js +75 -64
  11. package/examples/jsm/lines/LineMaterial.js +1 -15
  12. package/examples/jsm/lines/LineSegments2.js +15 -0
  13. package/examples/jsm/lines/Wireframe.js +16 -1
  14. package/examples/jsm/loaders/DRACOLoader.js +1 -1
  15. package/examples/jsm/loaders/FBXLoader.js +24 -13
  16. package/examples/jsm/loaders/GLTFLoader.js +2 -0
  17. package/examples/jsm/loaders/LDrawLoader.js +3 -2
  18. package/examples/jsm/loaders/MMDLoader.js +31 -12
  19. package/examples/jsm/modifiers/CurveModifier.js +11 -9
  20. package/examples/jsm/nodes/Nodes.js +12 -11
  21. package/examples/jsm/nodes/accessors/BitangentNode.js +7 -83
  22. package/examples/jsm/nodes/accessors/BufferNode.js +6 -0
  23. package/examples/jsm/nodes/accessors/CameraNode.js +12 -119
  24. package/examples/jsm/nodes/accessors/MaterialNode.js +2 -0
  25. package/examples/jsm/nodes/accessors/ModelNode.js +3 -0
  26. package/examples/jsm/nodes/accessors/NormalNode.js +9 -101
  27. package/examples/jsm/nodes/accessors/PositionNode.js +6 -100
  28. package/examples/jsm/nodes/accessors/ReferenceNode.js +6 -0
  29. package/examples/jsm/nodes/accessors/ReflectVectorNode.js +2 -31
  30. package/examples/jsm/nodes/accessors/{TextureStoreNode.js → StorageTextureNode.js} +19 -6
  31. package/examples/jsm/nodes/accessors/TangentNode.js +11 -97
  32. package/examples/jsm/nodes/accessors/Texture3DNode.js +100 -0
  33. package/examples/jsm/nodes/accessors/UVNode.js +2 -46
  34. package/examples/jsm/nodes/core/AttributeNode.js +15 -3
  35. package/examples/jsm/nodes/core/ContextNode.js +6 -0
  36. package/examples/jsm/nodes/core/Node.js +15 -2
  37. package/examples/jsm/nodes/core/NodeBuilder.js +20 -9
  38. package/examples/jsm/nodes/core/NodeKeywords.js +1 -1
  39. package/examples/jsm/nodes/core/OutputStructNode.js +1 -5
  40. package/examples/jsm/nodes/core/PropertyNode.js +1 -0
  41. package/examples/jsm/nodes/core/VaryingNode.js +40 -9
  42. package/examples/jsm/nodes/display/AfterImageNode.js +14 -2
  43. package/examples/jsm/nodes/display/PassNode.js +3 -1
  44. package/examples/jsm/nodes/display/ViewportNode.js +1 -1
  45. package/examples/jsm/nodes/functions/PhysicalLightingModel.js +61 -17
  46. package/examples/jsm/nodes/functions/ToonLightingModel.js +49 -0
  47. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +2 -1
  48. package/examples/jsm/nodes/lighting/LightsNode.js +17 -0
  49. package/examples/jsm/nodes/materials/Line2NodeMaterial.js +1 -1
  50. package/examples/jsm/nodes/materials/Materials.js +3 -0
  51. package/examples/jsm/nodes/materials/MeshMatcapNodeMaterial.js +52 -0
  52. package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +21 -4
  53. package/examples/jsm/nodes/materials/MeshToonNodeMaterial.js +34 -0
  54. package/examples/jsm/nodes/materials/NodeMaterial.js +13 -5
  55. package/examples/jsm/nodes/materials/VolumeNodeMaterial.js +106 -0
  56. package/examples/jsm/nodes/math/HashNode.js +2 -2
  57. package/examples/jsm/nodes/shadernode/ShaderNode.js +55 -33
  58. package/examples/jsm/nodes/utils/ArrayElementNode.js +1 -1
  59. package/examples/jsm/nodes/utils/MatcapUVNode.js +1 -1
  60. package/examples/jsm/nodes/utils/TimerNode.js +1 -1
  61. package/examples/jsm/objects/Lensflare.js +2 -2
  62. package/examples/jsm/postprocessing/RenderPass.js +1 -1
  63. package/examples/jsm/renderers/CSS2DRenderer.js +25 -5
  64. package/examples/jsm/renderers/CSS3DRenderer.js +24 -3
  65. package/examples/jsm/renderers/common/Attributes.js +2 -0
  66. package/examples/jsm/renderers/common/Bindings.js +17 -0
  67. package/examples/jsm/renderers/common/ChainMap.js +18 -48
  68. package/examples/jsm/renderers/common/ClippingContext.js +4 -4
  69. package/examples/jsm/renderers/common/Pipelines.js +2 -2
  70. package/examples/jsm/renderers/common/RenderBundle.js +18 -0
  71. package/examples/jsm/renderers/common/RenderBundles.js +38 -0
  72. package/examples/jsm/renderers/common/RenderList.js +9 -0
  73. package/examples/jsm/renderers/common/RenderObject.js +6 -0
  74. package/examples/jsm/renderers/common/Renderer.js +139 -11
  75. package/examples/jsm/renderers/common/Uniform.js +1 -1
  76. package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +18 -4
  77. package/examples/jsm/renderers/common/nodes/NodeSampler.js +6 -0
  78. package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +17 -5
  79. package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +93 -6
  80. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +50 -4
  81. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +69 -11
  82. package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +10 -1
  83. package/examples/jsm/renderers/webgpu/utils/WebGPUConstants.js +6 -0
  84. package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +62 -19
  85. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +62 -3
  86. package/examples/jsm/utils/BufferGeometryUtils.js +18 -16
  87. package/examples/jsm/utils/GPUStatsPanel.js +2 -0
  88. package/examples/jsm/utils/SortUtils.js +8 -5
  89. package/package.json +3 -2
  90. package/src/animation/tracks/BooleanKeyframeTrack.js +10 -1
  91. package/src/animation/tracks/QuaternionKeyframeTrack.js +1 -2
  92. package/src/animation/tracks/StringKeyframeTrack.js +10 -1
  93. package/src/constants.js +1 -1
  94. package/src/core/Object3D.js +2 -0
  95. package/src/core/Raycaster.js +6 -2
  96. package/src/loaders/FileLoader.js +4 -0
  97. package/src/loaders/LoaderUtils.js +3 -1
  98. package/src/loaders/ObjectLoader.js +1 -0
  99. package/src/objects/BatchedMesh.js +91 -1
  100. package/src/renderers/WebGLRenderer.js +288 -57
  101. package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +15 -0
  102. package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -1
  103. package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +9 -1
  104. package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +8 -22
  105. package/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js +1 -1
  106. package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +1 -1
  107. package/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +3 -14
  108. package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +10 -31
  109. package/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js +3 -23
  110. package/src/renderers/webgl/WebGLBackground.js +6 -0
  111. package/src/renderers/webgl/WebGLExtensions.js +3 -1
  112. package/src/renderers/webgl/WebGLLights.js +9 -12
  113. package/src/renderers/webgl/WebGLMaterials.js +1 -5
  114. package/src/renderers/webgl/WebGLMorphtargets.js +1 -2
  115. package/src/renderers/webgl/WebGLProgram.js +2 -31
  116. package/src/renderers/webgl/WebGLPrograms.js +14 -14
  117. package/src/renderers/webgl/WebGLRenderStates.js +2 -2
  118. package/src/renderers/webgl/WebGLTextures.js +139 -70
  119. package/src/renderers/webxr/WebXRDepthSensing.js +3 -3
  120. package/src/renderers/webxr/WebXRManager.js +6 -2
  121. package/src/textures/CompressedArrayTexture.js +14 -0
  122. package/src/textures/DataArrayTexture.js +14 -0
  123. package/src/textures/DepthTexture.js +1 -3
  124. package/src/utils.js +30 -1
@@ -32,7 +32,7 @@ const _unit = {
32
32
  };
33
33
 
34
34
  const _changeEvent = { type: 'change' };
35
- const _mouseDownEvent = { type: 'mouseDown' };
35
+ const _mouseDownEvent = { type: 'mouseDown', mode: null };
36
36
  const _mouseUpEvent = { type: 'mouseUp', mode: null };
37
37
  const _objectChangeEvent = { type: 'objectChange' };
38
38
 
@@ -24,11 +24,7 @@ class RoomEnvironment extends Scene {
24
24
  const roomMaterial = new MeshStandardMaterial( { side: BackSide } );
25
25
  const boxMaterial = new MeshStandardMaterial();
26
26
 
27
- let intensity = 5;
28
-
29
- if ( renderer !== null && renderer._useLegacyLights === false ) intensity = 900;
30
-
31
- const mainLight = new PointLight( 0xffffff, intensity, 28, 2 );
27
+ const mainLight = new PointLight( 0xffffff, 900, 28, 2 );
32
28
  mainLight.position.set( 0.418, 16.199, 0.300 );
33
29
  this.add( mainLight );
34
30
 
@@ -24,9 +24,9 @@ import {
24
24
  CompressedTexture,
25
25
  Vector3,
26
26
  Quaternion,
27
+ REVISION
27
28
  } from 'three';
28
29
  import { decompress } from './../utils/TextureUtils.js';
29
- import { REVISION } from '../../../src/constants.js';
30
30
 
31
31
 
32
32
  /**
@@ -25,6 +25,7 @@ class USDZExporter {
25
25
  anchoring: { type: 'plane' },
26
26
  planeAnchoring: { alignment: 'horizontal' }
27
27
  },
28
+ includeAnchoringProperties: true,
28
29
  quickLookCompatible: false,
29
30
  maxTextureSize: 1024,
30
31
  }, options );
@@ -198,6 +199,10 @@ function buildHeader() {
198
199
 
199
200
  function buildSceneStart( options ) {
200
201
 
202
+ const alignment = options.includeAnchoringProperties === true ? `
203
+ token preliminary:anchoring:type = "${options.ar.anchoring.type}"
204
+ token preliminary:planeAnchoring:alignment = "${options.ar.planeAnchoring.alignment}"
205
+ ` : '';
201
206
  return `def Xform "Root"
202
207
  {
203
208
  def Scope "Scenes" (
@@ -211,10 +216,7 @@ function buildSceneStart( options ) {
211
216
  }
212
217
  sceneName = "Scene"
213
218
  )
214
- {
215
- token preliminary:anchoring:type = "${options.ar.anchoring.type}"
216
- token preliminary:planeAnchoring:alignment = "${options.ar.planeAnchoring.alignment}"
217
-
219
+ {${alignment}
218
220
  `;
219
221
 
220
222
  }
@@ -1,5 +1,5 @@
1
1
  import {
2
- BoxGeometry,
2
+ CylinderGeometry,
3
3
  CanvasTexture,
4
4
  Color,
5
5
  Euler,
@@ -11,6 +11,7 @@ import {
11
11
  Raycaster,
12
12
  Sprite,
13
13
  SpriteMaterial,
14
+ SRGBColorSpace,
14
15
  Vector2,
15
16
  Vector3,
16
17
  Vector4
@@ -27,9 +28,10 @@ class ViewHelper extends Object3D {
27
28
  this.animating = false;
28
29
  this.center = new Vector3();
29
30
 
30
- const color1 = new Color( '#ff3653' );
31
- const color2 = new Color( '#8adb00' );
32
- const color3 = new Color( '#2c8fff' );
31
+ const color1 = new Color( '#ff4466' );
32
+ const color2 = new Color( '#88ff44' );
33
+ const color3 = new Color( '#4488ff' );
34
+ const color4 = new Color( '#000000' );
33
35
 
34
36
  const interactiveObjects = [];
35
37
  const raycaster = new Raycaster();
@@ -39,7 +41,7 @@ class ViewHelper extends Object3D {
39
41
  const orthoCamera = new OrthographicCamera( - 2, 2, 2, - 2, 0, 4 );
40
42
  orthoCamera.position.set( 0, 0, 2 );
41
43
 
42
- const geometry = new BoxGeometry( 0.8, 0.05, 0.05 ).translate( 0.4, 0, 0 );
44
+ const geometry = new CylinderGeometry( 0.04, 0.04, 0.8, 5 ).rotateZ( - Math.PI / 2 ).translate( 0.4, 0, 0 );
43
45
 
44
46
  const xAxis = new Mesh( geometry, getAxisMaterial( color1 ) );
45
47
  const yAxis = new Mesh( geometry, getAxisMaterial( color2 ) );
@@ -52,28 +54,35 @@ class ViewHelper extends Object3D {
52
54
  this.add( zAxis );
53
55
  this.add( yAxis );
54
56
 
55
- const posXAxisHelper = new Sprite( getSpriteMaterial( color1, 'X' ) );
56
- posXAxisHelper.userData.type = 'posX';
57
- const posYAxisHelper = new Sprite( getSpriteMaterial( color2, 'Y' ) );
58
- posYAxisHelper.userData.type = 'posY';
59
- const posZAxisHelper = new Sprite( getSpriteMaterial( color3, 'Z' ) );
60
- posZAxisHelper.userData.type = 'posZ';
61
- const negXAxisHelper = new Sprite( getSpriteMaterial( color1 ) );
62
- negXAxisHelper.userData.type = 'negX';
63
- const negYAxisHelper = new Sprite( getSpriteMaterial( color2 ) );
64
- negYAxisHelper.userData.type = 'negY';
65
- const negZAxisHelper = new Sprite( getSpriteMaterial( color3 ) );
66
- negZAxisHelper.userData.type = 'negZ';
57
+ const spriteMaterial1 = getSpriteMaterial( color1 );
58
+ const spriteMaterial2 = getSpriteMaterial( color2 );
59
+ const spriteMaterial3 = getSpriteMaterial( color3 );
60
+ const spriteMaterial4 = getSpriteMaterial( color4 );
61
+
62
+ const posXAxisHelper = new Sprite( spriteMaterial1 );
63
+ const posYAxisHelper = new Sprite( spriteMaterial2 );
64
+ const posZAxisHelper = new Sprite( spriteMaterial3 );
65
+ const negXAxisHelper = new Sprite( spriteMaterial4 );
66
+ const negYAxisHelper = new Sprite( spriteMaterial4 );
67
+ const negZAxisHelper = new Sprite( spriteMaterial4 );
67
68
 
68
69
  posXAxisHelper.position.x = 1;
69
70
  posYAxisHelper.position.y = 1;
70
71
  posZAxisHelper.position.z = 1;
71
72
  negXAxisHelper.position.x = - 1;
72
- negXAxisHelper.scale.setScalar( 0.8 );
73
73
  negYAxisHelper.position.y = - 1;
74
- negYAxisHelper.scale.setScalar( 0.8 );
75
74
  negZAxisHelper.position.z = - 1;
76
- negZAxisHelper.scale.setScalar( 0.8 );
75
+
76
+ negXAxisHelper.material.opacity = 0.2;
77
+ negYAxisHelper.material.opacity = 0.2;
78
+ negZAxisHelper.material.opacity = 0.2;
79
+
80
+ posXAxisHelper.userData.type = 'posX';
81
+ posYAxisHelper.userData.type = 'posY';
82
+ posZAxisHelper.userData.type = 'posZ';
83
+ negXAxisHelper.userData.type = 'negX';
84
+ negYAxisHelper.userData.type = 'negY';
85
+ negZAxisHelper.userData.type = 'negZ';
77
86
 
78
87
  this.add( posXAxisHelper );
79
88
  this.add( posYAxisHelper );
@@ -101,42 +110,6 @@ class ViewHelper extends Object3D {
101
110
  point.set( 0, 0, 1 );
102
111
  point.applyQuaternion( camera.quaternion );
103
112
 
104
- if ( point.x >= 0 ) {
105
-
106
- posXAxisHelper.material.opacity = 1;
107
- negXAxisHelper.material.opacity = 0.5;
108
-
109
- } else {
110
-
111
- posXAxisHelper.material.opacity = 0.5;
112
- negXAxisHelper.material.opacity = 1;
113
-
114
- }
115
-
116
- if ( point.y >= 0 ) {
117
-
118
- posYAxisHelper.material.opacity = 1;
119
- negYAxisHelper.material.opacity = 0.5;
120
-
121
- } else {
122
-
123
- posYAxisHelper.material.opacity = 0.5;
124
- negYAxisHelper.material.opacity = 1;
125
-
126
- }
127
-
128
- if ( point.z >= 0 ) {
129
-
130
- posZAxisHelper.material.opacity = 1;
131
- negZAxisHelper.material.opacity = 0.5;
132
-
133
- } else {
134
-
135
- posZAxisHelper.material.opacity = 0.5;
136
- negZAxisHelper.material.opacity = 1;
137
-
138
- }
139
-
140
113
  //
141
114
 
142
115
  const x = domElement.offsetWidth - dim;
@@ -298,7 +271,7 @@ class ViewHelper extends Object3D {
298
271
 
299
272
  }
300
273
 
301
- function getSpriteMaterial( color, text = null ) {
274
+ function getSpriteMaterial( color ) {
302
275
 
303
276
  const canvas = document.createElement( 'canvas' );
304
277
  canvas.width = 64;
@@ -306,21 +279,13 @@ class ViewHelper extends Object3D {
306
279
 
307
280
  const context = canvas.getContext( '2d' );
308
281
  context.beginPath();
309
- context.arc( 32, 32, 16, 0, 2 * Math.PI );
282
+ context.arc( 32, 32, 14, 0, 2 * Math.PI );
310
283
  context.closePath();
311
284
  context.fillStyle = color.getStyle();
312
285
  context.fill();
313
286
 
314
- if ( text !== null ) {
315
-
316
- context.font = '24px Arial';
317
- context.textAlign = 'center';
318
- context.fillStyle = '#000000';
319
- context.fillText( text, 32, 41 );
320
-
321
- }
322
-
323
287
  const texture = new CanvasTexture( canvas );
288
+ texture.colorSpace = SRGBColorSpace;
324
289
 
325
290
  return new SpriteMaterial( { map: texture, toneMapped: false } );
326
291
 
@@ -7,13 +7,13 @@ var Easing = Object.freeze({
7
7
  return amount;
8
8
  },
9
9
  In: function (amount) {
10
- return this.None(amount);
10
+ return amount;
11
11
  },
12
12
  Out: function (amount) {
13
- return this.None(amount);
13
+ return amount;
14
14
  },
15
15
  InOut: function (amount) {
16
- return this.None(amount);
16
+ return amount;
17
17
  },
18
18
  }),
19
19
  Quadratic: Object.freeze({
@@ -676,13 +676,11 @@ var Tween = /** @class */ (function () {
676
676
  * it is still playing, just paused).
677
677
  */
678
678
  Tween.prototype.update = function (time, autoStart) {
679
- var _this = this;
680
679
  var _a;
681
680
  if (time === void 0) { time = now(); }
682
681
  if (autoStart === void 0) { autoStart = true; }
683
682
  if (this._isPaused)
684
683
  return true;
685
- var property;
686
684
  var endTime = this._startTime + this._duration;
687
685
  if (!this._goToEnd && !this._isPlaying) {
688
686
  if (time > endTime)
@@ -709,72 +707,85 @@ var Tween = /** @class */ (function () {
709
707
  var elapsedTime = time - this._startTime;
710
708
  var durationAndDelay = this._duration + ((_a = this._repeatDelayTime) !== null && _a !== void 0 ? _a : this._delayTime);
711
709
  var totalTime = this._duration + this._repeat * durationAndDelay;
712
- var calculateElapsedPortion = function () {
713
- if (_this._duration === 0)
714
- return 1;
715
- if (elapsedTime > totalTime) {
716
- return 1;
717
- }
718
- var timesRepeated = Math.trunc(elapsedTime / durationAndDelay);
719
- var timeIntoCurrentRepeat = elapsedTime - timesRepeated * durationAndDelay;
720
- // TODO use %?
721
- // const timeIntoCurrentRepeat = elapsedTime % durationAndDelay
722
- var portion = Math.min(timeIntoCurrentRepeat / _this._duration, 1);
723
- if (portion === 0 && elapsedTime === _this._duration) {
724
- return 1;
725
- }
726
- return portion;
727
- };
728
- var elapsed = calculateElapsedPortion();
710
+ var elapsed = this._calculateElapsedPortion(elapsedTime, durationAndDelay, totalTime);
729
711
  var value = this._easingFunction(elapsed);
730
- // properties transformations
712
+ var status = this._calculateCompletionStatus(elapsedTime, durationAndDelay);
713
+ if (status === 'repeat') {
714
+ // the current update is happening after the instant the tween repeated
715
+ this._processRepetition(elapsedTime, durationAndDelay);
716
+ }
731
717
  this._updateProperties(this._object, this._valuesStart, this._valuesEnd, value);
718
+ if (status === 'about-to-repeat') {
719
+ // the current update is happening at the exact instant the tween is going to repeat
720
+ // the values should match the end of the tween, not the beginning,
721
+ // that's why _processRepetition happens after _updateProperties
722
+ this._processRepetition(elapsedTime, durationAndDelay);
723
+ }
732
724
  if (this._onUpdateCallback) {
733
725
  this._onUpdateCallback(this._object, elapsed);
734
726
  }
735
- if (this._duration === 0 || elapsedTime >= this._duration) {
736
- if (this._repeat > 0) {
737
- var completeCount = Math.min(Math.trunc((elapsedTime - this._duration) / durationAndDelay) + 1, this._repeat);
738
- if (isFinite(this._repeat)) {
739
- this._repeat -= completeCount;
740
- }
741
- // Reassign starting values, restart by making startTime = now
742
- for (property in this._valuesStartRepeat) {
743
- if (!this._yoyo && typeof this._valuesEnd[property] === 'string') {
744
- this._valuesStartRepeat[property] =
745
- // eslint-disable-next-line
746
- // @ts-ignore FIXME?
747
- this._valuesStartRepeat[property] + parseFloat(this._valuesEnd[property]);
748
- }
749
- if (this._yoyo) {
750
- this._swapEndStartRepeatValues(property);
751
- }
752
- this._valuesStart[property] = this._valuesStartRepeat[property];
753
- }
754
- if (this._yoyo) {
755
- this._reversed = !this._reversed;
756
- }
757
- this._startTime += durationAndDelay * completeCount;
758
- if (this._onRepeatCallback) {
759
- this._onRepeatCallback(this._object);
760
- }
761
- this._onEveryStartCallbackFired = false;
762
- return true;
727
+ if (status === 'repeat' || status === 'about-to-repeat') {
728
+ if (this._onRepeatCallback) {
729
+ this._onRepeatCallback(this._object);
763
730
  }
764
- else {
765
- if (this._onCompleteCallback) {
766
- this._onCompleteCallback(this._object);
767
- }
768
- for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) {
769
- // Make the chained tweens start exactly at the time they should,
770
- // even if the `update()` method was called way past the duration of the tween
771
- this._chainedTweens[i].start(this._startTime + this._duration, false);
772
- }
773
- this._isPlaying = false;
774
- return false;
731
+ this._onEveryStartCallbackFired = false;
732
+ }
733
+ else if (status === 'completed') {
734
+ this._isPlaying = false;
735
+ if (this._onCompleteCallback) {
736
+ this._onCompleteCallback(this._object);
737
+ }
738
+ for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) {
739
+ // Make the chained tweens start exactly at the time they should,
740
+ // even if the `update()` method was called way past the duration of the tween
741
+ this._chainedTweens[i].start(this._startTime + this._duration, false);
775
742
  }
776
743
  }
777
- return true;
744
+ return status !== 'completed';
745
+ };
746
+ Tween.prototype._calculateElapsedPortion = function (elapsedTime, durationAndDelay, totalTime) {
747
+ if (this._duration === 0 || elapsedTime > totalTime) {
748
+ return 1;
749
+ }
750
+ var timeIntoCurrentRepeat = elapsedTime % durationAndDelay;
751
+ var portion = Math.min(timeIntoCurrentRepeat / this._duration, 1);
752
+ if (portion === 0 && elapsedTime !== 0 && elapsedTime % this._duration === 0) {
753
+ return 1;
754
+ }
755
+ return portion;
756
+ };
757
+ Tween.prototype._calculateCompletionStatus = function (elapsedTime, durationAndDelay) {
758
+ if (this._duration !== 0 && elapsedTime < this._duration) {
759
+ return 'playing';
760
+ }
761
+ if (this._repeat <= 0) {
762
+ return 'completed';
763
+ }
764
+ if (elapsedTime === this._duration) {
765
+ return 'about-to-repeat';
766
+ }
767
+ return 'repeat';
768
+ };
769
+ Tween.prototype._processRepetition = function (elapsedTime, durationAndDelay) {
770
+ var completeCount = Math.min(Math.trunc((elapsedTime - this._duration) / durationAndDelay) + 1, this._repeat);
771
+ if (isFinite(this._repeat)) {
772
+ this._repeat -= completeCount;
773
+ }
774
+ // Reassign starting values, restart by making startTime = now
775
+ for (var property in this._valuesStartRepeat) {
776
+ var valueEnd = this._valuesEnd[property];
777
+ if (!this._yoyo && typeof valueEnd === 'string') {
778
+ this._valuesStartRepeat[property] = this._valuesStartRepeat[property] + parseFloat(valueEnd);
779
+ }
780
+ if (this._yoyo) {
781
+ this._swapEndStartRepeatValues(property);
782
+ }
783
+ this._valuesStart[property] = this._valuesStartRepeat[property];
784
+ }
785
+ if (this._yoyo) {
786
+ this._reversed = !this._reversed;
787
+ }
788
+ this._startTime += durationAndDelay * completeCount;
778
789
  };
779
790
  Tween.prototype._updateProperties = function (_object, _valuesStart, _valuesEnd, value) {
780
791
  for (var property in _valuesEnd) {
@@ -830,7 +841,7 @@ var Tween = /** @class */ (function () {
830
841
  return Tween;
831
842
  }());
832
843
 
833
- var VERSION = '23.1.1';
844
+ var VERSION = '23.1.2';
834
845
 
835
846
  /**
836
847
  * Tween.js - Licensed under the MIT license
@@ -1,25 +1,11 @@
1
- /**
2
- * parameters = {
3
- * color: <hex>,
4
- * linewidth: <float>,
5
- * dashed: <boolean>,
6
- * dashScale: <float>,
7
- * dashSize: <float>,
8
- * dashOffset: <float>,
9
- * gapSize: <float>,
10
- * resolution: <Vector2>, // to be set by renderer
11
- * }
12
- */
13
-
14
1
  import {
15
2
  ShaderLib,
16
3
  ShaderMaterial,
17
4
  UniformsLib,
18
5
  UniformsUtils,
19
- Vector2
6
+ Vector2,
20
7
  } from 'three';
21
8
 
22
-
23
9
  UniformsLib.line = {
24
10
 
25
11
  worldUnits: { value: 1 },
@@ -13,6 +13,8 @@ import {
13
13
  import { LineSegmentsGeometry } from '../lines/LineSegmentsGeometry.js';
14
14
  import { LineMaterial } from '../lines/LineMaterial.js';
15
15
 
16
+ const _viewport = new Vector4();
17
+
16
18
  const _start = new Vector3();
17
19
  const _end = new Vector3();
18
20
 
@@ -356,6 +358,19 @@ class LineSegments2 extends Mesh {
356
358
 
357
359
  }
358
360
 
361
+ onBeforeRender( renderer ) {
362
+
363
+ const uniforms = this.material.uniforms;
364
+
365
+ if ( uniforms && uniforms.resolution ) {
366
+
367
+ renderer.getViewport( _viewport );
368
+ this.material.uniforms.resolution.value.set( _viewport.z, _viewport.w );
369
+
370
+ }
371
+
372
+ }
373
+
359
374
  }
360
375
 
361
376
  export { LineSegments2 };
@@ -2,13 +2,15 @@ import {
2
2
  InstancedInterleavedBuffer,
3
3
  InterleavedBufferAttribute,
4
4
  Mesh,
5
- Vector3
5
+ Vector3,
6
+ Vector4
6
7
  } from 'three';
7
8
  import { LineSegmentsGeometry } from '../lines/LineSegmentsGeometry.js';
8
9
  import { LineMaterial } from '../lines/LineMaterial.js';
9
10
 
10
11
  const _start = new Vector3();
11
12
  const _end = new Vector3();
13
+ const _viewport = new Vector4();
12
14
 
13
15
  class Wireframe extends Mesh {
14
16
 
@@ -51,6 +53,19 @@ class Wireframe extends Mesh {
51
53
 
52
54
  }
53
55
 
56
+ onBeforeRender( renderer ) {
57
+
58
+ const uniforms = this.material.uniforms;
59
+
60
+ if ( uniforms && uniforms.resolution ) {
61
+
62
+ renderer.getViewport( _viewport );
63
+ this.material.uniforms.resolution.value.set( _viewport.z, _viewport.w );
64
+
65
+ }
66
+
67
+ }
68
+
54
69
  }
55
70
 
56
71
  export { Wireframe };
@@ -85,7 +85,7 @@ class DRACOLoader extends Loader {
85
85
 
86
86
  parse( buffer, onLoad, onError = ()=>{} ) {
87
87
 
88
- this.decodeDracoFile( buffer, onLoad, null, null, SRGBColorSpace ).catch( onError );
88
+ this.decodeDracoFile( buffer, onLoad, null, null, SRGBColorSpace, onError ).catch( onError );
89
89
 
90
90
  }
91
91
 
@@ -2051,14 +2051,18 @@ class GeometryParser {
2051
2051
  // Triangulate n-gon using earcut
2052
2052
 
2053
2053
  const vertices = [];
2054
-
2054
+ // in morphing scenario vertexPositions represent morphPositions
2055
+ // while baseVertexPositions represent the original geometry's positions
2056
+ const positions = geoInfo.baseVertexPositions || geoInfo.vertexPositions;
2055
2057
  for ( let i = 0; i < facePositionIndexes.length; i += 3 ) {
2056
2058
 
2057
- vertices.push( new Vector3(
2058
- geoInfo.vertexPositions[ facePositionIndexes[ i ] ],
2059
- geoInfo.vertexPositions[ facePositionIndexes[ i + 1 ] ],
2060
- geoInfo.vertexPositions[ facePositionIndexes[ i + 2 ] ]
2061
- ) );
2059
+ vertices.push(
2060
+ new Vector3(
2061
+ positions[ facePositionIndexes[ i ] ],
2062
+ positions[ facePositionIndexes[ i + 1 ] ],
2063
+ positions[ facePositionIndexes[ i + 2 ] ]
2064
+ )
2065
+ );
2062
2066
 
2063
2067
  }
2064
2068
 
@@ -2071,6 +2075,12 @@ class GeometryParser {
2071
2075
 
2072
2076
  }
2073
2077
 
2078
+ // When vertices is an array of [0,0,0] elements (which is the case for vertices not participating in morph)
2079
+ // the triangulationInput will be an array of [0,0] elements
2080
+ // resulting in an array of 0 triangles being returned from ShapeUtils.triangulateShape
2081
+ // leading to not pushing into buffers.vertex the redundant vertices (the vertices that are not morphed).
2082
+ // That's why, in order to support morphing scenario, "positions" is looking first for baseVertexPositions,
2083
+ // so that we don't end up with an array of 0 triangles for the faces not participating in morph.
2074
2084
  triangles = ShapeUtils.triangulateShape( triangulationInput, [] );
2075
2085
 
2076
2086
  } else {
@@ -2225,17 +2235,18 @@ class GeometryParser {
2225
2235
  // Normal and position attributes only have data for the vertices that are affected by the morph
2226
2236
  genMorphGeometry( parentGeo, parentGeoNode, morphGeoNode, preTransform, name ) {
2227
2237
 
2228
- const vertexIndices = ( parentGeoNode.PolygonVertexIndex !== undefined ) ? parentGeoNode.PolygonVertexIndex.a : [];
2238
+ const basePositions = parentGeoNode.Vertices !== undefined ? parentGeoNode.Vertices.a : [];
2239
+ const baseIndices = parentGeoNode.PolygonVertexIndex !== undefined ? parentGeoNode.PolygonVertexIndex.a : [];
2229
2240
 
2230
- const morphPositionsSparse = ( morphGeoNode.Vertices !== undefined ) ? morphGeoNode.Vertices.a : [];
2231
- const indices = ( morphGeoNode.Indexes !== undefined ) ? morphGeoNode.Indexes.a : [];
2241
+ const morphPositionsSparse = morphGeoNode.Vertices !== undefined ? morphGeoNode.Vertices.a : [];
2242
+ const morphIndices = morphGeoNode.Indexes !== undefined ? morphGeoNode.Indexes.a : [];
2232
2243
 
2233
2244
  const length = parentGeo.attributes.position.count * 3;
2234
2245
  const morphPositions = new Float32Array( length );
2235
2246
 
2236
- for ( let i = 0; i < indices.length; i ++ ) {
2247
+ for ( let i = 0; i < morphIndices.length; i ++ ) {
2237
2248
 
2238
- const morphIndex = indices[ i ] * 3;
2249
+ const morphIndex = morphIndices[ i ] * 3;
2239
2250
 
2240
2251
  morphPositions[ morphIndex ] = morphPositionsSparse[ i * 3 ];
2241
2252
  morphPositions[ morphIndex + 1 ] = morphPositionsSparse[ i * 3 + 1 ];
@@ -2245,9 +2256,9 @@ class GeometryParser {
2245
2256
 
2246
2257
  // TODO: add morph normal support
2247
2258
  const morphGeoInfo = {
2248
- vertexIndices: vertexIndices,
2259
+ vertexIndices: baseIndices,
2249
2260
  vertexPositions: morphPositions,
2250
-
2261
+ baseVertexPositions: basePositions
2251
2262
  };
2252
2263
 
2253
2264
  const morphBuffers = this.genBuffers( morphGeoInfo );
@@ -3317,6 +3317,8 @@ class GLTFParser {
3317
3317
 
3318
3318
  }
3319
3319
 
3320
+ assignExtrasToUserData( texture, sourceDef );
3321
+
3320
3322
  texture.userData.mimeType = sourceDef.mimeType || getImageURIMimeType( sourceDef.uri );
3321
3323
 
3322
3324
  return texture;
@@ -1974,7 +1974,7 @@ class LDrawLoader extends Loader {
1974
1974
 
1975
1975
  }
1976
1976
 
1977
- parse( text, onLoad ) {
1977
+ parse( text, onLoad, onError ) {
1978
1978
 
1979
1979
  this.partsCache
1980
1980
  .parseModel( text, this.materialLibrary )
@@ -1985,7 +1985,8 @@ class LDrawLoader extends Loader {
1985
1985
  group.userData.fileName = '';
1986
1986
  onLoad( group );
1987
1987
 
1988
- } );
1988
+ } )
1989
+ .catch( onError );
1989
1990
 
1990
1991
  }
1991
1992