super-three 0.157.0 → 0.158.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 (183) hide show
  1. package/README.md +6 -4
  2. package/build/three.cjs +1486 -842
  3. package/build/three.js +1486 -842
  4. package/build/three.min.js +1 -1
  5. package/build/three.module.js +1481 -843
  6. package/build/three.module.min.js +1 -1
  7. package/examples/jsm/Addons.js +290 -0
  8. package/examples/jsm/controls/FlyControls.js +26 -0
  9. package/examples/jsm/controls/OrbitControls.js +12 -1
  10. package/examples/jsm/controls/TransformControls.js +27 -11
  11. package/examples/jsm/csm/CSMShader.js +1 -1
  12. package/examples/jsm/exporters/GLTFExporter.js +72 -2
  13. package/examples/jsm/geometries/InstancedPointsGeometry.js +174 -0
  14. package/examples/jsm/geometries/SDFGeometryGenerator.js +144 -0
  15. package/examples/jsm/libs/lottie_canvas.module.js +6 -1
  16. package/examples/jsm/libs/opentype.module.js +13 -75
  17. package/examples/jsm/libs/surfaceNet.js +201 -0
  18. package/examples/jsm/loaders/GLTFLoader.js +12 -3
  19. package/examples/jsm/loaders/LUTImageLoader.js +162 -0
  20. package/examples/jsm/loaders/lwo/IFFParser.js +89 -93
  21. package/examples/jsm/materials/MeshGouraudMaterial.js +2 -0
  22. package/examples/jsm/math/Capsule.js +0 -55
  23. package/examples/jsm/math/Octree.js +70 -3
  24. package/examples/jsm/modifiers/SimplifyModifier.js +103 -11
  25. package/examples/jsm/modifiers/TessellateModifier.js +3 -3
  26. package/examples/jsm/nodes/Nodes.js +6 -6
  27. package/examples/jsm/nodes/accessors/CubeTextureNode.js +3 -3
  28. package/examples/jsm/nodes/accessors/InstanceNode.js +3 -3
  29. package/examples/jsm/nodes/accessors/InstancedPointsMaterialNode.js +21 -0
  30. package/examples/jsm/nodes/accessors/MaterialNode.js +68 -31
  31. package/examples/jsm/nodes/accessors/ModelNode.js +1 -2
  32. package/examples/jsm/nodes/accessors/MorphNode.js +5 -5
  33. package/examples/jsm/nodes/accessors/NormalNode.js +1 -1
  34. package/examples/jsm/nodes/accessors/PositionNode.js +1 -1
  35. package/examples/jsm/nodes/accessors/SkinningNode.js +13 -3
  36. package/examples/jsm/nodes/accessors/TextureNode.js +3 -3
  37. package/examples/jsm/nodes/code/FunctionNode.js +1 -1
  38. package/examples/jsm/nodes/core/AssignNode.js +72 -0
  39. package/examples/jsm/nodes/core/LightingModel.js +3 -1
  40. package/examples/jsm/nodes/core/Node.js +7 -12
  41. package/examples/jsm/nodes/core/NodeBuilder.js +126 -16
  42. package/examples/jsm/nodes/core/NodeUtils.js +4 -2
  43. package/examples/jsm/nodes/core/OutputStructNode.js +1 -1
  44. package/examples/jsm/nodes/core/ParameterNode.js +33 -0
  45. package/examples/jsm/nodes/core/PropertyNode.js +4 -10
  46. package/examples/jsm/nodes/core/StackNode.js +7 -17
  47. package/examples/jsm/nodes/core/TempNode.js +1 -1
  48. package/examples/jsm/nodes/core/VarNode.js +6 -35
  49. package/examples/jsm/nodes/core/VaryingNode.js +2 -0
  50. package/examples/jsm/nodes/display/BumpMapNode.js +35 -13
  51. package/examples/jsm/nodes/display/NormalMapNode.js +3 -1
  52. package/examples/jsm/nodes/display/ViewportNode.js +14 -4
  53. package/examples/jsm/nodes/functions/BSDF/BRDF_Sheen.js +20 -6
  54. package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +8 -7
  55. package/examples/jsm/nodes/functions/BSDF/D_GGX.js +8 -3
  56. package/examples/jsm/nodes/functions/BSDF/Schlick_to_F0.js +8 -0
  57. package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +8 -0
  58. package/examples/jsm/nodes/functions/PhysicalLightingModel.js +93 -43
  59. package/examples/jsm/nodes/gpgpu/ComputeNode.js +2 -2
  60. package/examples/jsm/nodes/lighting/AmbientLightNode.js +1 -1
  61. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +19 -5
  62. package/examples/jsm/nodes/lighting/DirectionalLightNode.js +1 -1
  63. package/examples/jsm/nodes/lighting/EnvironmentNode.js +0 -6
  64. package/examples/jsm/nodes/lighting/LightingContextNode.js +21 -57
  65. package/examples/jsm/nodes/lighting/LightsNode.js +62 -4
  66. package/examples/jsm/nodes/lighting/PointLightNode.js +1 -1
  67. package/examples/jsm/nodes/lighting/SpotLightNode.js +1 -1
  68. package/examples/jsm/nodes/materials/InstancedPointsNodeMaterial.js +162 -0
  69. package/examples/jsm/nodes/materials/Line2NodeMaterial.js +70 -71
  70. package/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +5 -5
  71. package/examples/jsm/nodes/materials/Materials.js +1 -0
  72. package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +2 -2
  73. package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +3 -3
  74. package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +47 -20
  75. package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +6 -6
  76. package/examples/jsm/nodes/materials/NodeMaterial.js +17 -20
  77. package/examples/jsm/nodes/materialx/lib/mx_noise.js +5 -5
  78. package/examples/jsm/nodes/math/OperatorNode.js +5 -21
  79. package/examples/jsm/nodes/shadernode/ShaderNode.js +128 -9
  80. package/examples/jsm/nodes/utils/ArrayElementNode.js +2 -0
  81. package/examples/jsm/nodes/utils/DiscardNode.js +3 -2
  82. package/examples/jsm/nodes/utils/JoinNode.js +11 -1
  83. package/examples/jsm/nodes/utils/LoopNode.js +36 -24
  84. package/examples/jsm/nodes/utils/SplitNode.js +2 -0
  85. package/examples/jsm/objects/BatchedMesh.js +586 -0
  86. package/examples/jsm/objects/InstancedPoints.js +21 -0
  87. package/examples/jsm/objects/Lensflare.js +20 -0
  88. package/examples/jsm/objects/ReflectorForSSRPass.js +3 -0
  89. package/examples/jsm/objects/Refractor.js +3 -0
  90. package/examples/jsm/objects/Sky.js +5 -3
  91. package/examples/jsm/objects/Water.js +5 -2
  92. package/examples/jsm/objects/Water2.js +3 -0
  93. package/examples/jsm/physics/AmmoPhysics.js +21 -0
  94. package/examples/jsm/physics/RapierPhysics.js +21 -0
  95. package/examples/jsm/postprocessing/BokehPass.js +3 -2
  96. package/examples/jsm/postprocessing/LUTPass.js +2 -1
  97. package/examples/jsm/postprocessing/OutputPass.js +1 -0
  98. package/examples/jsm/postprocessing/Pass.js +14 -3
  99. package/examples/jsm/postprocessing/SAOPass.js +0 -1
  100. package/examples/jsm/postprocessing/SMAAPass.js +0 -2
  101. package/examples/jsm/postprocessing/TAARenderPass.js +1 -2
  102. package/examples/jsm/renderers/CSS3DRenderer.js +3 -9
  103. package/examples/jsm/renderers/SVGRenderer.js +9 -6
  104. package/examples/jsm/renderers/common/Bindings.js +1 -1
  105. package/examples/jsm/renderers/common/RenderObject.js +8 -1
  106. package/examples/jsm/renderers/common/RenderObjects.js +1 -1
  107. package/examples/jsm/renderers/common/Textures.js +4 -36
  108. package/examples/jsm/renderers/common/nodes/Nodes.js +53 -18
  109. package/examples/jsm/renderers/webgl/WebGLBackend.js +291 -50
  110. package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +88 -12
  111. package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +40 -5
  112. package/examples/jsm/renderers/webgl/utils/WebGLState.js +14 -2
  113. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +2 -0
  114. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +36 -4
  115. package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +2 -0
  116. package/examples/jsm/shaders/AfterimageShader.js +2 -0
  117. package/examples/jsm/shaders/BasicShader.js +2 -0
  118. package/examples/jsm/shaders/BlendShader.js +2 -0
  119. package/examples/jsm/shaders/BokehShader.js +2 -0
  120. package/examples/jsm/shaders/BokehShader2.js +4 -0
  121. package/examples/jsm/shaders/BrightnessContrastShader.js +2 -0
  122. package/examples/jsm/shaders/ColorCorrectionShader.js +2 -0
  123. package/examples/jsm/shaders/DOFMipMapShader.js +2 -0
  124. package/examples/jsm/shaders/DepthLimitedBlurShader.js +5 -0
  125. package/examples/jsm/shaders/FXAAShader.js +2 -0
  126. package/examples/jsm/shaders/FilmShader.js +1 -1
  127. package/examples/jsm/shaders/FocusShader.js +2 -0
  128. package/examples/jsm/shaders/FreiChenShader.js +2 -0
  129. package/examples/jsm/shaders/GodRaysShader.js +8 -0
  130. package/examples/jsm/shaders/HalftoneShader.js +2 -0
  131. package/examples/jsm/shaders/HorizontalTiltShiftShader.js +2 -0
  132. package/examples/jsm/shaders/HueSaturationShader.js +2 -0
  133. package/examples/jsm/shaders/KaleidoShader.js +2 -0
  134. package/examples/jsm/shaders/LuminosityHighPassShader.js +2 -0
  135. package/examples/jsm/shaders/LuminosityShader.js +2 -0
  136. package/examples/jsm/shaders/MMDToonShader.js +2 -0
  137. package/examples/jsm/shaders/MirrorShader.js +2 -0
  138. package/examples/jsm/shaders/NormalMapShader.js +2 -0
  139. package/examples/jsm/shaders/OutputShader.js +4 -5
  140. package/examples/jsm/shaders/SAOShader.js +5 -0
  141. package/examples/jsm/shaders/SMAAShader.js +6 -0
  142. package/examples/jsm/shaders/SSAOShader.js +6 -0
  143. package/examples/jsm/shaders/SSRShader.js +6 -0
  144. package/examples/jsm/shaders/SobelOperatorShader.js +2 -0
  145. package/examples/jsm/shaders/SubsurfaceScatteringShader.js +2 -0
  146. package/examples/jsm/shaders/TechnicolorShader.js +2 -0
  147. package/examples/jsm/shaders/TriangleBlurShader.js +2 -0
  148. package/examples/jsm/shaders/UnpackDepthRGBAShader.js +2 -0
  149. package/examples/jsm/shaders/VelocityShader.js +2 -0
  150. package/examples/jsm/shaders/VerticalTiltShiftShader.js +2 -0
  151. package/examples/jsm/shaders/WaterRefractionShader.js +2 -0
  152. package/examples/jsm/transpiler/AST.js +231 -0
  153. package/examples/jsm/transpiler/GLSLDecoder.js +899 -0
  154. package/examples/jsm/transpiler/ShaderToyDecoder.js +49 -0
  155. package/examples/jsm/transpiler/TSLEncoder.js +611 -0
  156. package/examples/jsm/transpiler/Transpiler.js +18 -0
  157. package/examples/jsm/webxr/VRButton.js +1 -1
  158. package/examples/jsm/webxr/XRButton.js +7 -5
  159. package/examples/jsm/webxr/XREstimatedLight.js +1 -1
  160. package/package.json +4 -1
  161. package/src/constants.js +7 -1
  162. package/src/extras/PMREMGenerator.js +7 -1
  163. package/src/loaders/MaterialLoader.js +10 -2
  164. package/src/materials/Material.js +27 -13
  165. package/src/math/Box3.js +35 -18
  166. package/src/math/Vector3.js +11 -12
  167. package/src/objects/SkinnedMesh.js +6 -7
  168. package/src/renderers/WebGLMultiviewRenderTarget.js +35 -0
  169. package/src/renderers/WebGLRenderer.js +199 -45
  170. package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +8 -0
  171. package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +3 -2
  172. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +1 -1
  173. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +8 -6
  174. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +2 -2
  175. package/src/renderers/webgl/WebGLBackground.js +1 -1
  176. package/src/renderers/webgl/WebGLMultiview.js +100 -0
  177. package/src/renderers/webgl/WebGLProgram.js +130 -50
  178. package/src/renderers/webgl/WebGLPrograms.js +8 -0
  179. package/src/renderers/webgl/WebGLState.js +25 -4
  180. package/src/renderers/webgl/WebGLTextures.js +197 -20
  181. package/src/renderers/webxr/WebXRManager.js +36 -12
  182. package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +0 -76
  183. package/examples/jsm/nodes/accessors/LineMaterialNode.js +0 -29
