super-three 0.161.0 → 0.162.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 (131) hide show
  1. package/build/three.cjs +490 -393
  2. package/build/three.module.js +490 -391
  3. package/build/three.module.min.js +1 -1
  4. package/examples/jsm/controls/DragControls.js +91 -30
  5. package/examples/jsm/controls/OrbitControls.js +32 -6
  6. package/examples/jsm/controls/TransformControls.js +6 -6
  7. package/examples/jsm/exporters/GLTFExporter.js +11 -1
  8. package/examples/jsm/interactive/InteractiveGroup.js +15 -25
  9. package/examples/jsm/libs/rhino3dm/rhino3dm.js +1 -8723
  10. package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +1 -8734
  11. package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
  12. package/examples/jsm/libs/tween.module.js +32 -14
  13. package/examples/jsm/loaders/3DMLoader.js +13 -21
  14. package/examples/jsm/loaders/VOXLoader.js +9 -2
  15. package/examples/jsm/loaders/VRMLLoader.js +6 -2
  16. package/examples/jsm/misc/ProgressiveLightMap.js +1 -0
  17. package/examples/jsm/nodes/Nodes.js +9 -7
  18. package/examples/jsm/nodes/accessors/AccessorsUtils.js +10 -0
  19. package/examples/jsm/nodes/accessors/ClippingNode.js +144 -0
  20. package/examples/jsm/nodes/accessors/MaterialNode.js +2 -2
  21. package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +2 -12
  22. package/examples/jsm/nodes/accessors/MorphNode.js +8 -8
  23. package/examples/jsm/nodes/accessors/ReferenceNode.js +87 -29
  24. package/examples/jsm/nodes/accessors/SkinningNode.js +31 -10
  25. package/examples/jsm/nodes/accessors/StorageBufferNode.js +18 -0
  26. package/examples/jsm/nodes/accessors/TangentNode.js +8 -2
  27. package/examples/jsm/nodes/accessors/TextureNode.js +1 -1
  28. package/examples/jsm/nodes/accessors/UniformsNode.js +140 -0
  29. package/examples/jsm/nodes/code/CodeNode.js +6 -0
  30. package/examples/jsm/nodes/core/AssignNode.js +68 -12
  31. package/examples/jsm/nodes/core/Node.js +14 -4
  32. package/examples/jsm/nodes/core/NodeBuilder.js +3 -9
  33. package/examples/jsm/nodes/core/NodeFrame.js +2 -2
  34. package/examples/jsm/nodes/core/TempNode.js +1 -1
  35. package/examples/jsm/nodes/display/BlendModeNode.js +30 -1
  36. package/examples/jsm/nodes/display/NormalMapNode.js +3 -5
  37. package/examples/jsm/nodes/materials/NodeMaterial.js +37 -6
  38. package/examples/jsm/nodes/math/CondNode.js +42 -7
  39. package/examples/jsm/nodes/math/MathNode.js +20 -0
  40. package/examples/jsm/nodes/utils/ArrayElementNode.js +0 -6
  41. package/examples/jsm/nodes/utils/LoopNode.js +2 -0
  42. package/examples/jsm/nodes/utils/StorageArrayElementNode.js +91 -0
  43. package/examples/jsm/postprocessing/OutputPass.js +2 -0
  44. package/examples/jsm/renderers/common/Background.js +2 -2
  45. package/examples/jsm/renderers/common/ClippingContext.js +165 -0
  46. package/examples/jsm/renderers/common/RenderContext.js +2 -0
  47. package/examples/jsm/renderers/common/RenderContexts.js +2 -13
  48. package/examples/jsm/renderers/common/RenderObject.js +44 -1
  49. package/examples/jsm/renderers/common/RenderObjects.js +3 -1
  50. package/examples/jsm/renderers/common/Renderer.js +94 -37
  51. package/examples/jsm/renderers/common/StorageBufferAttribute.js +2 -2
  52. package/examples/jsm/renderers/common/StorageInstancedBufferAttribute.js +17 -0
  53. package/examples/jsm/renderers/common/Textures.js +3 -13
  54. package/examples/jsm/renderers/common/UniformsGroup.js +6 -4
  55. package/examples/jsm/renderers/common/nodes/NodeStorageBuffer.js +23 -0
  56. package/examples/jsm/renderers/common/nodes/NodeUniformBuffer.js +23 -0
  57. package/examples/jsm/renderers/common/nodes/Nodes.js +1 -0
  58. package/examples/jsm/renderers/webgl/WebGLBackend.js +26 -6
  59. package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +135 -10
  60. package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +7 -1
  61. package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +47 -0
  62. package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +1 -0
  63. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +13 -12
  64. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +15 -40
  65. package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +7 -1
  66. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +2 -2
  67. package/examples/jsm/shaders/OutputShader.js +4 -0
  68. package/examples/jsm/utils/SkeletonUtils.js +14 -3
  69. package/examples/jsm/webxr/VRButton.js +13 -5
  70. package/examples/jsm/webxr/XRButton.js +0 -1
  71. package/examples/jsm/webxr/XRControllerModelFactory.js +8 -0
  72. package/package.json +4 -3
  73. package/src/Three.Legacy.js +20 -0
  74. package/src/Three.js +0 -1
  75. package/src/constants.js +2 -5
  76. package/src/core/BufferAttribute.js +0 -11
  77. package/src/core/BufferGeometry.js +23 -29
  78. package/src/core/Object3D.js +11 -0
  79. package/src/core/Raycaster.js +18 -4
  80. package/src/core/RenderTarget.js +44 -21
  81. package/src/extras/PMREMGenerator.js +2 -0
  82. package/src/extras/curves/EllipseCurve.js +2 -2
  83. package/src/helpers/SpotLightHelper.js +18 -1
  84. package/src/loaders/DataTextureLoader.js +0 -4
  85. package/src/loaders/MaterialLoader.js +1 -0
  86. package/src/loaders/ObjectLoader.js +2 -1
  87. package/src/materials/Material.js +2 -1
  88. package/src/materials/MeshBasicMaterial.js +3 -0
  89. package/src/materials/MeshLambertMaterial.js +3 -0
  90. package/src/materials/MeshPhongMaterial.js +3 -0
  91. package/src/materials/MeshStandardMaterial.js +3 -0
  92. package/src/math/Quaternion.js +13 -12
  93. package/src/math/Vector3.js +7 -7
  94. package/src/objects/InstancedMesh.js +53 -0
  95. package/src/objects/Mesh.js +0 -1
  96. package/src/renderers/WebGLCubeRenderTarget.js +1 -10
  97. package/src/renderers/WebGLRenderer.js +15 -22
  98. package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -0
  99. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
  100. package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +2 -2
  101. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +1 -1
  102. package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +14 -0
  103. package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +11 -2
  104. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +23 -0
  105. package/src/renderers/shaders/ShaderChunk.js +2 -0
  106. package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +3 -2
  107. package/src/renderers/shaders/ShaderLib/depth.glsl.js +2 -0
  108. package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +2 -0
  109. package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +1 -0
  110. package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +1 -0
  111. package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +1 -0
  112. package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +1 -0
  113. package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -0
  114. package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +1 -0
  115. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +1 -0
  116. package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +1 -0
  117. package/src/renderers/shaders/ShaderLib/points.glsl.js +1 -0
  118. package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -0
  119. package/src/renderers/shaders/ShaderLib.js +2 -1
  120. package/src/renderers/shaders/UniformsLib.js +1 -0
  121. package/src/renderers/webgl/WebGLBackground.js +18 -0
  122. package/src/renderers/webgl/WebGLMaterials.js +24 -1
  123. package/src/renderers/webgl/WebGLMorphtargets.js +15 -8
  124. package/src/renderers/webgl/WebGLProgram.js +12 -1
  125. package/src/renderers/webgl/WebGLPrograms.js +19 -16
  126. package/src/renderers/webgl/WebGLState.js +11 -21
  127. package/src/renderers/webgl/WebGLTextures.js +80 -50
  128. package/src/scenes/Scene.js +8 -0
  129. package/src/textures/Texture.js +1 -29
  130. package/examples/jsm/nodes/core/ArrayUniformNode.js +0 -26
  131. package/src/renderers/WebGLMultipleRenderTargets.js +0 -82
