@needle-tools/three 0.145.4 → 0.146.2

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 (393) hide show
  1. package/README.md +1 -1
  2. package/build/three.cjs +32586 -35951
  3. package/build/three.js +32600 -35965
  4. package/build/three.min.js +6 -7
  5. package/build/three.module.js +1547 -1154
  6. package/examples/js/animation/AnimationClipCreator.js +0 -8
  7. package/examples/js/animation/CCDIKSolver.js +49 -66
  8. package/examples/js/animation/MMDAnimationHelper.js +66 -137
  9. package/examples/js/animation/MMDPhysics.js +70 -134
  10. package/examples/js/cameras/CinematicCamera.js +33 -22
  11. package/examples/js/controls/ArcballControls.js +138 -405
  12. package/examples/js/controls/DragControls.js +8 -33
  13. package/examples/js/controls/FirstPersonControls.js +32 -54
  14. package/examples/js/controls/FlyControls.js +29 -55
  15. package/examples/js/controls/OrbitControls.js +85 -95
  16. package/examples/js/controls/PointerLockControls.js +5 -14
  17. package/examples/js/controls/TrackballControls.js +33 -86
  18. package/examples/js/controls/TransformControls.js +84 -169
  19. package/examples/js/csm/CSM.js +4 -39
  20. package/examples/js/csm/CSMFrustum.js +3 -9
  21. package/examples/js/csm/CSMHelper.js +24 -4
  22. package/examples/js/csm/CSMShader.js +2 -6
  23. package/examples/js/curves/CurveExtras.js +27 -27
  24. package/examples/js/curves/NURBSCurve.js +4 -16
  25. package/examples/js/curves/NURBSSurface.js +3 -9
  26. package/examples/js/curves/NURBSUtils.js +8 -45
  27. package/examples/js/effects/AnaglyphEffect.js +4 -18
  28. package/examples/js/effects/AsciiEffect.js +32 -31
  29. package/examples/js/effects/OutlineEffect.js +26 -30
  30. package/examples/js/effects/ParallaxBarrierEffect.js +0 -13
  31. package/examples/js/effects/PeppersGhostEffect.js +12 -39
  32. package/examples/js/effects/StereoEffect.js +0 -4
  33. package/examples/js/environments/RoomEnvironment.js +12 -10
  34. package/examples/js/exporters/ColladaExporter.js +48 -65
  35. package/examples/js/exporters/DRACOExporter.js +22 -22
  36. package/examples/js/exporters/EXRExporter.js +15 -18
  37. package/examples/js/exporters/GLTFExporter.js +143 -261
  38. package/examples/js/exporters/MMDExporter.js +5 -12
  39. package/examples/js/exporters/OBJExporter.js +42 -33
  40. package/examples/js/exporters/PLYExporter.js +38 -33
  41. package/examples/js/exporters/STLExporter.js +5 -7
  42. package/examples/js/exporters/USDZExporter.js +110 -25
  43. package/examples/js/geometries/BoxLineGeometry.js +0 -1
  44. package/examples/js/geometries/ConvexGeometry.js +11 -6
  45. package/examples/js/geometries/DecalGeometry.js +53 -20
  46. package/examples/js/geometries/LightningStrike.js +54 -67
  47. package/examples/js/geometries/ParametricGeometries.js +8 -7
  48. package/examples/js/geometries/ParametricGeometry.js +25 -12
  49. package/examples/js/geometries/RoundedBoxGeometry.js +21 -19
  50. package/examples/js/geometries/TeapotGeometry.js +54 -50
  51. package/examples/js/geometries/TextGeometry.js +6 -4
  52. package/examples/js/helpers/LightProbeHelper.js +1 -2
  53. package/examples/js/helpers/OctreeHelper.js +22 -20
  54. package/examples/js/helpers/PositionalAudioHelper.js +8 -6
  55. package/examples/js/helpers/RectAreaLightHelper.js +6 -7
  56. package/examples/js/helpers/VertexNormalsHelper.js +15 -13
  57. package/examples/js/helpers/VertexTangentsHelper.js +15 -9
  58. package/examples/js/helpers/ViewHelper.js +31 -16
  59. package/examples/js/interactive/HTMLMesh.js +22 -33
  60. package/examples/js/interactive/InteractiveGroup.js +6 -12
  61. package/examples/js/interactive/SelectionBox.js +3 -70
  62. package/examples/js/interactive/SelectionHelper.js +0 -8
  63. package/examples/js/lights/LightProbeGenerator.js +32 -39
  64. package/examples/js/lights/RectAreaLightUniformsLib.js +5 -1
  65. package/examples/js/lines/LineGeometry.js +3 -5
  66. package/examples/js/lines/LineMaterial.js +4 -11
  67. package/examples/js/lines/LineSegments2.js +38 -89
  68. package/examples/js/lines/LineSegmentsGeometry.js +7 -28
  69. package/examples/js/lines/Wireframe.js +2 -7
  70. package/examples/js/lines/WireframeGeometry2.js +3 -1
  71. package/examples/js/loaders/3DMLoader.js +58 -155
  72. package/examples/js/loaders/3MFLoader.js +72 -106
  73. package/examples/js/loaders/AMFLoader.js +0 -25
  74. package/examples/js/loaders/BVHLoader.js +44 -43
  75. package/examples/js/loaders/BasisTextureLoader.js +16 -46
  76. package/examples/js/loaders/ColladaLoader.js +201 -359
  77. package/examples/js/loaders/DDSLoader.js +24 -25
  78. package/examples/js/loaders/DRACOLoader.js +29 -66
  79. package/examples/js/loaders/EXRLoader.js +67 -164
  80. package/examples/js/loaders/FBXLoader.js +286 -441
  81. package/examples/js/loaders/FontLoader.js +6 -15
  82. package/examples/js/loaders/GCodeLoader.js +15 -16
  83. package/examples/js/loaders/GLTFLoader.js +354 -405
  84. package/examples/js/loaders/HDRCubeTextureLoader.js +0 -6
  85. package/examples/js/loaders/KMZLoader.js +3 -7
  86. package/examples/js/loaders/KTXLoader.js +12 -30
  87. package/examples/js/loaders/LDrawLoader.js +178 -289
  88. package/examples/js/loaders/LUT3dlLoader.js +7 -11
  89. package/examples/js/loaders/LUTCubeLoader.js +0 -8
  90. package/examples/js/loaders/LWOLoader.js +59 -124
  91. package/examples/js/loaders/LogLuvLoader.js +27 -77
  92. package/examples/js/loaders/LottieLoader.js +4 -4
  93. package/examples/js/loaders/MD2Loader.js +26 -27
  94. package/examples/js/loaders/MDDLoader.js +6 -10
  95. package/examples/js/loaders/MMDLoader.js +180 -189
  96. package/examples/js/loaders/MTLLoader.js +18 -47
  97. package/examples/js/loaders/MaterialXLoader.js +392 -0
  98. package/examples/js/loaders/NRRDLoader.js +44 -84
  99. package/examples/js/loaders/OBJLoader.js +50 -65
  100. package/examples/js/loaders/PCDLoader.js +34 -29
  101. package/examples/js/loaders/PDBLoader.js +17 -13
  102. package/examples/js/loaders/PLYLoader.js +9 -39
  103. package/examples/js/loaders/PRWMLoader.js +11 -22
  104. package/examples/js/loaders/PVRLoader.js +7 -16
  105. package/examples/js/loaders/RGBELoader.js +36 -61
  106. package/examples/js/loaders/RGBMLoader.js +26 -87
  107. package/examples/js/loaders/STLLoader.js +20 -27
  108. package/examples/js/loaders/SVGLoader.js +361 -233
  109. package/examples/js/loaders/TDSLoader.js +81 -118
  110. package/examples/js/loaders/TGALoader.js +39 -41
  111. package/examples/js/loaders/TIFFLoader.js +0 -1
  112. package/examples/js/loaders/TTFLoader.js +0 -8
  113. package/examples/js/loaders/TiltLoader.js +14 -15
  114. package/examples/js/loaders/VOXLoader.js +8 -16
  115. package/examples/js/loaders/VRMLLoader.js +243 -340
  116. package/examples/js/loaders/VTKLoader.js +101 -118
  117. package/examples/js/loaders/XYZLoader.js +2 -4
  118. package/examples/js/loaders/lwo/IFFParser.js +55 -136
  119. package/examples/js/loaders/lwo/LWO2Parser.js +32 -83
  120. package/examples/js/loaders/lwo/LWO3Parser.js +31 -73
  121. package/examples/js/materials/MeshGouraudMaterial.js +15 -13
  122. package/examples/js/math/Capsule.js +0 -17
  123. package/examples/js/math/ColorConverter.js +3 -3
  124. package/examples/js/math/ConvexHull.js +183 -139
  125. package/examples/js/math/ImprovedNoise.js +1 -1
  126. package/examples/js/math/Lut.js +8 -15
  127. package/examples/js/math/MeshSurfaceSampler.js +6 -28
  128. package/examples/js/math/OBB.js +90 -49
  129. package/examples/js/math/Octree.js +2 -57
  130. package/examples/js/math/SimplexNoise.js +74 -88
  131. package/examples/js/misc/ConvexObjectBreaker.js +37 -48
  132. package/examples/js/misc/GPUComputationRenderer.js +14 -18
  133. package/examples/js/misc/Gyroscope.js +5 -9
  134. package/examples/js/misc/MD2Character.js +14 -23
  135. package/examples/js/misc/MD2CharacterComplex.js +73 -54
  136. package/examples/js/misc/MorphAnimMesh.js +0 -6
  137. package/examples/js/misc/MorphBlendMesh.js +3 -30
  138. package/examples/js/misc/ProgressiveLightMap.js +47 -43
  139. package/examples/js/misc/RollerCoaster.js +17 -24
  140. package/examples/js/misc/TubePainter.js +18 -12
  141. package/examples/js/misc/Volume.js +16 -45
  142. package/examples/js/misc/VolumeSlice.js +14 -24
  143. package/examples/js/modifiers/CurveModifier.js +19 -21
  144. package/examples/js/modifiers/EdgeSplitModifier.js +0 -30
  145. package/examples/js/modifiers/SimplifyModifier.js +56 -59
  146. package/examples/js/modifiers/TessellateModifier.js +2 -9
  147. package/examples/js/objects/GroundProjectedEnv.js +2 -14
  148. package/examples/js/objects/Lensflare.js +47 -38
  149. package/examples/js/objects/LightningStorm.js +10 -13
  150. package/examples/js/objects/MarchingCubes.js +80 -59
  151. package/examples/js/objects/Reflector.js +22 -20
  152. package/examples/js/objects/ReflectorForSSRPass.js +19 -23
  153. package/examples/js/objects/Refractor.js +52 -30
  154. package/examples/js/objects/ShadowMesh.js +1 -2
  155. package/examples/js/objects/Sky.js +2 -7
  156. package/examples/js/objects/Water.js +23 -18
  157. package/examples/js/objects/Water2.js +20 -19
  158. package/examples/js/physics/AmmoPhysics.js +23 -20
  159. package/examples/js/physics/OimoPhysics.js +19 -17
  160. package/examples/js/postprocessing/AdaptiveToneMappingPass.js +13 -20
  161. package/examples/js/postprocessing/AfterimagePass.js +19 -12
  162. package/examples/js/postprocessing/BloomPass.js +38 -17
  163. package/examples/js/postprocessing/BokehPass.js +29 -12
  164. package/examples/js/postprocessing/ClearPass.js +1 -6
  165. package/examples/js/postprocessing/CubeTexturePass.js +12 -9
  166. package/examples/js/postprocessing/DotScreenPass.js +7 -5
  167. package/examples/js/postprocessing/EffectComposer.js +25 -32
  168. package/examples/js/postprocessing/FilmPass.js +7 -5
  169. package/examples/js/postprocessing/GlitchPass.js +10 -11
  170. package/examples/js/postprocessing/HalftonePass.js +9 -9
  171. package/examples/js/postprocessing/LUTPass.js +2 -15
  172. package/examples/js/postprocessing/MaskPass.js +20 -17
  173. package/examples/js/postprocessing/OutlinePass.js +45 -36
  174. package/examples/js/postprocessing/Pass.js +11 -14
  175. package/examples/js/postprocessing/RenderPass.js +3 -7
  176. package/examples/js/postprocessing/SAOPass.js +40 -32
  177. package/examples/js/postprocessing/SMAAPass.js +34 -17
  178. package/examples/js/postprocessing/SSAARenderPass.js +14 -14
  179. package/examples/js/postprocessing/SSAOPass.js +56 -42
  180. package/examples/js/postprocessing/SSRPass.js +78 -61
  181. package/examples/js/postprocessing/SavePass.js +14 -6
  182. package/examples/js/postprocessing/ShaderPass.js +9 -8
  183. package/examples/js/postprocessing/TAARenderPass.js +11 -9
  184. package/examples/js/postprocessing/TexturePass.js +7 -4
  185. package/examples/js/postprocessing/UnrealBloomPass.js +43 -25
  186. package/examples/js/renderers/CSS2DRenderer.js +2 -21
  187. package/examples/js/renderers/CSS3DRenderer.js +3 -24
  188. package/examples/js/renderers/Projector.js +29 -85
  189. package/examples/js/renderers/SVGRenderer.js +4 -50
  190. package/examples/js/shaders/ACESFilmicToneMappingShader.js +3 -6
  191. package/examples/js/shaders/AfterimageShader.js +3 -6
  192. package/examples/js/shaders/BasicShader.js +3 -6
  193. package/examples/js/shaders/BleachBypassShader.js +3 -6
  194. package/examples/js/shaders/BlendShader.js +3 -6
  195. package/examples/js/shaders/BokehShader.js +3 -6
  196. package/examples/js/shaders/BokehShader2.js +4 -13
  197. package/examples/js/shaders/BrightnessContrastShader.js +3 -6
  198. package/examples/js/shaders/ColorCorrectionShader.js +2 -6
  199. package/examples/js/shaders/ColorifyShader.js +2 -6
  200. package/examples/js/shaders/ConvolutionShader.js +5 -10
  201. package/examples/js/shaders/CopyShader.js +3 -6
  202. package/examples/js/shaders/DOFMipMapShader.js +3 -6
  203. package/examples/js/shaders/DepthLimitedBlurShader.js +2 -9
  204. package/examples/js/shaders/DigitalGlitch.js +3 -6
  205. package/examples/js/shaders/DotScreenShader.js +2 -6
  206. package/examples/js/shaders/FXAAShader.js +1 -3
  207. package/examples/js/shaders/FilmShader.js +3 -6
  208. package/examples/js/shaders/FocusShader.js +3 -6
  209. package/examples/js/shaders/FreiChenShader.js +2 -6
  210. package/examples/js/shaders/GammaCorrectionShader.js +3 -6
  211. package/examples/js/shaders/GodRaysShader.js +11 -24
  212. package/examples/js/shaders/HalftoneShader.js +3 -6
  213. package/examples/js/shaders/HorizontalBlurShader.js +3 -6
  214. package/examples/js/shaders/HorizontalTiltShiftShader.js +3 -6
  215. package/examples/js/shaders/HueSaturationShader.js +3 -6
  216. package/examples/js/shaders/KaleidoShader.js +3 -6
  217. package/examples/js/shaders/LuminosityHighPassShader.js +2 -6
  218. package/examples/js/shaders/LuminosityShader.js +3 -6
  219. package/examples/js/shaders/MMDToonShader.js +2 -6
  220. package/examples/js/shaders/MirrorShader.js +3 -6
  221. package/examples/js/shaders/NormalMapShader.js +2 -6
  222. package/examples/js/shaders/RGBShiftShader.js +3 -6
  223. package/examples/js/shaders/SAOShader.js +2 -6
  224. package/examples/js/shaders/SMAAShader.js +6 -18
  225. package/examples/js/shaders/SSAOShader.js +2 -6
  226. package/examples/js/shaders/SSRShader.js +6 -18
  227. package/examples/js/shaders/SepiaShader.js +3 -6
  228. package/examples/js/shaders/SobelOperatorShader.js +2 -6
  229. package/examples/js/shaders/TechnicolorShader.js +3 -6
  230. package/examples/js/shaders/ToneMapShader.js +3 -6
  231. package/examples/js/shaders/ToonShader.js +8 -24
  232. package/examples/js/shaders/TriangleBlurShader.js +2 -6
  233. package/examples/js/shaders/UnpackDepthRGBAShader.js +3 -6
  234. package/examples/js/shaders/VelocityShader.js +126 -0
  235. package/examples/js/shaders/VerticalBlurShader.js +3 -6
  236. package/examples/js/shaders/VerticalTiltShiftShader.js +3 -6
  237. package/examples/js/shaders/VignetteShader.js +3 -6
  238. package/examples/js/shaders/VolumeShader.js +2 -6
  239. package/examples/js/shaders/WaterRefractionShader.js +2 -6
  240. package/examples/js/textures/FlakesTexture.js +0 -1
  241. package/examples/js/utils/BufferGeometryUtils.js +234 -168
  242. package/examples/js/utils/CameraUtils.js +5 -20
  243. package/examples/js/utils/GPUStatsPanel.js +3 -12
  244. package/examples/js/utils/GeometryCompressionUtils.js +19 -44
  245. package/examples/js/utils/GeometryUtils.js +13 -18
  246. package/examples/js/utils/LDrawUtils.js +8 -11
  247. package/examples/js/utils/PackedPhongMaterial.js +6 -4
  248. package/examples/js/utils/SceneUtils.js +117 -6
  249. package/examples/js/utils/ShadowMapViewer.js +17 -14
  250. package/examples/js/utils/SkeletonUtils.js +13 -27
  251. package/examples/js/utils/UVsDebug.js +20 -12
  252. package/examples/js/utils/WorkerPool.js +1 -11
  253. package/examples/jsm/animation/CCDIKSolver.js +1 -1
  254. package/examples/jsm/capabilities/WebGPU.js +3 -1
  255. package/examples/jsm/controls/OrbitControls.js +44 -4
  256. package/examples/jsm/exporters/GLTFExporter.js +17 -131
  257. package/examples/jsm/exporters/USDZExporter.js +75 -19
  258. package/examples/jsm/interactive/HTMLMesh.js +2 -0
  259. package/examples/jsm/libs/lottie_canvas.module.js +14844 -0
  260. package/examples/jsm/loaders/3DMLoader.js +1 -2
  261. package/examples/jsm/loaders/ColladaLoader.js +28 -0
  262. package/examples/jsm/loaders/FBXLoader.js +16 -2
  263. package/examples/jsm/loaders/GLTFLoader.js +204 -377
  264. package/examples/jsm/loaders/KTX2Loader.js +68 -29
  265. package/examples/jsm/loaders/LDrawLoader.js +14 -13
  266. package/examples/jsm/loaders/LottieLoader.js +4 -2
  267. package/examples/jsm/loaders/MaterialXLoader.js +728 -0
  268. package/examples/jsm/loaders/PCDLoader.js +1 -1
  269. package/examples/jsm/loaders/PLYLoader.js +68 -16
  270. package/examples/jsm/loaders/SVGLoader.js +227 -14
  271. package/examples/jsm/loaders/USDZLoader.js +31 -16
  272. package/examples/jsm/nodes/Nodes.js +14 -2
  273. package/examples/jsm/nodes/accessors/Object3DNode.js +1 -1
  274. package/examples/jsm/nodes/accessors/PositionNode.js +6 -0
  275. package/examples/jsm/nodes/accessors/ReferenceNode.js +1 -1
  276. package/examples/jsm/nodes/accessors/SkinningNode.js +1 -1
  277. package/examples/jsm/nodes/core/Node.js +1 -1
  278. package/examples/jsm/nodes/core/NodeBuilder.js +36 -4
  279. package/examples/jsm/nodes/core/NodeFrame.js +2 -2
  280. package/examples/jsm/nodes/core/NodeVarying.js +7 -4
  281. package/examples/jsm/nodes/core/VaryingNode.js +6 -4
  282. package/examples/jsm/nodes/core/constants.js +13 -13
  283. package/examples/jsm/nodes/display/PosterizeNode.js +25 -0
  284. package/examples/jsm/nodes/display/ViewportNode.js +106 -0
  285. package/examples/jsm/nodes/gpgpu/ComputeNode.js +1 -1
  286. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +1 -1
  287. package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +3 -1
  288. package/examples/jsm/nodes/materials/Materials.js +9 -7
  289. package/examples/jsm/nodes/materials/NodeMaterial.js +9 -1
  290. package/examples/jsm/nodes/materialx/MaterialXNodes.js +6 -2
  291. package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +18 -0
  292. package/examples/jsm/nodes/math/MathNode.js +5 -0
  293. package/examples/jsm/nodes/math/OperatorNode.js +6 -1
  294. package/examples/jsm/nodes/shadernode/ShaderNode.js +26 -13
  295. package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +2 -0
  296. package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +18 -0
  297. package/examples/jsm/nodes/utils/EquirectUVNode.js +27 -0
  298. package/examples/jsm/nodes/utils/JoinNode.js +8 -2
  299. package/examples/jsm/nodes/utils/MatcapUVNode.js +2 -4
  300. package/examples/jsm/nodes/utils/MaxMipLevelNode.js +1 -1
  301. package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +8 -10
  302. package/examples/jsm/nodes/utils/TimerNode.js +1 -1
  303. package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +51 -0
  304. package/examples/jsm/postprocessing/AfterimagePass.js +17 -4
  305. package/examples/jsm/postprocessing/BloomPass.js +22 -3
  306. package/examples/jsm/postprocessing/BokehPass.js +18 -4
  307. package/examples/jsm/postprocessing/CubeTexturePass.js +12 -5
  308. package/examples/jsm/postprocessing/DotScreenPass.js +8 -0
  309. package/examples/jsm/postprocessing/EffectComposer.js +9 -0
  310. package/examples/jsm/postprocessing/FilmPass.js +8 -0
  311. package/examples/jsm/postprocessing/GlitchPass.js +13 -1
  312. package/examples/jsm/postprocessing/HalftonePass.js +8 -0
  313. package/examples/jsm/postprocessing/OutlinePass.js +10 -0
  314. package/examples/jsm/postprocessing/Pass.js +2 -0
  315. package/examples/jsm/postprocessing/RenderPixelatedPass.js +234 -0
  316. package/examples/jsm/postprocessing/SAOPass.js +20 -0
  317. package/examples/jsm/postprocessing/SMAAPass.js +16 -0
  318. package/examples/jsm/postprocessing/SSAARenderPass.js +4 -0
  319. package/examples/jsm/postprocessing/SavePass.js +17 -1
  320. package/examples/jsm/postprocessing/ShaderPass.js +8 -0
  321. package/examples/jsm/postprocessing/TAARenderPass.js +9 -0
  322. package/examples/jsm/postprocessing/TexturePass.js +8 -0
  323. package/examples/jsm/postprocessing/UnrealBloomPass.js +16 -0
  324. package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +39 -16
  325. package/examples/jsm/renderers/webgpu/WebGPUAnimation.js +58 -0
  326. package/examples/jsm/renderers/webgpu/WebGPUAttributes.js +63 -5
  327. package/examples/jsm/renderers/webgpu/WebGPUBackground.js +36 -7
  328. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +47 -12
  329. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +35 -5
  330. package/examples/jsm/shaders/MMDToonShader.js +0 -2
  331. package/examples/jsm/shaders/VelocityShader.js +128 -0
  332. package/examples/jsm/utils/BufferGeometryUtils.js +130 -6
  333. package/examples/jsm/utils/SceneUtils.js +129 -4
  334. package/examples/jsm/utils/TextureUtils.js +85 -0
  335. package/examples/jsm/webxr/OculusHandModel.js +1 -1
  336. package/examples/jsm/webxr/XRHandMeshModel.js +6 -3
  337. package/package.json +11 -12
  338. package/src/Three.js +1 -0
  339. package/src/audio/AudioContext.js +5 -5
  340. package/src/cameras/CubeCamera.js +14 -14
  341. package/src/constants.js +1 -1
  342. package/src/core/InstancedBufferGeometry.js +1 -7
  343. package/src/extras/Earcut.js +67 -67
  344. package/src/helpers/DirectionalLightHelper.js +5 -1
  345. package/src/helpers/HemisphereLightHelper.js +4 -1
  346. package/src/helpers/PointLightHelper.js +2 -1
  347. package/src/helpers/SpotLightHelper.js +4 -2
  348. package/src/lights/PointLight.js +2 -2
  349. package/src/lights/SpotLight.js +2 -2
  350. package/src/loaders/FileLoader.js +4 -1
  351. package/src/loaders/ObjectLoader.js +5 -1
  352. package/src/materials/Material.js +1 -1
  353. package/src/math/Color.js +5 -5
  354. package/src/math/Matrix3.js +53 -18
  355. package/src/math/Ray.js +2 -5
  356. package/src/math/Sphere.js +19 -26
  357. package/src/objects/InstancedMesh.js +7 -0
  358. package/src/objects/LOD.js +25 -6
  359. package/src/renderers/WebGL3DRenderTarget.js +1 -1
  360. package/src/renderers/WebGLArrayRenderTarget.js +1 -1
  361. package/src/renderers/WebGLCubeRenderTarget.js +1 -1
  362. package/src/renderers/WebGLMultipleRenderTargets.js +1 -1
  363. package/src/renderers/WebGLRenderTarget.js +1 -1
  364. package/src/renderers/WebGLRenderer.js +36 -62
  365. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +0 -4
  366. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +0 -1
  367. package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +0 -2
  368. package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +0 -2
  369. package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +0 -2
  370. package/src/renderers/shaders/ShaderChunk/packing.glsl.js +8 -0
  371. package/src/renderers/shaders/ShaderChunk.js +3 -0
  372. package/src/renderers/shaders/ShaderLib/background.glsl.js +7 -2
  373. package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +62 -0
  374. package/src/renderers/shaders/ShaderLib/cube.glsl.js +4 -6
  375. package/src/renderers/shaders/ShaderLib.js +20 -6
  376. package/src/renderers/shaders/UniformsLib.js +1 -1
  377. package/src/renderers/shaders/UniformsUtils.js +15 -0
  378. package/src/renderers/webgl/WebGLAttributes.js +2 -0
  379. package/src/renderers/webgl/WebGLBackground.js +15 -7
  380. package/src/renderers/webgl/WebGLLights.js +0 -4
  381. package/src/renderers/webgl/WebGLMaterials.js +2 -1
  382. package/src/renderers/webgl/WebGLShadowMap.js +3 -1
  383. package/src/renderers/webgl/WebGLState.js +31 -1
  384. package/src/renderers/webgl/WebGLTextures.js +71 -18
  385. package/src/renderers/webgl/WebGLUniforms.js +116 -20
  386. package/src/renderers/webgl/WebGLUtils.js +1 -1
  387. package/src/renderers/webxr/WebXRController.js +46 -13
  388. package/src/renderers/webxr/WebXRManager.js +85 -3
  389. package/src/scenes/Scene.js +8 -0
  390. package/src/textures/CompressedArrayTexture.js +18 -0
  391. package/examples/js/libs/lottie_canvas.js +0 -12751
  392. package/examples/js/shaders/PixelShader.js +0 -51
  393. package/examples/jsm/shaders/PixelShader.js +0 -44