@@ -35,18 +35,16 @@
35
35
  import { LWO2Parser } from './LWO2Parser.js';
36
36
  import { LWO3Parser } from './LWO3Parser.js';
37
37
 
38
- function IFFParser( ) {
38
+ class IFFParser {
39
39
 
40
- this.debugger = new Debugger();
41
- // this.debugger.enable(); // un-comment to log IFF hierarchy.
40
+ constructor() {
42
41
 
43
- }
44
-
45
- IFFParser.prototype = {
42
+ this.debugger = new Debugger();
43
+ // this.debugger.enable(); // un-comment to log IFF hierarchy.
46
44
 
47
- constructor: IFFParser,
45
+ }
48
46
 
49
- parse: function ( buffer ) {
47
+ parse( buffer ) {
50
48
 
51
49
  this.reader = new DataViewReader( buffer );
52
50
 
@@ -82,7 +80,7 @@ IFFParser.prototype = {
82
80
 
83
81
  return this.tree;
84
82
 
85
- },
83
+ }
86
84
 
87
85
  parseTopForm() {
88
86
 
@@ -120,7 +118,7 @@ IFFParser.prototype = {
120
118
 
121
119
  return;
122
120
 
123
- },
121
+ }
124
122
 
125
123
 
126
124
  ///
@@ -306,7 +304,7 @@ IFFParser.prototype = {
306
304
  this.debugger.nodeID = type;
307
305
  this.debugger.log();
308
306
 
309
- },
307
+ }
310
308
 
311
309
  setupForm( type, length ) {
312
310
 
@@ -331,13 +329,13 @@ IFFParser.prototype = {
331
329
  }
332
330
 
333
331
 
334
- },
332
+ }
335
333
 
336
334
  skipForm( length ) {
337
335
 
338
336
  this.reader.skip( length - 4 );
339
337
 
340
- },
338
+ }
341
339
 