@@ -413,18 +413,21 @@ var Tween = /** @class */ (function () {
413
413
  Tween.prototype.isPaused = function () {
414
414
  return this._isPaused;
415
415
  };
416
+ Tween.prototype.getDuration = function () {
417
+ return this._duration;
418
+ };
416
419
  Tween.prototype.to = function (target, duration) {
417
420
  if (duration === void 0) { duration = 1000; }
418
421
  if (this._isPlaying)
419
422
  throw new Error('Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.');
420
423
  this._valuesEnd = target;
421
424
  this._propertiesAreSetUp = false;
422
- this._duration = duration;
425
+ this._duration = duration < 0 ? 0 : duration;
423
426
  return this;
424
427
  };
425
428
  Tween.prototype.duration = function (duration) {
426
429
  if (duration === void 0) { duration = 1000; }
427
- this._duration = duration;
430
+ this._duration = duration < 0 ? 0 : duration;
428
431
  return this;
429
432
  };
430
433
  Tween.prototype.dynamic = function (dynamic) {
@@ -673,12 +676,13 @@ var Tween = /** @class */ (function () {
673
676
  * it is still playing, just paused).
674
677
  */
675
678
  Tween.prototype.update = function (time, autoStart) {
679
+ var _this = this;
680
+ var _a;
676
681
  if (time === void 0) { time = now(); }
677
682
  if (autoStart === void 0) { autoStart = true; }
678
683
  if (this._isPaused)
679
684
  return true;
680
685
  var property;
681
- var elapsed;
682
686
  var endTime = this._startTime + this._duration;
683
687
  if (!this._goToEnd && !this._isPlaying) {
684
688
  if (time > endTime)
@@ -702,18 +706,37 @@ var Tween = /** @class */ (function () {
702
706
  }
703
707
  this._onEveryStartCallbackFired = true;
704
708
  }
705
- elapsed = (time - this._startTime) / this._duration;
706
- elapsed = this._duration === 0 || elapsed > 1 ? 1 : elapsed;
709
+ var elapsedTime = time - this._startTime;
710
+ var durationAndDelay = this._duration + ((_a = this._repeatDelayTime) !== null && _a !== void 0 ? _a : this._delayTime);
711
+ 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();
707
729
  var value = this._easingFunction(elapsed);
708
730
  // properties transformations
709
731
  this._updateProperties(this._object, this._valuesStart, this._valuesEnd, value);
710
732
  if (this._onUpdateCallback) {
711
733
  this._onUpdateCallback(this._object, elapsed);
712
734
  }
713
- if (elapsed === 1) {
735
+ if (this._duration === 0 || elapsedTime >= this._duration) {
714
736
  if (this._repeat > 0) {
737
+ var completeCount = Math.min(Math.trunc((elapsedTime - this._duration) / durationAndDelay) + 1, this._repeat);
715
738
  if (isFinite(this._repeat)) {
716
- this._repeat--;
739
+ this._repeat -= completeCount;
717
740
  }
718
741
  // Reassign starting values, restart by making startTime = now
719
742
  for (property in this._valuesStartRepeat) {
@@ -731,12 +754,7 @@ var Tween = /** @class */ (function () {
731
754
  if (this._yoyo) {
732
755
  this._reversed = !this._reversed;
733
756
  }
734
- if (this._repeatDelayTime !== undefined) {
735
- this._startTime = time + this._repeatDelayTime;
736
- }
737
- else {
738
- this._startTime = time + this._delayTime;
739
- }
757
+ this._startTime += durationAndDelay * completeCount;
740
758
  if (this._onRepeatCallback) {
741
759
  this._onRepeatCallback(this._object);
742
760
  }
@@ -812,7 +830,7 @@ var Tween = /** @class */ (function () {
812
830
  return Tween;
813
831
  }());
814
832
 
815
- var VERSION = '21.0.0';
833
+ var VERSION = '23.1.1';
816
834
 
817
835
  /**
818
836
  * Tween.js - Licensed under the MIT license
@@ -192,6 +192,7 @@ class Rhino3dmLoader extends Loader {
192
192
  mat.color.g = material.color.g;
193
193
  mat.color.b = material.color.b;
194
194
  mat.type = material.type;
195
+ mat.vertexColors = material.vertexColors;
195
196
 
196
197
  const json = JSON.stringify( mat );
197
198
 
@@ -205,6 +206,7 @@ class Rhino3dmLoader extends Loader {
205
206
  _mat.color.g = m.color.g;
206
207
  _mat.color.b = m.color.b;
207
208
  _mat.type = m.type;
209
+ _mat.vertexColors = m.vertexColors;
208
210
 
209
211
  if ( JSON.stringify( _mat ) === json ) {
210
212
 
@@ -488,7 +490,7 @@ class Rhino3dmLoader extends Loader {
488
490
 
489
491
  default:
490
492
 
491
- let matId;
493
+ let matId = null;
492
494
 
493
495
  switch ( attributes.materialSource.name ) {
494
496
 
@@ -498,10 +500,6 @@ class Rhino3dmLoader extends Loader {
498
500
 
499
501
  matId = data.layers[ attributes.layerIndex ].renderMaterialIndex;
500
502
 
501
- } else {
502
-
503
- matId = null;
504
-
505
503
  }
506
504
 
507
505
  break;
@@ -512,17 +510,13 @@ class Rhino3dmLoader extends Loader {
512
510
 
513
511
  matId = attributes.materialIndex;
514
512
 
515
- } else {
516
-
517
- matId = null;
518
-
519
513
  }
520
514
 
521
515
  break;
522
516
 
523
517
  }
524
518
 
525
- let material;
519
+ let material = null;
526
520
 
527
521
  if ( matId >= 0 ) {
528
522
 
@@ -530,13 +524,8 @@ class Rhino3dmLoader extends Loader {
530
524
  material = this._createMaterial( rMaterial, data.renderEnvironment );
531
525
 
532
526
 
533
- } else {
534
-
535
- material = this._createMaterial();
536
-
537
527
  }
538
528
 
539
- material = this._compareMaterials( material );
540
529
  const _object = this._createObject( obj, material );
541
530
 
542
531
  if ( _object === undefined ) {
@@ -675,19 +664,22 @@ class Rhino3dmLoader extends Loader {
675
664
 
676
665
  geometry = loader.parse( obj.geometry );
677
666
 
678
- if ( geometry.attributes.hasOwnProperty( 'color' ) ) {
679
667
 
680
- mat.vertexColors = true;
668
+ if ( mat === null ) {
669
+
670
+ mat = this._createMaterial();
681
671
 
682
672
  }
683
673
 
684
- if ( mat === null ) {
685
674
 
686
- mat = this._createMaterial();
687
- mat = this._compareMaterials( mat );
675
+ if ( geometry.attributes.hasOwnProperty( 'color' ) ) {
676
+
677
+ mat.vertexColors = true;
688
678
 
689
679
  }
690
680
 
681
+ mat = this._compareMaterials( mat );
682
+
691
683
  const mesh = new Mesh( geometry, mat );
692
684
  mesh.castShadow = attributes.castsShadows;
693
685
  mesh.receiveShadow = attributes.receivesShadows;
@@ -1529,7 +1521,7 @@ function Rhino3dmWorker() {
1529
1521
 
1530
1522
  // TODO: precalculate resulting vertices and faces and warn on excessive results
1531
1523
  _geometry.subdivide( 3 );
1532
- mesh = rhino.Mesh.createFromSubDControlNet( _geometry );
1524
+ mesh = rhino.Mesh.createFromSubDControlNet( _geometry, false );
1533
1525
  if ( mesh ) {
1534
1526
 
1535
1527
  geometry = mesh.toThreejsJSON();
@@ -56,9 +56,16 @@ class VOXLoader extends Loader {
56
56
  const id = data.getUint32( 0, true );
57
57
  const version = data.getUint32( 4, true );
58
58
 
59
- if ( id !== 542658390 || version !== 150 ) {
59
+ if ( id !== 542658390 ) {
60
60
 
61
- console.error( 'Not a valid VOX file' );
61
+ console.error( 'THREE.VOXLoader: Invalid VOX file.' );
62
+ return;
63
+
64
+ }
65
+
66
+ if ( version !== 150 ) {
67
+
68
+ console.error( 'THREE.VOXLoader: Invalid VOX file. Unsupported version:', version );
62
69
  return;
63
70
 
64
71
  }
@@ -1012,7 +1012,9 @@ class VRMLLoader extends Loader {
1012
1012
 
1013
1013
  const pointsMaterial = new PointsMaterial( {
1014
1014
  name: Loader.DEFAULT_MATERIAL_NAME,
1015
- color: 0xffffff
1015
+ color: 0xffffff,
1016
+ opacity: material.opacity,
1017
+ transparent: material.transparent
1016
1018
  } );
1017
1019
 
1018
1020
  if ( geometry.attributes.color !== undefined ) {
@@ -1037,7 +1039,9 @@ class VRMLLoader extends Loader {
1037
1039
 
1038
1040
  const lineMaterial = new LineBasicMaterial( {
1039
1041
  name: Loader.DEFAULT_MATERIAL_NAME,
1040
- color: 0xffffff
1042
+ color: 0xffffff,
1043
+ opacity: material.opacity,
1044
+ transparent: material.transparent
1041
1045
  } );
1042
1046
 
1043
1047
  if ( geometry.attributes.color !== undefined ) {
@@ -45,6 +45,7 @@ class ProgressiveLightMap {
45
45
 
46
46
  // Vertex Shader: Set Vertex Positions to the Unwrapped UV Positions
47
47
  shader.vertexShader =
48
+ 'attribute vec2 uv1;\n' +
48
49
  '#define USE_LIGHTMAP\n' +
49
50
  '#define LIGHTMAP_UV uv1\n' +
50
51
  shader.vertexShader.slice( 0, - 1 ) +
@@ -5,7 +5,6 @@
5
5
  export * from './core/constants.js';
6
6
 
7
7
  // core
8
- export { default as ArrayUniformNode /* @TODO: arrayUniform */ } from './core/ArrayUniformNode.js';
9
8
  export { default as AssignNode, assign } from './core/AssignNode.js';
10
9
  export { default as AttributeNode, attribute } from './core/AttributeNode.js';
11
10
  export { default as BypassNode, bypass } from './core/BypassNode.js';
@@ -39,7 +38,7 @@ import * as NodeUtils from './core/NodeUtils.js';
39
38
  export { NodeUtils };
40
39
 
41
40
  // math
42
- export { default as MathNode, PI, PI2, EPSILON, INFINITY, radians, degrees, exp, exp2, log, log2, sqrt, inverseSqrt, floor, ceil, normalize, fract, sin, cos, tan, asin, acos, atan, abs, sign, length, lengthSq, negate, oneMinus, dFdx, dFdy, round, reciprocal, trunc, fwidth, bitcast, atan2, min, max, mod, step, reflect, distance, difference, dot, cross, pow, pow2, pow3, pow4, transformDirection, mix, clamp, saturate, refract, smoothstep, faceForward, cbrt } from './math/MathNode.js';
41
+ export { default as MathNode, PI, PI2, EPSILON, INFINITY, radians, degrees, exp, exp2, log, log2, sqrt, inverseSqrt, floor, ceil, normalize, fract, sin, cos, tan, asin, acos, atan, abs, sign, length, lengthSq, negate, oneMinus, dFdx, dFdy, round, reciprocal, trunc, fwidth, bitcast, atan2, min, max, mod, step, reflect, distance, difference, dot, cross, pow, pow2, pow3, pow4, transformDirection, mix, clamp, saturate, refract, smoothstep, faceForward, cbrt, all, any, equals } from './math/MathNode.js';
43
42
 
44
43
  export { default as OperatorNode, add, sub, mul, div, remainder, equal, lessThan, greaterThan, lessThanEqual, greaterThanEqual, and, or, not, xor, bitAnd, bitNot, bitOr, bitXor, shiftLeft, shiftRight } from './math/OperatorNode.js';
45
44
  export { default as CondNode, cond } from './math/CondNode.js';
@@ -56,7 +55,7 @@ export { default as DiscardNode, discard } from './utils/DiscardNode.js';
56
55
  export { default as EquirectUVNode, equirectUV } from './utils/EquirectUVNode.js';
57
56
  export { default as FunctionOverloadingNode, overloadingFn } from './utils/FunctionOverloadingNode.js';
58
57
  export { default as JoinNode } from './utils/JoinNode.js';
59
- export { default as LoopNode, loop } from './utils/LoopNode.js';
58
+ export { default as LoopNode, loop, Continue, Break } from './utils/LoopNode.js';
60
59
  export { default as MatcapUVNode, matcapUV } from './utils/MatcapUVNode.js';
61
60
  export { default as MaxMipLevelNode, maxMipLevel } from './utils/MaxMipLevelNode.js';
62
61
  export { default as OscNode, oscSine, oscSquare, oscTriangle, oscSawtooth } from './utils/OscNode.js';
@@ -68,6 +67,7 @@ export { default as SetNode } from './utils/SetNode.js';
68
67
  export { default as SpecularMIPLevelNode, specularMIPLevel } from './utils/SpecularMIPLevelNode.js';
69
68
  export { default as SplitNode } from './utils/SplitNode.js';
70
69
  export { default as SpriteSheetUVNode, spritesheetUV } from './utils/SpriteSheetUVNode.js';
70
+ export { default as StorageArrayElementNode } from './utils/StorageArrayElementNode.js';
71
71
  export { default as TimerNode, timerLocal, timerGlobal, timerDelta, frameId } from './utils/TimerNode.js';
72
72
  export { default as TriplanarTexturesNode, triplanarTextures, triplanarTexture } from './utils/TriplanarTexturesNode.js';
73
73
  export { default as ReflectorNode, reflector } from './utils/ReflectorNode.js';
@@ -76,6 +76,8 @@ export { default as ReflectorNode, reflector } from './utils/ReflectorNode.js';
76
76
  export * from './shadernode/ShaderNode.js';
77
77
 
78
78
  // accessors
79
+ export { TBNViewMatrix, parallaxDirection, parallaxUV } from './accessors/AccessorsUtils.js';
80
+ export { default as UniformsNode, uniforms } from './accessors/UniformsNode.js';
79
81
  export { default as BitangentNode, bitangentGeometry, bitangentLocal, bitangentView, bitangentWorld, transformedBitangentView, transformedBitangentWorld } from './accessors/BitangentNode.js';
80
82
  export { default as BufferAttributeNode, bufferAttribute, dynamicBufferAttribute, instancedBufferAttribute, instancedDynamicBufferAttribute } from './accessors/BufferAttributeNode.js';
81
83
  export { default as BufferNode, buffer } from './accessors/BufferNode.js';
@@ -85,7 +87,7 @@ export { default as CubeTextureNode, cubeTexture } from './accessors/CubeTexture
85
87
  export { default as InstanceNode, instance } from './accessors/InstanceNode.js';
86
88
  export { default as MaterialNode, materialAlphaTest, materialColor, materialShininess, materialEmissive, materialOpacity, materialSpecularColor, materialSpecularStrength, materialReflectivity, materialRoughness, materialMetalness, materialNormal, materialClearcoat, materialClearcoatRoughness, materialClearcoatNormal, materialRotation, materialSheen, materialSheenRoughness, materialIridescence, materialIridescenceIOR, materialIridescenceThickness, materialLineScale, materialLineDashSize, materialLineGapSize, materialLineWidth, materialLineDashOffset, materialPointWidth } from './accessors/MaterialNode.js';
87
89
  export { default as MaterialReferenceNode, materialReference } from './accessors/MaterialReferenceNode.js';
88
- export { default as MorphNode, morph } from './accessors/MorphNode.js';
90
+ export { default as MorphNode, morphReference } from './accessors/MorphNode.js';
89
91
  export { default as TextureBicubicNode, textureBicubic } from './accessors/TextureBicubicNode.js';
90
92
  export { default as ModelNode, modelDirection, modelViewMatrix, modelNormalMatrix, modelWorldMatrix, modelPosition, modelViewPosition, modelScale } from './accessors/ModelNode.js';
91
93
  export { default as ModelViewProjectionNode, modelViewProjection } from './accessors/ModelViewProjectionNode.js';
@@ -93,11 +95,11 @@ export { default as NormalNode, normalGeometry, normalLocal, normalView, normalW
93
95
  export { default as Object3DNode, objectDirection, objectViewMatrix, objectNormalMatrix, objectWorldMatrix, objectPosition, objectScale, objectViewPosition } from './accessors/Object3DNode.js';
94
96
  export { default as PointUVNode, pointUV } from './accessors/PointUVNode.js';
95
97
  export { default as PositionNode, positionGeometry, positionLocal, positionWorld, positionWorldDirection, positionView, positionViewDirection } from './accessors/PositionNode.js';
96
- export { default as ReferenceNode, reference, referenceIndex } from './accessors/ReferenceNode.js';
98
+ export { default as ReferenceNode, reference, referenceBuffer } from './accessors/ReferenceNode.js';
97
99
  export { default as ReflectVectorNode, reflectVector } from './accessors/ReflectVectorNode.js';
98
100
  export { default as SkinningNode, skinning } from './accessors/SkinningNode.js';
99
101
  export { default as SceneNode, backgroundBlurriness, backgroundIntensity } from './accessors/SceneNode.js';
100
- export { default as StorageBufferNode, storage } from './accessors/StorageBufferNode.js';
102
+ export { default as StorageBufferNode, storage, storageObject } from './accessors/StorageBufferNode.js';
101
103
  export { default as TangentNode, tangentGeometry, tangentLocal, tangentView, tangentWorld, transformedTangentView, transformedTangentWorld } from './accessors/TangentNode.js';
102
104
  export { default as TextureNode, texture, textureLoad, /*textureLevel,*/ sampler } from './accessors/TextureNode.js';
103
105
  export { default as TextureStoreNode, textureStore } from './accessors/TextureStoreNode.js';
@@ -110,7 +112,7 @@ export { default as BumpMapNode, bumpMap } from './display/BumpMapNode.js';
110
112
  export { default as ColorAdjustmentNode, saturation, vibrance, hue, lumaCoeffs, luminance, threshold } from './display/ColorAdjustmentNode.js';
111
113
  export { default as ColorSpaceNode, linearToColorSpace, colorSpaceToLinear, linearTosRGB, sRGBToLinear } from './display/ColorSpaceNode.js';
112
114
  export { default as FrontFacingNode, frontFacing, faceDirection } from './display/FrontFacingNode.js';
113
- export { default as NormalMapNode, normalMap, TBNViewMatrix } from './display/NormalMapNode.js';
115
+ export { default as NormalMapNode, normalMap } from './display/NormalMapNode.js';
114
116
  export { default as PosterizeNode, posterize } from './display/PosterizeNode.js';
115
117
  export { default as ToneMappingNode, toneMapping } from './display/ToneMappingNode.js';
116
118
  export { default as ViewportNode, viewport, viewportCoordinate, viewportResolution, viewportTopLeft, viewportBottomLeft, viewportTopRight, viewportBottomRight } from './display/ViewportNode.js';
@@ -0,0 +1,10 @@
1
+ import { bitangentView } from './BitangentNode.js';
2
+ import { normalView } from './NormalNode.js';
3
+ import { tangentView } from './TangentNode.js';
4
+ import { mat3 } from '../shadernode/ShaderNode.js';
5
+ import { positionViewDirection } from './PositionNode.js';
6
+
7
+ export const TBNViewMatrix = mat3( tangentView, bitangentView, normalView );
8
+
9
+ export const parallaxDirection = positionViewDirection.mul( TBNViewMatrix )/*.normalize()*/;
10
+ export const parallaxUV = ( uv, scale ) => uv.sub( parallaxDirection.mul( scale ) );
@@ -0,0 +1,144 @@
1
+
2
+ import Node from '../core/Node.js';
3
+ import { nodeObject } from '../shadernode/ShaderNode.js';
4
+ import { positionView } from './PositionNode.js';
5
+ import { diffuseColor, property } from '../core/PropertyNode.js';
6
+ import { tslFn } from '../shadernode/ShaderNode.js';
7
+ import { loop } from '../utils/LoopNode.js';
8
+ import { smoothstep } from '../math/MathNode.js';
9
+ import { uniforms } from './UniformsNode.js';
10
+
11
+ class ClippingNode extends Node {
12
+
13
+ constructor( scope = ClippingNode.DEFAULT ) {
14
+
15
+ super();
16
+
17
+ this.scope = scope;
18
+
19
+ }
20
+
21
+ setup( builder ) {
22
+
23
+ super.setup( builder );
24
+
25
+ const clippingContext = builder.clippingContext;
26
+ const { localClipIntersection, localClippingCount, globalClippingCount } = clippingContext;
27
+
28
+ const numClippingPlanes = globalClippingCount + localClippingCount;
29
+ const numUnionClippingPlanes = localClipIntersection ? numClippingPlanes - localClippingCount : numClippingPlanes;
30
+
31
+ if ( this.scope === ClippingNode.ALPHA_TO_COVERAGE ) {
32
+
33
+ return this.setupAlphaToCoverage( clippingContext.planes, numClippingPlanes, numUnionClippingPlanes );
34
+
35
+ } else {
36
+
37
+ return this.setupDefault( clippingContext.planes, numClippingPlanes, numUnionClippingPlanes );
38
+
39
+ }
40
+
41
+ }
42
+
43
+ setupAlphaToCoverage( planes, numClippingPlanes, numUnionClippingPlanes ) {
44
+
45
+ return tslFn( () => {
46
+
47
+ const clippingPlanes = uniforms( planes );
48
+
49
+ const distanceToPlane = property( 'float', 'distanceToPlane' );
50
+ const distanceGradient = property( 'float', 'distanceToGradient' );
51
+
52
+ const clipOpacity = property( 'float', 'clipOpacity' );
53
+
54
+ clipOpacity.assign( 1 );
55
+
56
+ let plane;
57
+
58
+ loop( numUnionClippingPlanes, ( { i } ) => {
59
+
60
+ plane = clippingPlanes.element( i );
61
+
62
+ distanceToPlane.assign( positionView.dot( plane.xyz ).negate().add( plane.w ) );
63
+ distanceGradient.assign( distanceToPlane.fwidth().div( 2.0 ) );
64
+
65
+ clipOpacity.mulAssign( smoothstep( distanceGradient.negate(), distanceGradient, distanceToPlane ) );
66
+
67
+ clipOpacity.equal( 0.0 ).discard();
68
+
69
+ } );
70
+
71
+ if ( numUnionClippingPlanes < numClippingPlanes ) {
72
+
73
+ const unionClipOpacity = property( 'float', 'unionclipOpacity' );
74
+
75
+ unionClipOpacity.assign( 1 );
76
+
77
+ loop( { start: numUnionClippingPlanes, end: numClippingPlanes }, ( { i } ) => {
78
+
79
+ plane = clippingPlanes.element( i );
80
+
81
+ distanceToPlane.assign( positionView.dot( plane.xyz ).negate().add( plane.w ) );
82
+ distanceGradient.assign( distanceToPlane.fwidth().div( 2.0 ) );
83
+
84
+ unionClipOpacity.mulAssign( smoothstep( distanceGradient.negate(), distanceGradient, distanceToPlane ).oneMinus() );
85
+
86
+ } );
87
+
88
+ clipOpacity.mulAssign( unionClipOpacity.oneMinus() );
89
+
90
+ }
91
+
92
+ diffuseColor.a.mulAssign( clipOpacity );
93
+
94
+ diffuseColor.a.equal( 0.0 ).discard();
95
+
96
+ } )();
97
+
98
+ }
99
+
100
+ setupDefault( planes, numClippingPlanes, numUnionClippingPlanes ) {
101
+
102
+ return tslFn( () => {
103
+
104
+ const clippingPlanes = uniforms( planes );
105
+
106
+ let plane;
107
+
108
+ loop( numUnionClippingPlanes, ( { i } ) => {
109
+
110
+ plane = clippingPlanes.element( i );
111
+ positionView.dot( plane.xyz ).greaterThan( plane.w ).discard();
112
+
113
+ } );
114
+
115
+ if ( numUnionClippingPlanes < numClippingPlanes ) {
116
+
117
+ const clipped = property( 'bool', 'clipped' );
118
+
119
+ clipped.assign( true );
120
+
121
+ loop( { start: numUnionClippingPlanes, end: numClippingPlanes }, ( { i } ) => {
122
+
123
+ plane = clippingPlanes.element( i );
124
+ clipped.assign( positionView.dot( plane.xyz ).greaterThan( plane.w ).and( clipped ) );
125
+
126
+ } );
127
+
128
+ clipped.discard();
129
+ }
130
+
131
+ } )();
132
+
133
+ }
134
+
135
+ }
136
+
137
+ ClippingNode.ALPHA_TO_COVERAGE = 'alphaToCoverage';
138
+ ClippingNode.DEFAULT = 'default';
139
+
140
+ export default ClippingNode;
141
+
142
+ export const clipping = () => nodeObject( new ClippingNode() );
143
+
144
+ export const clippingAlpha = () => nodeObject( new ClippingNode( ClippingNode.ALPHA_TO_COVERAGE ) );
@@ -227,11 +227,11 @@ class MaterialNode extends Node {
227
227
 
228
228
  } else if ( scope === MaterialNode.IRIDESCENCE_THICKNESS ) {
229
229
 
230
- const iridescenceThicknessMaximum = reference( 1, 'float', material.iridescenceThicknessRange );
230
+ const iridescenceThicknessMaximum = reference( '1', 'float', material.iridescenceThicknessRange );
231
231
 
232
232
  if ( material.iridescenceThicknessMap ) {
233
233
 
234
- const iridescenceThicknessMinimum = reference( 0, 'float', material.iridescenceThicknessRange );
234
+ const iridescenceThicknessMinimum = reference( '0', 'float', material.iridescenceThicknessRange );
235
235
 
236
236
  node = iridescenceThicknessMaximum.sub( iridescenceThicknessMinimum ).mul( this.getTexture( scope ).g ).add( iridescenceThicknessMinimum );
237
237
 
@@ -24,24 +24,14 @@ class MaterialReferenceNode extends ReferenceNode {
24
24
 
25
25
  }*/
26
26
 
27
- updateReference( frame ) {
27
+ setReference( state ) {
28
28
 
29
- this.reference = this.material !== null ? this.material : frame.material;
29
+ this.reference = this.material !== null ? this.material : state.material;
30
30
 
31
31
  return this.reference;
32
32
 
33
33
  }
34
34
 
35
- setup( builder ) {
36
-
37
- const material = this.material !== null ? this.material : builder.material;
38
-
39
- this.node.value = material[ this.property ];
40
-
41
- return super.setup( builder );
42
-
43
- }
44
-
45
35
  }
46
36
 
47
37
  export default MaterialReferenceNode;
@@ -2,13 +2,14 @@ import Node, { addNodeClass } from '../core/Node.js';
2
2
  import { NodeUpdateType } from '../core/constants.js';
3
3
  import { nodeProxy, tslFn } from '../shadernode/ShaderNode.js';
4
4
  import { uniform } from '../core/UniformNode.js';
5
- import { referenceIndex } from './ReferenceNode.js';
5
+ import { reference } from './ReferenceNode.js';
6
6
  import { positionLocal } from './PositionNode.js';
7
7
  import { normalLocal } from './NormalNode.js';
8
8
  import { textureLoad } from './TextureNode.js';
9
9
  import { vertexIndex } from '../core/IndexNode.js';
10
10
  import { ivec2, int } from '../shadernode/ShaderNode.js';
11
11
  import { DataArrayTexture, Vector2, Vector4, FloatType } from 'three';
12
+ import { loop } from '../utils/LoopNode.js';
12
13
 
13
14
  const morphTextures = new WeakMap();
14
15
  const morphVec4 = new Vector4();
@@ -185,10 +186,9 @@ class MorphNode extends Node {
185
186
 
186
187
  const width = int( size.width );
187
188
 
188
- for ( let i = 0; i < morphTargetsCount; i ++ ) {
189
+ loop( morphTargetsCount, ( { i } ) => {
189
190
 
190
- const influence = referenceIndex( 'morphTargetInfluences', i, 'float' );
191
- const depth = int( i );
191
+ const influence = reference( 'morphTargetInfluences', 'float' ).element( i );
192
192
 
193
193
  if ( hasMorphPosition === true ) {
194
194
 
@@ -197,7 +197,7 @@ class MorphNode extends Node {
197
197
  influence,
198
198
  stride,
199
199
  width,
200
- depth,
200
+ depth: i,
201
201
  offset: int( 0 )
202
202
  } ) );
203
203
 
@@ -210,13 +210,13 @@ class MorphNode extends Node {
210
210
  influence,
211
211
  stride,
212
212
  width,
213
- depth,
213
+ depth: i,
214
214
  offset: int( 1 )
215
215
  } ) );
216
216
 
217
217
  }
218
218
 
219
- }
219
+ } );
220
220
 
221
221
  }
222
222
 
@@ -240,6 +240,6 @@ class MorphNode extends Node {
240
240
 
241
241
  export default MorphNode;
242
242
 
243
- export const morph = nodeProxy( MorphNode );
243
+ export const morphReference = nodeProxy( MorphNode );
244
244
 
245
245
  addNodeClass( 'MorphNode', MorphNode );