@@ -16,7 +16,6 @@
16
16
  * @param {WebGLRenderer} renderer A WebGL Rendering Context
17
17
  * @param {number} res The side-long dimension of you total lightmap
18
18
  */
19
-
20
19
  class ProgressiveLightMap {
21
20
 
22
21
  constructor( renderer, res = 1024 ) {
@@ -30,59 +29,62 @@
30
29
  this.tinyTarget = new THREE.WebGLRenderTarget( 1, 1 );
31
30
  this.buffer1Active = false;
32
31
  this.firstUpdate = true;
33
- this.warned = false; // Create the Progressive LightMap Texture
32
+ this.warned = false;
34
33
 
34
+ // Create the Progressive LightMap Texture
35
35
  const format = /(Android|iPad|iPhone|iPod)/g.test( navigator.userAgent ) ? THREE.HalfFloatType : THREE.FloatType;
36
36
  this.progressiveLightMap1 = new THREE.WebGLRenderTarget( this.res, this.res, {
37
37
  type: format
38
38
  } );
39
39
  this.progressiveLightMap2 = new THREE.WebGLRenderTarget( this.res, this.res, {
40
40
  type: format
41
- } ); // Inject some spicy new logic into a standard phong material
41
+ } );
42
42
 
43
+ // Inject some spicy new logic into a standard phong material
43
44
  this.uvMat = new THREE.MeshPhongMaterial();