342
340
  parseUnknownForm( type, length ) {
343
341
 
@@ -346,7 +344,7 @@ IFFParser.prototype = {
346
344
  printBuffer( this.reader.dv.buffer, this.reader.offset, length - 4 );
347
345
  this.reader.skip( length - 4 );
348
346
 
349
- },
347
+ }
350
348
 
351
349
  parseSurfaceForm( length ) {
352
350
 
@@ -370,7 +368,7 @@ IFFParser.prototype = {
370
368
  this.currentForm = surface;
371
369
  this.currentFormEnd = this.reader.offset + length;
372
370
 
373
- },
371
+ }
374
372
 
375
373
  parseSurfaceLwo2( length ) {
376
374
 
@@ -391,7 +389,7 @@ IFFParser.prototype = {
391
389
  this.currentForm = surface;
392
390
  this.currentFormEnd = this.reader.offset + length;
393
391
 
394
- },
392
+ }
395
393
 
396
394
  parseSubNode( length ) {
397
395
 
@@ -411,7 +409,7 @@ IFFParser.prototype = {
411
409
  this.currentFormEnd = this.reader.offset + length;
412
410
 
413
411
 
414
- },
412
+ }
415
413
 
416
414
  // collect attributes from all nodes at the top level of a surface
417
415
  parseConnections( length ) {
@@ -421,7 +419,7 @@ IFFParser.prototype = {
421
419
 
422
420
  this.currentForm = this.currentSurface.connections;
423
421
 
424
- },
422
+ }
425
423
 
