super-three 0.141.0 → 0.147.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 (646) hide show
  1. package/README.md +9 -9
  2. package/build/three.cjs +2441 -1569
  3. package/build/three.js +2441 -1569
  4. package/build/three.min.js +1 -1
  5. package/build/three.module.js +2847 -1576
  6. package/examples/js/animation/AnimationClipCreator.js +0 -8
  7. package/examples/js/animation/CCDIKSolver.js +50 -67
  8. package/examples/js/animation/MMDAnimationHelper.js +66 -137
  9. package/examples/js/animation/MMDPhysics.js +71 -150
  10. package/examples/js/cameras/CinematicCamera.js +33 -22
  11. package/examples/js/controls/ArcballControls.js +149 -403
  12. package/examples/js/controls/DragControls.js +8 -33
  13. package/examples/js/controls/FirstPersonControls.js +32 -61
  14. package/examples/js/controls/FlyControls.js +29 -63
  15. package/examples/js/controls/OrbitControls.js +125 -103
  16. package/examples/js/controls/PointerLockControls.js +5 -22
  17. package/examples/js/controls/TrackballControls.js +33 -88
  18. package/examples/js/controls/TransformControls.js +101 -182
  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 +6 -20
  28. package/examples/js/effects/AsciiEffect.js +32 -31
  29. package/examples/js/effects/OutlineEffect.js +30 -54
  30. package/examples/js/effects/ParallaxBarrierEffect.js +2 -15
  31. package/examples/js/effects/PeppersGhostEffect.js +14 -41
  32. package/examples/js/effects/StereoEffect.js +2 -6
  33. package/examples/js/environments/RoomEnvironment.js +32 -8
  34. package/examples/js/exporters/ColladaExporter.js +52 -78
  35. package/examples/js/exporters/DRACOExporter.js +22 -34
  36. package/examples/js/exporters/EXRExporter.js +15 -18
  37. package/examples/js/exporters/GLTFExporter.js +168 -345
  38. package/examples/js/exporters/MMDExporter.js +5 -12
  39. package/examples/js/exporters/OBJExporter.js +40 -52
  40. package/examples/js/exporters/PLYExporter.js +50 -57
  41. package/examples/js/exporters/STLExporter.js +5 -14
  42. package/examples/js/exporters/USDZExporter.js +119 -27
  43. package/examples/js/geometries/BoxLineGeometry.js +0 -1
  44. package/examples/js/geometries/ConvexGeometry.js +12 -7
  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 +23 -17
  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 +25 -39
  60. package/examples/js/interactive/InteractiveGroup.js +9 -14
  61. package/examples/js/interactive/SelectionBox.js +3 -70
  62. package/examples/js/interactive/SelectionHelper.js +2 -8
  63. package/examples/js/libs/ktx-parse.umd.js +1 -0
  64. package/examples/js/libs/meshopt_decoder.js +98 -32
  65. package/examples/js/lights/LightProbeGenerator.js +32 -39
  66. package/examples/js/lights/RectAreaLightUniformsLib.js +5 -1
  67. package/examples/js/lines/LineGeometry.js +3 -5
  68. package/examples/js/lines/LineMaterial.js +4 -11
  69. package/examples/js/lines/LineSegments2.js +40 -89
  70. package/examples/js/lines/LineSegmentsGeometry.js +7 -28
  71. package/examples/js/lines/Wireframe.js +2 -7
  72. package/examples/js/lines/WireframeGeometry2.js +3 -1
  73. package/examples/js/loaders/3DMLoader.js +58 -155
  74. package/examples/js/loaders/3MFLoader.js +72 -106
  75. package/examples/js/loaders/AMFLoader.js +0 -25
  76. package/examples/js/loaders/BVHLoader.js +44 -43
  77. package/examples/js/loaders/BasisTextureLoader.js +16 -46
  78. package/examples/js/loaders/ColladaLoader.js +229 -359
  79. package/examples/js/loaders/DDSLoader.js +24 -25
  80. package/examples/js/loaders/DRACOLoader.js +30 -90
  81. package/examples/js/loaders/EXRLoader.js +69 -177
  82. package/examples/js/loaders/FBXLoader.js +294 -441
  83. package/examples/js/loaders/FontLoader.js +9 -31
  84. package/examples/js/loaders/GCodeLoader.js +15 -16
  85. package/examples/js/loaders/GLTFLoader.js +458 -739
  86. package/examples/js/loaders/HDRCubeTextureLoader.js +0 -17
  87. package/examples/js/loaders/KMZLoader.js +3 -7
  88. package/examples/js/loaders/KTXLoader.js +12 -30
  89. package/examples/js/loaders/LDrawLoader.js +309 -355
  90. package/examples/js/loaders/LUT3dlLoader.js +7 -11
  91. package/examples/js/loaders/LUTCubeLoader.js +0 -8
  92. package/examples/js/loaders/LWOLoader.js +59 -124
  93. package/examples/js/loaders/LogLuvLoader.js +27 -77
  94. package/examples/js/loaders/LottieLoader.js +4 -4
  95. package/examples/js/loaders/MD2Loader.js +26 -27
  96. package/examples/js/loaders/MDDLoader.js +6 -10
  97. package/examples/js/loaders/MMDLoader.js +180 -189
  98. package/examples/js/loaders/MTLLoader.js +18 -47
  99. package/examples/js/loaders/NRRDLoader.js +44 -84
  100. package/examples/js/loaders/OBJLoader.js +56 -77
  101. package/examples/js/loaders/PCDLoader.js +92 -42
  102. package/examples/js/loaders/PDBLoader.js +17 -13
  103. package/examples/js/loaders/PLYLoader.js +65 -51
  104. package/examples/js/loaders/PRWMLoader.js +11 -22
  105. package/examples/js/loaders/PVRLoader.js +7 -16
  106. package/examples/js/loaders/RGBELoader.js +36 -61
  107. package/examples/js/loaders/RGBMLoader.js +26 -87
  108. package/examples/js/loaders/STLLoader.js +20 -27
  109. package/examples/js/loaders/SVGLoader.js +365 -236
  110. package/examples/js/loaders/TDSLoader.js +81 -118
  111. package/examples/js/loaders/TGALoader.js +39 -41
  112. package/examples/js/loaders/TIFFLoader.js +30 -0
  113. package/examples/js/loaders/TTFLoader.js +0 -8
  114. package/examples/js/loaders/TiltLoader.js +14 -15
  115. package/examples/js/loaders/VOXLoader.js +8 -16
  116. package/examples/js/loaders/VRMLLoader.js +266 -354
  117. package/examples/js/loaders/VTKLoader.js +102 -119
  118. package/examples/js/loaders/XYZLoader.js +2 -4
  119. package/examples/js/loaders/lwo/IFFParser.js +55 -136
  120. package/examples/js/loaders/lwo/LWO2Parser.js +39 -89
  121. package/examples/js/loaders/lwo/LWO3Parser.js +38 -79
  122. package/examples/js/materials/MeshGouraudMaterial.js +387 -0
  123. package/examples/js/math/Capsule.js +0 -17
  124. package/examples/js/math/ColorConverter.js +3 -53
  125. package/examples/js/math/ConvexHull.js +185 -141
  126. package/examples/js/math/ImprovedNoise.js +1 -1
  127. package/examples/js/math/Lut.js +8 -15
  128. package/examples/js/math/MeshSurfaceSampler.js +6 -28
  129. package/examples/js/math/OBB.js +90 -49
  130. package/examples/js/math/Octree.js +2 -57
  131. package/examples/js/math/SimplexNoise.js +74 -88
  132. package/examples/js/misc/ConvexObjectBreaker.js +37 -48
  133. package/examples/js/misc/GPUComputationRenderer.js +47 -14
  134. package/examples/js/misc/Gyroscope.js +5 -9
  135. package/examples/js/misc/MD2Character.js +14 -23
  136. package/examples/js/misc/MD2CharacterComplex.js +73 -54
  137. package/examples/js/misc/MorphAnimMesh.js +0 -6
  138. package/examples/js/misc/MorphBlendMesh.js +3 -30
  139. package/examples/js/misc/ProgressiveLightMap.js +47 -43
  140. package/examples/js/misc/RollerCoaster.js +17 -24
  141. package/examples/js/misc/TubePainter.js +18 -12
  142. package/examples/js/misc/Volume.js +173 -194
  143. package/examples/js/misc/VolumeSlice.js +91 -99
  144. package/examples/js/modifiers/CurveModifier.js +19 -21
  145. package/examples/js/modifiers/EdgeSplitModifier.js +0 -30
  146. package/examples/js/modifiers/SimplifyModifier.js +57 -60
  147. package/examples/js/modifiers/TessellateModifier.js +2 -9
  148. package/examples/js/objects/GroundProjectedEnv.js +181 -0
  149. package/examples/js/objects/Lensflare.js +47 -38
  150. package/examples/js/objects/LightningStorm.js +10 -13
  151. package/examples/js/objects/MarchingCubes.js +80 -59
  152. package/examples/js/objects/Reflector.js +31 -22
  153. package/examples/js/objects/ReflectorForSSRPass.js +20 -25
  154. package/examples/js/objects/Refractor.js +61 -33
  155. package/examples/js/objects/ShadowMesh.js +6 -3
  156. package/examples/js/objects/Sky.js +2 -7
  157. package/examples/js/objects/Water.js +23 -18
  158. package/examples/js/objects/Water2.js +20 -19
  159. package/examples/js/physics/AmmoPhysics.js +23 -20
  160. package/examples/js/physics/OimoPhysics.js +19 -17
  161. package/examples/js/postprocessing/AdaptiveToneMappingPass.js +13 -20
  162. package/examples/js/postprocessing/AfterimagePass.js +19 -12
  163. package/examples/js/postprocessing/BloomPass.js +38 -17
  164. package/examples/js/postprocessing/BokehPass.js +29 -12
  165. package/examples/js/postprocessing/ClearPass.js +1 -6
  166. package/examples/js/postprocessing/CubeTexturePass.js +12 -9
  167. package/examples/js/postprocessing/DotScreenPass.js +7 -5
  168. package/examples/js/postprocessing/EffectComposer.js +25 -32
  169. package/examples/js/postprocessing/FilmPass.js +7 -5
  170. package/examples/js/postprocessing/GlitchPass.js +10 -11
  171. package/examples/js/postprocessing/HalftonePass.js +9 -9
  172. package/examples/js/postprocessing/LUTPass.js +2 -15
  173. package/examples/js/postprocessing/MaskPass.js +20 -17
  174. package/examples/js/postprocessing/OutlinePass.js +49 -38
  175. package/examples/js/postprocessing/Pass.js +11 -14
  176. package/examples/js/postprocessing/RenderPass.js +3 -7
  177. package/examples/js/postprocessing/RenderPixelatedPass.js +215 -0
  178. package/examples/js/postprocessing/SAOPass.js +40 -32
  179. package/examples/js/postprocessing/SMAAPass.js +34 -17
  180. package/examples/js/postprocessing/SSAARenderPass.js +14 -14
  181. package/examples/js/postprocessing/SSAOPass.js +56 -42
  182. package/examples/js/postprocessing/SSRPass.js +78 -61
  183. package/examples/js/postprocessing/SavePass.js +14 -6
  184. package/examples/js/postprocessing/ShaderPass.js +9 -8
  185. package/examples/js/postprocessing/TAARenderPass.js +11 -9
  186. package/examples/js/postprocessing/TexturePass.js +7 -4
  187. package/examples/js/postprocessing/UnrealBloomPass.js +43 -25
  188. package/examples/js/renderers/CSS2DRenderer.js +4 -23
  189. package/examples/js/renderers/CSS3DRenderer.js +5 -26
  190. package/examples/js/renderers/Projector.js +31 -108
  191. package/examples/js/renderers/SVGRenderer.js +4 -50
  192. package/examples/js/shaders/ACESFilmicToneMappingShader.js +3 -6
  193. package/examples/js/shaders/AfterimageShader.js +3 -6
  194. package/examples/js/shaders/BasicShader.js +3 -6
  195. package/examples/js/shaders/BleachBypassShader.js +3 -6
  196. package/examples/js/shaders/BlendShader.js +3 -6
  197. package/examples/js/shaders/BokehShader.js +3 -6
  198. package/examples/js/shaders/BokehShader2.js +4 -13
  199. package/examples/js/shaders/BrightnessContrastShader.js +3 -6
  200. package/examples/js/shaders/ColorCorrectionShader.js +2 -6
  201. package/examples/js/shaders/ColorifyShader.js +2 -6
  202. package/examples/js/shaders/ConvolutionShader.js +5 -10
  203. package/examples/js/shaders/CopyShader.js +3 -6
  204. package/examples/js/shaders/DOFMipMapShader.js +3 -6
  205. package/examples/js/shaders/DepthLimitedBlurShader.js +2 -9
  206. package/examples/js/shaders/DigitalGlitch.js +3 -6
  207. package/examples/js/shaders/DotScreenShader.js +2 -6
  208. package/examples/js/shaders/FXAAShader.js +1 -3
  209. package/examples/js/shaders/FilmShader.js +3 -6
  210. package/examples/js/shaders/FocusShader.js +3 -6
  211. package/examples/js/shaders/FreiChenShader.js +2 -6
  212. package/examples/js/shaders/GammaCorrectionShader.js +3 -6
  213. package/examples/js/shaders/GodRaysShader.js +11 -24
  214. package/examples/js/shaders/HalftoneShader.js +3 -6
  215. package/examples/js/shaders/HorizontalBlurShader.js +3 -6
  216. package/examples/js/shaders/HorizontalTiltShiftShader.js +3 -6
  217. package/examples/js/shaders/HueSaturationShader.js +3 -6
  218. package/examples/js/shaders/KaleidoShader.js +3 -6
  219. package/examples/js/shaders/LuminosityHighPassShader.js +2 -6
  220. package/examples/js/shaders/LuminosityShader.js +4 -7
  221. package/examples/js/shaders/MMDToonShader.js +2 -4
  222. package/examples/js/shaders/MirrorShader.js +3 -6
  223. package/examples/js/shaders/NormalMapShader.js +2 -6
  224. package/examples/js/shaders/RGBShiftShader.js +3 -6
  225. package/examples/js/shaders/SAOShader.js +2 -6
  226. package/examples/js/shaders/SMAAShader.js +6 -18
  227. package/examples/js/shaders/SSAOShader.js +2 -6
  228. package/examples/js/shaders/SSRShader.js +6 -18
  229. package/examples/js/shaders/SepiaShader.js +3 -6
  230. package/examples/js/shaders/SobelOperatorShader.js +2 -6
  231. package/examples/js/shaders/TechnicolorShader.js +3 -6
  232. package/examples/js/shaders/ToneMapShader.js +4 -7
  233. package/examples/js/shaders/ToonShader.js +8 -24
  234. package/examples/js/shaders/TriangleBlurShader.js +2 -6
  235. package/examples/js/shaders/UnpackDepthRGBAShader.js +3 -6
  236. package/examples/js/shaders/VelocityShader.js +126 -0
  237. package/examples/js/shaders/VerticalBlurShader.js +3 -6
  238. package/examples/js/shaders/VerticalTiltShiftShader.js +3 -6
  239. package/examples/js/shaders/VignetteShader.js +3 -6
  240. package/examples/js/shaders/VolumeShader.js +2 -6
  241. package/examples/js/shaders/WaterRefractionShader.js +2 -6
  242. package/examples/js/textures/FlakesTexture.js +0 -1
  243. package/examples/js/utils/BufferGeometryUtils.js +237 -171
  244. package/examples/js/utils/CameraUtils.js +5 -20
  245. package/examples/js/utils/GPUStatsPanel.js +3 -12
  246. package/examples/js/utils/GeometryCompressionUtils.js +19 -44
  247. package/examples/js/utils/GeometryUtils.js +15 -36
  248. package/examples/js/utils/LDrawUtils.js +8 -11
  249. package/examples/js/utils/PackedPhongMaterial.js +6 -4
  250. package/examples/js/utils/SceneUtils.js +109 -14
  251. package/examples/js/utils/ShadowMapViewer.js +17 -14
  252. package/examples/js/utils/SkeletonUtils.js +13 -27
  253. package/examples/js/utils/UVsDebug.js +20 -12
  254. package/examples/js/utils/WorkerPool.js +1 -11
  255. package/examples/jsm/animation/CCDIKSolver.js +27 -3
  256. package/examples/jsm/animation/MMDPhysics.js +28 -22
  257. package/examples/jsm/capabilities/WebGPU.js +3 -1
  258. package/examples/jsm/controls/ArcballControls.js +17 -2
  259. package/examples/jsm/controls/FirstPersonControls.js +20 -27
  260. package/examples/jsm/controls/FlyControls.js +16 -24
  261. package/examples/jsm/controls/OrbitControls.js +44 -9
  262. package/examples/jsm/controls/PointerLockControls.js +0 -7
  263. package/examples/jsm/controls/TrackballControls.js +14 -5
  264. package/examples/jsm/controls/TransformControls.js +18 -16
  265. package/examples/jsm/csm/CSM.js +1 -0
  266. package/examples/jsm/csm/CSMHelper.js +30 -0
  267. package/examples/jsm/effects/AnaglyphEffect.js +2 -2
  268. package/examples/jsm/effects/OutlineEffect.js +4 -25
  269. package/examples/jsm/effects/ParallaxBarrierEffect.js +2 -2
  270. package/examples/jsm/effects/PeppersGhostEffect.js +2 -2
  271. package/examples/jsm/effects/StereoEffect.js +2 -2
  272. package/examples/jsm/environments/RoomEnvironment.js +23 -0
  273. package/examples/jsm/exporters/ColladaExporter.js +4 -13
  274. package/examples/jsm/exporters/DRACOExporter.js +0 -13
  275. package/examples/jsm/exporters/GLTFExporter.js +29 -110
  276. package/examples/jsm/exporters/KTX2Exporter.js +29 -29
  277. package/examples/jsm/exporters/OBJExporter.js +0 -18
  278. package/examples/jsm/exporters/PLYExporter.js +14 -22
  279. package/examples/jsm/exporters/STLExporter.js +1 -9
  280. package/examples/jsm/exporters/USDZExporter.js +107 -4
  281. package/examples/jsm/geometries/ConvexGeometry.js +1 -1
  282. package/examples/jsm/geometries/ParametricGeometry.js +0 -6
  283. package/examples/jsm/helpers/OctreeHelper.js +22 -8
  284. package/examples/jsm/helpers/VertexNormalsHelper.js +7 -1
  285. package/examples/jsm/helpers/VertexTangentsHelper.js +7 -0
  286. package/examples/jsm/helpers/ViewHelper.js +24 -0
  287. package/examples/jsm/interactive/HTMLMesh.js +14 -15
  288. package/examples/jsm/interactive/InteractiveGroup.js +4 -2
  289. package/examples/jsm/interactive/SelectionHelper.js +5 -3
  290. package/examples/jsm/libs/flow.module.js +610 -160
  291. package/examples/jsm/libs/lottie_canvas.module.js +14844 -0
  292. package/examples/jsm/libs/meshopt_decoder.module.js +97 -32
  293. package/examples/jsm/libs/utif.module.js +1579 -0
  294. package/examples/jsm/libs/zstddec.module.js +1 -0
  295. package/examples/jsm/lines/LineSegments2.js +4 -0
  296. package/examples/jsm/loaders/3DMLoader.js +1 -2
  297. package/examples/jsm/loaders/ColladaLoader.js +29 -0
  298. package/examples/jsm/loaders/DRACOLoader.js +2 -28
  299. package/examples/jsm/loaders/EXRLoader.js +3 -13
  300. package/examples/jsm/loaders/FBXLoader.js +26 -3
  301. package/examples/jsm/loaders/FontLoader.js +3 -16
  302. package/examples/jsm/loaders/GLTFLoader.js +321 -464
  303. package/examples/jsm/loaders/HDRCubeTextureLoader.js +0 -13
  304. package/examples/jsm/loaders/KTX2Loader.js +254 -53
  305. package/examples/jsm/loaders/LDrawLoader.js +149 -87
  306. package/examples/jsm/loaders/LottieLoader.js +4 -2
  307. package/examples/jsm/loaders/MaterialXLoader.js +728 -0
  308. package/examples/jsm/loaders/OBJLoader.js +6 -14
  309. package/examples/jsm/loaders/PCDLoader.js +60 -14
  310. package/examples/jsm/loaders/PLYLoader.js +71 -19
  311. package/examples/jsm/loaders/RGBELoader.js +1 -1
  312. package/examples/jsm/loaders/SVGLoader.js +231 -17
  313. package/examples/jsm/loaders/TIFFLoader.js +36 -0
  314. package/examples/jsm/loaders/USDZLoader.js +633 -0
  315. package/examples/jsm/loaders/VRMLLoader.js +36 -26
  316. package/examples/jsm/loaders/VTKLoader.js +1 -1
  317. package/examples/jsm/loaders/lwo/LWO2Parser.js +6 -8
  318. package/examples/jsm/loaders/lwo/LWO3Parser.js +6 -8
  319. package/examples/jsm/materials/MeshGouraudMaterial.js +423 -0
  320. package/examples/jsm/math/ColorConverter.js +1 -49
  321. package/examples/jsm/math/ConvexHull.js +4 -4
  322. package/examples/jsm/math/Octree.js +1 -1
  323. package/examples/jsm/misc/GPUComputationRenderer.js +43 -0
  324. package/examples/jsm/misc/Volume.js +169 -171
  325. package/examples/jsm/misc/VolumeSlice.js +78 -80
  326. package/examples/jsm/modifiers/SimplifyModifier.js +1 -1
  327. package/examples/jsm/node-editor/NodeEditor.js +91 -12
  328. package/examples/jsm/node-editor/accessors/MatcapUVEditor.js +1 -1
  329. package/examples/jsm/node-editor/accessors/NormalEditor.js +1 -1
  330. package/examples/jsm/node-editor/accessors/PositionEditor.js +1 -1
  331. package/examples/jsm/node-editor/accessors/UVEditor.js +1 -1
  332. package/examples/jsm/node-editor/core/BaseNode.js +10 -3
  333. package/examples/jsm/node-editor/display/BlendEditor.js +1 -1
  334. package/examples/jsm/node-editor/display/NormalMapEditor.js +1 -1
  335. package/examples/jsm/node-editor/inputs/ColorEditor.js +1 -1
  336. package/examples/jsm/node-editor/inputs/FloatEditor.js +1 -1
  337. package/examples/jsm/node-editor/inputs/SliderEditor.js +1 -1
  338. package/examples/jsm/node-editor/inputs/TextureEditor.js +1 -1
  339. package/examples/jsm/node-editor/inputs/Vector2Editor.js +1 -1
  340. package/examples/jsm/node-editor/inputs/Vector3Editor.js +1 -1
  341. package/examples/jsm/node-editor/inputs/Vector4Editor.js +1 -1
  342. package/examples/jsm/node-editor/materials/BasicMaterialEditor.js +7 -10
  343. package/examples/jsm/node-editor/materials/PointsMaterialEditor.js +1 -1
  344. package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +7 -10
  345. package/examples/jsm/node-editor/math/AngleEditor.js +4 -4
  346. package/examples/jsm/node-editor/math/DotEditor.js +1 -1
  347. package/examples/jsm/node-editor/math/InvertEditor.js +3 -3
  348. package/examples/jsm/node-editor/math/LimiterEditor.js +1 -1
  349. package/examples/jsm/node-editor/math/NormalizeEditor.js +1 -1
  350. package/examples/jsm/node-editor/math/OperatorEditor.js +1 -1
  351. package/examples/jsm/node-editor/math/PowerEditor.js +1 -1
  352. package/examples/jsm/node-editor/math/TrigonometryEditor.js +1 -1
  353. package/examples/jsm/node-editor/procedural/CheckerEditor.js +1 -1
  354. package/examples/jsm/node-editor/scene/MeshEditor.js +11 -8
  355. package/examples/jsm/node-editor/utils/JoinEditor.js +1 -1
  356. package/examples/jsm/node-editor/utils/OscillatorEditor.js +1 -1
  357. package/examples/jsm/node-editor/utils/PreviewEditor.js +7 -3
  358. package/examples/jsm/node-editor/utils/SplitEditor.js +1 -1
  359. package/examples/jsm/node-editor/utils/TimerEditor.js +1 -1
  360. package/examples/jsm/nodes/Nodes.js +70 -13
  361. package/examples/jsm/nodes/accessors/BitangentNode.js +62 -0
  362. package/examples/jsm/nodes/accessors/CubeTextureNode.js +9 -5
  363. package/examples/jsm/nodes/accessors/NormalNode.js +8 -8
  364. package/examples/jsm/nodes/accessors/Object3DNode.js +1 -1
  365. package/examples/jsm/nodes/accessors/PositionNode.js +11 -5
  366. package/examples/jsm/nodes/accessors/ReferenceNode.js +1 -1
  367. package/examples/jsm/nodes/accessors/ReflectVectorNode.js +31 -0
  368. package/examples/jsm/nodes/accessors/SkinningNode.js +8 -1
  369. package/examples/jsm/nodes/accessors/TangentNode.js +95 -0
  370. package/examples/jsm/nodes/core/AttributeNode.js +32 -9
  371. package/examples/jsm/nodes/core/CodeNode.js +3 -3
  372. package/examples/jsm/nodes/core/FunctionCallNode.js +20 -5
  373. package/examples/jsm/nodes/core/FunctionNode.js +2 -2
  374. package/examples/jsm/nodes/core/Node.js +15 -13
  375. package/examples/jsm/nodes/core/NodeBuilder.js +67 -18
  376. package/examples/jsm/nodes/core/NodeFrame.js +2 -2
  377. package/examples/jsm/nodes/core/NodeUtils.js +23 -1
  378. package/examples/jsm/nodes/core/NodeVarying.js +17 -0
  379. package/examples/jsm/nodes/core/VaryingNode.js +56 -0
  380. package/examples/jsm/nodes/core/constants.js +13 -13
  381. package/examples/jsm/nodes/display/BlendModeNode.js +85 -0
  382. package/examples/jsm/nodes/display/ColorAdjustmentNode.js +84 -0
  383. package/examples/jsm/nodes/display/NormalMapNode.js +19 -12
  384. package/examples/jsm/nodes/display/PosterizeNode.js +25 -0
  385. package/examples/jsm/nodes/display/ViewportNode.js +106 -0
  386. package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +5 -5
  387. package/examples/jsm/nodes/functions/PhysicalLightingModel.js +3 -3
  388. package/examples/jsm/nodes/functions/light/getDistanceAttenuation.js +2 -2
  389. package/examples/jsm/nodes/geometry/RangeNode.js +109 -0
  390. package/examples/jsm/nodes/gpgpu/ComputeNode.js +3 -1
  391. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +1 -1
  392. package/examples/jsm/nodes/lighting/EnvironmentNode.js +8 -7
  393. package/examples/jsm/nodes/lighting/LightingContextNode.js +4 -4
  394. package/examples/jsm/nodes/loaders/NodeLoader.js +2 -2
  395. package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +33 -0
  396. package/examples/jsm/nodes/materials/Materials.js +21 -31
  397. package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +70 -0
  398. package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +4 -7
  399. package/examples/jsm/nodes/materials/NodeMaterial.js +11 -3
  400. package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +28 -17
  401. package/examples/jsm/nodes/materialx/DISCLAIMER.md +199 -0
  402. package/examples/jsm/nodes/materialx/MaterialXNodes.js +59 -0
  403. package/examples/jsm/nodes/materialx/lib/mx_hsv.js +56 -0
  404. package/examples/jsm/nodes/materialx/lib/mx_noise.js +617 -0
  405. package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +18 -0
  406. package/examples/jsm/nodes/math/MathNode.js +7 -17
  407. package/examples/jsm/nodes/math/OperatorNode.js +16 -3
  408. package/examples/jsm/nodes/parsers/GLSLNodeFunction.js +21 -6
  409. package/examples/jsm/nodes/procedural/CheckerNode.js +2 -2
  410. package/examples/jsm/nodes/shadernode/ShaderNode.js +40 -25
  411. package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +95 -68
  412. package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +49 -6
  413. package/examples/jsm/nodes/utils/ConvertNode.js +18 -12
  414. package/examples/jsm/nodes/utils/EquirectUVNode.js +27 -0
  415. package/examples/jsm/nodes/utils/JoinNode.js +15 -9
  416. package/examples/jsm/nodes/utils/MatcapUVNode.js +2 -4
  417. package/examples/jsm/nodes/utils/MaxMipLevelNode.js +3 -2
  418. package/examples/jsm/nodes/utils/OscNode.js +2 -2
  419. package/examples/jsm/nodes/utils/RemapNode.js +34 -0
  420. package/examples/jsm/nodes/utils/RotateUVNode.js +32 -0
  421. package/examples/jsm/nodes/utils/SplitNode.js +21 -5
  422. package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +8 -10
  423. package/examples/jsm/nodes/utils/TimerNode.js +23 -3
  424. package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +51 -0
  425. package/examples/jsm/objects/GroundProjectedEnv.js +186 -0
  426. package/examples/jsm/objects/Reflector.js +12 -5
  427. package/examples/jsm/objects/ReflectorForSSRPass.js +3 -5
  428. package/examples/jsm/objects/Refractor.js +12 -6
  429. package/examples/jsm/objects/ShadowMesh.js +8 -2
  430. package/examples/jsm/postprocessing/AfterimagePass.js +17 -4
  431. package/examples/jsm/postprocessing/BloomPass.js +22 -3
  432. package/examples/jsm/postprocessing/BokehPass.js +18 -4
  433. package/examples/jsm/postprocessing/CubeTexturePass.js +12 -5
  434. package/examples/jsm/postprocessing/DotScreenPass.js +8 -0
  435. package/examples/jsm/postprocessing/EffectComposer.js +9 -0
  436. package/examples/jsm/postprocessing/FilmPass.js +8 -0
  437. package/examples/jsm/postprocessing/GlitchPass.js +13 -1
  438. package/examples/jsm/postprocessing/HalftonePass.js +8 -0
  439. package/examples/jsm/postprocessing/OutlinePass.js +25 -3
  440. package/examples/jsm/postprocessing/Pass.js +2 -0
  441. package/examples/jsm/postprocessing/RenderPixelatedPass.js +234 -0
  442. package/examples/jsm/postprocessing/SAOPass.js +20 -0
  443. package/examples/jsm/postprocessing/SMAAPass.js +16 -0
  444. package/examples/jsm/postprocessing/SSAARenderPass.js +4 -0
  445. package/examples/jsm/postprocessing/SavePass.js +17 -1
  446. package/examples/jsm/postprocessing/ShaderPass.js +8 -0
  447. package/examples/jsm/postprocessing/TAARenderPass.js +9 -0
  448. package/examples/jsm/postprocessing/TexturePass.js +8 -0
  449. package/examples/jsm/postprocessing/UnrealBloomPass.js +16 -0
  450. package/examples/jsm/renderers/CSS2DRenderer.js +2 -2
  451. package/examples/jsm/renderers/CSS3DRenderer.js +2 -2
  452. package/examples/jsm/renderers/Projector.js +2 -24
  453. package/examples/jsm/renderers/webgl/nodes/SlotNode.js +9 -5
  454. package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +363 -231
  455. package/examples/jsm/renderers/webgl/nodes/WebGLNodes.js +7 -3
  456. package/examples/jsm/renderers/webgpu/WebGPUAnimation.js +58 -0
  457. package/examples/jsm/renderers/webgpu/WebGPUAttributes.js +63 -5
  458. package/examples/jsm/renderers/webgpu/WebGPUBackground.js +68 -3
  459. package/examples/jsm/renderers/webgpu/WebGPUComputePipelines.js +6 -0
  460. package/examples/jsm/renderers/webgpu/WebGPUGeometries.js +6 -0
  461. package/examples/jsm/renderers/webgpu/WebGPUObjects.js +1 -1
  462. package/examples/jsm/renderers/webgpu/WebGPURenderPipeline.js +17 -19
  463. package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +16 -14
  464. package/examples/jsm/renderers/webgpu/WebGPURenderStates.js +2 -2
  465. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +113 -93
  466. package/examples/jsm/renderers/webgpu/WebGPUTextureUtils.js +5 -3
  467. package/examples/jsm/renderers/webgpu/WebGPUTextures.js +2 -2
  468. package/examples/jsm/renderers/webgpu/WebGPUUtils.js +81 -0
  469. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +63 -36
  470. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodes.js +1 -1
  471. package/examples/jsm/shaders/LuminosityShader.js +1 -1
  472. package/examples/jsm/shaders/MMDToonShader.js +2 -4
  473. package/examples/jsm/shaders/ToneMapShader.js +1 -1
  474. package/examples/jsm/shaders/VelocityShader.js +128 -0
  475. package/examples/jsm/utils/BufferGeometryUtils.js +176 -43
  476. package/examples/jsm/utils/GeometryUtils.js +17 -25
  477. package/examples/jsm/utils/PackedPhongMaterial.js +0 -1
  478. package/examples/jsm/utils/SceneUtils.js +117 -12
  479. package/examples/jsm/webxr/OculusHandModel.js +3 -2
  480. package/examples/jsm/webxr/OculusHandPointerModel.js +6 -1
  481. package/examples/jsm/webxr/VRButton.js +1 -7
  482. package/examples/jsm/webxr/XRHandMeshModel.js +8 -3
  483. package/package.json +22 -18
  484. package/src/Three.Legacy.js +262 -36
  485. package/src/Three.js +4 -2
  486. package/src/animation/AnimationAction.js +6 -5
  487. package/src/animation/AnimationClip.js +1 -1
  488. package/src/animation/AnimationMixer.js +1 -1
  489. package/src/animation/AnimationUtils.js +204 -199
  490. package/src/animation/KeyframeTrack.js +1 -1
  491. package/src/animation/PropertyBinding.js +31 -5
  492. package/src/audio/AudioContext.js +5 -5
  493. package/src/cameras/CubeCamera.js +14 -21
  494. package/src/constants.js +2 -4
  495. package/src/core/BufferAttribute.js +81 -111
  496. package/src/core/BufferGeometry.js +3 -41
  497. package/src/core/InstancedBufferAttribute.js +0 -10
  498. package/src/core/InstancedBufferGeometry.js +1 -7
  499. package/src/core/InterleavedBuffer.js +1 -1
  500. package/src/core/InterleavedBufferAttribute.js +57 -8
  501. package/src/core/Object3D.js +22 -5
  502. package/src/core/Uniform.js +0 -7
  503. package/src/core/UniformsGroup.js +92 -0
  504. package/src/extras/DataUtils.js +104 -88
  505. package/src/extras/Earcut.js +67 -67
  506. package/src/extras/core/Path.js +1 -0
  507. package/src/extras/core/ShapePath.js +1 -4
  508. package/src/extras/curves/CatmullRomCurve3.js +4 -2
  509. package/src/geometries/BoxGeometry.js +1 -1
  510. package/src/geometries/CapsuleGeometry.js +1 -1
  511. package/src/geometries/CircleGeometry.js +1 -1
  512. package/src/geometries/ConeGeometry.js +1 -1
  513. package/src/geometries/CylinderGeometry.js +2 -1
  514. package/src/geometries/DodecahedronGeometry.js +1 -1
  515. package/src/geometries/EdgesGeometry.js +5 -4
  516. package/src/geometries/ExtrudeGeometry.js +2 -11
  517. package/src/geometries/IcosahedronGeometry.js +1 -1
  518. package/src/geometries/LatheGeometry.js +2 -2
  519. package/src/geometries/OctahedronGeometry.js +1 -1
  520. package/src/geometries/PlaneGeometry.js +2 -1
  521. package/src/geometries/PolyhedronGeometry.js +2 -2
  522. package/src/geometries/RingGeometry.js +1 -1
  523. package/src/geometries/ShapeGeometry.js +3 -2
  524. package/src/geometries/SphereGeometry.js +2 -1
  525. package/src/geometries/TetrahedronGeometry.js +1 -1
  526. package/src/geometries/TorusGeometry.js +2 -1
  527. package/src/geometries/TorusKnotGeometry.js +2 -1
  528. package/src/geometries/TubeGeometry.js +2 -1
  529. package/src/geometries/WireframeGeometry.js +1 -0
  530. package/src/helpers/ArrowHelper.js +9 -0
  531. package/src/helpers/Box3Helper.js +7 -0
  532. package/src/helpers/BoxHelper.js +7 -1
  533. package/src/helpers/CameraHelper.js +97 -38
  534. package/src/helpers/DirectionalLightHelper.js +6 -1
  535. package/src/helpers/GridHelper.js +7 -0
  536. package/src/helpers/HemisphereLightHelper.js +5 -1
  537. package/src/helpers/PlaneHelper.js +15 -9
  538. package/src/helpers/PointLightHelper.js +2 -1
  539. package/src/helpers/PolarGridHelper.js +25 -14
  540. package/src/helpers/SkeletonHelper.js +7 -0
  541. package/src/helpers/SpotLightHelper.js +5 -2
  542. package/src/lights/LightShadow.js +1 -2
  543. package/src/lights/PointLight.js +2 -2
  544. package/src/lights/SpotLight.js +4 -2
  545. package/src/loaders/FileLoader.js +16 -2
  546. package/src/loaders/LoadingManager.js +1 -1
  547. package/src/loaders/MaterialLoader.js +49 -7
  548. package/src/loaders/ObjectLoader.js +9 -42
  549. package/src/materials/Material.js +2 -34
  550. package/src/materials/Materials.js +0 -27
  551. package/src/materials/MeshLambertMaterial.js +28 -1
  552. package/src/materials/MeshPhysicalMaterial.js +1 -1
  553. package/src/materials/ShaderMaterial.js +3 -7
  554. package/src/math/Color.js +8 -18
  555. package/src/math/MathUtils.js +1 -7
  556. package/src/math/Matrix3.js +54 -25
  557. package/src/math/Matrix4.js +3 -27
  558. package/src/math/Quaternion.js +1 -21
  559. package/src/math/Ray.js +2 -5
  560. package/src/math/Sphere.js +36 -21
  561. package/src/math/Vector2.js +4 -24
  562. package/src/math/Vector3.js +7 -46
  563. package/src/math/Vector4.js +4 -24
  564. package/src/objects/InstancedMesh.js +7 -0
  565. package/src/objects/LOD.js +25 -6
  566. package/src/renderers/WebGL3DRenderTarget.js +1 -1
  567. package/src/renderers/WebGLArrayRenderTarget.js +1 -1
  568. package/src/renderers/WebGLCubeRenderTarget.js +1 -1
  569. package/src/renderers/WebGLMultipleRenderTargets.js +1 -1
  570. package/src/renderers/WebGLRenderTarget.js +1 -1
  571. package/src/renderers/WebGLRenderer.js +119 -69
  572. package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +12 -12
  573. package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +3 -5
  574. package/src/renderers/shaders/ShaderChunk/common.glsl.js +6 -5
  575. package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +24 -24
  576. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +0 -4
  577. package/src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js +1 -1
  578. package/src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js +1 -1
  579. package/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js +2 -1
  580. package/src/renderers/shaders/ShaderChunk/iridescence_fragment.glsl.js +113 -99
  581. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +34 -13
  582. package/src/renderers/shaders/ShaderChunk/lights_lambert_fragment.glsl.js +5 -0
  583. package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +28 -0
  584. package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +0 -2
  585. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +3 -1
  586. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +13 -1
  587. package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +0 -2
  588. package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +2 -4
  589. package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +2 -4
  590. package/src/renderers/shaders/ShaderChunk/output_fragment.glsl.js +1 -1
  591. package/src/renderers/shaders/ShaderChunk/packing.glsl.js +8 -0
  592. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +18 -7
  593. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +8 -3
  594. package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +9 -6
  595. package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +1 -1
  596. package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +14 -10
  597. package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +2 -2
  598. package/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js +1 -1
  599. package/src/renderers/shaders/ShaderChunk.js +7 -2
  600. package/src/renderers/shaders/ShaderLib/background.glsl.js +7 -2
  601. package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +62 -0
  602. package/src/renderers/shaders/ShaderLib/cube.glsl.js +4 -6
  603. package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +0 -1
  604. package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +22 -50
  605. package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +0 -1
  606. package/src/renderers/shaders/ShaderLib/vsm.glsl.js +0 -3
  607. package/src/renderers/shaders/ShaderLib.js +50 -36
  608. package/src/renderers/shaders/UniformsLib.js +13 -12
  609. package/src/renderers/shaders/UniformsUtils.js +29 -0
  610. package/src/renderers/webgl/WebGLAttributes.js +2 -0
  611. package/src/renderers/webgl/WebGLBackground.js +17 -9
  612. package/src/renderers/webgl/WebGLLights.js +37 -17
  613. package/src/renderers/webgl/WebGLMaterials.js +2 -1
  614. package/src/renderers/webgl/WebGLMorphtargets.js +0 -20
  615. package/src/renderers/webgl/WebGLProgram.js +6 -11
  616. package/src/renderers/webgl/WebGLPrograms.js +30 -26
  617. package/src/renderers/webgl/WebGLRenderLists.js +5 -4
  618. package/src/renderers/webgl/WebGLRenderStates.js +5 -4
  619. package/src/renderers/webgl/WebGLShaderCache.js +9 -6
  620. package/src/renderers/webgl/WebGLShadowMap.js +13 -16
  621. package/src/renderers/webgl/WebGLState.js +125 -41
  622. package/src/renderers/webgl/WebGLTextures.js +94 -39
  623. package/src/renderers/webgl/WebGLUniforms.js +156 -28
  624. package/src/renderers/webgl/WebGLUniformsGroups.js +372 -0
  625. package/src/renderers/webgl/WebGLUtils.js +3 -1
  626. package/src/renderers/webvr/WebVRManager.js +42 -9
  627. package/src/renderers/webvr/WebVRUtils.js +1 -1
  628. package/src/renderers/webxr/WebXRController.js +91 -50
  629. package/src/renderers/webxr/WebXRManager.js +127 -34
  630. package/src/scenes/Scene.js +24 -3
  631. package/src/textures/CompressedArrayTexture.js +18 -0
  632. package/src/textures/Source.js +1 -1
  633. package/src/textures/Texture.js +2 -1
  634. package/src/utils.js +1 -1
  635. package/examples/js/controls/experimental/CameraControls.js +0 -1048
  636. package/examples/js/libs/lottie_canvas.js +0 -12751
  637. package/examples/js/loaders/KTX2Loader.js +0 -558
  638. package/examples/js/shaders/PixelShader.js +0 -51
  639. package/examples/jsm/controls/experimental/CameraControls.js +0 -1248
  640. package/examples/jsm/nodes/accessors/ReflectNode.js +0 -70
  641. package/examples/jsm/nodes/core/NodeVary.js +0 -14
  642. package/examples/jsm/nodes/core/VaryNode.js +0 -54
  643. package/examples/jsm/package.json +0 -3
  644. package/examples/jsm/renderers/webgl/nodes/WebGLPhysicalContextNode.js +0 -45
  645. package/examples/jsm/shaders/PixelShader.js +0 -44
  646. package/src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl.js +0 -122