44
45
  this.uvMat.uniforms = {};
45
-
46
46
  this.uvMat.onBeforeCompile = shader => {
47
47
 
48
48
  // Vertex Shader: Set Vertex Positions to the Unwrapped UV Positions
49
- shader.vertexShader = '#define USE_LIGHTMAP\n' + shader.vertexShader.slice( 0, - 1 ) + ' gl_Position = vec4((uv2 - 0.5) * 2.0, 1.0, 1.0); }'; // Fragment Shader: Set Pixels to average in the Previous frame's Shadows
49
+ shader.vertexShader = '#define USE_LIGHTMAP\n' + shader.vertexShader.slice( 0, - 1 ) + ' gl_Position = vec4((uv2 - 0.5) * 2.0, 1.0, 1.0); }';
50
50
 
51
+ // Fragment Shader: Set Pixels to average in the Previous frame's Shadows
51
52
  const bodyStart = shader.fragmentShader.indexOf( 'void main() {' );
52
53
  shader.fragmentShader = 'varying vec2 vUv2;\n' + shader.fragmentShader.slice( 0, bodyStart ) + ' uniform sampler2D previousShadowMap;\n uniform float averagingWindow;\n' + shader.fragmentShader.slice( bodyStart - 1, - 1 ) + `\nvec3 texelOld = texture2D(previousShadowMap, vUv2).rgb;
53
54
  gl_FragColor.rgb = mix(texelOld, gl_FragColor.rgb, 1.0/averagingWindow);
54
- }`; // Set the Previous Frame's Texture Buffer and Averaging Window
55
+ }`;
55
56
 
57
+ // Set the Previous Frame's Texture Buffer and Averaging Window
56
58
  shader.uniforms.previousShadowMap = {
57
59
  value: this.progressiveLightMap1.texture
58
60
  };
59
61
  shader.uniforms.averagingWindow = {
60
62
  value: 100
61
63
  };
62
- this.uvMat.uniforms = shader.uniforms; // Set the new Shader to this
64
+ this.uvMat.uniforms = shader.uniforms;
63
65
 
66
+ // Set the new Shader to this
64
67
  this.uvMat.userData.shader = shader;
65
68
  this.compiled = true;
66
69
 
67
70
  };
68
71
 
69
72
  }
73
+
70
74
  /**
71
75
  * Sets these objects' materials' lightmaps and modifies their uv2's.
72
76
  * @param {Object3D} objects An array of objects and lights to set up your lightmap.
73
77
  */
74
-
75
-
76
78
  addObjectsToLightMap( objects ) {
77
79
 
78
80
  // Prepare list of UV bounding boxes for packing later...
79
81
  this.uv_boxes = [];
80
82
  const padding = 3 / this.res;
81
-
82
83
  for ( let ob = 0; ob < objects.length; ob ++ ) {
83
84
 
84
- const object = objects[ ob ]; // If this object is a light, simply add it to the internal scene
85
+ const object = objects[ ob ];
85
86
 
87
+ // If this object is a light, simply add it to the internal scene
86
88
  if ( object.isLight ) {
87
89
 
88
90
  this.scene.attach( object );
@@ -101,16 +103,17 @@
101
103
 
102
104
  this._initializeBlurPlane( this.res, this.progressiveLightMap1 );
103
105
 
104
- } // Apply the lightmap to the object
105
-
106
+ }
106
107
 
108
+ // Apply the lightmap to the object
107
109
  object.material.lightMap = this.progressiveLightMap2.texture;
108
110
  object.material.dithering = true;
109
111
  object.castShadow = true;
110
112
  object.receiveShadow = true;
111
- object.renderOrder = 1000 + ob; // Prepare UV boxes for potpack
112
- // TODO: Size these by object surface area
113
+ object.renderOrder = 1000 + ob;
113
114
 
115
+ // Prepare UV boxes for potpack
116
+ // TODO: Size these by object surface area
114
117
  this.uv_boxes.push( {
115
118
  w: 1 + padding * 2,
116
119
  h: 1 + padding * 2,
@@ -122,14 +125,13 @@
122
125
  } );
123
126
  this.compiled = false;
124
127
 
125
- } // Pack the objects' lightmap UVs into the same global space
126
-
128
+ }
127
129
 
130
+ // Pack the objects' lightmap UVs into the same global space
128
131
  const dimensions = potpack( this.uv_boxes );
129
132
  this.uv_boxes.forEach( box => {
130
133
 
131
134
  const uv2 = objects[ box.index ].geometry.getAttribute( 'uv' ).clone();
132
-
133
135
  for ( let i = 0; i < uv2.array.length; i += uv2.itemSize ) {
134
136
 
135
137
  uv2.array[ i ] = ( uv2.array[ i ] + box.x + padding ) / dimensions.w;
@@ -143,45 +145,45 @@
143
145
  } );
144
146
 
145
147
  }
148
+
146
149
  /**
147
150
  * This function renders each mesh one at a time into their respective surface maps
148
151
  * @param {Camera} camera Standard Rendering Camera
149
152
  * @param {number} blendWindow When >1, samples will accumulate over time.
150
153
  * @param {boolean} blurEdges Whether to fix UV Edges via blurring
151
154
  */
152
-
153
-
154
155
  update( camera, blendWindow = 100, blurEdges = true ) {
155
156
 
156
157
  if ( this.blurringPlane == null ) {
157
158
 
158
159
  return;
159
160
 
160
- } // Store the original Render Target
161
-
161
+ }
162
162
 
163
- const oldTarget = this.renderer.getRenderTarget(); // The blurring plane applies blur to the seams of the lightmap
163
+ // Store the original Render Target
164
+ const oldTarget = this.renderer.getRenderTarget();
164
165
 
165
- this.blurringPlane.visible = blurEdges; // Steal the Object3D from the real world to our special dimension
166
+ // The blurring plane applies blur to the seams of the lightmap
167
+ this.blurringPlane.visible = blurEdges;
166
168
 
169
+ // Steal the Object3D from the real world to our special dimension
167
170
  for ( let l = 0; l < this.lightMapContainers.length; l ++ ) {
168
171
 
169
172
  this.lightMapContainers[ l ].object.oldScene = this.lightMapContainers[ l ].object.parent;
170
173
  this.scene.attach( this.lightMapContainers[ l ].object );
171
174
 
172
- } // Render once normally to initialize everything
173
-
175
+ }
174
176
 
177
+ // Render once normally to initialize everything
175
178
  if ( this.firstUpdate ) {
176
179
 
177
180
  this.renderer.setRenderTarget( this.tinyTarget ); // Tiny for Speed
178
-
179
181
  this.renderer.render( this.scene, camera );
180
182
  this.firstUpdate = false;
181
183
 
182
- } // Set each object's material to the UV Unwrapped Surface Mapping Version
183
-
184
+ }
184
185
 
186
+ // Set each object's material to the UV Unwrapped Surface Mapping Version
185
187
  for ( let l = 0; l < this.lightMapContainers.length; l ++ ) {
186
188
 
187
189
  this.uvMat.uniforms.averagingWindow = {
@@ -191,12 +193,13 @@
191
193
  this.lightMapContainers[ l ].object.oldFrustumCulled = this.lightMapContainers[ l ].object.frustumCulled;
192
194
  this.lightMapContainers[ l ].object.frustumCulled = false;
193
195
 
194
- } // Ping-pong two surface buffers for reading/writing
195
-
196
+ }
196
197
 
198
+ // Ping-pong two surface buffers for reading/writing
197
199
  const activeMap = this.buffer1Active ? this.progressiveLightMap1 : this.progressiveLightMap2;
198
- const inactiveMap = this.buffer1Active ? this.progressiveLightMap2 : this.progressiveLightMap1; // Render the object's surface maps
200
+ const inactiveMap = this.buffer1Active ? this.progressiveLightMap2 : this.progressiveLightMap1;
199
201
 
202
+ // Render the object's surface maps
200
203
  this.renderer.setRenderTarget( activeMap );
201
204
  this.uvMat.uniforms.previousShadowMap = {
202
205
  value: inactiveMap.texture
@@ -205,27 +208,27 @@
205
208
  value: inactiveMap.texture
206
209
  };
207
210
  this.buffer1Active = ! this.buffer1Active;
208
- this.renderer.render( this.scene, camera ); // Restore the object's Real-time Material and add it back to the original world
211
+ this.renderer.render( this.scene, camera );
209
212
 
213
+ // Restore the object's Real-time Material and add it back to the original world
210
214
  for ( let l = 0; l < this.lightMapContainers.length; l ++ ) {
211
215
 
212
216
  this.lightMapContainers[ l ].object.frustumCulled = this.lightMapContainers[ l ].object.oldFrustumCulled;
213
217
  this.lightMapContainers[ l ].object.material = this.lightMapContainers[ l ].basicMat;
214
218
  this.lightMapContainers[ l ].object.oldScene.attach( this.lightMapContainers[ l ].object );
215
219
 
216
- } // Restore the original Render Target
217
-
220
+ }
218
221
 
222
+ // Restore the original Render Target
219
223
  this.renderer.setRenderTarget( oldTarget );
220
224
 
221
225
  }
226
+
222
227
  /** DEBUG
223
228
  * Draw the lightmap in the main scene. Call this after adding the objects to it.
224
229
  * @param {boolean} visible Whether the debug plane should be visible
225
230
  * @param {Vector3} position Where the debug plane should be drawn
226
231
  */
227
-
228
-
229
232
  showDebugLightmap( visible, position = undefined ) {
230
233
 
231
234
  if ( this.lightMapContainers.length == 0 ) {
@@ -263,13 +266,12 @@
263
266
  this.labelMesh.visible = visible;
264
267
 
265
268
  }
269
+
266
270
  /**
267
271
  * INTERNAL Creates the Blurring Plane
268
272
  * @param {number} res The square resolution of this object's lightMap.
269
273
  * @param {WebGLRenderTexture} lightMap The lightmap to initialize the plane with.
270
274
  */
271
-
272
-
273
275
  _initializeBlurPlane( res, lightMap = null ) {
274
276
 
275
277
  const blurMaterial = new THREE.MeshBasicMaterial();
@@ -284,12 +286,12 @@
284
286
  polygonOffsetFactor: - 1,
285
287
  polygonOffsetUnits: 3.0
286
288
  };
287
-
288
289
  blurMaterial.onBeforeCompile = shader => {
289
290
 
290
291
  // Vertex Shader: Set Vertex Positions to the Unwrapped UV Positions
291
- shader.vertexShader = '#define USE_UV\n' + shader.vertexShader.slice( 0, - 1 ) + ' gl_Position = vec4((uv - 0.5) * 2.0, 1.0, 1.0); }'; // Fragment Shader: Set Pixels to 9-tap box blur the current frame's Shadows
292
+ shader.vertexShader = '#define USE_UV\n' + shader.vertexShader.slice( 0, - 1 ) + ' gl_Position = vec4((uv - 0.5) * 2.0, 1.0, 1.0); }';
292
293
 
294
+ // Fragment Shader: Set Pixels to 9-tap box blur the current frame's Shadows
293
295
  const bodyStart = shader.fragmentShader.indexOf( 'void main() {' );
294
296
  shader.fragmentShader = '#define USE_UV\n' + shader.fragmentShader.slice( 0, bodyStart ) + ' uniform sampler2D previousShadowMap;\n uniform float pixelOffset;\n' + shader.fragmentShader.slice( bodyStart - 1, - 1 ) + ` gl_FragColor.rgb = (
295
297
  texture2D(previousShadowMap, vUv + vec2( pixelOffset, 0.0 )).rgb +
@@ -300,16 +302,18 @@
300
302
  texture2D(previousShadowMap, vUv + vec2(-pixelOffset, pixelOffset)).rgb +
301
303
  texture2D(previousShadowMap, vUv + vec2( pixelOffset, -pixelOffset)).rgb +
302
304
  texture2D(previousShadowMap, vUv + vec2(-pixelOffset, -pixelOffset)).rgb)/8.0;