426
424
  // surface node attribute data, e.g. specular, roughness etc
427
425
  parseEntryForm( length ) {
@@ -432,7 +430,7 @@ IFFParser.prototype = {
432
430
 
433
431
  this.setupForm( name, length );
434
432
 
435
- },
433
+ }
436
434
 
437
435
  // parse values from material - doesn't match up to other LWO3 data types
438
436
  // sub form of entry form
@@ -462,7 +460,7 @@ IFFParser.prototype = {
462
460
 
463
461
  }
464
462
 
465
- },
463
+ }
466
464
 
467
465
  // holds various data about texture node image state
468
466
  // Data other thanmipMapLevel unknown
@@ -472,7 +470,7 @@ IFFParser.prototype = {
472
470
 
473
471
  this.currentForm.mipMapLevel = this.reader.getFloat32();
474
472
 
475
- },
473
+ }
476
474
 
477
475
  // LWO2 style image data node OR LWO3 textures defined at top level in editor (not as SURF node)
478
476
  parseImageMap( length ) {
@@ -488,7 +486,7 @@ IFFParser.prototype = {
488
486
 
489
487
  this.reader.skip( 10 ); // unknown, could be an issue if it contains a VX
490
488
 
491
- },
489
+ }
492
490
 
493
491
  parseTextureNodeAttribute( type ) {
494
492
 
@@ -526,14 +524,14 @@ IFFParser.prototype = {
526
524
  this.reader.skip( 2 ); // unknown
527
525
 
528
526
 
529
- },
527
+ }
530
528
 
531
529
  // ENVL forms are currently ignored