@@ -4,17 +4,19 @@
4
4
 
5
5
  constructor( manager ) {
6
6
 
7
- super( manager ); // dependency check
7
+ super( manager );
8
+
9
+ // dependency check
8
10
 
9
11
  if ( typeof chevrotain === 'undefined' ) {
10
12
 
11
13
  // eslint-disable-line no-undef
14
+
12
15
  throw Error( 'THREE.VRMLLoader: External library chevrotain.min.js required.' );
13
16
 
14
17
  }
15
18
 
16
19
  }
17
-
18
20
  load( url, onLoad, onProgress, onError ) {
19
21
 
20
22
  const scope = this;
@@ -48,31 +50,34 @@
48
50
  }, onProgress, onError );
49
51
 
50
52
  }
51
-
52
53
  parse( data, path ) {
53
54
 
54
55
  const nodeMap = {};
55
-
56
56
  function generateVRMLTree( data ) {
57
57
 
58
58
  // create lexer, parser and visitor
59
+
59
60
  const tokenData = createTokens();
60
61
  const lexer = new VRMLLexer( tokenData.tokens );
61
62
  const parser = new VRMLParser( tokenData.tokenVocabulary );
62
- const visitor = createVisitor( parser.getBaseCstVisitorConstructor() ); // lexing
63
+ const visitor = createVisitor( parser.getBaseCstVisitorConstructor() );
64
+
65
+ // lexing
63
66
 
64
67
  const lexingResult = lexer.lex( data );
65
- parser.input = lexingResult.tokens; // parsing
68
+ parser.input = lexingResult.tokens;
66
69
 
67
- const cstOutput = parser.vrml();
70
+ // parsing
68
71
 
72
+ const cstOutput = parser.vrml();
69
73
  if ( parser.errors.length > 0 ) {
70
74
 
71
75
  console.error( parser.errors );
72
76
  throw Error( 'THREE.VRMLLoader: Parsing errors detected.' );
73
77
 
74
- } // actions
78
+ }
75
79
 
80
+ // actions
76
81
 
77
82
  const ast = visitor.visit( cstOutput );
78
83
  return ast;
@@ -82,6 +87,7 @@
82
87
  function createTokens() {
83
88
 
84
89
  const createToken = chevrotain.createToken; // eslint-disable-line no-undef
90
+
85
91
  // from http://gun.teipir.gr/VRML-amgem/spec/part1/concepts.html#SyntaxBasics
86
92
 
87
93
  const RouteIdentifier = createToken( {
@@ -92,19 +98,32 @@
92
98
  name: 'Identifier',
93
99
  pattern: /[^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d][^\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]*/,
94
100
  longer_alt: RouteIdentifier
95
- } ); // from http://gun.teipir.gr/VRML-amgem/spec/part1/nodesRef.html
96
-
97
- const nodeTypes = [ 'Anchor', 'Billboard', 'Collision', 'Group', 'Transform', // grouping nodes
98
- 'Inline', 'LOD', 'Switch', // special groups
99
- 'AudioClip', 'DirectionalLight', 'PointLight', 'Script', 'Shape', 'Sound', 'SpotLight', 'WorldInfo', // common nodes
100
- 'CylinderSensor', 'PlaneSensor', 'ProximitySensor', 'SphereSensor', 'TimeSensor', 'TouchSensor', 'VisibilitySensor', // sensors
101
- 'Box', 'Cone', 'Cylinder', 'ElevationGrid', 'Extrusion', 'IndexedFaceSet', 'IndexedLineSet', 'PointSet', 'Sphere', // geometries
102
- 'Color', 'Coordinate', 'Normal', 'TextureCoordinate', // geometric properties
103
- 'Appearance', 'FontStyle', 'ImageTexture', 'Material', 'MovieTexture', 'PixelTexture', 'TextureTransform', // appearance
104
- 'ColorInterpolator', 'CoordinateInterpolator', 'NormalInterpolator', 'OrientationInterpolator', 'PositionInterpolator', 'ScalarInterpolator', // interpolators
105
- 'Background', 'Fog', 'NavigationInfo', 'Viewpoint', // bindable nodes
101
+ } );
102
+
103
+ // from http://gun.teipir.gr/VRML-amgem/spec/part1/nodesRef.html
104
+
105
+ const nodeTypes = [ 'Anchor', 'Billboard', 'Collision', 'Group', 'Transform',
106
+ // grouping nodes
107
+ 'Inline', 'LOD', 'Switch',
108
+ // special groups
109
+ 'AudioClip', 'DirectionalLight', 'PointLight', 'Script', 'Shape', 'Sound', 'SpotLight', 'WorldInfo',
110
+ // common nodes
111
+ 'CylinderSensor', 'PlaneSensor', 'ProximitySensor', 'SphereSensor', 'TimeSensor', 'TouchSensor', 'VisibilitySensor',
112
+ // sensors
113
+ 'Box', 'Cone', 'Cylinder', 'ElevationGrid', 'Extrusion', 'IndexedFaceSet', 'IndexedLineSet', 'PointSet', 'Sphere',
114
+ // geometries
115
+ 'Color', 'Coordinate', 'Normal', 'TextureCoordinate',
116
+ // geometric properties
117
+ 'Appearance', 'FontStyle', 'ImageTexture', 'Material', 'MovieTexture', 'PixelTexture', 'TextureTransform',
118
+ // appearance
119
+ 'ColorInterpolator', 'CoordinateInterpolator', 'NormalInterpolator', 'OrientationInterpolator', 'PositionInterpolator', 'ScalarInterpolator',
120
+ // interpolators
121
+ 'Background', 'Fog', 'NavigationInfo', 'Viewpoint',
122
+ // bindable nodes
106
123
  'Text' // Text must be placed at the end of the regex so there are no matches for TextureTransform and TextureCoordinate
107
- ]; //
124
+ ];
125
+
126
+ //
108
127
 