303
- }`; // Set the LightMap Accumulation Buffer
305
+ }`;
304
306
 
307
+ // Set the LightMap Accumulation Buffer
305
308
  shader.uniforms.previousShadowMap = {
306
309
  value: lightMap.texture
307
310
  };
308
311
  shader.uniforms.pixelOffset = {
309
312
  value: 0.5 / res
310
313
  };
311
- blurMaterial.uniforms = shader.uniforms; // Set the new Shader to this
314
+ blurMaterial.uniforms = shader.uniforms;
312
315
 
316
+ // Set the new Shader to this
313
317
  blurMaterial.userData.shader = shader;
314
318
  this.compiled = true;
315
319
 
@@ -18,13 +18,14 @@
18
18
  prevQuaternion.setFromAxisAngle( up, Math.PI / 2 );
19
19
  const point = new THREE.Vector3();
20
20
  const prevPoint = new THREE.Vector3();
21
- prevPoint.copy( curve.getPointAt( 0 ) ); // shapes
21
+ prevPoint.copy( curve.getPointAt( 0 ) );
22
+
23
+ // shapes
22
24
 
23
25
  const step = [ new THREE.Vector3( - 0.225, 0, 0 ), new THREE.Vector3( 0, - 0.050, 0 ), new THREE.Vector3( 0, - 0.175, 0 ), new THREE.Vector3( 0, - 0.050, 0 ), new THREE.Vector3( 0.225, 0, 0 ), new THREE.Vector3( 0, - 0.175, 0 ) ];