532
530
  parseEnvelope( length ) {
533
531
 
534
532
  this.reader.skip( length - 4 ); // skipping entirely for now
535
533
 
536
- },
534
+ }
537
535
 
538
536
  ///
539
537
  // CHUNK PARSING METHODS
@@ -570,7 +568,7 @@ IFFParser.prototype = {
570
568
  this.tree.textures.push( texture );
571
569
  this.currentForm = texture;
572
570
 
573
- },
571
+ }
574
572
 
575
573
  parseClipLwo2( length ) {
576
574
 
@@ -602,14 +600,14 @@ IFFParser.prototype = {
602
600
  this.tree.textures.push( texture );
603
601
  this.currentForm = texture;
604
602
 
605
- },
603
+ }
606
604
 
607
605
  parseImage() {
608
606
 
609
607
  this.reader.skip( 8 ); // unknown
610
608
  this.currentForm.fileName = this.reader.getString();
611
609
 
612
- },
610
+ }
613
611
 
614
612
  parseXVAL( type, length ) {
615
613
 
@@ -620,7 +618,7 @@ IFFParser.prototype = {
620
618
 
621
619
  this.reader.setOffset( endOffset ); // set end offset directly to skip optional envelope
622
620
 
623
- },
621
+ }
624
622
 
625
623
  parseXVAL3( type, length ) {
626
624
 
@@ -635,7 +633,7 @@ IFFParser.prototype = {
635
633
 
636
634
  this.reader.setOffset( endOffset );
637
635
 
638
- },
636
+ }
639
637
 
640
638
  // Tags associated with an object
641
639
  // OTAG { type[ID4], tag-string[S0] }
@@ -647,7 +645,7 @@ IFFParser.prototype = {
647
645
  tagString: this.reader.getString()
648
646
  };
649
647
 
650
- },
648
+ }
651
649
 
652
650
  // Signals the start of a new layer. All the data chunks which follow will be included in this layer until another layer chunk is encountered.
653
651
  // LAYR: number[U2], flags[U2], pivot[VEC12], name[S0], parent[U2]
@@ -668,7 +666,7 @@ IFFParser.prototype = {
668
666
  // if we have not reached then end of the layer block, there must be a parent defined
669
667
  this.currentLayer.parent = ( parsedLength < length ) ? this.reader.getUint16() : - 1; // omitted or -1 for no parent
670
668
 
671
- },
669
+ }
672
670
 
673
671
  // VEC12 * ( F4 + F4 + F4 ) array of x,y,z vectors
674
672
  // Converting from left to right handed coordinate system:
@@ -683,7 +681,7 @@ IFFParser.prototype = {
683
681
 
684
682
  }
685
683
 
686
- },
684
+ }
687
685
 
688
686
  // parse VMAP or VMAD
689
687
  // Associates a set of floating-point vectors with a set of points.
@@ -744,7 +742,7 @@ IFFParser.prototype = {
744
742
 
745
743
  }
746
744
 
747
- },
745
+ }
748
746
 
749
747
  parseUVMapping( name, finalOffset, discontinuous ) {
750
748
 
@@ -783,7 +781,7 @@ IFFParser.prototype = {
783
781
 
784
782
  }
785
783
 
786
- },
784
+ }
787
785
 
788
786
  parseMorphTargets( name, finalOffset, type ) {
789
787
 
@@ -808,7 +806,7 @@ IFFParser.prototype = {
808
806
  type: type,
809
807
  };
810
808
 
811
- },
809
+ }
812
810
 
813
811
  // A list of polygons for the current layer.
814
812
  // POLS { type[ID4], ( numvert+flags[U2], vert[VX] # numvert ) * }
@@ -847,7 +845,7 @@ IFFParser.prototype = {
847
845
 
848
846
  this.currentLayer.geometry = geometryData;
849
847
 
850
- },
848
+ }
851
849
 
852
850
  // Lists the tag strings that can be associated with polygons by the PTAG chunk.
853
851
  // TAGS { tag-string[S0] * }
@@ -855,7 +853,7 @@ IFFParser.prototype = {
855
853
 
856
854
  this.tree.tags = this.reader.getStringArray( length );
857
855
 
858
- },
856
+ }
859
857
 
860
858
  // Associates tags of a given type with polygons in the most recent POLS chunk.
861
859
  // PTAG { type[ID4], ( poly[VX], tag[U2] ) * }
@@ -870,7 +868,7 @@ IFFParser.prototype = {
870
868
 
871
869
  }
872
870
 
873
- },
871
+ }
874
872
 