109
128
  const Version = createToken( {
110
129
  name: 'Version',
@@ -135,7 +154,9 @@
135
154
  name: 'TO',
136
155
  pattern: /TO/,
137
156
  longer_alt: Identifier
138
- } ); //
157
+ } );
158
+
159
+ //
139
160
 
140
161
  const StringLiteral = createToken( {
141
162
  name: 'StringLiteral',
@@ -181,20 +202,22 @@
181
202
  name: 'Comment',
182
203
  pattern: /#.*/,
183
204
  group: chevrotain.Lexer.SKIPPED // eslint-disable-line no-undef
205
+ } );
184
206
 
185
- } ); // commas, blanks, tabs, newlines and carriage returns are whitespace characters wherever they appear outside of string fields
207
+ // commas, blanks, tabs, newlines and carriage returns are whitespace characters wherever they appear outside of string fields
186
208
 
187
209
  const WhiteSpace = createToken( {
188
210
  name: 'WhiteSpace',
189
211
  pattern: /[ ,\s]/,
190
212
  group: chevrotain.Lexer.SKIPPED // eslint-disable-line no-undef
191
-
192
213
  } );
193
- const tokens = [ WhiteSpace, // keywords appear before the Identifier
194
- NodeName, DEF, USE, ROUTE, TO, TrueLiteral, FalseLiteral, NullLiteral, // the Identifier must appear after the keywords because all keywords are valid identifiers
214
+
215
+ const tokens = [ WhiteSpace,
216
+ // keywords appear before the Identifier
217
+ NodeName, DEF, USE, ROUTE, TO, TrueLiteral, FalseLiteral, NullLiteral,
218
+ // the Identifier must appear after the keywords because all keywords are valid identifiers
195
219
  Version, Identifier, RouteIdentifier, StringLiteral, HexLiteral, NumberLiteral, LSquare, RSquare, LCurly, RCurly, Comment ];
196
220
  const tokenVocabulary = {};
197
-
198
221
  for ( let i = 0, l = tokens.length; i < l; i ++ ) {
199
222
 
200
223
  const token = tokens[ i ];
@@ -212,23 +235,22 @@
212
235
  function createVisitor( BaseVRMLVisitor ) {
213
236
 
214
237
  // the visitor is created dynmaically based on the given base class
215
- function VRMLToASTVisitor() {
216
238
 
217
- BaseVRMLVisitor.call( this );
218
- this.validateVisitor();
239
+ class VRMLToASTVisitor extends BaseVRMLVisitor {
219
240
 
220
- }
241
+ constructor() {
242
+
243
+ super();
244
+ this.validateVisitor();
221
245
 
222
- VRMLToASTVisitor.prototype = Object.assign( Object.create( BaseVRMLVisitor.prototype ), {
223
- constructor: VRMLToASTVisitor,
224
- vrml: function ( ctx ) {
246
+ }
247
+ vrml( ctx ) {
225
248
 
226
249
  const data = {
227
250
  version: this.visit( ctx.version ),
228
251
  nodes: [],
229
252
  routes: []
230
253
  };
231
-
232
254
  for ( let i = 0, l = ctx.node.length; i < l; i ++ ) {
233
255
 
234
256
  const node = ctx.node[ i ];
@@ -249,19 +271,18 @@
249
271
 
250
272
  return data;
251
273
 
252
- },
253
- version: function ( ctx ) {
274
+ }
275
+ version( ctx ) {
254
276
 
255
277
  return ctx.Version[ 0 ].image;
256
278
 
257
- },
258
- node: function ( ctx ) {
279
+ }
280
+ node( ctx ) {
259
281
 
260
282
  const data = {
261
283
  name: ctx.NodeName[ 0 ].image,
262
284
  fields: []
263
285
  };
264
-
265
286
  if ( ctx.field ) {
266
287
 
267
288
  for ( let i = 0, l = ctx.field.length; i < l; i ++ ) {
@@ -271,8 +292,9 @@
271
292
 
272
293
  }
273
294
 
274
- } // DEF
295
+ }
275
296
 
297
+ // DEF
276
298
 
277
299
  if ( ctx.def ) {
278
300
 
@@ -282,22 +304,25 @@
282
304
 
283
305
  return data;
284
306
 
285
- },
286
- field: function ( ctx ) {
307
+ }
308
+ field( ctx ) {
287
309
 
288
310
  const data = {
289
311
  name: ctx.Identifier[ 0 ].image,
290
312
  type: null,
291
313
  values: null
292
314
  };
293
- let result; // SFValue
315
+ let result;
316
+
317
+ // SFValue
294
318
 
295
319
  if ( ctx.singleFieldValue ) {
296
320
 
297
321
  result = this.visit( ctx.singleFieldValue[ 0 ] );
298
322
 
299
- } // MFValue
323
+ }
300
324
 
325
+ // MFValue
301
326
 
302
327
  if ( ctx.multiFieldValue ) {
303
328
 
@@ -309,30 +334,30 @@
309
334
  data.values = result.values;
310
335
  return data;
311
336
 
312
- },
313
- def: function ( ctx ) {
337
+ }
338
+ def( ctx ) {
314
339
 
315
340
  return ( ctx.Identifier || ctx.NodeName )[ 0 ].image;
316
341
 
317
- },
318
- use: function ( ctx ) {
342
+ }
343
+ use( ctx ) {
319
344
 
320
345
  return {
321
346
  USE: ( ctx.Identifier || ctx.NodeName )[ 0 ].image
322
347
  };
323
348
 
324
- },
325
- singleFieldValue: function ( ctx ) {
349
+ }
350
+ singleFieldValue( ctx ) {
326
351
 
327
352
  return processField( this, ctx );
328
353
 
329
- },
330
- multiFieldValue: function ( ctx ) {
354
+ }
355
+ multiFieldValue( ctx ) {
331
356
 
332
357
  return processField( this, ctx );
333
358
 
334
- },
335
- route: function ( ctx ) {
359
+ }
360
+ route( ctx ) {
336
361
 
337
362
  const data = {
338
363
  FROM: ctx.RouteIdentifier[ 0 ].image,
@@ -341,19 +366,17 @@
341
366
  return data;
342
367
 
343
368
  }
344
- } );
345
369
 
370
+ }
346
371
  function processField( scope, ctx ) {
347
372
 
348
373
  const field = {
349
374
  type: null,
350
375
  values: []
351
376
  };
352
-
353
377
  if ( ctx.node ) {
354
378
 
355
379
  field.type = 'node';
356
-
357
380
  for ( let i = 0, l = ctx.node.length; i < l; i ++ ) {
358
381
 
359
382
  const node = ctx.node[ i ];
@@ -366,7 +389,6 @@
366
389
  if ( ctx.use ) {
367
390
 
368
391
  field.type = 'use';
369
-
370
392
  for ( let i = 0, l = ctx.use.length; i < l; i ++ ) {
371
393
 
372
394
  const use = ctx.use[ i ];
@@ -379,7 +401,6 @@
379
401
  if ( ctx.StringLiteral ) {
380
402
 
381
403
  field.type = 'string';
382
-
383
404
  for ( let i = 0, l = ctx.StringLiteral.length; i < l; i ++ ) {
384
405
 
385
406
  const stringLiteral = ctx.StringLiteral[ i ];
@@ -392,7 +413,6 @@
392
413
  if ( ctx.NumberLiteral ) {
393
414
 
394
415
  field.type = 'number';
395
-
396
416
  for ( let i = 0, l = ctx.NumberLiteral.length; i < l; i ++ ) {
397
417
 
398
418
  const numberLiteral = ctx.NumberLiteral[ i ];
@@ -405,7 +425,6 @@
405
425
  if ( ctx.HexLiteral ) {
406
426
 
407
427
  field.type = 'hex';
408
-
409
428
  for ( let i = 0, l = ctx.HexLiteral.length; i < l; i ++ ) {
410
429
 
411
430
  const hexLiteral = ctx.HexLiteral[ i ];
@@ -418,7 +437,6 @@
418
437
  if ( ctx.TrueLiteral ) {
419
438
 
420
439
  field.type = 'boolean';
421
-
422
440
  for ( let i = 0, l = ctx.TrueLiteral.length; i < l; i ++ ) {
423
441
 
424
442
  const trueLiteral = ctx.TrueLiteral[ i ];
@@ -431,7 +449,6 @@
431
449
  if ( ctx.FalseLiteral ) {
432
450
 
433
451
  field.type = 'boolean';
434
-
435
452
  for ( let i = 0, l = ctx.FalseLiteral.length; i < l; i ++ ) {
436
453
 
437
454
  const falseLiteral = ctx.FalseLiteral[ i ];
@@ -463,16 +480,20 @@
463
480
  function parseTree( tree ) {
464
481
 
465
482
  // console.log( JSON.stringify( tree, null, 2 ) );
483
+
466
484
  const nodes = tree.nodes;
467
- const scene = new THREE.Scene(); // first iteration: build nodemap based on DEF statements
485
+ const scene = new THREE.Scene();
486
+
487
+ // first iteration: build nodemap based on DEF statements
468
488
 
469
489
  for ( let i = 0, l = nodes.length; i < l; i ++ ) {
470
490
 
471
491
  const node = nodes[ i ];
472
492
  buildNodeMap( node );
473
493
 
474
- } // second iteration: build nodes
494
+ }
475
495
 
496
+ // second iteration: build nodes
476
497
 
477
498
  for ( let i = 0, l = nodes.length; i < l; i ++ ) {
478
499
 
@@ -496,15 +517,12 @@
496
517
  }
497
518
 
498
519
  const fields = node.fields;
499
-
500
520
  for ( let i = 0, l = fields.length; i < l; i ++ ) {
501
521
 
502
522
  const field = fields[ i ];
503
-
504
523
  if ( field.type === 'node' ) {
505
524
 
506
525
  const fieldValues = field.values;
507
-
508
526
  for ( let j = 0, jl = fieldValues.length; j < jl; j ++ ) {
509
527
 
510
528
  buildNodeMap( fieldValues[ j ] );
@@ -520,6 +538,7 @@
520
538
  function getNode( node ) {
521
539
 
522
540
  // handle case where a node refers to a different one
541
+
523
542
  if ( node.USE ) {
524
543
 
525
544
  return resolveUSE( node.USE );
@@ -530,98 +549,79 @@
530
549
  node.build = buildNode( node );
531
550
  return node.build;
532
551
 
533
- } // node builder
552
+ }
534
553
 
554
+ // node builder
535
555
 
536
556
  function buildNode( node ) {
537
557
 
538
558
  const nodeName = node.name;
539
559
  let build;
540
-
541
560
  switch ( nodeName ) {
542
561
 
562
+ case 'Anchor':
543
563
  case 'Group':
544
564
  case 'Transform':
545
565
  case 'Collision':
546
566
  build = buildGroupingNode( node );
547
567
  break;
548
-
549
568
  case 'Background':
550
569
  build = buildBackgroundNode( node );
551
570
  break;
552
-
553
571
  case 'Shape':
554
572
  build = buildShapeNode( node );
555
573
  break;
556
-
557
574
  case 'Appearance':
558
575
  build = buildAppearanceNode( node );
559
576
  break;
560
-
561
577
  case 'Material':
562
578
  build = buildMaterialNode( node );
563
579
  break;
564
-
565
580
  case 'ImageTexture':
566
581
  build = buildImageTextureNode( node );
567
582
  break;
568
-
569
583
  case 'PixelTexture':
570
584
  build = buildPixelTextureNode( node );
571
585
  break;
572
-
573
586
  case 'TextureTransform':
574
587
  build = buildTextureTransformNode( node );
575
588
  break;
576
-
577
589
  case 'IndexedFaceSet':
578
590
  build = buildIndexedFaceSetNode( node );
579
591
  break;
580
-
581
592
  case 'IndexedLineSet':
582
593
  build = buildIndexedLineSetNode( node );
583
594
  break;
584
-
585
595
  case 'PointSet':
586
596
  build = buildPointSetNode( node );
587
597
  break;
588
-
589
598
  case 'Box':
590
599
  build = buildBoxNode( node );
591
600
  break;
592
-
593
601
  case 'Cone':
594
602
  build = buildConeNode( node );
595
603
  break;
596
-
597
604
  case 'Cylinder':
598
605
  build = buildCylinderNode( node );
599
606
  break;
600
-
601
607
  case 'Sphere':
602
608
  build = buildSphereNode( node );
603
609
  break;
604
-
605
610
  case 'ElevationGrid':
606
611
  build = buildElevationGridNode( node );
607
612
  break;
608
-
609
613
  case 'Extrusion':
610
614
  build = buildExtrusionNode( node );
611
615
  break;
612
-
613
616
  case 'Color':
614
617
  case 'Coordinate':
615
618
  case 'Normal':
616
619
  case 'TextureCoordinate':
617
620
  build = buildGeometricNode( node );
618
621
  break;
619
-
620
622
  case 'WorldInfo':
621
623
  build = buildWorldInfoNode( node );
622
624
  break;
623
-
624
- case 'Anchor':
625
625
  case 'Billboard':
626
626
  case 'Inline':
627
627
  case 'LOD':
@@ -653,7 +653,6 @@
653
653
  case 'Viewpoint':
654
654
  // node not supported yet
655
655
  break;
656
-
657
656
  default:
658
657
  console.warn( 'THREE.VRMLLoader: Unknown node:', nodeName );
659
658
  break;
@@ -672,60 +671,59 @@
672
671
 
673
672
  function buildGroupingNode( node ) {
674
673
 
675
- const object = new THREE.Group(); //
674
+ const object = new THREE.Group();
676
675
 
677
- const fields = node.fields;
676
+ //
678
677
 
678
+ const fields = node.fields;
679
679
  for ( let i = 0, l = fields.length; i < l; i ++ ) {
680
680
 
681
681
  const field = fields[ i ];
682
682
  const fieldName = field.name;
683
683
  const fieldValues = field.values;
684
-
685
684
  switch ( fieldName ) {
686
685
 
687
686
  case 'bboxCenter':
688
687
  // field not supported
689
688
  break;
690
-
691
689
  case 'bboxSize':
692
690
  // field not supported
693
691
  break;
694
-
695
692
  case 'center':
696
693
  // field not supported
697
694
  break;
698
-
699
695
  case 'children':
700
696
  parseFieldChildren( fieldValues, object );
701
697
  break;
702
-
698
+ case 'description':
699
+ // field not supported
700
+ break;
703
701
  case 'collide':
704
702
  // field not supported
705
703
  break;
706
-
704
+ case 'parameter':
705
+ // field not supported
706
+ break;
707
707
  case 'rotation':
708
708
  const axis = new THREE.Vector3( fieldValues[ 0 ], fieldValues[ 1 ], fieldValues[ 2 ] );
709
709
  const angle = fieldValues[ 3 ];
710
710
  object.quaternion.setFromAxisAngle( axis, angle );
711
711
  break;
712
-
713
712
  case 'scale':
714
713
  object.scale.set( fieldValues[ 0 ], fieldValues[ 1 ], fieldValues[ 2 ] );
715
714
  break;
716
-
717
715
  case 'scaleOrientation':
718
716
  // field not supported
719
717
  break;
720
-
721
718
  case 'translation':
722
719
  object.position.set( fieldValues[ 0 ], fieldValues[ 1 ], fieldValues[ 2 ] );
723
720
  break;
724
-
725
721
  case 'proxy':
726
722
  // field not supported
727
723
  break;
728
-
724
+ case 'url':
725
+ // field not supported
726
+ break;
729
727
  default:
730
728
  console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
731
729
  break;
@@ -744,55 +742,43 @@
744
742
  let groundAngle, groundColor;
745
743
  let skyAngle, skyColor;
746
744
  const fields = node.fields;
747
-
748
745
  for ( let i = 0, l = fields.length; i < l; i ++ ) {
749
746
 
750
747
  const field = fields[ i ];
751
748
  const fieldName = field.name;
752
749
  const fieldValues = field.values;
753
-
754
750
  switch ( fieldName ) {
755
751
 
756
752
  case 'groundAngle':
757
753
  groundAngle = fieldValues;
758
754
  break;
759
-
760
755
  case 'groundColor':
761
756
  groundColor = fieldValues;
762
757
  break;
763
-
764
758
  case 'backUrl':
765
759
  // field not supported
766
760
  break;
767
-
768
761
  case 'bottomUrl':
769
762
  // field not supported
770
763
  break;
771
-
772
764
  case 'frontUrl':
773
765
  // field not supported
774
766
  break;
775
-
776
767
  case 'leftUrl':
777
768
  // field not supported
778
769
  break;
779
-
780
770
  case 'rightUrl':
781
771
  // field not supported
782
772
  break;
783
-
784
773
  case 'topUrl':
785
774
  // field not supported
786
775
  break;
787
-
788
776
  case 'skyAngle':
789
777
  skyAngle = fieldValues;
790
778
  break;
791
-
792
779
  case 'skyColor':
793
780
  skyColor = fieldValues;
794
781
  break;
795
-
796
782
  default:
797
783
  console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
798
784
  break;
@@ -801,7 +787,9 @@
801
787
 
802
788
  }
803
789
 
804
- const radius = 10000; // sky
790
+ const radius = 10000;
791
+
792
+ // sky
805
793
 
806
794
  if ( skyColor ) {
807
795
 
@@ -812,7 +800,6 @@
812
800
  depthWrite: false,
813
801
  depthTest: false
814
802
  } );
815
-
816
803
  if ( skyColor.length > 3 ) {
817
804
 
818
805
  paintFaces( skyGeometry, radius, skyAngle, toColorArray( skyColor ), true );
@@ -827,8 +814,9 @@
827
814
  const sky = new THREE.Mesh( skyGeometry, skyMaterial );
828
815
  group.add( sky );
829
816
 
830
- } // ground
817
+ }
831
818
 
819
+ // ground
832
820
 
833
821
  if ( groundColor ) {
834
822
 
@@ -848,8 +836,9 @@
848
836
 
849
837
  }
850
838
 
851
- } // render background group first
839
+ }
852
840
 
841
+ // render background group first
853
842
 
854
843
  group.renderOrder = - Infinity;
855
844
  return group;
@@ -858,19 +847,19 @@
858
847
 
859
848
  function buildShapeNode( node ) {
860
849
 
861
- const fields = node.fields; // if the appearance field is NULL or unspecified, lighting is off and the unlit object color is (0, 0, 0)
850
+ const fields = node.fields;
851
+
852
+ // if the appearance field is NULL or unspecified, lighting is off and the unlit object color is (0, 0, 0)
862
853
 
863
854
  let material = new THREE.MeshBasicMaterial( {
864
855
  color: 0x000000
865
856
  } );
866
857
  let geometry;
867
-
868
858
  for ( let i = 0, l = fields.length; i < l; i ++ ) {
869
859
 
870
860
  const field = fields[ i ];
871
861
  const fieldName = field.name;
872
862
  const fieldValues = field.values;
873
-
874
863
  switch ( fieldName ) {
875
864
 
876
865
  case 'appearance':
@@ -881,7 +870,6 @@
881
870
  }
882
871
 
883
872
  break;
884
-
885
873
  case 'geometry':
886
874
  if ( fieldValues[ 0 ] !== null ) {
887
875
 
@@ -890,29 +878,27 @@
890
878
  }
891
879
 
892
880
  break;
893
-
894
881
  default:
895
882
  console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
896
883
  break;
897
884
 
898
885
  }
899
886
 
900
- } // build 3D object
887
+ }
901
888
 
889
+ // build 3D object
902
890
 
903
891
  let object;
904
-
905
892
  if ( geometry && geometry.attributes.position ) {
906
893
 
907
894
  const type = geometry._type;
908
-
909
895
  if ( type === 'points' ) {
910
896
 
911
897
  // points
898
+
912
899
  const pointsMaterial = new THREE.PointsMaterial( {
913
900
  color: 0xffffff
914
901
  } );
915
-
916
902
  if ( geometry.attributes.color !== undefined ) {
917
903
 
918
904
  pointsMaterial.vertexColors = true;
@@ -920,6 +906,7 @@
920
906
  } else {
921
907
 
922
908
  // if the color field is NULL and there is a material defined for the appearance affecting this PointSet, then use the emissiveColor of the material to draw the points
909
+
923
910
  if ( material.isMeshPhongMaterial ) {
924
911
 
925
912
  pointsMaterial.color.copy( material.emissive );
@@ -933,10 +920,10 @@
933
920
  } else if ( type === 'line' ) {
934
921
 
935
922
  // lines
923
+
936
924
  const lineMaterial = new THREE.LineBasicMaterial( {
937
925
  color: 0xffffff
938
926
  } );
939
-
940
927
  if ( geometry.attributes.color !== undefined ) {
941
928
 
942
929
  lineMaterial.vertexColors = true;
@@ -944,6 +931,7 @@
944
931
  } else {
945
932
 
946
933
  // if the color field is NULL and there is a material defined for the appearance affecting this IndexedLineSet, then use the emissiveColor of the material to draw the lines
934
+
947
935
  if ( material.isMeshPhongMaterial ) {
948
936
 
949
937
  lineMaterial.color.copy( material.emissive );
@@ -957,13 +945,16 @@
957
945
  } else {
958
946
 
959
947
  // consider meshes
948
+
960
949
  // check "solid" hint (it's placed in the geometry but affects the material)
950
+
961
951
  if ( geometry._solid !== undefined ) {
962
952
 
963
953
  material.side = geometry._solid ? THREE.FrontSide : THREE.DoubleSide;
964
954
 
965
- } // check for vertex colors
955
+ }
966
956
 
957
+ // check for vertex colors
967
958
 
968
959
  if ( geometry.attributes.color !== undefined ) {
969
960
 
@@ -977,7 +968,9 @@
977
968
 
978
969
  } else {
979
970
 
980
- object = new THREE.Object3D(); // if the geometry field is NULL or no vertices are defined the object is not drawn
971
+ object = new THREE.Object3D();
972
+
973
+ // if the geometry field is NULL or no vertices are defined the object is not drawn
981
974
 
982
975
  object.visible = false;
983
976
 
@@ -992,13 +985,11 @@
992
985
  let material = new THREE.MeshPhongMaterial();
993
986
  let transformData;
994
987
  const fields = node.fields;
995
-
996
988
  for ( let i = 0, l = fields.length; i < l; i ++ ) {
997
989
 
998
990
  const field = fields[ i ];
999
991
  const fieldName = field.name;
1000
992
  const fieldValues = field.values;
1001
-
1002
993
  switch ( fieldName ) {
1003
994
 
1004
995
  case 'material':
@@ -1015,6 +1006,7 @@
1015
1006
  } else {
1016
1007
 
1017
1008
  // if the material field is NULL or unspecified, lighting is off and the unlit object color is (0, 0, 0)
1009
+
1018
1010
  material = new THREE.MeshBasicMaterial( {
1019
1011
  color: 0x000000
1020
1012
  } );
@@ -1022,23 +1014,22 @@
1022
1014
  }
1023
1015
 
1024
1016
  break;
1025
-
1026
1017
  case 'texture':
1027
1018
  const textureNode = fieldValues[ 0 ];
1028
-
1029
1019
  if ( textureNode !== null ) {
1030
1020
 
1031
1021
  if ( textureNode.name === 'ImageTexture' || textureNode.name === 'PixelTexture' ) {
1032
1022
 
1033
1023
  material.map = getNode( textureNode );
1034
1024
 
1035
- } else { // MovieTexture not supported yet
1025
+ } else {
1026
+
1027
+ // MovieTexture not supported yet
1036
1028
  }
1037
1029
 
1038
1030
  }
1039
1031
 
1040
1032
  break;
1041
-
1042
1033
  case 'textureTransform':
1043
1034
  if ( fieldValues[ 0 ] !== null ) {
1044
1035
 
@@ -1047,48 +1038,43 @@
1047
1038
  }
1048
1039
 
1049
1040
  break;
1050
-
1051
1041
  default:
1052
1042
  console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
1053
1043
  break;
1054
1044
 
1055
1045
  }
1056
1046
 
1057
- } // only apply texture transform data if a texture was defined
1047
+ }
1058
1048
 
1049
+ // only apply texture transform data if a texture was defined
1059
1050
 
1060
1051
  if ( material.map ) {
1061
1052
 
1062
1053
  // respect VRML lighting model
1054
+
1063
1055
  if ( material.map.__type ) {
1064
1056
 
1065
1057
  switch ( material.map.__type ) {
1066
1058
 
1067
1059
  case TEXTURE_TYPE.INTENSITY_ALPHA:
1068
1060
  material.opacity = 1; // ignore transparency
1069
-
1070
1061
  break;
1071
-
1072
1062
  case TEXTURE_TYPE.RGB:
1073
1063
  material.color.set( 0xffffff ); // ignore material color
1074
-
1075
1064
  break;
1076
-
1077
1065
  case TEXTURE_TYPE.RGBA:
1078
1066
  material.color.set( 0xffffff ); // ignore material color
1079
-
1080
1067
  material.opacity = 1; // ignore transparency
1081
-
1082
1068
  break;
1083
-
1084
1069
  default:
1085
1070
 
1086
1071
  }
1087
1072
 
1088
1073
  delete material.map.__type;
1089
1074
 
1090
- } // apply texture transform
1075
+ }
1091
1076
 
1077
+ // apply texture transform
1092
1078
 
1093
1079
  if ( transformData ) {
1094
1080
 
@@ -1109,39 +1095,31 @@
1109
1095
 
1110
1096
  const materialData = {};
1111
1097
  const fields = node.fields;
1112
-
1113
1098
  for ( let i = 0, l = fields.length; i < l; i ++ ) {
1114
1099
 
1115
1100
  const field = fields[ i ];
1116
1101
  const fieldName = field.name;
1117
1102
  const fieldValues = field.values;
1118
-
1119
1103
  switch ( fieldName ) {
1120
1104
 
1121
1105
  case 'ambientIntensity':
1122
1106
  // field not supported
1123
1107
  break;
1124
-
1125
1108
  case 'diffuseColor':
1126
1109
  materialData.diffuseColor = new THREE.Color( fieldValues[ 0 ], fieldValues[ 1 ], fieldValues[ 2 ] );
1127
1110
  break;
1128
-
1129
1111
  case 'emissiveColor':
1130
1112
  materialData.emissiveColor = new THREE.Color( fieldValues[ 0 ], fieldValues[ 1 ], fieldValues[ 2 ] );
1131
1113
  break;
1132
-
1133
1114
  case 'shininess':
1134
1115
  materialData.shininess = fieldValues[ 0 ];
1135
1116
  break;
1136
-
1137
1117
  case 'specularColor':
1138
1118
  materialData.emissiveColor = new THREE.Color( fieldValues[ 0 ], fieldValues[ 1 ], fieldValues[ 2 ] );
1139
1119
  break;
1140
-
1141
1120
  case 'transparency':
1142
1121
  materialData.transparency = fieldValues[ 0 ];
1143
1122
  break;
1144
-
1145
1123
  default:
1146
1124
  console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
1147
1125
  break;
@@ -1157,7 +1135,6 @@
1157
1135
  function parseHexColor( hex, textureType, color ) {
1158
1136
 
1159
1137
  let value;
1160
-
1161
1138
  switch ( textureType ) {
1162
1139
 
1163
1140
  case TEXTURE_TYPE.INTENSITY:
@@ -1168,7 +1145,6 @@
1168
1145
  color.b = value;
1169
1146
  color.a = 1;
1170
1147
  break;
1171
-
1172
1148
  case TEXTURE_TYPE.INTENSITY_ALPHA:
1173
1149
  // Intensity+Alpha texture: A two-component image specifies the intensity in the first (high) byte and the alpha opacity in the second (low) byte.
1174
1150
  value = parseInt( '0x' + hex.substring( 2, 4 ) );
@@ -1177,7 +1153,6 @@
1177
1153
  color.b = value;
1178
1154
  color.a = parseInt( '0x' + hex.substring( 4, 6 ) );
1179
1155
  break;
1180
-
1181
1156
  case TEXTURE_TYPE.RGB:
1182
1157
  // RGB texture: Pixels in a three-component image specify the red component in the first (high) byte, followed by the green and blue components
1183
1158
  color.r = parseInt( '0x' + hex.substring( 2, 4 ) );
@@ -1185,7 +1160,6 @@
1185
1160
  color.b = parseInt( '0x' + hex.substring( 6, 8 ) );
1186
1161
  color.a = 1;
1187
1162
  break;
1188
-
1189
1163
  case TEXTURE_TYPE.RGBA:
1190
1164
  // RGBA texture: Four-component images specify the alpha opacity byte after red/green/blue
1191
1165
  color.r = parseInt( '0x' + hex.substring( 2, 4 ) );
@@ -1193,7 +1167,6 @@
1193
1167
  color.b = parseInt( '0x' + hex.substring( 6, 8 ) );
1194
1168
  color.a = parseInt( '0x' + hex.substring( 8, 10 ) );
1195
1169
  break;
1196
-
1197
1170
  default:
1198
1171
 
1199
1172
  }
@@ -1203,25 +1176,20 @@
1203
1176
  function getTextureType( num_components ) {
1204
1177
 
1205
1178
  let type;
1206
-
1207
1179
  switch ( num_components ) {
1208
1180
 
1209
1181
  case 1:
1210
1182
  type = TEXTURE_TYPE.INTENSITY;
1211
1183
  break;
1212
-
1213
1184
  case 2:
1214
1185
  type = TEXTURE_TYPE.INTENSITY_ALPHA;
1215
1186
  break;
1216
-
1217
1187
  case 3:
1218
1188
  type = TEXTURE_TYPE.RGB;
1219
1189
  break;
1220
-
1221
1190
  case 4:
1222
1191
  type = TEXTURE_TYPE.RGBA;
1223
1192
  break;
1224
-
1225
1193
  default:
1226
1194
 
1227
1195
  }
@@ -1236,13 +1204,11 @@
1236
1204
  let wrapS = THREE.RepeatWrapping;
1237
1205
  let wrapT = THREE.RepeatWrapping;
1238
1206
  const fields = node.fields;
1239
-
1240
1207
  for ( let i = 0, l = fields.length; i < l; i ++ ) {
1241
1208
 
1242
1209
  const field = fields[ i ];
1243
1210
  const fieldName = field.name;
1244
1211
  const fieldValues = field.values;
1245
-
1246
1212
  switch ( fieldName ) {
1247
1213
 
1248
1214
  case 'image':
@@ -1257,7 +1223,6 @@
1257
1223
  b: 0,
1258
1224
  a: 0
1259
1225
  };
1260
-
1261
1226
  for ( let j = 3, k = 0, jl = fieldValues.length; j < jl; j ++, k ++ ) {
1262
1227
 
1263
1228
  parseHexColor( fieldValues[ j ], textureType, color );
@@ -1272,17 +1237,13 @@
1272
1237
  texture = new THREE.DataTexture( data, width, height );
1273
1238
  texture.needsUpdate = true;
1274
1239
  texture.__type = textureType; // needed for material modifications
1275
-
1276
1240
  break;
1277
-
1278
1241
  case 'repeatS':
1279
1242
  if ( fieldValues[ 0 ] === false ) wrapS = THREE.ClampToEdgeWrapping;
1280
1243
  break;
1281
-
1282
1244
  case 'repeatT':
1283
1245
  if ( fieldValues[ 0 ] === false ) wrapT = THREE.ClampToEdgeWrapping;
1284
1246
  break;
1285
-
1286
1247
  default:
1287
1248
  console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
1288
1249
  break;
@@ -1308,28 +1269,23 @@
1308
1269
  let wrapS = THREE.RepeatWrapping;
1309
1270
  let wrapT = THREE.RepeatWrapping;
1310
1271
  const fields = node.fields;
1311
-
1312
1272
  for ( let i = 0, l = fields.length; i < l; i ++ ) {
1313
1273
 
1314
1274
  const field = fields[ i ];
1315
1275
  const fieldName = field.name;
1316
1276
  const fieldValues = field.values;
1317
-
1318
1277
  switch ( fieldName ) {
1319
1278
 
1320
1279
  case 'url':
1321
1280
  const url = fieldValues[ 0 ];
1322
1281
  if ( url ) texture = textureLoader.load( url );
1323
1282
  break;
1324
-
1325
1283
  case 'repeatS':
1326
1284
  if ( fieldValues[ 0 ] === false ) wrapS = THREE.ClampToEdgeWrapping;
1327
1285
  break;
1328
-
1329
1286
  case 'repeatT':
1330
1287
  if ( fieldValues[ 0 ] === false ) wrapT = THREE.ClampToEdgeWrapping;
1331
1288
  break;
1332
-
1333
1289
  default:
1334
1290
  console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
1335
1291
  break;
@@ -1358,31 +1314,25 @@
1358
1314
  translation: new THREE.Vector2()
1359
1315
  };
1360
1316
  const fields = node.fields;
1361
-
1362
1317
  for ( let i = 0, l = fields.length; i < l; i ++ ) {
1363
1318
 
1364
1319
  const field = fields[ i ];
1365
1320
  const fieldName = field.name;
1366
1321
  const fieldValues = field.values;
1367
-
1368
1322
  switch ( fieldName ) {
1369
1323
 
1370
1324
  case 'center':
1371
1325
  transformData.center.set( fieldValues[ 0 ], fieldValues[ 1 ] );
1372
1326
  break;
1373
-
1374
1327
  case 'rotation':
1375
1328
  transformData.rotation = fieldValues[ 0 ];
1376
1329
  break;
1377
-
1378
1330
  case 'scale':
1379
1331
  transformData.scale.set( fieldValues[ 0 ], fieldValues[ 1 ] );
1380
1332
  break;
1381
-
1382
1333
  case 'translation':
1383
1334
  transformData.translation.set( fieldValues[ 0 ], fieldValues[ 1 ] );
1384
1335
  break;
1385
-
1386
1336
  default:
1387
1337
  console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
1388
1338
  break;
@@ -1405,23 +1355,19 @@
1405
1355
 
1406
1356
  const worldInfo = {};
1407
1357
  const fields = node.fields;
1408
-
1409
1358
  for ( let i = 0, l = fields.length; i < l; i ++ ) {
1410
1359
 
1411
1360
  const field = fields[ i ];
1412
1361
  const fieldName = field.name;
1413
1362
  const fieldValues = field.values;
1414
-
1415
1363
  switch ( fieldName ) {
1416
1364
 
1417
1365
  case 'title':
1418
1366
  worldInfo.title = fieldValues[ 0 ];
1419
1367
  break;
1420
-
1421
1368
  case 'info':
1422
1369
  worldInfo.info = fieldValues;
1423
1370
  break;
1424
-
1425
1371
  default:
1426
1372
  console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
1427
1373
  break;
@@ -1444,18 +1390,15 @@
1444
1390
  let colorPerVertex = true,
1445
1391
  normalPerVertex = true;
1446
1392
  const fields = node.fields;
1447
-
1448
1393
  for ( let i = 0, l = fields.length; i < l; i ++ ) {
1449
1394
 
1450
1395
  const field = fields[ i ];
1451
1396
  const fieldName = field.name;
1452
1397
  const fieldValues = field.values;
1453
-
1454
1398
  switch ( fieldName ) {
1455
1399
 
1456
1400
  case 'color':
1457
1401
  const colorNode = fieldValues[ 0 ];
1458
-
1459
1402
  if ( colorNode !== null ) {
1460
1403
 
1461
1404
  color = getNode( colorNode );
@@ -1463,10 +1406,8 @@
1463
1406
  }
1464
1407
 
1465
1408
  break;
1466
-
1467
1409
  case 'coord':
1468
1410
  const coordNode = fieldValues[ 0 ];
1469
-
1470
1411
  if ( coordNode !== null ) {
1471
1412
 
1472
1413
  coord = getNode( coordNode );
@@ -1474,10 +1415,8 @@
1474
1415
  }
1475
1416
 
1476
1417
  break;
1477
-
1478
1418
  case 'normal':
1479
1419
  const normalNode = fieldValues[ 0 ];
1480
-
1481
1420
  if ( normalNode !== null ) {
1482
1421
 
1483
1422
  normal = getNode( normalNode );
@@ -1485,10 +1424,8 @@
1485
1424
  }
1486
1425
 
1487
1426
  break;
1488
-
1489
1427
  case 'texCoord':
1490
1428
  const texCoordNode = fieldValues[ 0 ];
1491
-
1492
1429
  if ( texCoordNode !== null ) {
1493
1430
 
1494
1431
  texCoord = getNode( texCoordNode );
@@ -1496,47 +1433,36 @@
1496
1433
  }
1497
1434
 
1498
1435
  break;
1499
-
1500
1436
  case 'ccw':
1501
1437
  ccw = fieldValues[ 0 ];
1502
1438
  break;
1503
-
1504
1439
  case 'colorIndex':
1505
1440
  colorIndex = fieldValues;
1506
1441
  break;
1507
-
1508
1442
  case 'colorPerVertex':
1509
1443
  colorPerVertex = fieldValues[ 0 ];
1510
1444
  break;
1511
-
1512
1445
  case 'convex':
1513
1446
  // field not supported
1514
1447
  break;
1515
-
1516
1448
  case 'coordIndex':
1517
1449
  coordIndex = fieldValues;
1518
1450
  break;
1519
-
1520
1451
  case 'creaseAngle':
1521
1452
  creaseAngle = fieldValues[ 0 ];
1522
1453
  break;
1523
-
1524
1454
  case 'normalIndex':
1525
1455
  normalIndex = fieldValues;
1526
1456
  break;
1527
-
1528
1457
  case 'normalPerVertex':
1529
1458
  normalPerVertex = fieldValues[ 0 ];
1530
1459
  break;
1531
-
1532
1460
  case 'solid':
1533
1461
  solid = fieldValues[ 0 ];
1534
1462
  break;
1535
-
1536
1463
  case 'texCoordIndex':
1537
1464
  texCoordIndex = fieldValues;
1538
1465
  break;
1539
-
1540
1466
  default:
1541
1467
  console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
1542
1468
  break;
@@ -1556,7 +1482,6 @@
1556
1482
  let colorAttribute;
1557
1483
  let normalAttribute;
1558
1484
  let uvAttribute;
1559
-
1560
1485
  if ( color ) {
1561
1486
 
1562
1487
  if ( colorPerVertex === true ) {
@@ -1564,12 +1489,14 @@
1564
1489
  if ( colorIndex && colorIndex.length > 0 ) {
1565
1490
 
1566
1491
  // if the colorIndex field is not empty, then it is used to choose colors for each vertex of the IndexedFaceSet.
1492
+
1567
1493
  const triangulatedColorIndex = triangulateFaceIndex( colorIndex, ccw );
1568
1494
  colorAttribute = computeAttributeFromIndexedData( triangulatedCoordIndex, triangulatedColorIndex, color, 3 );
1569
1495
 
1570
1496
  } else {
1571
1497
 
1572
1498
  // if the colorIndex field is empty, then the coordIndex field is used to choose colors from the THREE.Color node
1499
+
1573
1500
  colorAttribute = toNonIndexedAttribute( triangulatedCoordIndex, new THREE.Float32BufferAttribute( color, 3 ) );
1574
1501
 
1575
1502
  }
@@ -1579,6 +1506,7 @@
1579
1506
  if ( colorIndex && colorIndex.length > 0 ) {
1580
1507
 
1581
1508
  // if the colorIndex field is not empty, then they are used to choose one color for each face of the IndexedFaceSet
1509
+
1582
1510
  const flattenFaceColors = flattenData( color, colorIndex );
1583
1511
  const triangulatedFaceColors = triangulateFaceData( flattenFaceColors, coordIndex );
1584
1512
  colorAttribute = computeAttributeFromFaceData( triangulatedCoordIndex, triangulatedFaceColors );
@@ -1586,6 +1514,7 @@
1586
1514
  } else {
1587
1515
 
1588
1516
  // if the colorIndex field is empty, then the color are applied to each face of the IndexedFaceSet in order
1517
+
1589
1518
  const triangulatedFaceColors = triangulateFaceData( color, coordIndex );
1590
1519
  colorAttribute = computeAttributeFromFaceData( triangulatedCoordIndex, triangulatedFaceColors );
1591
1520
 
@@ -1600,15 +1529,18 @@
1600
1529
  if ( normalPerVertex === true ) {
1601
1530
 
1602
1531
  // consider vertex normals
1532
+
1603
1533
  if ( normalIndex && normalIndex.length > 0 ) {
1604
1534
 
1605
1535
  // if the normalIndex field is not empty, then it is used to choose normals for each vertex of the IndexedFaceSet.
1536
+
1606
1537
  const triangulatedNormalIndex = triangulateFaceIndex( normalIndex, ccw );
1607
1538
  normalAttribute = computeAttributeFromIndexedData( triangulatedCoordIndex, triangulatedNormalIndex, normal, 3 );
1608
1539
 
1609
1540
  } else {
1610
1541
 
1611
1542
  // if the normalIndex field is empty, then the coordIndex field is used to choose normals from the Normal node
1543
+
1612
1544
  normalAttribute = toNonIndexedAttribute( triangulatedCoordIndex, new THREE.Float32BufferAttribute( normal, 3 ) );
1613
1545
 
1614
1546
  }
@@ -1616,9 +1548,11 @@
1616
1548
  } else {
1617
1549
 
1618
1550
  // consider face normals
1551
+
1619
1552
  if ( normalIndex && normalIndex.length > 0 ) {
1620
1553
 
1621
1554
  // if the normalIndex field is not empty, then they are used to choose one normal for each face of the IndexedFaceSet
1555
+
1622
1556
  const flattenFaceNormals = flattenData( normal, normalIndex );
1623
1557
  const triangulatedFaceNormals = triangulateFaceData( flattenFaceNormals, coordIndex );
1624
1558
  normalAttribute = computeAttributeFromFaceData( triangulatedCoordIndex, triangulatedFaceNormals );
@@ -1626,6 +1560,7 @@
1626
1560
  } else {
1627
1561
 
1628
1562
  // if the normalIndex field is empty, then the normals are applied to each face of the IndexedFaceSet in order
1563
+
1629
1564
  const triangulatedFaceNormals = triangulateFaceData( normal, coordIndex );
1630
1565
  normalAttribute = computeAttributeFromFaceData( triangulatedCoordIndex, triangulatedFaceNormals );
1631
1566
 
@@ -1636,6 +1571,7 @@
1636
1571
  } else {
1637
1572
 
1638
1573
  // if the normal field is NULL, then the loader should automatically generate normals, using creaseAngle to determine if and how normals are smoothed across shared vertices
1574
+
1639
1575
  normalAttribute = computeNormalAttribute( triangulatedCoordIndex, coord, creaseAngle );
1640
1576
 
1641
1577
  }
@@ -1643,15 +1579,18 @@
1643
1579
  if ( texCoord ) {
1644
1580
 
1645
1581
  // texture coordinates are always defined on vertex level
1582
+
1646
1583
  if ( texCoordIndex && texCoordIndex.length > 0 ) {
1647
1584
 
1648
1585
  // if the texCoordIndex field is not empty, then it is used to choose texture coordinates for each vertex of the IndexedFaceSet.
1586
+
1649
1587
  const triangulatedTexCoordIndex = triangulateFaceIndex( texCoordIndex, ccw );
1650
1588
  uvAttribute = computeAttributeFromIndexedData( triangulatedCoordIndex, triangulatedTexCoordIndex, texCoord, 2 );
1651
1589
 
1652
1590
  } else {
1653
1591
 
1654
1592
  // if the texCoordIndex field is empty, then the coordIndex array is used to choose texture coordinates from the TextureCoordinate node
1593
+
1655
1594
  uvAttribute = toNonIndexedAttribute( triangulatedCoordIndex, new THREE.Float32BufferAttribute( texCoord, 2 ) );
1656
1595
 
1657
1596
  }
@@ -1661,10 +1600,14 @@
1661
1600
  const geometry = new THREE.BufferGeometry();
1662
1601
  const positionAttribute = toNonIndexedAttribute( triangulatedCoordIndex, new THREE.Float32BufferAttribute( coord, 3 ) );
1663
1602
  geometry.setAttribute( 'position', positionAttribute );
1664
- geometry.setAttribute( 'normal', normalAttribute ); // optional attributes
1603
+ geometry.setAttribute( 'normal', normalAttribute );
1604
+
1605
+ // optional attributes
1665
1606
 
1666
1607
  if ( colorAttribute ) geometry.setAttribute( 'color', colorAttribute );
1667
- if ( uvAttribute ) geometry.setAttribute( 'uv', uvAttribute ); // "solid" influences the material so let's store it for later use
1608
+ if ( uvAttribute ) geometry.setAttribute( 'uv', uvAttribute );
1609
+
1610
+ // "solid" influences the material so let's store it for later use
1668
1611
 
1669
1612
  geometry._solid = solid;
1670
1613
  geometry._type = 'mesh';
@@ -1678,18 +1621,15 @@
1678
1621
  let colorIndex, coordIndex;
1679
1622
  let colorPerVertex = true;
1680
1623
  const fields = node.fields;
1681
-
1682
1624
  for ( let i = 0, l = fields.length; i < l; i ++ ) {
1683
1625
 
1684
1626
  const field = fields[ i ];
1685
1627
  const fieldName = field.name;
1686
1628
  const fieldValues = field.values;
1687
-
1688
1629
  switch ( fieldName ) {
1689
1630
 
1690
1631
  case 'color':
1691
1632
  const colorNode = fieldValues[ 0 ];
1692
-
1693
1633
  if ( colorNode !== null ) {
1694
1634
 
1695
1635
  color = getNode( colorNode );
@@ -1697,10 +1637,8 @@
1697
1637
  }
1698
1638
 
1699
1639
  break;
1700
-
1701
1640
  case 'coord':
1702
1641
  const coordNode = fieldValues[ 0 ];
1703
-
1704
1642
  if ( coordNode !== null ) {
1705
1643
 
1706
1644
  coord = getNode( coordNode );
@@ -1708,27 +1646,24 @@
1708
1646
  }
1709
1647
 
1710
1648
  break;
1711
-
1712
1649
  case 'colorIndex':
1713
1650
  colorIndex = fieldValues;
1714
1651
  break;
1715
-
1716
1652
  case 'colorPerVertex':
1717
1653
  colorPerVertex = fieldValues[ 0 ];
1718
1654
  break;
1719
-
1720
1655
  case 'coordIndex':
1721
1656
  coordIndex = fieldValues;
1722
1657
  break;
1723
-
1724
1658
  default:
1725
1659
  console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
1726
1660
  break;
1727
1661
 
1728
1662
  }
1729
1663
 
1730
- } // build lines
1664
+ }
1731
1665
 
1666
+ // build lines
1732
1667
 
1733
1668
  let colorAttribute;
1734
1669
  const expandedLineIndex = expandLineIndex( coordIndex ); // create an index for three.js's linesegment primitive
@@ -1740,13 +1675,14 @@
1740
1675
  if ( colorIndex.length > 0 ) {
1741
1676
 
1742
1677
  // if the colorIndex field is not empty, then one color is used for each polyline of the IndexedLineSet.
1743
- const expandedColorIndex = expandLineIndex( colorIndex ); // compute colors for each line segment (rendering primitve)
1744
1678
 
1679
+ const expandedColorIndex = expandLineIndex( colorIndex ); // compute colors for each line segment (rendering primitve)
1745
1680
  colorAttribute = computeAttributeFromIndexedData( expandedLineIndex, expandedColorIndex, color, 3 ); // compute data on vertex level
1746
1681
 
1747
1682
  } else {
1748
1683
 
1749
1684
  // if the colorIndex field is empty, then the colors are applied to each polyline of the IndexedLineSet in order.
1685
+
1750
1686
  colorAttribute = toNonIndexedAttribute( expandedLineIndex, new THREE.Float32BufferAttribute( color, 3 ) );
1751
1687
 
1752
1688
  }
@@ -1756,25 +1692,25 @@
1756
1692
  if ( colorIndex.length > 0 ) {
1757
1693
 
1758
1694
  // if the colorIndex field is not empty, then colors are applied to each vertex of the IndexedLineSet
1759
- const flattenLineColors = flattenData( color, colorIndex ); // compute colors for each VRML primitve
1760
1695
 
1696
+ const flattenLineColors = flattenData( color, colorIndex ); // compute colors for each VRML primitve
1761
1697
  const expandedLineColors = expandLineData( flattenLineColors, coordIndex ); // compute colors for each line segment (rendering primitve)
1762
-
1763
1698
  colorAttribute = computeAttributeFromLineData( expandedLineIndex, expandedLineColors ); // compute data on vertex level
1764
1699
 
1765
1700
  } else {
1766
1701
 
1767
1702
  // if the colorIndex field is empty, then the coordIndex field is used to choose colors from the THREE.Color node
1768
- const expandedLineColors = expandLineData( color, coordIndex ); // compute colors for each line segment (rendering primitve)
1769
1703
 
1704
+ const expandedLineColors = expandLineData( color, coordIndex ); // compute colors for each line segment (rendering primitve)
1770
1705
  colorAttribute = computeAttributeFromLineData( expandedLineIndex, expandedLineColors ); // compute data on vertex level
1771
1706
 
1772
1707
  }
1773
1708
 
1774
1709
  }
1775
1710
 
1776
- } //
1711
+ }
1777
1712
 
1713
+ //
1778
1714
 
1779
1715
  const geometry = new THREE.BufferGeometry();
1780
1716
  const positionAttribute = toNonIndexedAttribute( expandedLineIndex, new THREE.Float32BufferAttribute( coord, 3 ) );
@@ -1789,18 +1725,15 @@
1789
1725
 
1790
1726
  let color, coord;
1791
1727
  const fields = node.fields;
1792
-
1793
1728
  for ( let i = 0, l = fields.length; i < l; i ++ ) {
1794
1729
 
1795
1730
  const field = fields[ i ];
1796
1731
  const fieldName = field.name;
1797
1732
  const fieldValues = field.values;
1798
-
1799
1733
  switch ( fieldName ) {
1800
1734
 
1801
1735
  case 'color':
1802
1736
  const colorNode = fieldValues[ 0 ];
1803
-
1804
1737
  if ( colorNode !== null ) {
1805
1738
 
1806
1739
  color = getNode( colorNode );
@@ -1808,10 +1741,8 @@
1808
1741
  }
1809
1742
 
1810
1743
  break;
1811
-
1812
1744
  case 'coord':
1813
1745
  const coordNode = fieldValues[ 0 ];
1814
-
1815
1746
  if ( coordNode !== null ) {
1816
1747
 
1817
1748
  coord = getNode( coordNode );
@@ -1819,7 +1750,6 @@
1819
1750
  }
1820
1751
 
1821
1752
  break;
1822
-
1823
1753
  default:
1824
1754
  console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
1825
1755
  break;
@@ -1840,13 +1770,11 @@
1840
1770
 
1841
1771
  const size = new THREE.Vector3( 2, 2, 2 );
1842
1772
  const fields = node.fields;
1843
-
1844
1773
  for ( let i = 0, l = fields.length; i < l; i ++ ) {
1845
1774
 
1846
1775
  const field = fields[ i ];
1847
1776
  const fieldName = field.name;
1848
1777
  const fieldValues = field.values;
1849
-
1850
1778
  switch ( fieldName ) {
1851
1779
 
1852
1780
  case 'size':
@@ -1854,7 +1782,6 @@
1854
1782
  size.y = fieldValues[ 1 ];
1855
1783
  size.z = fieldValues[ 2 ];
1856
1784
  break;
1857
-
1858
1785
  default:
1859
1786
  console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
1860
1787
  break;
@@ -1874,31 +1801,25 @@
1874
1801
  height = 2,
1875
1802
  openEnded = false;
1876
1803
  const fields = node.fields;
1877
-
1878
1804
  for ( let i = 0, l = fields.length; i < l; i ++ ) {
1879
1805
 
1880
1806
  const field = fields[ i ];
1881
1807
  const fieldName = field.name;
1882
1808
  const fieldValues = field.values;
1883
-
1884
1809
  switch ( fieldName ) {
1885
1810
 
1886
1811
  case 'bottom':
1887
1812
  openEnded = ! fieldValues[ 0 ];
1888
1813
  break;
1889
-
1890
1814
  case 'bottomRadius':
1891
1815
  radius = fieldValues[ 0 ];
1892
1816
  break;
1893
-
1894
1817
  case 'height':
1895
1818
  height = fieldValues[ 0 ];
1896
1819
  break;
1897
-
1898
1820
  case 'side':
1899
1821
  // field not supported
1900
1822
  break;
1901
-
1902
1823
  default:
1903
1824
  console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
1904
1825
  break;
@@ -1917,35 +1838,28 @@
1917
1838
  let radius = 1,
1918
1839
  height = 2;
1919
1840
  const fields = node.fields;
1920
-
1921
1841
  for ( let i = 0, l = fields.length; i < l; i ++ ) {
1922
1842
 
1923
1843
  const field = fields[ i ];
1924
1844
  const fieldName = field.name;
1925
1845
  const fieldValues = field.values;
1926
-
1927
1846
  switch ( fieldName ) {
1928
1847
 
1929
1848
  case 'bottom':
1930
1849
  // field not supported
1931
1850
  break;
1932
-
1933
1851
  case 'radius':
1934
1852
  radius = fieldValues[ 0 ];
1935
1853
  break;
1936
-
1937
1854
  case 'height':
1938
1855
  height = fieldValues[ 0 ];
1939
1856
  break;
1940
-
1941
1857
  case 'side':
1942
1858
  // field not supported
1943
1859
  break;
1944
-
1945
1860
  case 'top':
1946
1861
  // field not supported
1947
1862
  break;
1948
-
1949
1863
  default:
1950
1864
  console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
1951
1865
  break;
@@ -1963,19 +1877,16 @@
1963
1877
 
1964
1878
  let radius = 1;
1965
1879
  const fields = node.fields;
1966
-
1967
1880
  for ( let i = 0, l = fields.length; i < l; i ++ ) {
1968
1881
 
1969
1882
  const field = fields[ i ];
1970
1883
  const fieldName = field.name;
1971
1884
  const fieldValues = field.values;
1972
-
1973
1885
  switch ( fieldName ) {
1974
1886
 
1975
1887
  case 'radius':
1976
1888
  radius = fieldValues[ 0 ];
1977
1889
  break;
1978
-
1979
1890
  default:
1980
1891
  console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
1981
1892
  break;
@@ -2005,18 +1916,15 @@
2005
1916
  let xSpacing = 1;
2006
1917
  let zSpacing = 1;
2007
1918
  const fields = node.fields;
2008
-
2009
1919
  for ( let i = 0, l = fields.length; i < l; i ++ ) {
2010
1920
 
2011
1921
  const field = fields[ i ];
2012
1922
  const fieldName = field.name;
2013
1923
  const fieldValues = field.values;
2014
-
2015
1924
  switch ( fieldName ) {
2016
1925
 
2017
1926
  case 'color':
2018
1927
  const colorNode = fieldValues[ 0 ];
2019
-
2020
1928
  if ( colorNode !== null ) {
2021
1929
 
2022
1930
  color = getNode( colorNode );
@@ -2024,10 +1932,8 @@
2024
1932
  }
2025
1933
 
2026
1934
  break;
2027
-
2028
1935
  case 'normal':
2029
1936
  const normalNode = fieldValues[ 0 ];
2030
-
2031
1937
  if ( normalNode !== null ) {
2032
1938
 
2033
1939
  normal = getNode( normalNode );
@@ -2035,10 +1941,8 @@
2035
1941
  }
2036
1942
 
2037
1943
  break;
2038
-
2039
1944
  case 'texCoord':
2040
1945
  const texCoordNode = fieldValues[ 0 ];
2041
-
2042
1946
  if ( texCoordNode !== null ) {
2043
1947
 
2044
1948
  texCoord = getNode( texCoordNode );
@@ -2046,72 +1950,66 @@
2046
1950
  }
2047
1951
 
2048
1952
  break;
2049
-
2050
1953
  case 'height':
2051
1954
  height = fieldValues;
2052
1955
  break;
2053
-
2054
1956
  case 'ccw':
2055
1957
  ccw = fieldValues[ 0 ];
2056
1958
  break;
2057
-
2058
1959
  case 'colorPerVertex':
2059
1960
  colorPerVertex = fieldValues[ 0 ];
2060
1961
  break;
2061
-
2062
1962
  case 'creaseAngle':
2063
1963
  creaseAngle = fieldValues[ 0 ];
2064
1964
  break;
2065
-
2066
1965
  case 'normalPerVertex':
2067
1966
  normalPerVertex = fieldValues[ 0 ];
2068
1967
  break;
2069
-
2070
1968
  case 'solid':
2071
1969
  solid = fieldValues[ 0 ];
2072
1970
  break;
2073
-
2074
1971
  case 'xDimension':
2075
1972
  xDimension = fieldValues[ 0 ];
2076
1973
  break;
2077
-
2078
1974
  case 'xSpacing':
2079
1975
  xSpacing = fieldValues[ 0 ];
2080
1976
  break;
2081
-
2082
1977
  case 'zDimension':
2083
1978
  zDimension = fieldValues[ 0 ];
2084
1979
  break;
2085
-
2086
1980
  case 'zSpacing':
2087
1981
  zSpacing = fieldValues[ 0 ];
2088
1982
  break;
2089
-
2090
1983
  default:
2091
1984
  console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
2092
1985
  break;
2093
1986
 
2094
1987
  }
2095
1988
 
2096
- } // vertex data
1989
+ }
2097
1990
 
1991
+ // vertex data
2098
1992
 
2099
1993
  const vertices = [];
2100
1994
  const normals = [];
2101
1995
  const colors = [];
2102
1996
  const uvs = [];
2103
-
2104
1997
  for ( let i = 0; i < zDimension; i ++ ) {
2105
1998
 
2106
1999
  for ( let j = 0; j < xDimension; j ++ ) {
2107
2000
 
2108
2001
  // compute a row major index
2109
- const index = i * xDimension + j; // vertices
2002
+
2003
+ const index = i * xDimension + j;
2004
+
2005
+ // vertices
2110
2006
 
2111
2007
  const x = xSpacing * i;
2112
2008
  const y = height[ index ];
2113
2009
  const z = zSpacing * j;
2114
- vertices.push( x, y, z ); // colors
2010
+ vertices.push( x, y, z );
2011
+
2012
+ // colors
2115
2013
 
2116
2014
  if ( color && colorPerVertex === true ) {
2117
2015
 
@@ -2120,8 +2018,9 @@
2120
2018
  const b = color[ index * 3 + 2 ];
2121
2019
  colors.push( r, g, b );
2122
2020
 
2123
- } // normals
2021
+ }
2124
2022
 
2023
+ // normals
2125
2024
 
2126
2025
  if ( normal && normalPerVertex === true ) {
2127
2026
 
@@ -2130,8 +2029,9 @@
2130
2029
  const zn = normal[ index * 3 + 2 ];
2131
2030
  normals.push( xn, yn, zn );
2132
2031
 
2133
- } // uvs
2032
+ }
2134
2033
 
2034
+ // uvs
2135
2035
 
2136
2036
  if ( texCoord ) {
2137
2037
 
@@ -2147,20 +2047,23 @@
2147
2047
 
2148
2048
  }
2149
2049
 
2150
- } // indices
2050
+ }
2151
2051
 
2052
+ // indices
2152
2053
 
2153
2054
  const indices = [];
2154
-
2155
2055
  for ( let i = 0; i < xDimension - 1; i ++ ) {
2156
2056
 
2157
2057
  for ( let j = 0; j < zDimension - 1; j ++ ) {
2158
2058
 
2159
2059
  // from https://tecfa.unige.ch/guides/vrml/vrml97/spec/part1/nodesRef.html#ElevationGrid
2060
+
2160
2061
  const a = i + j * xDimension;
2161
2062
  const b = i + ( j + 1 ) * xDimension;
2162
2063
  const c = i + 1 + ( j + 1 ) * xDimension;
2163
- const d = i + 1 + j * xDimension; // faces
2064
+ const d = i + 1 + j * xDimension;
2065
+
2066
+ // faces
2164
2067
 
2165
2068
  if ( ccw === true ) {
2166
2069
 
@@ -2176,13 +2079,16 @@
2176
2079
 
2177
2080
  }
2178
2081
 
2179
- } //
2082
+ }
2180
2083
 
2084
+ //
2181
2085
 
2182
2086
  const positionAttribute = toNonIndexedAttribute( indices, new THREE.Float32BufferAttribute( vertices, 3 ) );
2183
2087
  const uvAttribute = toNonIndexedAttribute( indices, new THREE.Float32BufferAttribute( uvs, 2 ) );
2184
2088
  let colorAttribute;
2185
- let normalAttribute; // color attribute
2089
+ let normalAttribute;
2090
+
2091
+ // color attribute
2186
2092
 
2187
2093
  if ( color ) {
2188
2094
 
@@ -2195,7 +2101,9 @@
2195
2101
  const index = i + j * ( xDimension - 1 );
2196
2102
  const r = color[ index * 3 + 0 ];
2197
2103
  const g = color[ index * 3 + 1 ];
2198
- const b = color[ index * 3 + 2 ]; // one color per quad
2104
+ const b = color[ index * 3 + 2 ];
2105
+
2106
+ // one color per quad
2199
2107
 
2200
2108
  colors.push( r, g, b );
2201
2109
  colors.push( r, g, b );
@@ -2216,8 +2124,9 @@
2216
2124
 
2217
2125
  }
2218
2126
 
2219
- } // normal attribute
2127
+ }
2220
2128
 
2129
+ // normal attribute
2221
2130
 
2222
2131
  if ( normal ) {
2223
2132
 
@@ -2230,7 +2139,9 @@
2230
2139
  const index = i + j * ( xDimension - 1 );
2231
2140
  const xn = normal[ index * 3 + 0 ];
2232
2141
  const yn = normal[ index * 3 + 1 ];
2233
- const zn = normal[ index * 3 + 2 ]; // one normal per quad
2142
+ const zn = normal[ index * 3 + 2 ];
2143
+
2144
+ // one normal per quad
2234
2145
 
2235
2146
  normals.push( xn, yn, zn );
2236
2147
  normals.push( xn, yn, zn );
@@ -2255,14 +2166,17 @@
2255
2166
 
2256
2167
  normalAttribute = computeNormalAttribute( indices, vertices, creaseAngle );
2257
2168
 
2258
- } // build geometry
2169
+ }
2259
2170
 
2171
+ // build geometry
2260
2172
 
2261
2173
  const geometry = new THREE.BufferGeometry();
2262
2174
  geometry.setAttribute( 'position', positionAttribute );
2263
2175
  geometry.setAttribute( 'normal', normalAttribute );
2264
2176
  geometry.setAttribute( 'uv', uvAttribute );
2265
- if ( colorAttribute ) geometry.setAttribute( 'color', colorAttribute ); // "solid" influences the material so let's store it for later use
2177
+ if ( colorAttribute ) geometry.setAttribute( 'color', colorAttribute );
2178
+
2179
+ // "solid" influences the material so let's store it for later use
2266
2180
 
2267
2181
  geometry._solid = solid;
2268
2182
  geometry._type = 'mesh';
@@ -2282,56 +2196,43 @@
2282
2196
  let endCap = true;
2283
2197
  let solid = true;
2284
2198
  const fields = node.fields;
2285
-
2286
2199
  for ( let i = 0, l = fields.length; i < l; i ++ ) {
2287
2200
 
2288
2201
  const field = fields[ i ];
2289
2202
  const fieldName = field.name;
2290
2203
  const fieldValues = field.values;
2291
-
2292
2204
  switch ( fieldName ) {
2293
2205
 
2294
2206
  case 'beginCap':
2295
2207
  beginCap = fieldValues[ 0 ];
2296
2208
  break;
2297
-
2298
2209
  case 'ccw':
2299
2210
  ccw = fieldValues[ 0 ];
2300
2211
  break;
2301
-
2302
2212
  case 'convex':
2303
2213
  // field not supported
2304
2214
  break;
2305
-
2306
2215
  case 'creaseAngle':
2307
2216
  creaseAngle = fieldValues[ 0 ];
2308
2217
  break;
2309
-
2310
2218
  case 'crossSection':
2311
2219
  crossSection = fieldValues;
2312
2220
  break;
2313
-
2314
2221
  case 'endCap':
2315
2222
  endCap = fieldValues[ 0 ];
2316
2223
  break;
2317
-
2318
2224
  case 'orientation':
2319
2225
  orientation = fieldValues;
2320
2226
  break;
2321
-
2322
2227
  case 'scale':
2323
2228
  scale = fieldValues;
2324
2229
  break;
2325
-
2326
2230
  case 'solid':
2327
2231
  solid = fieldValues[ 0 ];
2328
2232
  break;
2329
-
2330
2233
  case 'spine':
2331
2234
  spine = fieldValues; // only extrusion along the Y-axis are supported so far
2332
-
2333
2235
  break;
2334
-
2335
2236
  default:
2336
2237
  console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
2337
2238
  break;
@@ -2340,7 +2241,9 @@
2340
2241
 
2341
2242
  }
2342
2243
 
2343
- const crossSectionClosed = crossSection[ 0 ] === crossSection[ crossSection.length - 2 ] && crossSection[ 1 ] === crossSection[ crossSection.length - 1 ]; // vertices
2244
+ const crossSectionClosed = crossSection[ 0 ] === crossSection[ crossSection.length - 2 ] && crossSection[ 1 ] === crossSection[ crossSection.length - 1 ];
2245
+
2246
+ // vertices
2344
2247
 
2345
2248
  const vertices = [];
2346
2249
  const spineVector = new THREE.Vector3();
@@ -2348,7 +2251,6 @@
2348
2251
  const axis = new THREE.Vector3();
2349
2252
  const vertex = new THREE.Vector3();
2350
2253
  const quaternion = new THREE.Quaternion();
2351
-
2352
2254
  for ( let i = 0, j = 0, o = 0, il = spine.length; i < il; i += 3, j += 2, o += 4 ) {
2353
2255
 
2354
2256
  spineVector.fromArray( spine, i );
@@ -2359,30 +2261,35 @@
2359
2261
  axis.y = orientation ? orientation[ o + 1 ] : 0;
2360
2262
  axis.z = orientation ? orientation[ o + 2 ] : 1;
2361
2263
  const angle = orientation ? orientation[ o + 3 ] : 0;
2362
-
2363
2264
  for ( let k = 0, kl = crossSection.length; k < kl; k += 2 ) {
2364
2265
 
2365
2266
  vertex.x = crossSection[ k + 0 ];
2366
2267
  vertex.y = 0;
2367
- vertex.z = crossSection[ k + 1 ]; // scale
2268
+ vertex.z = crossSection[ k + 1 ];
2368
2269
 
2369
- vertex.multiply( scaling ); // rotate
2270
+ // scale
2271
+
2272
+ vertex.multiply( scaling );
2273
+
2274
+ // rotate
2370
2275
 
2371
2276
  quaternion.setFromAxisAngle( axis, angle );
2372
- vertex.applyQuaternion( quaternion ); // translate
2277
+ vertex.applyQuaternion( quaternion );
2278
+
2279
+ // translate
2373
2280
 
2374
2281
  vertex.add( spineVector );
2375
2282
  vertices.push( vertex.x, vertex.y, vertex.z );
2376
2283
 
2377
2284
  }
2378
2285
 
2379
- } // indices
2286
+ }
2380
2287
 
2288
+ // indices
2381
2289
 
2382
2290
  const indices = [];
2383
2291
  const spineCount = spine.length / 3;
2384
2292
  const crossSectionCount = crossSection.length / 2;
2385
-
2386
2293
  for ( let i = 0; i < spineCount - 1; i ++ ) {
2387
2294
 
2388
2295
  for ( let j = 0; j < crossSectionCount - 1; j ++ ) {
@@ -2391,7 +2298,6 @@
2391
2298
  let b = j + 1 + i * crossSectionCount;
2392
2299
  const c = j + ( i + 1 ) * crossSectionCount;
2393
2300
  let d = j + 1 + ( i + 1 ) * crossSectionCount;
2394
-
2395
2301
  if ( j === crossSectionCount - 2 && crossSectionClosed === true ) {
2396
2302
 
2397
2303
  b = i * crossSectionCount;
@@ -2413,13 +2319,13 @@
2413
2319
 
2414
2320
  }
2415
2321
 
2416
- } // triangulate cap
2322
+ }
2417
2323
 
2324
+ // triangulate cap
2418
2325
 
2419
2326
  if ( beginCap === true || endCap === true ) {
2420
2327
 
2421
2328
  const contour = [];
2422
-
2423
2329
  for ( let i = 0, l = crossSection.length; i < l; i += 2 ) {
2424
2330
 
2425
2331
  contour.push( new THREE.Vector2( crossSection[ i ], crossSection[ i + 1 ] ) );
@@ -2428,14 +2334,14 @@
2428
2334
 
2429
2335
  const faces = THREE.ShapeUtils.triangulateShape( contour, [] );
2430
2336
  const capIndices = [];
2431
-
2432
2337
  for ( let i = 0, l = faces.length; i < l; i ++ ) {
2433
2338
 
2434
2339
  const face = faces[ i ];
2435
2340
  capIndices.push( face[ 0 ], face[ 1 ], face[ 2 ] );
2436
2341
 
2437
- } // begin cap
2342
+ }
2438
2343
 
2344
+ // begin cap
2439
2345
 
2440
2346
  if ( beginCap === true ) {
2441
2347
 
@@ -2453,8 +2359,9 @@
2453
2359
 
2454
2360
  }
2455
2361
 
2456
- } // end cap
2362
+ }
2457
2363
 
2364
+ // end cap
2458
2365
 
2459
2366
  if ( endCap === true ) {
2460
2367
 
@@ -2482,20 +2389,25 @@
2482
2389
  const normalAttribute = computeNormalAttribute( indices, vertices, creaseAngle );
2483
2390
  const geometry = new THREE.BufferGeometry();
2484
2391
  geometry.setAttribute( 'position', positionAttribute );
2485
- geometry.setAttribute( 'normal', normalAttribute ); // no uvs yet
2392
+ geometry.setAttribute( 'normal', normalAttribute );
2393
+ // no uvs yet
2394
+
2486
2395
  // "solid" influences the material so let's store it for later use
2487
2396
 
2488
2397
  geometry._solid = solid;
2489
2398
  geometry._type = 'mesh';
2490
2399
  return geometry;
2491
2400
 
2492
- } // helper functions
2401
+ }
2493
2402
 
2403
+ // helper functions
2494
2404
 
2495
2405
  function resolveUSE( identifier ) {
2496
2406
 
2497
2407
  const node = nodeMap[ identifier ];
2498
- const build = getNode( node ); // because the same 3D objects can have different transformations, it's necessary to clone them.
2408
+ const build = getNode( node );
2409
+
2410
+ // because the same 3D objects can have different transformations, it's necessary to clone them.
2499
2411
  // materials can be influenced by the geometry (e.g. vertex normals). cloning is necessary to avoid
2500
2412
  // any side effects
2501
2413
 
@@ -2516,17 +2428,20 @@
2516
2428
 
2517
2429
  function triangulateFaceIndex( index, ccw ) {
2518
2430
 
2519
- const indices = []; // since face defintions can have more than three vertices, it's necessary to
2431
+ const indices = [];
2432
+
2433
+ // since face defintions can have more than three vertices, it's necessary to
2520
2434
  // perform a simple triangulation
2521
2435
 
2522
2436
  let start = 0;
2523
-
2524
2437
  for ( let i = 0, l = index.length; i < l; i ++ ) {
2525
2438
 
2526
2439
  const i1 = index[ start ];
2527
2440
  const i2 = index[ i + ( ccw ? 1 : 2 ) ];
2528
2441
  const i3 = index[ i + ( ccw ? 2 : 1 ) ];
2529
- indices.push( i1, i2, i3 ); // an index of -1 indicates that the current face has ended and the next one begins
2442
+ indices.push( i1, i2, i3 );
2443
+
2444
+ // an index of -1 indicates that the current face has ended and the next one begins
2530
2445
 
2531
2446
  if ( index[ i + 3 ] === - 1 || i + 3 >= l ) {
2532
2447
 
@@ -2545,14 +2460,15 @@
2545
2460
 
2546
2461
  const triangulatedData = [];
2547
2462
  let start = 0;
2548
-
2549
2463
  for ( let i = 0, l = index.length; i < l; i ++ ) {
2550
2464
 
2551
2465
  const stride = start * 3;
2552
2466
  const x = data[ stride ];
2553
2467
  const y = data[ stride + 1 ];
2554
2468
  const z = data[ stride + 2 ];
2555
- triangulatedData.push( x, y, z ); // an index of -1 indicates that the current face has ended and the next one begins
2469
+ triangulatedData.push( x, y, z );
2470
+
2471
+ // an index of -1 indicates that the current face has ended and the next one begins
2556
2472
 
2557
2473
  if ( index[ i + 3 ] === - 1 || i + 3 >= l ) {
2558
2474
 
@@ -2570,7 +2486,6 @@
2570
2486
  function flattenData( data, index ) {
2571
2487
 
2572
2488
  const flattenData = [];
2573
-
2574
2489
  for ( let i = 0, l = index.length; i < l; i ++ ) {
2575
2490
 
2576
2491
  const i1 = index[ i ];
@@ -2589,12 +2504,13 @@
2589
2504
  function expandLineIndex( index ) {
2590
2505
 
2591
2506
  const indices = [];
2592
-
2593
2507
  for ( let i = 0, l = index.length; i < l; i ++ ) {
2594
2508
 
2595
2509
  const i1 = index[ i ];
2596
2510
  const i2 = index[ i + 1 ];
2597
- indices.push( i1, i2 ); // an index of -1 indicates that the current line has ended and the next one begins
2511
+ indices.push( i1, i2 );
2512
+
2513
+ // an index of -1 indicates that the current line has ended and the next one begins
2598
2514
 
2599
2515
  if ( index[ i + 2 ] === - 1 || i + 2 >= l ) {
2600
2516
 
@@ -2612,14 +2528,15 @@
2612
2528
 
2613
2529
  const triangulatedData = [];
2614
2530
  let start = 0;
2615
-
2616
2531
  for ( let i = 0, l = index.length; i < l; i ++ ) {
2617
2532
 
2618
2533
  const stride = start * 3;
2619
2534
  const x = data[ stride ];
2620
2535
  const y = data[ stride + 1 ];
2621
2536
  const z = data[ stride + 2 ];
2622
- triangulatedData.push( x, y, z ); // an index of -1 indicates that the current line has ended and the next one begins
2537
+ triangulatedData.push( x, y, z );
2538
+
2539
+ // an index of -1 indicates that the current line has ended and the next one begins
2623
2540
 
2624
2541
  if ( index[ i + 2 ] === - 1 || i + 2 >= l ) {
2625
2542
 
@@ -2640,17 +2557,17 @@
2640
2557
  const uvA = new THREE.Vector2();
2641
2558
  const uvB = new THREE.Vector2();
2642
2559
  const uvC = new THREE.Vector2();
2643
-
2644
2560
  function computeAttributeFromIndexedData( coordIndex, index, data, itemSize ) {
2645
2561
 
2646
- const array = []; // we use the coordIndex.length as delimiter since normalIndex must contain at least as many indices
2562
+ const array = [];
2563
+
2564
+ // we use the coordIndex.length as delimiter since normalIndex must contain at least as many indices
2647
2565
 
2648
2566
  for ( let i = 0, l = coordIndex.length; i < l; i += 3 ) {
2649
2567
 
2650
2568
  const a = index[ i ];
2651
2569
  const b = index[ i + 1 ];
2652
2570
  const c = index[ i + 2 ];
2653
-
2654
2571
  if ( itemSize === 2 ) {
2655
2572
 
2656
2573
  uvA.fromArray( data, a * itemSize );
@@ -2680,7 +2597,6 @@
2680
2597
  function computeAttributeFromFaceData( index, faceData ) {
2681
2598
 
2682
2599
  const array = [];
2683
-
2684
2600
  for ( let i = 0, j = 0, l = index.length; i < l; i += 3, j ++ ) {
2685
2601
 
2686
2602
  vA.fromArray( faceData, j * 3 );
@@ -2697,7 +2613,6 @@
2697
2613
  function computeAttributeFromLineData( index, lineData ) {
2698
2614
 
2699
2615
  const array = [];
2700
-
2701
2616
  for ( let i = 0, j = 0, l = index.length; i < l; i += 2, j ++ ) {
2702
2617
 
2703
2618
  vA.fromArray( lineData, j * 3 );
@@ -2717,11 +2632,9 @@
2717
2632
  const array2 = new array.constructor( indices.length * itemSize );
2718
2633
  let index = 0,
2719
2634
  index2 = 0;
2720
-
2721
2635
  for ( let i = 0, l = indices.length; i < l; i ++ ) {
2722
2636
 
2723
2637
  index = indices[ i ] * itemSize;
2724
-
2725
2638
  for ( let j = 0; j < itemSize; j ++ ) {
2726
2639
 
2727
2640
  array2[ index2 ++ ] = array[ index ++ ];
@@ -2736,11 +2649,12 @@
2736
2649
 
2737
2650
  const ab = new THREE.Vector3();
2738
2651
  const cb = new THREE.Vector3();
2739
-
2740
2652
  function computeNormalAttribute( index, coord, creaseAngle ) {
2741
2653
 
2742
2654
  const faces = [];
2743
- const vertexNormals = {}; // prepare face and raw vertex normals
2655
+ const vertexNormals = {};
2656
+
2657
+ // prepare face and raw vertex normals
2744
2658
 
2745
2659
  for ( let i = 0, l = index.length; i < l; i += 3 ) {
2746
2660
 
@@ -2764,11 +2678,11 @@
2764
2678
  vertexNormals[ c ].push( face.normal );
2765
2679
  faces.push( face );
2766
2680
 
2767
- } // compute vertex normals and build final geometry
2681
+ }
2768
2682
 
2683
+ // compute vertex normals and build final geometry
2769
2684
 
2770
2685
  const normals = [];
2771
-
2772
2686
  for ( let i = 0, l = faces.length; i < l; i ++ ) {
2773
2687
 
2774
2688
  const face = faces[ i ];
@@ -2791,7 +2705,6 @@
2791
2705
  function weightedNormal( normals, vector, creaseAngle ) {
2792
2706
 
2793
2707
  const normal = new THREE.Vector3();
2794
-
2795
2708
  if ( creaseAngle === 0 ) {
2796
2709
 
2797
2710
  normal.copy( vector );
@@ -2817,7 +2730,6 @@
2817
2730
  function toColorArray( colors ) {
2818
2731
 
2819
2732
  const array = [];
2820
-
2821
2733
  for ( let i = 0, l = colors.length; i < l; i += 3 ) {
2822
2734
 
2823
2735
  array.push( new THREE.Color( colors[ i ], colors[ i + 1 ], colors[ i + 2 ] ) );
@@ -2827,6 +2739,7 @@
2827
2739
  return array;
2828
2740
 
2829
2741
  }
2742
+
2830
2743
  /**
2831
2744
  * Vertically paints the faces interpolating between the
2832
2745
  * specified colors at the specified angels. This is used for the Background
@@ -2849,14 +2762,12 @@
2849
2762
  * @param {array} colors
2850
2763
  * @param {boolean} topDown - Whether to work top down or bottom up.
2851
2764
  */
2852
-
2853
-
2854
2765
  function paintFaces( geometry, radius, angles, colors, topDown ) {
2855
2766
 
2856
2767
  // compute threshold values
2768
+
2857
2769
  const thresholds = [];
2858
2770
  const startAngle = topDown === true ? 0 : Math.PI;
2859
-
2860
2771
  for ( let i = 0, l = colors.length; i < l; i ++ ) {
2861
2772
 
2862
2773
  let angle = i === 0 ? 0 : angles[ i - 1 ];
@@ -2865,32 +2776,31 @@
2865
2776
  point.setFromSphericalCoords( radius, angle, 0 );
2866
2777
  thresholds.push( point );
2867
2778
 
2868
- } // generate vertex colors
2779
+ }
2869
2780
 
2781
+ // generate vertex colors
2870
2782
 
2871
2783
  const indices = geometry.index;
2872
2784
  const positionAttribute = geometry.attributes.position;
2873
2785
  const colorAttribute = new THREE.BufferAttribute( new Float32Array( geometry.attributes.position.count * 3 ), 3 );
2874
2786
  const position = new THREE.Vector3();
2875
2787
  const color = new THREE.Color();
2876
-
2877
2788
  for ( let i = 0; i < indices.count; i ++ ) {
2878
2789
 
2879
2790
  const index = indices.getX( i );
2880
2791
  position.fromBufferAttribute( positionAttribute, index );
2881
2792
  let thresholdIndexA, thresholdIndexB;
2882
2793
  let t = 1;
2883
-
2884
2794
  for ( let j = 1; j < thresholds.length; j ++ ) {
2885
2795
 
2886
2796
  thresholdIndexA = j - 1;
2887
2797
  thresholdIndexB = j;
2888
2798
  const thresholdA = thresholds[ thresholdIndexA ];
2889
2799
  const thresholdB = thresholds[ thresholdIndexB ];
2890
-
2891
2800
  if ( topDown === true ) {
2892
2801
 
2893
2802
  // interpolation for sky color
2803
+
2894
2804
  if ( position.y <= thresholdA.y && position.y > thresholdB.y ) {
2895
2805
 
2896
2806
  t = Math.abs( thresholdA.y - position.y ) / Math.abs( thresholdA.y - thresholdB.y );
@@ -2901,6 +2811,7 @@
2901
2811
  } else {
2902
2812
 
2903
2813
  // interpolation for ground color
2814
+
2904
2815
  if ( position.y >= thresholdA.y && position.y < thresholdB.y ) {
2905
2816
 
2906
2817
  t = Math.abs( thresholdA.y - position.y ) / Math.abs( thresholdA.y - thresholdB.y );
@@ -2921,20 +2832,26 @@
2921
2832
 
2922
2833
  geometry.setAttribute( 'color', colorAttribute );
2923
2834
 
2924
- } //
2835
+ }
2925
2836
 
2837
+ //
2926
2838
 
2927
2839
  const textureLoader = new THREE.TextureLoader( this.manager );
2928
- textureLoader.setPath( this.resourcePath || path ).setCrossOrigin( this.crossOrigin ); // check version (only 2.0 is supported)
2840
+ textureLoader.setPath( this.resourcePath || path ).setCrossOrigin( this.crossOrigin );
2841
+
2842
+ // check version (only 2.0 is supported)
2929
2843
 
2930
2844
  if ( data.indexOf( '#VRML V2.0' ) === - 1 ) {
2931
2845
 
2932
2846
  throw Error( 'THREE.VRMLLexer: Version of VRML asset not supported.' );
2933
2847
 
2934
- } // create JSON representing the tree structure of the VRML asset
2848
+ }
2849
+
2850
+ // create JSON representing the tree structure of the VRML asset
2935
2851
 
2852
+ const tree = generateVRMLTree( data );
2936
2853
 
2937
- const tree = generateVRMLTree( data ); // parse the tree structure to a three.js scene
2854
+ // parse the tree structure to a three.js scene
2938
2855
 
2939
2856
  const scene = parseTree( tree );
2940
2857
  return scene;
@@ -2942,7 +2859,6 @@
2942
2859
  }
2943
2860
 
2944
2861
  }
2945
-
2946
2862
  class VRMLLexer {
2947
2863
 
2948
2864
  constructor( tokens ) {
@@ -2954,7 +2870,6 @@
2954
2870
  lex( inputText ) {
2955
2871
 
2956
2872
  const lexingResult = this.lexer.tokenize( inputText );
2957
-
2958
2873
  if ( lexingResult.errors.length > 0 ) {
2959
2874
 
2960
2875
  console.error( lexingResult.errors );
@@ -2967,7 +2882,6 @@
2967
2882
  }
2968
2883
 
2969
2884
  }
2970
-
2971
2885
  const CstParser = chevrotain.CstParser; // eslint-disable-line no-undef
2972
2886
 
2973
2887
  class VRMLParser extends CstParser {
@@ -3202,7 +3116,6 @@
3202
3116
  }
3203
3117
 
3204
3118
  }
3205
-
3206
3119
  class Face {
3207
3120
 
3208
3121
  constructor( a, b, c ) {
@@ -3215,7 +3128,6 @@
3215
3128
  }
3216
3129
 
3217
3130
  }
3218
-
3219
3131
  const TEXTURE_TYPE = {
3220
3132
  INTENSITY: 1,
3221
3133
  INTENSITY_ALPHA: 2,