24
26
  const PI2 = Math.PI * 2;
25
27
  let sides = 5;
26
28
  const tube1 = [];
27
-
28
29
  for ( let i = 0; i < sides; i ++ ) {
29
30
 
30
31
  const angle = i / sides * PI2;
@@ -34,7 +35,6 @@
34
35
 
35
36
  sides = 6;
36
37
  const tube2 = [];
37
-
38
38
  for ( let i = 0; i < sides; i ++ ) {
39
39
 
40
40
  const angle = i / sides * PI2;
@@ -44,11 +44,9 @@
44
44
 
45
45
  const vector = new THREE.Vector3();
46
46
  const normal = new THREE.Vector3();
47
-
48
47
  function drawShape( shape, color ) {
49
48
 
50
49
  normal.set( 0, 0, - 1 ).applyQuaternion( quaternion );
51
-
52
50
  for ( let j = 0; j < shape.length; j ++ ) {
53
51
 
54
52
  vector.copy( shape[ j ] );
@@ -61,7 +59,6 @@
61
59
  }
62
60
 
63
61
  normal.set( 0, 0, 1 ).applyQuaternion( quaternion );
64
-
65
62
  for ( let j = shape.length - 1; j >= 0; j -- ) {
66
63
 
67
64
  vector.copy( shape[ j ] );
@@ -83,7 +80,6 @@
83
80
  const normal2 = new THREE.Vector3();
84
81
  const normal3 = new THREE.Vector3();
85
82
  const normal4 = new THREE.Vector3();
86
-
87
83
  function extrudeShape( shape, offset, color ) {
88
84
 
89
85
  for ( let j = 0, jl = shape.length; j < jl; j ++ ) {
@@ -107,7 +103,9 @@
107
103
  vertices.push( vector4.x, vector4.y, vector4.z );
108
104
  vertices.push( vector2.x, vector2.y, vector2.z );
109
105
  vertices.push( vector3.x, vector3.y, vector3.z );
110
- vertices.push( vector4.x, vector4.y, vector4.z ); //
106
+ vertices.push( vector4.x, vector4.y, vector4.z );
107
+
108
+ //
111
109
 
112
110
  normal1.copy( point1 );
113
111
  normal1.applyQuaternion( quaternion );
@@ -139,7 +137,6 @@
139
137
  }
140
138
 
141
139
  const offset = new THREE.Vector3();
142
-
143
140
  for ( let i = 1; i <= divisions; i ++ ) {
144
141
 
145
142
  point.copy( curve.getPointAt( i / divisions ) );
@@ -149,7 +146,6 @@
149
146
  up.crossVectors( forward, right );
150
147
  const angle = Math.atan2( forward.x, forward.z );
151
148
  quaternion.setFromAxisAngle( up, angle );
152
-
153
149
  if ( i % 2 === 0 ) {
154
150
 
155
151
  drawShape( step, color2 );
@@ -162,8 +158,9 @@
162
158
  prevPoint.copy( point );
163
159
  prevQuaternion.copy( quaternion );
164
160
 
165
- } // console.log( vertices.length );
161
+ }
166
162
 
163
+ // console.log( vertices.length );
167
164
 
168
165
  this.setAttribute( 'position', new THREE.BufferAttribute( new Float32Array( vertices ), 3 ) );
169
166
  this.setAttribute( 'normal', new THREE.BufferAttribute( new Float32Array( normals ), 3 ) );
@@ -172,7 +169,6 @@
172
169
  }
173
170
 
174
171
  }
175
-
176
172
  class RollerCoasterLiftersGeometry extends THREE.BufferGeometry {
177
173
 
178
174
  constructor( curve, divisions ) {
@@ -183,7 +179,9 @@
183
179
  const quaternion = new THREE.Quaternion();
184
180
  const up = new THREE.Vector3( 0, 1, 0 );
185
181
  const point = new THREE.Vector3();
186
- const tangent = new THREE.Vector3(); // shapes
182
+ const tangent = new THREE.Vector3();
183
+
184
+ // shapes
187
185
 
188
186
  const tube1 = [ new THREE.Vector3( 0, 0.05, - 0.05 ), new THREE.Vector3( 0, 0.05, 0.05 ), new THREE.Vector3( 0, - 0.05, 0 ) ];
189
187
  const tube2 = [ new THREE.Vector3( - 0.05, 0, 0.05 ), new THREE.Vector3( - 0.05, 0, - 0.05 ), new THREE.Vector3( 0.05, 0, 0 ) ];
@@ -196,7 +194,6 @@
196
194
  const normal2 = new THREE.Vector3();
197
195
  const normal3 = new THREE.Vector3();
198
196
  const normal4 = new THREE.Vector3();
199
-
200
197
  function extrudeShape( shape, fromPoint, toPoint ) {
201
198
 
202
199
  for ( let j = 0, jl = shape.length; j < jl; j ++ ) {
@@ -220,7 +217,9 @@
220
217
  vertices.push( vector4.x, vector4.y, vector4.z );
221
218
  vertices.push( vector2.x, vector2.y, vector2.z );
222
219
  vertices.push( vector3.x, vector3.y, vector3.z );
223
- vertices.push( vector4.x, vector4.y, vector4.z ); //
220
+ vertices.push( vector4.x, vector4.y, vector4.z );
221
+
222
+ //
224
223
 
225
224
  normal1.copy( point1 );
226
225
  normal1.applyQuaternion( quaternion );
@@ -247,13 +246,14 @@
247
246
 
248
247
  const fromPoint = new THREE.Vector3();
249
248
  const toPoint = new THREE.Vector3();
250
-
251
249
  for ( let i = 1; i <= divisions; i ++ ) {
252
250
 
253
251
  point.copy( curve.getPointAt( i / divisions ) );
254
252
  tangent.copy( curve.getTangentAt( i / divisions ) );
255
253
  const angle = Math.atan2( tangent.x, tangent.z );
256
- quaternion.setFromAxisAngle( up, angle ); //
254
+ quaternion.setFromAxisAngle( up, angle );
255
+
256
+ //
257
257
 
258
258
  if ( point.y > 10 ) {
259
259
 
@@ -299,7 +299,6 @@
299
299
  }
300
300
 
301
301
  }
302
-
303
302
  class RollerCoasterShadowGeometry extends THREE.BufferGeometry {
304
303
 
305
304
  constructor( curve, divisions ) {
@@ -319,7 +318,6 @@
319
318
  const vector2 = new THREE.Vector3();
320
319
  const vector3 = new THREE.Vector3();
321
320
  const vector4 = new THREE.Vector3();
322
-
323
321
  for ( let i = 1; i <= divisions; i ++ ) {
324
322
 
325
323
  point.copy( curve.getPointAt( i / divisions ) );
@@ -355,14 +353,12 @@
355
353
  }
356
354
 
357
355
  }
358
-
359
356
  class SkyGeometry extends THREE.BufferGeometry {
360
357
 
361
358
  constructor() {
362
359
 
363
360
  super();
364
361
  const vertices = [];
365
-
366
362
  for ( let i = 0; i < 100; i ++ ) {
367
363
 
368
364
  const x = Math.random() * 800 - 400;
@@ -383,7 +379,6 @@
383
379
  }
384
380
 
385
381
  }
386
-
387
382
  class TreesGeometry extends THREE.BufferGeometry {
388
383
 
389
384
  constructor( landscape ) {
@@ -393,7 +388,6 @@
393
388
  const colors = [];
394
389
  const raycaster = new THREE.Raycaster();
395
390
  raycaster.ray.direction.set( 0, - 1, 0 );
396
-
397
391
  for ( let i = 0; i < 2000; i ++ ) {
398
392
 
399
393
  const x = Math.random() * 500 - 250;
@@ -412,7 +406,6 @@
412
406
  vertices.push( x, y + height, z );
413
407
  vertices.push( x + Math.sin( angle + Math.PI ), y, z + Math.cos( angle + Math.PI ) );
414
408
  const random = Math.random() * 0.1;
415
-
416
409
  for ( let j = 0; j < 6; j ++ ) {
417
410
 
418
411
  colors.push( 0.2 + random, 0.4 + random, 0 );
@@ -18,7 +18,9 @@
18
18
  vertexColors: true
19
19
  } );
20
20
  const mesh = new THREE.Mesh( geometry, material );
21
- mesh.frustumCulled = false; //
21
+ mesh.frustumCulled = false;
22
+
23
+ //
22
24
 
23
25
  function getPoints( size ) {
24
26
 
@@ -26,7 +28,6 @@
26
28
  const sides = 10;
27
29
  const array = [];
28
30
  const radius = 0.01 * size;
29
-
30
31
  for ( let i = 0; i < sides; i ++ ) {
31
32
 
32
33
  const angle = i / sides * PI2;
@@ -36,8 +37,9 @@
36
37
 
37
38
  return array;
38
39
 
39
- } //
40
+ }
40
41
 
42
+ //
41
43
 
42
44
  const vector1 = new THREE.Vector3();
43
45
  const vector2 = new THREE.Vector3();
@@ -45,17 +47,17 @@
45
47
  const vector4 = new THREE.Vector3();
46
48
  const color = new THREE.Color( 0xffffff );
47
49
  let size = 1;
48
-
49
50
  function stroke( position1, position2, matrix1, matrix2 ) {
50
51
 
51
52
  if ( position1.distanceToSquared( position2 ) === 0 ) return;
52
53
  let count = geometry.drawRange.count;
53
54
  const points = getPoints( size );
54
-
55
55
  for ( let i = 0, il = points.length; i < il; i ++ ) {
56
56
 
57
57
  const vertex1 = points[ i ];
58
- const vertex2 = points[ ( i + 1 ) % il ]; // positions
58
+ const vertex2 = points[ ( i + 1 ) % il ];
59
+
60
+ // positions
59
61
 
60
62
  vector1.copy( vertex1 ).applyMatrix4( matrix2 ).add( position2 );
61
63
  vector2.copy( vertex2 ).applyMatrix4( matrix2 ).add( position2 );
@@ -66,7 +68,9 @@
66
68
  vector4.toArray( positions.array, ( count + 2 ) * 3 );
67
69
  vector2.toArray( positions.array, ( count + 3 ) * 3 );
68
70
  vector3.toArray( positions.array, ( count + 4 ) * 3 );
69
- vector4.toArray( positions.array, ( count + 5 ) * 3 ); // normals
71
+ vector4.toArray( positions.array, ( count + 5 ) * 3 );
72
+
73
+ // normals
70
74
 
71
75
  vector1.copy( vertex1 ).applyMatrix4( matrix2 ).normalize();
72
76
  vector2.copy( vertex2 ).applyMatrix4( matrix2 ).normalize();
@@ -77,7 +81,9 @@
77
81
  vector4.toArray( normals.array, ( count + 2 ) * 3 );
78
82
  vector2.toArray( normals.array, ( count + 3 ) * 3 );
79
83
  vector3.toArray( normals.array, ( count + 4 ) * 3 );
80
- vector4.toArray( normals.array, ( count + 5 ) * 3 ); // colors
84
+ vector4.toArray( normals.array, ( count + 5 ) * 3 );
85
+
86
+ // colors
81
87
 
82
88
  color.toArray( colors.array, ( count + 0 ) * 3 );
83
89
  color.toArray( colors.array, ( count + 1 ) * 3 );
@@ -91,15 +97,15 @@
91
97
 
92
98
  geometry.drawRange.count = count;
93
99
 
94
- } //
100
+ }
95
101
 
102
+ //
96
103
 
97
104
  const up = new THREE.Vector3( 0, 1, 0 );
98
105
  const point1 = new THREE.Vector3();
99
106
  const point2 = new THREE.Vector3();
100
107
  const matrix1 = new THREE.Matrix4();
101
108
  const matrix2 = new THREE.Matrix4();
102
-
103
109
  function moveTo( position ) {
104
110
 
105
111
  point1.copy( position );
@@ -123,11 +129,11 @@
123
129
 
124
130
  size = value;
125
131
 
126
- } //
132
+ }
127
133
 
134
+ //
128
135
 
129
136
  let count = 0;
130
-
131
137
  function update() {
132
138
 
133
139
  const start = count;