875
873
  parseMaterialIndices( finalOffset ) {
876
874
 
@@ -886,7 +884,7 @@ IFFParser.prototype = {
886
884
 
887
885
  }
888
886
 
889
- },
887
+ }
890
888
 
891
889
  parseUnknownCHUNK( blockID, length ) {
892
890
 
@@ -901,26 +899,25 @@ IFFParser.prototype = {
901
899
 
902
900
  }
903
901
 
904
- };
902
+ }
905
903
 
906
- function DataViewReader( buffer ) {
907
904
 
908
- this.dv = new DataView( buffer );
909
- this.offset = 0;
910
- this._textDecoder = new TextDecoder();
911
- this._bytes = new Uint8Array( buffer );
905
+ class DataViewReader {
912
906
 
913
- }
907
+ constructor( buffer ) {
914
908
 
915
- DataViewReader.prototype = {
909
+ this.dv = new DataView( buffer );
910
+ this.offset = 0;
911
+ this._textDecoder = new TextDecoder();
912
+ this._bytes = new Uint8Array( buffer );
916
913
 
917
- constructor: DataViewReader,
914
+ }
918
915
 
919
- size: function () {
916
+ size() {
920
917
 
921
918
  return this.dv.buffer.byteLength;
922
919
 
923
- },
920
+ }
924
921
 
925
922
  setOffset( offset ) {
926
923
 
@@ -934,54 +931,54 @@ DataViewReader.prototype = {
934
931
 
935
932
  }
936
933
 
937
- },
934
+ }
938
935
 
939
- endOfFile: function () {
936
+ endOfFile() {
940
937
 
941
938
  if ( this.offset >= this.size() ) return true;
942
939
  return false;
943
940
 
944
- },
941
+ }
945
942
 
946
- skip: function ( length ) {
943
+ skip( length ) {
947
944
 
948
945
  this.offset += length;
949
946
 
950
- },
947
+ }
951
948
 
952
- getUint8: function () {
949
+ getUint8() {
953
950
 
954
951
  var value = this.dv.getUint8( this.offset );
955
952
  this.offset += 1;
956
953
  return value;
957
954
 
958
- },
955
+ }
959
956
 
960
- getUint16: function () {
957
+ getUint16() {
961
958
 
962
959
  var value = this.dv.getUint16( this.offset );
963
960
  this.offset += 2;
964
961
  return value;
965
962
 
966
- },
963
+ }
967
964
 
968
- getInt32: function () {
965
+ getInt32() {
969
966
 
970
967
  var value = this.dv.getInt32( this.offset, false );
971
968
  this.offset += 4;
972
969
  return value;
973
970
 
974
- },
971
+ }
975
972
 
976
- getUint32: function () {
973
+ getUint32() {
977
974
 
978
975
  var value = this.dv.getUint32( this.offset, false );
979
976
  this.offset += 4;
980
977
  return value;
981
978
 
982
- },
979
+ }
983
980
 
984
- getUint64: function () {
981
+ getUint64() {
985
982
 
986
983
  var low, high;
987
984
 
@@ -989,17 +986,17 @@ DataViewReader.prototype = {
989
986
  low = this.getUint32();
990
987
  return high * 0x100000000 + low;
991
988
 
992
- },
989
+ }
993
990
 
994
- getFloat32: function () {
991
+ getFloat32() {
995
992
 
996
993
  var value = this.dv.getFloat32( this.offset, false );
997
994
  this.offset += 4;
998
995
  return value;
999
996
 
1000
- },
997
+ }
1001
998
 
1002
- getFloat32Array: function ( size ) {
999
+ getFloat32Array( size ) {
1003
1000
 
1004
1001
  var a = [];
1005
1002
 
@@ -1011,17 +1008,17 @@ DataViewReader.prototype = {
1011
1008
 
1012
1009
  return a;
1013
1010
 
1014
- },
1011
+ }
1015
1012
 
1016
- getFloat64: function () {
1013
+ getFloat64() {
1017
1014
 
1018
1015
  var value = this.dv.getFloat64( this.offset, this.littleEndian );
1019
1016
  this.offset += 8;
1020
1017
  return value;
1021
1018
 
1022
- },
1019
+ }
1023
1020
 
1024
- getFloat64Array: function ( size ) {
1021
+ getFloat64Array( size ) {
1025
1022
 
1026
1023
  var a = [];
1027
1024
 
@@ -1033,7 +1030,7 @@ DataViewReader.prototype = {
1033
1030
 
1034
1031
  return a;
1035
1032
 
1036
- },
1033
+ }
1037
1034
 
1038
1035
  // get variable-length index data type
1039
1036
  // VX ::= index[U2] | (index + 0xFF000000)[U4]
@@ -1053,16 +1050,16 @@ DataViewReader.prototype = {
1053
1050
 
1054
1051
  return firstByte * 256 + this.getUint8();
1055
1052
 
1056
- },
1053
+ }
1057
1054
 
1058
1055
  // An ID tag is a sequence of 4 bytes containing 7-bit ASCII values
1059
1056
  getIDTag() {
1060
1057
 
1061
1058
  return this.getString( 4 );
1062
1059
 
1063
- },
1060
+ }
1064
1061
 
1065
- getString: function ( size ) {
1062
+ getString( size ) {
1066
1063
 
1067
1064
  if ( size === 0 ) return;
1068
1065
 
@@ -1095,9 +1092,9 @@ DataViewReader.prototype = {
1095
1092
 
1096
1093
  return result;
1097
1094
 
1098
- },
1095
+ }
1099
1096
 
1100
- getStringArray: function ( size ) {
1097
+ getStringArray( size ) {
1101
1098
 
1102
1099
  var a = this.getString( size );
1103
1100
  a = a.split( '\0' );
@@ -1106,29 +1103,28 @@ DataViewReader.prototype = {
1106
1103
 
1107
1104
  }
1108
1105
 
1109
- };
1106
+ }
1110
1107
 
1111
- // ************** DEBUGGER **************
1112
1108
 
1113
- function Debugger( ) {
1109
+ // ************** DEBUGGER **************
1114
1110
 
1115
- this.active = false;
1116
- this.depth = 0;
1117
- this.formList = [];
1111
+ class Debugger {
1118
1112
 
1119
- }
1113
+ constructor() {
1120
1114
 
1121
- Debugger.prototype = {
1115
+ this.active = false;
1116
+ this.depth = 0;
1117
+ this.formList = [];
1122
1118
 
1123
- constructor: Debugger,
1119
+ }
1124
1120
 
1125
- enable: function () {
1121
+ enable() {
1126
1122
 
1127
1123
  this.active = true;
1128
1124
 
1129
- },
1125
+ }
1130
1126
 
1131
- log: function () {
1127
+ log() {
1132
1128
 
1133
1129
  if ( ! this.active ) return;
1134
1130
 
@@ -1169,9 +1165,9 @@ Debugger.prototype = {
1169
1165
 
1170
1166
  this.skipped = false;
1171
1167
 
1172
- },
1168
+ }
1173
1169
 
1174
- closeForms: function () {
1170
+ closeForms() {
1175
1171
 
1176
1172
  if ( ! this.active ) return;
1177
1173
 
@@ -1189,7 +1185,7 @@ Debugger.prototype = {
1189
1185
 
1190
1186
  }
1191
1187
 
1192
- };
1188
+ }
1193
1189
 
1194
1190
  // ************** UTILITY FUNCTIONS **************
1195
1191
 
@@ -9,6 +9,8 @@ import { UniformsUtils, UniformsLib, ShaderMaterial, Color, MultiplyOperation }
9
9
 
10
10
  const GouraudShader = {
11
11
 
12
+ name: 'GouraudShader',
13
+
12
14
  uniforms: UniformsUtils.merge( [
13
15
  UniformsLib.common,
14
16
  UniformsLib.specularmap,
@@ -2,12 +2,6 @@ import {
2
2
  Vector3
3
3
  } from 'three';
4
4
 
5
- const _v1 = new Vector3();
6
- const _v2 = new Vector3();
7
- const _v3 = new Vector3();
8
-
9
- const EPS = 1e-10;
10
-
11
5
  class Capsule {
12
6
 
13
7
  constructor( start = new Vector3( 0, 0, 0 ), end = new Vector3( 0, 1, 0 ), radius = 1 ) {
@@ -83,55 +77,6 @@ class Capsule {
83
77
 
84
78
  }
85
79
 
86
- lineLineMinimumPoints( line1, line2 ) {
87
-
88
- const r = _v1.copy( line1.end ).sub( line1.start );
89
- const s = _v2.copy( line2.end ).sub( line2.start );
90
- const w = _v3.copy( line2.start ).sub( line1.start );
91
-
92
- const a = r.dot( s ),
93
- b = r.dot( r ),
94
- c = s.dot( s ),
95
- d = s.dot( w ),
96
- e = r.dot( w );
97
-
98
- let t1, t2;
99
- const divisor = b * c - a * a;
100
-
101
- if ( Math.abs( divisor ) < EPS ) {
102
-
103
- const d1 = - d / c;
104
- const d2 = ( a - d ) / c;
105
-
106
- if ( Math.abs( d1 - 0.5 ) < Math.abs( d2 - 0.5 ) ) {
107
-
108
- t1 = 0;
109
- t2 = d1;
110
-
111
- } else {
112
-
113
- t1 = 1;
114
- t2 = d2;
115
-
116
- }
117
-
118
- } else {
119
-
120
- t1 = ( d * a + e * c ) / divisor;
121
- t2 = ( t1 * a - d ) / c;
122
-
123
- }
124
-
125
- t2 = Math.max( 0, Math.min( 1, t2 ) );
126
- t1 = Math.max( 0, Math.min( 1, t1 ) );
127
-
128
- const point1 = r.multiplyScalar( t1 ).add( line1.start );
129
- const point2 = s.multiplyScalar( t2 ).add( line2.start );
130
-
131
- return [ point1, point2 ];
132
-
133
- }
134
-
135
80
  }
136
81
 
137
82
  export { Capsule };
@@ -11,12 +11,75 @@ import { Capsule } from '../math/Capsule.js';
11
11
 
12
12
  const _v1 = new Vector3();
13
13
  const _v2 = new Vector3();
14
+ const _point1 = new Vector3();
15
+ const _point2 = new Vector3();
14
16
  const _plane = new Plane();
15
17
  const _line1 = new Line3();
16
18
  const _line2 = new Line3();
17
19
  const _sphere = new Sphere();
18
20
  const _capsule = new Capsule();
19
21
 
22
+ const _temp1 = new Vector3();
23
+ const _temp2 = new Vector3();
24
+ const _temp3 = new Vector3();
25
+ const EPS = 1e-10;
26
+
27
+ function lineToLineClosestPoints( line1, line2, target1 = null, target2 = null ) {
28
+
29
+ const r = _temp1.copy( line1.end ).sub( line1.start );
30
+ const s = _temp2.copy( line2.end ).sub( line2.start );
31
+ const w = _temp3.copy( line2.start ).sub( line1.start );
32
+
33
+ const a = r.dot( s ),
34
+ b = r.dot( r ),
35
+ c = s.dot( s ),
36
+ d = s.dot( w ),
37
+ e = r.dot( w );
38
+
39
+ let t1, t2;
40
+ const divisor = b * c - a * a;
41
+
42
+ if ( Math.abs( divisor ) < EPS ) {
43
+
44
+ const d1 = - d / c;
45
+ const d2 = ( a - d ) / c;
46
+
47
+ if ( Math.abs( d1 - 0.5 ) < Math.abs( d2 - 0.5 ) ) {
48
+
49
+ t1 = 0;
50
+ t2 = d1;
51
+
52
+ } else {
53
+
54
+ t1 = 1;
55
+ t2 = d2;
56
+
57
+ }
58
+
59
+ } else {
60
+
61
+ t1 = ( d * a + e * c ) / divisor;
62
+ t2 = ( t1 * a - d ) / c;
63
+
64
+ }
65
+
66
+ t2 = Math.max( 0, Math.min( 1, t2 ) );
67
+ t1 = Math.max( 0, Math.min( 1, t1 ) );
68
+
69
+ if ( target1 ) {
70
+
71
+ target1.copy( r ).multiplyScalar( t1 ).add( line1.start );
72
+
73
+ }
74
+
75
+ if ( target2 ) {
76
+
77
+ target2.copy( s ).multiplyScalar( t2 ).add( line2.start );
78
+
79
+ }
80
+
81
+ }
82
+
20
83
  class Octree {
21
84
 
22
85
 
@@ -195,11 +258,15 @@ class Octree {
195
258
 
196
259
  const line2 = _line2.set( lines[ i ][ 0 ], lines[ i ][ 1 ] );
197
260
 
198
- const [ point1, point2 ] = capsule.lineLineMinimumPoints( line1, line2 );
261
+ lineToLineClosestPoints( line1, line2, _point1, _point2 );
199
262
 
200
- if ( point1.distanceToSquared( point2 ) < r2 ) {
263
+ if ( _point1.distanceToSquared( _point2 ) < r2 ) {
201
264
 
202
- return { normal: point1.clone().sub( point2 ).normalize(), point: point2.clone(), depth: capsule.radius - point1.distanceTo( point2 ) };
265
+ return {
266
+ normal: _point1.clone().sub( _point2 ).normalize(),
267
+ point: _point2.clone(),
268
+ depth: capsule.radius - _point1.distanceTo( _point2 )
269
+ };
203
270
 
204
271
  }
205
272