@gnsx/three 0.184.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 (1182) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +85 -0
  3. package/build/three.cjs +79695 -0
  4. package/build/three.core.js +59732 -0
  5. package/build/three.core.min.js +6 -0
  6. package/build/three.module.js +19552 -0
  7. package/build/three.module.min.js +6 -0
  8. package/build/three.tsl.js +654 -0
  9. package/build/three.tsl.min.js +6 -0
  10. package/build/three.webgpu.js +83969 -0
  11. package/build/three.webgpu.min.js +6 -0
  12. package/build/three.webgpu.nodes.js +83702 -0
  13. package/build/three.webgpu.nodes.min.js +6 -0
  14. package/examples/fonts/LICENSE +13 -0
  15. package/examples/fonts/MPLUSRounded1c/MPLUSRounded1c-Regular.typeface.json.zip +0 -0
  16. package/examples/fonts/MPLUSRounded1c/OFL.txt +91 -0
  17. package/examples/fonts/README.md +11 -0
  18. package/examples/fonts/droid/NOTICE +190 -0
  19. package/examples/fonts/droid/README.txt +18 -0
  20. package/examples/fonts/droid/droid_sans_bold.typeface.json +1 -0
  21. package/examples/fonts/droid/droid_sans_mono_regular.typeface.json +1 -0
  22. package/examples/fonts/droid/droid_sans_regular.typeface.json +1 -0
  23. package/examples/fonts/droid/droid_serif_bold.typeface.json +1 -0
  24. package/examples/fonts/droid/droid_serif_regular.typeface.json +1 -0
  25. package/examples/fonts/gentilis_bold.typeface.json +1 -0
  26. package/examples/fonts/gentilis_regular.typeface.json +1 -0
  27. package/examples/fonts/helvetiker_bold.typeface.json +1 -0
  28. package/examples/fonts/helvetiker_regular.typeface.json +1 -0
  29. package/examples/fonts/optimer_bold.typeface.json +1 -0
  30. package/examples/fonts/optimer_regular.typeface.json +1 -0
  31. package/examples/fonts/ttf/README.md +9 -0
  32. package/examples/fonts/ttf/kenpixel.ttf +0 -0
  33. package/examples/jsm/Addons.js +293 -0
  34. package/examples/jsm/animation/AnimationClipCreator.js +168 -0
  35. package/examples/jsm/animation/CCDIKSolver.js +595 -0
  36. package/examples/jsm/capabilities/WebGL.js +113 -0
  37. package/examples/jsm/capabilities/WebGPU.js +59 -0
  38. package/examples/jsm/controls/ArcballControls.js +3539 -0
  39. package/examples/jsm/controls/DragControls.js +452 -0
  40. package/examples/jsm/controls/FirstPersonControls.js +451 -0
  41. package/examples/jsm/controls/FlyControls.js +384 -0
  42. package/examples/jsm/controls/MapControls.js +116 -0
  43. package/examples/jsm/controls/OrbitControls.js +1963 -0
  44. package/examples/jsm/controls/PointerLockControls.js +264 -0
  45. package/examples/jsm/controls/TrackballControls.js +1001 -0
  46. package/examples/jsm/controls/TransformControls.js +1950 -0
  47. package/examples/jsm/csm/CSM.js +598 -0
  48. package/examples/jsm/csm/CSMFrustum.js +209 -0
  49. package/examples/jsm/csm/CSMHelper.js +243 -0
  50. package/examples/jsm/csm/CSMShader.js +307 -0
  51. package/examples/jsm/csm/CSMShadowNode.js +603 -0
  52. package/examples/jsm/curves/CurveExtras.js +694 -0
  53. package/examples/jsm/curves/NURBSCurve.js +155 -0
  54. package/examples/jsm/curves/NURBSSurface.js +98 -0
  55. package/examples/jsm/curves/NURBSUtils.js +532 -0
  56. package/examples/jsm/curves/NURBSVolume.js +82 -0
  57. package/examples/jsm/effects/AnaglyphEffect.js +274 -0
  58. package/examples/jsm/effects/AsciiEffect.js +310 -0
  59. package/examples/jsm/effects/OutlineEffect.js +489 -0
  60. package/examples/jsm/effects/ParallaxBarrierEffect.js +155 -0
  61. package/examples/jsm/effects/StereoEffect.js +91 -0
  62. package/examples/jsm/environments/ColorEnvironment.js +59 -0
  63. package/examples/jsm/environments/DebugEnvironment.js +102 -0
  64. package/examples/jsm/environments/RoomEnvironment.js +185 -0
  65. package/examples/jsm/exporters/DRACOExporter.js +311 -0
  66. package/examples/jsm/exporters/EXRExporter.js +618 -0
  67. package/examples/jsm/exporters/GLTFExporter.js +3738 -0
  68. package/examples/jsm/exporters/KTX2Exporter.js +347 -0
  69. package/examples/jsm/exporters/OBJExporter.js +308 -0
  70. package/examples/jsm/exporters/PLYExporter.js +562 -0
  71. package/examples/jsm/exporters/STLExporter.js +221 -0
  72. package/examples/jsm/exporters/USDZExporter.js +1254 -0
  73. package/examples/jsm/geometries/BoxLineGeometry.js +92 -0
  74. package/examples/jsm/geometries/ConvexGeometry.js +72 -0
  75. package/examples/jsm/geometries/DecalGeometry.js +420 -0
  76. package/examples/jsm/geometries/ParametricFunctions.js +100 -0
  77. package/examples/jsm/geometries/ParametricGeometry.js +172 -0
  78. package/examples/jsm/geometries/RoundedBoxGeometry.js +216 -0
  79. package/examples/jsm/geometries/TeapotGeometry.js +689 -0
  80. package/examples/jsm/geometries/TextGeometry.js +102 -0
  81. package/examples/jsm/gpgpu/BitonicSort.js +715 -0
  82. package/examples/jsm/helpers/AnimationPathHelper.js +302 -0
  83. package/examples/jsm/helpers/LightProbeGridHelper.js +221 -0
  84. package/examples/jsm/helpers/LightProbeHelper.js +165 -0
  85. package/examples/jsm/helpers/LightProbeHelperGPU.js +102 -0
  86. package/examples/jsm/helpers/OctreeHelper.js +109 -0
  87. package/examples/jsm/helpers/PositionalAudioHelper.js +169 -0
  88. package/examples/jsm/helpers/RapierHelper.js +59 -0
  89. package/examples/jsm/helpers/RectAreaLightHelper.js +118 -0
  90. package/examples/jsm/helpers/TextureHelper.js +265 -0
  91. package/examples/jsm/helpers/TextureHelperGPU.js +214 -0
  92. package/examples/jsm/helpers/VertexNormalsHelper.js +155 -0
  93. package/examples/jsm/helpers/VertexTangentsHelper.js +133 -0
  94. package/examples/jsm/helpers/ViewHelper.js +519 -0
  95. package/examples/jsm/inspector/Extension.js +13 -0
  96. package/examples/jsm/inspector/Inspector.js +542 -0
  97. package/examples/jsm/inspector/RendererInspector.js +425 -0
  98. package/examples/jsm/inspector/extensions/extensions.json +6 -0
  99. package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.js +916 -0
  100. package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.js +281 -0
  101. package/examples/jsm/inspector/tabs/Console.js +238 -0
  102. package/examples/jsm/inspector/tabs/Memory.js +128 -0
  103. package/examples/jsm/inspector/tabs/Parameters.js +380 -0
  104. package/examples/jsm/inspector/tabs/Performance.js +268 -0
  105. package/examples/jsm/inspector/tabs/Settings.js +264 -0
  106. package/examples/jsm/inspector/tabs/Timeline.js +1611 -0
  107. package/examples/jsm/inspector/tabs/Viewer.js +268 -0
  108. package/examples/jsm/inspector/ui/Graph.js +95 -0
  109. package/examples/jsm/inspector/ui/Item.js +170 -0
  110. package/examples/jsm/inspector/ui/List.js +75 -0
  111. package/examples/jsm/inspector/ui/Profiler.js +2072 -0
  112. package/examples/jsm/inspector/ui/Style.js +1667 -0
  113. package/examples/jsm/inspector/ui/Tab.js +265 -0
  114. package/examples/jsm/inspector/ui/Values.js +476 -0
  115. package/examples/jsm/inspector/ui/utils.js +69 -0
  116. package/examples/jsm/interaction/InteractionManager.js +226 -0
  117. package/examples/jsm/interactive/HTMLMesh.js +601 -0
  118. package/examples/jsm/interactive/InteractiveGroup.js +224 -0
  119. package/examples/jsm/interactive/SelectionBox.js +324 -0
  120. package/examples/jsm/interactive/SelectionHelper.js +150 -0
  121. package/examples/jsm/libs/ammo.wasm.js +822 -0
  122. package/examples/jsm/libs/ammo.wasm.wasm +0 -0
  123. package/examples/jsm/libs/basis/README.md +46 -0
  124. package/examples/jsm/libs/basis/basis_transcoder.js +19 -0
  125. package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
  126. package/examples/jsm/libs/chevrotain.module.min.js +141 -0
  127. package/examples/jsm/libs/demuxer_mp4.js +109 -0
  128. package/examples/jsm/libs/draco/README.md +32 -0
  129. package/examples/jsm/libs/draco/draco_decoder.js +34 -0
  130. package/examples/jsm/libs/draco/draco_decoder.wasm +0 -0
  131. package/examples/jsm/libs/draco/draco_encoder.js +33 -0
  132. package/examples/jsm/libs/draco/draco_wasm_wrapper.js +117 -0
  133. package/examples/jsm/libs/draco/gltf/draco_decoder.js +33 -0
  134. package/examples/jsm/libs/draco/gltf/draco_decoder.wasm +0 -0
  135. package/examples/jsm/libs/draco/gltf/draco_encoder.js +33 -0
  136. package/examples/jsm/libs/draco/gltf/draco_wasm_wrapper.js +116 -0
  137. package/examples/jsm/libs/ecsy.module.js +1792 -0
  138. package/examples/jsm/libs/fflate.module.js +2672 -0
  139. package/examples/jsm/libs/ktx-parse.module.js +1 -0
  140. package/examples/jsm/libs/lil-gui.module.min.js +8 -0
  141. package/examples/jsm/libs/lottie_canvas.module.js +14849 -0
  142. package/examples/jsm/libs/meshopt_decoder.module.js +196 -0
  143. package/examples/jsm/libs/mikktspace.module.js +128 -0
  144. package/examples/jsm/libs/motion-controllers.module.js +397 -0
  145. package/examples/jsm/libs/opentype.module.js +14506 -0
  146. package/examples/jsm/libs/potpack.module.js +125 -0
  147. package/examples/jsm/libs/rhino3dm/rhino3dm.js +21 -0
  148. package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +16 -0
  149. package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
  150. package/examples/jsm/libs/stats.module.js +167 -0
  151. package/examples/jsm/libs/surfaceNet.js +201 -0
  152. package/examples/jsm/libs/tween.module.js +876 -0
  153. package/examples/jsm/libs/utif.module.js +1665 -0
  154. package/examples/jsm/libs/zstddec.module.js +1 -0
  155. package/examples/jsm/lighting/DynamicLighting.js +82 -0
  156. package/examples/jsm/lighting/LightProbeGrid.js +651 -0
  157. package/examples/jsm/lighting/TiledLighting.js +42 -0
  158. package/examples/jsm/lights/LightProbeGenerator.js +337 -0
  159. package/examples/jsm/lights/RectAreaLightTexturesLib.js +127 -0
  160. package/examples/jsm/lights/RectAreaLightUniformsLib.js +40 -0
  161. package/examples/jsm/lines/Line2.js +56 -0
  162. package/examples/jsm/lines/LineGeometry.js +157 -0
  163. package/examples/jsm/lines/LineMaterial.js +703 -0
  164. package/examples/jsm/lines/LineSegments2.js +426 -0
  165. package/examples/jsm/lines/LineSegmentsGeometry.js +298 -0
  166. package/examples/jsm/lines/Wireframe.js +108 -0
  167. package/examples/jsm/lines/WireframeGeometry2.js +49 -0
  168. package/examples/jsm/lines/webgpu/Line2.js +46 -0
  169. package/examples/jsm/lines/webgpu/LineSegments2.js +411 -0
  170. package/examples/jsm/lines/webgpu/Wireframe.js +86 -0
  171. package/examples/jsm/loaders/3DMLoader.js +1836 -0
  172. package/examples/jsm/loaders/3MFLoader.js +1621 -0
  173. package/examples/jsm/loaders/AMFLoader.js +541 -0
  174. package/examples/jsm/loaders/BVHLoader.js +484 -0
  175. package/examples/jsm/loaders/ColladaLoader.js +153 -0
  176. package/examples/jsm/loaders/DDSLoader.js +385 -0
  177. package/examples/jsm/loaders/DRACOLoader.js +739 -0
  178. package/examples/jsm/loaders/EXRLoader.js +3423 -0
  179. package/examples/jsm/loaders/FBXLoader.js +4580 -0
  180. package/examples/jsm/loaders/FontLoader.js +260 -0
  181. package/examples/jsm/loaders/GCodeLoader.js +318 -0
  182. package/examples/jsm/loaders/GLTFLoader.js +4860 -0
  183. package/examples/jsm/loaders/HDRCubeTextureLoader.js +164 -0
  184. package/examples/jsm/loaders/HDRLoader.js +485 -0
  185. package/examples/jsm/loaders/IESLoader.js +379 -0
  186. package/examples/jsm/loaders/KMZLoader.js +163 -0
  187. package/examples/jsm/loaders/KTX2Loader.js +1257 -0
  188. package/examples/jsm/loaders/KTXLoader.js +197 -0
  189. package/examples/jsm/loaders/LDrawLoader.js +2510 -0
  190. package/examples/jsm/loaders/LUT3dlLoader.js +205 -0
  191. package/examples/jsm/loaders/LUTCubeLoader.js +190 -0
  192. package/examples/jsm/loaders/LUTImageLoader.js +190 -0
  193. package/examples/jsm/loaders/LWOLoader.js +1047 -0
  194. package/examples/jsm/loaders/LottieLoader.js +130 -0
  195. package/examples/jsm/loaders/MD2Loader.js +435 -0
  196. package/examples/jsm/loaders/MDDLoader.js +147 -0
  197. package/examples/jsm/loaders/MTLLoader.js +593 -0
  198. package/examples/jsm/loaders/MaterialXLoader.js +1104 -0
  199. package/examples/jsm/loaders/NRRDLoader.js +718 -0
  200. package/examples/jsm/loaders/OBJLoader.js +955 -0
  201. package/examples/jsm/loaders/PCDLoader.js +620 -0
  202. package/examples/jsm/loaders/PDBLoader.js +272 -0
  203. package/examples/jsm/loaders/PLYLoader.js +805 -0
  204. package/examples/jsm/loaders/PVRLoader.js +270 -0
  205. package/examples/jsm/loaders/RGBELoader.js +18 -0
  206. package/examples/jsm/loaders/STLLoader.js +421 -0
  207. package/examples/jsm/loaders/SVGLoader.js +3267 -0
  208. package/examples/jsm/loaders/TDSLoader.js +1142 -0
  209. package/examples/jsm/loaders/TGALoader.js +538 -0
  210. package/examples/jsm/loaders/TIFFLoader.js +59 -0
  211. package/examples/jsm/loaders/TTFLoader.js +261 -0
  212. package/examples/jsm/loaders/USDLoader.js +279 -0
  213. package/examples/jsm/loaders/USDZLoader.js +16 -0
  214. package/examples/jsm/loaders/UltraHDRLoader.js +755 -0
  215. package/examples/jsm/loaders/VOXLoader.js +919 -0
  216. package/examples/jsm/loaders/VRMLLoader.js +3646 -0
  217. package/examples/jsm/loaders/VTKLoader.js +1293 -0
  218. package/examples/jsm/loaders/XYZLoader.js +143 -0
  219. package/examples/jsm/loaders/collada/ColladaComposer.js +3044 -0
  220. package/examples/jsm/loaders/collada/ColladaParser.js +1977 -0
  221. package/examples/jsm/loaders/lwo/IFFParser.js +1217 -0
  222. package/examples/jsm/loaders/lwo/LWO2Parser.js +414 -0
  223. package/examples/jsm/loaders/lwo/LWO3Parser.js +373 -0
  224. package/examples/jsm/loaders/usd/USDAParser.js +828 -0
  225. package/examples/jsm/loaders/usd/USDCParser.js +1878 -0
  226. package/examples/jsm/loaders/usd/USDComposer.js +4594 -0
  227. package/examples/jsm/materials/LDrawConditionalLineMaterial.js +183 -0
  228. package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +154 -0
  229. package/examples/jsm/materials/WoodNodeMaterial.js +533 -0
  230. package/examples/jsm/math/Capsule.js +159 -0
  231. package/examples/jsm/math/ColorConverter.js +58 -0
  232. package/examples/jsm/math/ColorSpaces.js +147 -0
  233. package/examples/jsm/math/ConvexHull.js +1695 -0
  234. package/examples/jsm/math/ImprovedNoise.js +88 -0
  235. package/examples/jsm/math/Lut.js +317 -0
  236. package/examples/jsm/math/MeshSurfaceSampler.js +315 -0
  237. package/examples/jsm/math/OBB.js +535 -0
  238. package/examples/jsm/math/Octree.js +822 -0
  239. package/examples/jsm/math/SimplexNoise.js +470 -0
  240. package/examples/jsm/misc/ConvexObjectBreaker.js +539 -0
  241. package/examples/jsm/misc/GPUComputationRenderer.js +508 -0
  242. package/examples/jsm/misc/Gyroscope.js +78 -0
  243. package/examples/jsm/misc/MD2Character.js +391 -0
  244. package/examples/jsm/misc/MD2CharacterComplex.js +740 -0
  245. package/examples/jsm/misc/MorphAnimMesh.js +119 -0
  246. package/examples/jsm/misc/MorphBlendMesh.js +425 -0
  247. package/examples/jsm/misc/ProgressiveLightMap.js +370 -0
  248. package/examples/jsm/misc/ProgressiveLightMapGPU.js +322 -0
  249. package/examples/jsm/misc/RollerCoaster.js +661 -0
  250. package/examples/jsm/misc/TubePainter.js +599 -0
  251. package/examples/jsm/misc/Volume.js +520 -0
  252. package/examples/jsm/misc/VolumeSlice.js +275 -0
  253. package/examples/jsm/modifiers/CurveModifier.js +374 -0
  254. package/examples/jsm/modifiers/CurveModifierGPU.js +256 -0
  255. package/examples/jsm/modifiers/EdgeSplitModifier.js +299 -0
  256. package/examples/jsm/modifiers/SimplifyModifier.js +632 -0
  257. package/examples/jsm/modifiers/TessellateModifier.js +340 -0
  258. package/examples/jsm/objects/GroundedSkybox.js +69 -0
  259. package/examples/jsm/objects/Lensflare.js +489 -0
  260. package/examples/jsm/objects/LensflareMesh.js +376 -0
  261. package/examples/jsm/objects/MarchingCubes.js +1261 -0
  262. package/examples/jsm/objects/Reflector.js +386 -0
  263. package/examples/jsm/objects/ReflectorForSSRPass.js +393 -0
  264. package/examples/jsm/objects/Refractor.js +389 -0
  265. package/examples/jsm/objects/ShadowMesh.js +130 -0
  266. package/examples/jsm/objects/Sky.js +321 -0
  267. package/examples/jsm/objects/SkyMesh.js +377 -0
  268. package/examples/jsm/objects/Water.js +374 -0
  269. package/examples/jsm/objects/Water2.js +403 -0
  270. package/examples/jsm/objects/Water2Mesh.js +199 -0
  271. package/examples/jsm/objects/WaterMesh.js +194 -0
  272. package/examples/jsm/offscreen/jank.js +45 -0
  273. package/examples/jsm/offscreen/offscreen.js +8 -0
  274. package/examples/jsm/offscreen/scene.js +86 -0
  275. package/examples/jsm/physics/AmmoPhysics.js +359 -0
  276. package/examples/jsm/physics/JoltPhysics.js +334 -0
  277. package/examples/jsm/physics/RapierPhysics.js +436 -0
  278. package/examples/jsm/postprocessing/AfterimagePass.js +185 -0
  279. package/examples/jsm/postprocessing/BloomPass.js +274 -0
  280. package/examples/jsm/postprocessing/BokehPass.js +218 -0
  281. package/examples/jsm/postprocessing/ClearPass.js +97 -0
  282. package/examples/jsm/postprocessing/CubeTexturePass.js +146 -0
  283. package/examples/jsm/postprocessing/DotScreenPass.js +114 -0
  284. package/examples/jsm/postprocessing/EffectComposer.js +365 -0
  285. package/examples/jsm/postprocessing/FXAAPass.js +40 -0
  286. package/examples/jsm/postprocessing/FilmPass.js +113 -0
  287. package/examples/jsm/postprocessing/GTAOPass.js +727 -0
  288. package/examples/jsm/postprocessing/GlitchPass.js +177 -0
  289. package/examples/jsm/postprocessing/HalftonePass.js +134 -0
  290. package/examples/jsm/postprocessing/LUTPass.js +138 -0
  291. package/examples/jsm/postprocessing/MaskPass.js +195 -0
  292. package/examples/jsm/postprocessing/OutlinePass.js +776 -0
  293. package/examples/jsm/postprocessing/OutputPass.js +148 -0
  294. package/examples/jsm/postprocessing/Pass.js +191 -0
  295. package/examples/jsm/postprocessing/RenderPass.js +193 -0
  296. package/examples/jsm/postprocessing/RenderPixelatedPass.js +314 -0
  297. package/examples/jsm/postprocessing/RenderTransitionPass.js +267 -0
  298. package/examples/jsm/postprocessing/SAOPass.js +407 -0
  299. package/examples/jsm/postprocessing/SMAAPass.js +230 -0
  300. package/examples/jsm/postprocessing/SSAARenderPass.js +313 -0
  301. package/examples/jsm/postprocessing/SSAOPass.js +527 -0
  302. package/examples/jsm/postprocessing/SSRPass.js +856 -0
  303. package/examples/jsm/postprocessing/SavePass.js +132 -0
  304. package/examples/jsm/postprocessing/ShaderPass.js +135 -0
  305. package/examples/jsm/postprocessing/TAARenderPass.js +243 -0
  306. package/examples/jsm/postprocessing/TexturePass.js +131 -0
  307. package/examples/jsm/postprocessing/UnrealBloomPass.js +524 -0
  308. package/examples/jsm/renderers/CSS2DRenderer.js +328 -0
  309. package/examples/jsm/renderers/CSS3DRenderer.js +454 -0
  310. package/examples/jsm/renderers/Projector.js +1154 -0
  311. package/examples/jsm/renderers/SVGRenderer.js +799 -0
  312. package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +96 -0
  313. package/examples/jsm/shaders/AfterimageShader.js +63 -0
  314. package/examples/jsm/shaders/BasicShader.js +36 -0
  315. package/examples/jsm/shaders/BleachBypassShader.js +68 -0
  316. package/examples/jsm/shaders/BlendShader.js +56 -0
  317. package/examples/jsm/shaders/BokehShader.js +151 -0
  318. package/examples/jsm/shaders/BokehShader2.js +404 -0
  319. package/examples/jsm/shaders/BrightnessContrastShader.js +62 -0
  320. package/examples/jsm/shaders/ColorCorrectionShader.js +59 -0
  321. package/examples/jsm/shaders/ColorifyShader.js +57 -0
  322. package/examples/jsm/shaders/ConvolutionShader.js +74 -0
  323. package/examples/jsm/shaders/CopyShader.js +52 -0
  324. package/examples/jsm/shaders/DOFMipMapShader.js +63 -0
  325. package/examples/jsm/shaders/DepthLimitedBlurShader.js +180 -0
  326. package/examples/jsm/shaders/DigitalGlitch.js +104 -0
  327. package/examples/jsm/shaders/DotScreenShader.js +75 -0
  328. package/examples/jsm/shaders/ExposureShader.js +51 -0
  329. package/examples/jsm/shaders/FXAAShader.js +298 -0
  330. package/examples/jsm/shaders/FilmShader.js +72 -0
  331. package/examples/jsm/shaders/FocusShader.js +94 -0
  332. package/examples/jsm/shaders/FreiChenShader.js +103 -0
  333. package/examples/jsm/shaders/GTAOShader.js +434 -0
  334. package/examples/jsm/shaders/GammaCorrectionShader.js +52 -0
  335. package/examples/jsm/shaders/HalftoneShader.js +332 -0
  336. package/examples/jsm/shaders/HorizontalBlurShader.js +68 -0
  337. package/examples/jsm/shaders/HorizontalTiltShiftShader.js +70 -0
  338. package/examples/jsm/shaders/HueSaturationShader.js +74 -0
  339. package/examples/jsm/shaders/KaleidoShader.js +65 -0
  340. package/examples/jsm/shaders/LuminosityHighPassShader.js +68 -0
  341. package/examples/jsm/shaders/LuminosityShader.js +54 -0
  342. package/examples/jsm/shaders/MirrorShader.js +62 -0
  343. package/examples/jsm/shaders/NormalMapShader.js +60 -0
  344. package/examples/jsm/shaders/OutputShader.js +103 -0
  345. package/examples/jsm/shaders/PoissonDenoiseShader.js +239 -0
  346. package/examples/jsm/shaders/RGBShiftShader.js +61 -0
  347. package/examples/jsm/shaders/SAOShader.js +201 -0
  348. package/examples/jsm/shaders/SMAAShader.js +489 -0
  349. package/examples/jsm/shaders/SSAOShader.js +331 -0
  350. package/examples/jsm/shaders/SSRShader.js +396 -0
  351. package/examples/jsm/shaders/SepiaShader.js +57 -0
  352. package/examples/jsm/shaders/SobelOperatorShader.js +98 -0
  353. package/examples/jsm/shaders/SubsurfaceScatteringShader.js +95 -0
  354. package/examples/jsm/shaders/TechnicolorShader.js +51 -0
  355. package/examples/jsm/shaders/ToonShader.js +349 -0
  356. package/examples/jsm/shaders/TriangleBlurShader.js +79 -0
  357. package/examples/jsm/shaders/UnpackDepthRGBAShader.js +60 -0
  358. package/examples/jsm/shaders/VelocityShader.js +137 -0
  359. package/examples/jsm/shaders/VerticalBlurShader.js +66 -0
  360. package/examples/jsm/shaders/VerticalTiltShiftShader.js +70 -0
  361. package/examples/jsm/shaders/VignetteShader.js +56 -0
  362. package/examples/jsm/shaders/VolumeShader.js +298 -0
  363. package/examples/jsm/shaders/WaterRefractionShader.js +106 -0
  364. package/examples/jsm/textures/FlakesTexture.js +54 -0
  365. package/examples/jsm/transpiler/AST.js +675 -0
  366. package/examples/jsm/transpiler/GLSLDecoder.js +1228 -0
  367. package/examples/jsm/transpiler/Linker.js +327 -0
  368. package/examples/jsm/transpiler/ShaderToyDecoder.js +51 -0
  369. package/examples/jsm/transpiler/TSLEncoder.js +983 -0
  370. package/examples/jsm/transpiler/Transpiler.js +67 -0
  371. package/examples/jsm/transpiler/TranspilerUtils.js +29 -0
  372. package/examples/jsm/transpiler/WGSLEncoder.js +839 -0
  373. package/examples/jsm/tsl/WebGLNodesHandler.js +605 -0
  374. package/examples/jsm/tsl/display/AfterImageNode.js +254 -0
  375. package/examples/jsm/tsl/display/AnaglyphPassNode.js +549 -0
  376. package/examples/jsm/tsl/display/AnamorphicNode.js +293 -0
  377. package/examples/jsm/tsl/display/BilateralBlurNode.js +374 -0
  378. package/examples/jsm/tsl/display/BleachBypass.js +33 -0
  379. package/examples/jsm/tsl/display/BloomNode.js +534 -0
  380. package/examples/jsm/tsl/display/CRT.js +150 -0
  381. package/examples/jsm/tsl/display/ChromaticAberrationNode.js +174 -0
  382. package/examples/jsm/tsl/display/DenoiseNode.js +334 -0
  383. package/examples/jsm/tsl/display/DepthOfFieldNode.js +554 -0
  384. package/examples/jsm/tsl/display/DotScreenNode.js +104 -0
  385. package/examples/jsm/tsl/display/FSR1Node.js +477 -0
  386. package/examples/jsm/tsl/display/FXAANode.js +365 -0
  387. package/examples/jsm/tsl/display/FilmNode.js +101 -0
  388. package/examples/jsm/tsl/display/GTAONode.js +572 -0
  389. package/examples/jsm/tsl/display/GaussianBlurNode.js +399 -0
  390. package/examples/jsm/tsl/display/GodraysNode.js +615 -0
  391. package/examples/jsm/tsl/display/LensflareNode.js +279 -0
  392. package/examples/jsm/tsl/display/Lut3DNode.js +109 -0
  393. package/examples/jsm/tsl/display/MotionBlur.js +33 -0
  394. package/examples/jsm/tsl/display/OutlineNode.js +812 -0
  395. package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +89 -0
  396. package/examples/jsm/tsl/display/PixelationPassNode.js +335 -0
  397. package/examples/jsm/tsl/display/RGBShiftNode.js +96 -0
  398. package/examples/jsm/tsl/display/RetroPassNode.js +263 -0
  399. package/examples/jsm/tsl/display/SMAANode.js +768 -0
  400. package/examples/jsm/tsl/display/SSAAPassNode.js +358 -0
  401. package/examples/jsm/tsl/display/SSGINode.js +638 -0
  402. package/examples/jsm/tsl/display/SSRNode.js +656 -0
  403. package/examples/jsm/tsl/display/SSSNode.js +490 -0
  404. package/examples/jsm/tsl/display/Sepia.js +24 -0
  405. package/examples/jsm/tsl/display/Shape.js +29 -0
  406. package/examples/jsm/tsl/display/SharpenNode.js +283 -0
  407. package/examples/jsm/tsl/display/SobelOperatorNode.js +168 -0
  408. package/examples/jsm/tsl/display/StereoCompositePassNode.js +192 -0
  409. package/examples/jsm/tsl/display/StereoPassNode.js +119 -0
  410. package/examples/jsm/tsl/display/TAAUNode.js +835 -0
  411. package/examples/jsm/tsl/display/TRAANode.js +767 -0
  412. package/examples/jsm/tsl/display/TransitionNode.js +141 -0
  413. package/examples/jsm/tsl/display/boxBlur.js +65 -0
  414. package/examples/jsm/tsl/display/depthAwareBlend.js +80 -0
  415. package/examples/jsm/tsl/display/hashBlur.js +54 -0
  416. package/examples/jsm/tsl/display/radialBlur.js +68 -0
  417. package/examples/jsm/tsl/lighting/DynamicLightsNode.js +300 -0
  418. package/examples/jsm/tsl/lighting/TiledLightsNode.js +442 -0
  419. package/examples/jsm/tsl/lighting/data/AmbientLightDataNode.js +61 -0
  420. package/examples/jsm/tsl/lighting/data/DirectionalLightDataNode.js +111 -0
  421. package/examples/jsm/tsl/lighting/data/HemisphereLightDataNode.js +99 -0
  422. package/examples/jsm/tsl/lighting/data/PointLightDataNode.js +134 -0
  423. package/examples/jsm/tsl/lighting/data/SpotLightDataNode.js +161 -0
  424. package/examples/jsm/tsl/math/Bayer.js +84 -0
  425. package/examples/jsm/tsl/shadows/TileShadowNode.js +456 -0
  426. package/examples/jsm/tsl/shadows/TileShadowNodeHelper.js +212 -0
  427. package/examples/jsm/tsl/utils/Raymarching.js +70 -0
  428. package/examples/jsm/utils/BufferGeometryUtils.js +1434 -0
  429. package/examples/jsm/utils/CameraUtils.js +82 -0
  430. package/examples/jsm/utils/ColorUtils.js +76 -0
  431. package/examples/jsm/utils/GeometryCompressionUtils.js +547 -0
  432. package/examples/jsm/utils/GeometryUtils.js +226 -0
  433. package/examples/jsm/utils/LDrawUtils.js +211 -0
  434. package/examples/jsm/utils/SceneOptimizer.js +458 -0
  435. package/examples/jsm/utils/SceneUtils.js +363 -0
  436. package/examples/jsm/utils/ShadowMapViewer.js +244 -0
  437. package/examples/jsm/utils/ShadowMapViewerGPU.js +233 -0
  438. package/examples/jsm/utils/SkeletonUtils.js +496 -0
  439. package/examples/jsm/utils/SortUtils.js +175 -0
  440. package/examples/jsm/utils/UVsDebug.js +173 -0
  441. package/examples/jsm/utils/WebGLTextureUtils.js +115 -0
  442. package/examples/jsm/utils/WebGPUTextureUtils.js +81 -0
  443. package/examples/jsm/utils/WorkerPool.js +167 -0
  444. package/examples/jsm/webxr/ARButton.js +251 -0
  445. package/examples/jsm/webxr/OculusHandModel.js +194 -0
  446. package/examples/jsm/webxr/OculusHandPointerModel.js +539 -0
  447. package/examples/jsm/webxr/Text2D.js +52 -0
  448. package/examples/jsm/webxr/VRButton.js +264 -0
  449. package/examples/jsm/webxr/XRButton.js +246 -0
  450. package/examples/jsm/webxr/XRControllerModelFactory.js +403 -0
  451. package/examples/jsm/webxr/XREstimatedLight.js +254 -0
  452. package/examples/jsm/webxr/XRHandMeshModel.js +177 -0
  453. package/examples/jsm/webxr/XRHandModelFactory.js +198 -0
  454. package/examples/jsm/webxr/XRHandPrimitiveModel.js +147 -0
  455. package/examples/jsm/webxr/XRPlanes.js +118 -0
  456. package/package.json +123 -0
  457. package/src/Three.Core.js +187 -0
  458. package/src/Three.Legacy.js +0 -0
  459. package/src/Three.TSL.js +647 -0
  460. package/src/Three.WebGPU.Nodes.js +31 -0
  461. package/src/Three.WebGPU.js +37 -0
  462. package/src/Three.js +10 -0
  463. package/src/animation/AnimationAction.js +942 -0
  464. package/src/animation/AnimationClip.js +628 -0
  465. package/src/animation/AnimationMixer.js +860 -0
  466. package/src/animation/AnimationObjectGroup.js +411 -0
  467. package/src/animation/AnimationUtils.js +495 -0
  468. package/src/animation/KeyframeTrack.js +636 -0
  469. package/src/animation/PropertyBinding.js +794 -0
  470. package/src/animation/PropertyMixer.js +385 -0
  471. package/src/animation/tracks/BooleanKeyframeTrack.js +55 -0
  472. package/src/animation/tracks/ColorKeyframeTrack.js +36 -0
  473. package/src/animation/tracks/NumberKeyframeTrack.js +36 -0
  474. package/src/animation/tracks/QuaternionKeyframeTrack.js +51 -0
  475. package/src/animation/tracks/StringKeyframeTrack.js +55 -0
  476. package/src/animation/tracks/VectorKeyframeTrack.js +36 -0
  477. package/src/audio/Audio.js +778 -0
  478. package/src/audio/AudioAnalyser.js +97 -0
  479. package/src/audio/AudioContext.js +40 -0
  480. package/src/audio/AudioListener.js +218 -0
  481. package/src/audio/PositionalAudio.js +253 -0
  482. package/src/cameras/ArrayCamera.js +54 -0
  483. package/src/cameras/Camera.js +160 -0
  484. package/src/cameras/CubeCamera.js +259 -0
  485. package/src/cameras/OrthographicCamera.js +245 -0
  486. package/src/cameras/PerspectiveCamera.js +407 -0
  487. package/src/cameras/StereoCamera.js +146 -0
  488. package/src/constants.js +1760 -0
  489. package/src/core/BufferAttribute.js +1056 -0
  490. package/src/core/BufferGeometry.js +1458 -0
  491. package/src/core/Clock.js +135 -0
  492. package/src/core/EventDispatcher.js +131 -0
  493. package/src/core/GLBufferAttribute.js +171 -0
  494. package/src/core/InstancedBufferAttribute.js +68 -0
  495. package/src/core/InstancedBufferGeometry.js +60 -0
  496. package/src/core/InstancedInterleavedBuffer.js +74 -0
  497. package/src/core/InterleavedBuffer.js +291 -0
  498. package/src/core/InterleavedBufferAttribute.js +549 -0
  499. package/src/core/Layers.js +121 -0
  500. package/src/core/Object3D.js +1667 -0
  501. package/src/core/Raycaster.js +262 -0
  502. package/src/core/RenderTarget.js +392 -0
  503. package/src/core/RenderTarget3D.js +48 -0
  504. package/src/core/Timer.js +184 -0
  505. package/src/core/Uniform.js +46 -0
  506. package/src/core/UniformsGroup.js +180 -0
  507. package/src/extras/Controls.js +120 -0
  508. package/src/extras/DataUtils.js +217 -0
  509. package/src/extras/Earcut.js +28 -0
  510. package/src/extras/ImageUtils.js +137 -0
  511. package/src/extras/PMREMGenerator.js +1167 -0
  512. package/src/extras/ShapeUtils.js +114 -0
  513. package/src/extras/TextureUtils.js +297 -0
  514. package/src/extras/core/Curve.js +517 -0
  515. package/src/extras/core/CurvePath.js +296 -0
  516. package/src/extras/core/Interpolations.js +111 -0
  517. package/src/extras/core/Path.js +329 -0
  518. package/src/extras/core/Shape.js +165 -0
  519. package/src/extras/core/ShapePath.js +367 -0
  520. package/src/extras/curves/ArcCurve.js +39 -0
  521. package/src/extras/curves/CatmullRomCurve3.js +327 -0
  522. package/src/extras/curves/CubicBezierCurve.js +145 -0
  523. package/src/extras/curves/CubicBezierCurve3.js +129 -0
  524. package/src/extras/curves/Curves.js +10 -0
  525. package/src/extras/curves/EllipseCurve.js +258 -0
  526. package/src/extras/curves/LineCurve.js +128 -0
  527. package/src/extras/curves/LineCurve3.js +128 -0
  528. package/src/extras/curves/QuadraticBezierCurve.js +133 -0
  529. package/src/extras/curves/QuadraticBezierCurve3.js +118 -0
  530. package/src/extras/curves/SplineCurve.js +145 -0
  531. package/src/extras/lib/earcut.js +685 -0
  532. package/src/geometries/BoxGeometry.js +219 -0
  533. package/src/geometries/CapsuleGeometry.js +218 -0
  534. package/src/geometries/CircleGeometry.js +142 -0
  535. package/src/geometries/ConeGeometry.js +70 -0
  536. package/src/geometries/CylinderGeometry.js +333 -0
  537. package/src/geometries/DodecahedronGeometry.js +99 -0
  538. package/src/geometries/EdgesGeometry.js +180 -0
  539. package/src/geometries/ExtrudeGeometry.js +910 -0
  540. package/src/geometries/Geometries.js +21 -0
  541. package/src/geometries/IcosahedronGeometry.js +75 -0
  542. package/src/geometries/LatheGeometry.js +230 -0
  543. package/src/geometries/OctahedronGeometry.js +70 -0
  544. package/src/geometries/PlaneGeometry.js +133 -0
  545. package/src/geometries/PolyhedronGeometry.js +348 -0
  546. package/src/geometries/RingGeometry.js +165 -0
  547. package/src/geometries/ShapeGeometry.js +233 -0
  548. package/src/geometries/SphereGeometry.js +175 -0
  549. package/src/geometries/TetrahedronGeometry.js +67 -0
  550. package/src/geometries/TorusGeometry.js +161 -0
  551. package/src/geometries/TorusKnotGeometry.js +206 -0
  552. package/src/geometries/TubeGeometry.js +253 -0
  553. package/src/geometries/WireframeGeometry.js +179 -0
  554. package/src/helpers/ArrowHelper.js +171 -0
  555. package/src/helpers/AxesHelper.js +96 -0
  556. package/src/helpers/Box3Helper.js +83 -0
  557. package/src/helpers/BoxHelper.js +149 -0
  558. package/src/helpers/CameraHelper.js +345 -0
  559. package/src/helpers/DirectionalLightHelper.js +148 -0
  560. package/src/helpers/GridHelper.js +82 -0
  561. package/src/helpers/HemisphereLightHelper.js +130 -0
  562. package/src/helpers/PlaneHelper.js +96 -0
  563. package/src/helpers/PointLightHelper.js +111 -0
  564. package/src/helpers/PolarGridHelper.js +126 -0
  565. package/src/helpers/SkeletonHelper.js +194 -0
  566. package/src/helpers/SpotLightHelper.js +154 -0
  567. package/src/lights/AmbientLight.js +42 -0
  568. package/src/lights/DirectionalLight.js +113 -0
  569. package/src/lights/DirectionalLightShadow.js +31 -0
  570. package/src/lights/HemisphereLight.js +76 -0
  571. package/src/lights/Light.js +85 -0
  572. package/src/lights/LightProbe.js +75 -0
  573. package/src/lights/LightShadow.js +347 -0
  574. package/src/lights/PointLight.js +131 -0
  575. package/src/lights/PointLightShadow.js +31 -0
  576. package/src/lights/RectAreaLight.js +115 -0
  577. package/src/lights/SpotLight.js +194 -0
  578. package/src/lights/SpotLightShadow.js +80 -0
  579. package/src/lights/webgpu/IESSpotLight.js +47 -0
  580. package/src/lights/webgpu/ProjectorLight.js +46 -0
  581. package/src/loaders/AnimationLoader.js +98 -0
  582. package/src/loaders/AudioLoader.js +108 -0
  583. package/src/loaders/BufferGeometryLoader.js +242 -0
  584. package/src/loaders/Cache.js +115 -0
  585. package/src/loaders/CompressedTextureLoader.js +167 -0
  586. package/src/loaders/CubeTextureLoader.js +103 -0
  587. package/src/loaders/DataTextureLoader.js +174 -0
  588. package/src/loaders/FileLoader.js +367 -0
  589. package/src/loaders/ImageBitmapLoader.js +223 -0
  590. package/src/loaders/ImageLoader.js +168 -0
  591. package/src/loaders/Loader.js +222 -0
  592. package/src/loaders/LoaderUtils.js +59 -0
  593. package/src/loaders/LoadingManager.js +329 -0
  594. package/src/loaders/MaterialLoader.js +439 -0
  595. package/src/loaders/ObjectLoader.js +1304 -0
  596. package/src/loaders/TextureLoader.js +74 -0
  597. package/src/loaders/nodes/NodeLoader.js +194 -0
  598. package/src/loaders/nodes/NodeMaterialLoader.js +108 -0
  599. package/src/loaders/nodes/NodeObjectLoader.js +169 -0
  600. package/src/materials/LineBasicMaterial.js +122 -0
  601. package/src/materials/LineDashedMaterial.js +86 -0
  602. package/src/materials/Material.js +1017 -0
  603. package/src/materials/Materials.js +39 -0
  604. package/src/materials/MeshBasicMaterial.js +250 -0
  605. package/src/materials/MeshDepthMaterial.js +148 -0
  606. package/src/materials/MeshDistanceMaterial.js +119 -0
  607. package/src/materials/MeshLambertMaterial.js +402 -0
  608. package/src/materials/MeshMatcapMaterial.js +245 -0
  609. package/src/materials/MeshNormalMaterial.js +175 -0
  610. package/src/materials/MeshPhongMaterial.js +421 -0
  611. package/src/materials/MeshPhysicalMaterial.js +536 -0
  612. package/src/materials/MeshStandardMaterial.js +425 -0
  613. package/src/materials/MeshToonMaterial.js +321 -0
  614. package/src/materials/PointsMaterial.js +139 -0
  615. package/src/materials/RawShaderMaterial.js +42 -0
  616. package/src/materials/ShaderMaterial.js +413 -0
  617. package/src/materials/ShadowMaterial.js +91 -0
  618. package/src/materials/SpriteMaterial.js +136 -0
  619. package/src/materials/nodes/Line2NodeMaterial.js +569 -0
  620. package/src/materials/nodes/LineBasicNodeMaterial.js +46 -0
  621. package/src/materials/nodes/LineDashedNodeMaterial.js +132 -0
  622. package/src/materials/nodes/MeshBasicNodeMaterial.js +134 -0
  623. package/src/materials/nodes/MeshLambertNodeMaterial.js +82 -0
  624. package/src/materials/nodes/MeshMatcapNodeMaterial.js +77 -0
  625. package/src/materials/nodes/MeshNormalNodeMaterial.js +67 -0
  626. package/src/materials/nodes/MeshPhongNodeMaterial.js +141 -0
  627. package/src/materials/nodes/MeshPhysicalNodeMaterial.js +521 -0
  628. package/src/materials/nodes/MeshSSSNodeMaterial.js +175 -0
  629. package/src/materials/nodes/MeshStandardNodeMaterial.js +187 -0
  630. package/src/materials/nodes/MeshToonNodeMaterial.js +66 -0
  631. package/src/materials/nodes/NodeMaterial.js +1330 -0
  632. package/src/materials/nodes/NodeMaterials.js +21 -0
  633. package/src/materials/nodes/PointsNodeMaterial.js +211 -0
  634. package/src/materials/nodes/ShadowNodeMaterial.js +76 -0
  635. package/src/materials/nodes/SpriteNodeMaterial.js +186 -0
  636. package/src/materials/nodes/VolumeNodeMaterial.js +81 -0
  637. package/src/materials/nodes/manager/NodeMaterialObserver.js +718 -0
  638. package/src/math/Box2.js +381 -0
  639. package/src/math/Box3.js +805 -0
  640. package/src/math/Color.js +967 -0
  641. package/src/math/ColorManagement.js +215 -0
  642. package/src/math/Cylindrical.js +120 -0
  643. package/src/math/Euler.js +449 -0
  644. package/src/math/Frustum.js +285 -0
  645. package/src/math/FrustumArray.js +258 -0
  646. package/src/math/Interpolant.js +320 -0
  647. package/src/math/Line3.js +337 -0
  648. package/src/math/MathUtils.js +751 -0
  649. package/src/math/Matrix2.js +128 -0
  650. package/src/math/Matrix3.js +617 -0
  651. package/src/math/Matrix4.js +1314 -0
  652. package/src/math/Plane.js +368 -0
  653. package/src/math/Quaternion.js +918 -0
  654. package/src/math/Ray.js +655 -0
  655. package/src/math/Sphere.js +420 -0
  656. package/src/math/Spherical.js +147 -0
  657. package/src/math/SphericalHarmonics3.js +341 -0
  658. package/src/math/Triangle.js +539 -0
  659. package/src/math/Vector2.js +870 -0
  660. package/src/math/Vector3.js +1263 -0
  661. package/src/math/Vector4.js +1067 -0
  662. package/src/math/interpolants/BezierInterpolant.js +108 -0
  663. package/src/math/interpolants/CubicInterpolant.js +159 -0
  664. package/src/math/interpolants/DiscreteInterpolant.js +34 -0
  665. package/src/math/interpolants/LinearInterpolant.js +51 -0
  666. package/src/math/interpolants/QuaternionLinearInterpolant.js +48 -0
  667. package/src/nodes/Nodes.js +166 -0
  668. package/src/nodes/TSL.js +173 -0
  669. package/src/nodes/accessors/AccessorsUtils.js +53 -0
  670. package/src/nodes/accessors/Arrays.js +68 -0
  671. package/src/nodes/accessors/BatchNode.js +163 -0
  672. package/src/nodes/accessors/Bitangent.js +82 -0
  673. package/src/nodes/accessors/BufferAttributeNode.js +432 -0
  674. package/src/nodes/accessors/BufferNode.js +128 -0
  675. package/src/nodes/accessors/BuiltinNode.js +63 -0
  676. package/src/nodes/accessors/Camera.js +403 -0
  677. package/src/nodes/accessors/ClippingNode.js +255 -0
  678. package/src/nodes/accessors/CubeTextureNode.js +215 -0
  679. package/src/nodes/accessors/InstanceNode.js +349 -0
  680. package/src/nodes/accessors/InstancedMeshNode.js +50 -0
  681. package/src/nodes/accessors/Lights.js +139 -0
  682. package/src/nodes/accessors/MaterialNode.js +783 -0
  683. package/src/nodes/accessors/MaterialProperties.js +56 -0
  684. package/src/nodes/accessors/MaterialReferenceNode.js +84 -0
  685. package/src/nodes/accessors/ModelNode.js +184 -0
  686. package/src/nodes/accessors/ModelViewProjectionNode.js +13 -0
  687. package/src/nodes/accessors/MorphNode.js +310 -0
  688. package/src/nodes/accessors/Normal.js +243 -0
  689. package/src/nodes/accessors/Object3DNode.js +268 -0
  690. package/src/nodes/accessors/PointUVNode.js +55 -0
  691. package/src/nodes/accessors/Position.js +122 -0
  692. package/src/nodes/accessors/ReferenceBaseNode.js +357 -0
  693. package/src/nodes/accessors/ReferenceNode.js +424 -0
  694. package/src/nodes/accessors/ReflectVector.js +36 -0
  695. package/src/nodes/accessors/RendererReferenceNode.js +78 -0
  696. package/src/nodes/accessors/SceneProperties.js +47 -0
  697. package/src/nodes/accessors/SkinningNode.js +328 -0
  698. package/src/nodes/accessors/StorageBufferNode.js +405 -0
  699. package/src/nodes/accessors/StorageTextureNode.js +295 -0
  700. package/src/nodes/accessors/Tangent.js +60 -0
  701. package/src/nodes/accessors/TangentUtils.js +46 -0
  702. package/src/nodes/accessors/Texture3DNode.js +196 -0
  703. package/src/nodes/accessors/TextureBicubic.js +92 -0
  704. package/src/nodes/accessors/TextureNode.js +971 -0
  705. package/src/nodes/accessors/TextureSizeNode.js +77 -0
  706. package/src/nodes/accessors/UV.js +11 -0
  707. package/src/nodes/accessors/UniformArrayNode.js +350 -0
  708. package/src/nodes/accessors/UserDataNode.js +76 -0
  709. package/src/nodes/accessors/VelocityNode.js +224 -0
  710. package/src/nodes/accessors/VertexColorNode.js +109 -0
  711. package/src/nodes/code/CodeNode.js +181 -0
  712. package/src/nodes/code/ExpressionNode.js +68 -0
  713. package/src/nodes/code/FunctionCallNode.js +187 -0
  714. package/src/nodes/code/FunctionNode.js +182 -0
  715. package/src/nodes/core/ArrayNode.js +174 -0
  716. package/src/nodes/core/AssignNode.js +202 -0
  717. package/src/nodes/core/AttributeNode.js +168 -0
  718. package/src/nodes/core/BypassNode.js +93 -0
  719. package/src/nodes/core/ConstNode.js +67 -0
  720. package/src/nodes/core/ContextNode.js +283 -0
  721. package/src/nodes/core/IndexNode.js +165 -0
  722. package/src/nodes/core/InputNode.js +136 -0
  723. package/src/nodes/core/InspectorNode.js +128 -0
  724. package/src/nodes/core/IsolateNode.js +133 -0
  725. package/src/nodes/core/LightingModel.js +77 -0
  726. package/src/nodes/core/MRTNode.js +196 -0
  727. package/src/nodes/core/Node.js +1180 -0
  728. package/src/nodes/core/NodeAttribute.js +53 -0
  729. package/src/nodes/core/NodeBuilder.js +3299 -0
  730. package/src/nodes/core/NodeCache.js +75 -0
  731. package/src/nodes/core/NodeCode.js +46 -0
  732. package/src/nodes/core/NodeError.js +28 -0
  733. package/src/nodes/core/NodeFrame.js +314 -0
  734. package/src/nodes/core/NodeFunction.js +69 -0
  735. package/src/nodes/core/NodeFunctionInput.js +61 -0
  736. package/src/nodes/core/NodeParser.js +23 -0
  737. package/src/nodes/core/NodeUniform.js +91 -0
  738. package/src/nodes/core/NodeUtils.js +408 -0
  739. package/src/nodes/core/NodeVar.js +60 -0
  740. package/src/nodes/core/NodeVarying.js +63 -0
  741. package/src/nodes/core/OutputStructNode.js +105 -0
  742. package/src/nodes/core/ParameterNode.js +94 -0
  743. package/src/nodes/core/PropertyNode.js +367 -0
  744. package/src/nodes/core/StackNode.js +426 -0
  745. package/src/nodes/core/StackTrace.js +139 -0
  746. package/src/nodes/core/StructNode.js +134 -0
  747. package/src/nodes/core/StructType.js +13 -0
  748. package/src/nodes/core/StructTypeNode.js +148 -0
  749. package/src/nodes/core/SubBuildNode.js +89 -0
  750. package/src/nodes/core/TempNode.js +88 -0
  751. package/src/nodes/core/UniformGroupNode.js +167 -0
  752. package/src/nodes/core/UniformNode.js +259 -0
  753. package/src/nodes/core/VarNode.js +367 -0
  754. package/src/nodes/core/VaryingNode.js +210 -0
  755. package/src/nodes/core/constants.js +68 -0
  756. package/src/nodes/display/BlendModes.js +171 -0
  757. package/src/nodes/display/BumpMapNode.js +117 -0
  758. package/src/nodes/display/ColorAdjustment.js +158 -0
  759. package/src/nodes/display/ColorSpaceFunctions.js +54 -0
  760. package/src/nodes/display/ColorSpaceNode.js +164 -0
  761. package/src/nodes/display/FrontFacingNode.js +102 -0
  762. package/src/nodes/display/NormalMapNode.js +153 -0
  763. package/src/nodes/display/PassNode.js +1055 -0
  764. package/src/nodes/display/RenderOutputNode.js +150 -0
  765. package/src/nodes/display/ScreenNode.js +292 -0
  766. package/src/nodes/display/ToneMappingFunctions.js +242 -0
  767. package/src/nodes/display/ToneMappingNode.js +147 -0
  768. package/src/nodes/display/ToonOutlinePassNode.js +191 -0
  769. package/src/nodes/display/ViewportDepthNode.js +342 -0
  770. package/src/nodes/display/ViewportDepthTextureNode.js +63 -0
  771. package/src/nodes/display/ViewportSharedTextureNode.js +73 -0
  772. package/src/nodes/display/ViewportTextureNode.js +256 -0
  773. package/src/nodes/fog/Fog.js +97 -0
  774. package/src/nodes/functions/BSDF/BRDF_GGX.js +55 -0
  775. package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +52 -0
  776. package/src/nodes/functions/BSDF/BRDF_Lambert.js +9 -0
  777. package/src/nodes/functions/BSDF/BRDF_Sheen.js +57 -0
  778. package/src/nodes/functions/BSDF/DFGLUT.js +56 -0
  779. package/src/nodes/functions/BSDF/D_GGX.js +23 -0
  780. package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +28 -0
  781. package/src/nodes/functions/BSDF/EnvironmentBRDF.js +13 -0
  782. package/src/nodes/functions/BSDF/F_Schlick.js +16 -0
  783. package/src/nodes/functions/BSDF/LTC.js +175 -0
  784. package/src/nodes/functions/BSDF/Schlick_to_F0.js +21 -0
  785. package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +26 -0
  786. package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +29 -0
  787. package/src/nodes/functions/BasicLightingModel.js +100 -0
  788. package/src/nodes/functions/PhongLightingModel.js +99 -0
  789. package/src/nodes/functions/PhysicalLightingModel.js +878 -0
  790. package/src/nodes/functions/ShadowMaskModel.js +58 -0
  791. package/src/nodes/functions/ToonLightingModel.js +70 -0
  792. package/src/nodes/functions/VolumetricLightingModel.js +183 -0
  793. package/src/nodes/functions/material/getAlphaHashThreshold.js +68 -0
  794. package/src/nodes/functions/material/getGeometryRoughness.js +19 -0
  795. package/src/nodes/functions/material/getParallaxCorrectNormal.js +37 -0
  796. package/src/nodes/functions/material/getRoughness.js +18 -0
  797. package/src/nodes/functions/material/getShIrradianceAt.js +28 -0
  798. package/src/nodes/geometry/RangeNode.js +210 -0
  799. package/src/nodes/gpgpu/AtomicFunctionNode.js +274 -0
  800. package/src/nodes/gpgpu/BarrierNode.js +98 -0
  801. package/src/nodes/gpgpu/ComputeBuiltinNode.js +227 -0
  802. package/src/nodes/gpgpu/ComputeNode.js +310 -0
  803. package/src/nodes/gpgpu/SubgroupFunctionNode.js +455 -0
  804. package/src/nodes/gpgpu/WorkgroupInfoNode.js +234 -0
  805. package/src/nodes/lighting/AONode.js +45 -0
  806. package/src/nodes/lighting/AmbientLightNode.js +35 -0
  807. package/src/nodes/lighting/AnalyticLightNode.js +309 -0
  808. package/src/nodes/lighting/BasicEnvironmentNode.js +49 -0
  809. package/src/nodes/lighting/BasicLightMapNode.js +49 -0
  810. package/src/nodes/lighting/DirectionalLightNode.js +39 -0
  811. package/src/nodes/lighting/EnvironmentNode.js +178 -0
  812. package/src/nodes/lighting/HemisphereLightNode.js +87 -0
  813. package/src/nodes/lighting/IESSpotLightNode.js +49 -0
  814. package/src/nodes/lighting/IrradianceNode.js +44 -0
  815. package/src/nodes/lighting/LightProbeNode.js +73 -0
  816. package/src/nodes/lighting/LightUtils.js +25 -0
  817. package/src/nodes/lighting/LightingContextNode.js +115 -0
  818. package/src/nodes/lighting/LightingNode.js +36 -0
  819. package/src/nodes/lighting/LightsNode.js +432 -0
  820. package/src/nodes/lighting/PointLightNode.js +102 -0
  821. package/src/nodes/lighting/PointShadowNode.js +325 -0
  822. package/src/nodes/lighting/ProjectorLightNode.js +91 -0
  823. package/src/nodes/lighting/RectAreaLightNode.js +133 -0
  824. package/src/nodes/lighting/ShadowBaseNode.js +81 -0
  825. package/src/nodes/lighting/ShadowFilterNode.js +264 -0
  826. package/src/nodes/lighting/ShadowNode.js +889 -0
  827. package/src/nodes/lighting/SpotLightNode.js +168 -0
  828. package/src/nodes/materialx/DISCLAIMER.md +199 -0
  829. package/src/nodes/materialx/MaterialXNodes.js +197 -0
  830. package/src/nodes/materialx/lib/mx_hsv.js +127 -0
  831. package/src/nodes/materialx/lib/mx_noise.js +1491 -0
  832. package/src/nodes/materialx/lib/mx_transform_color.js +23 -0
  833. package/src/nodes/math/BitcastNode.js +156 -0
  834. package/src/nodes/math/BitcountNode.js +433 -0
  835. package/src/nodes/math/ConditionalNode.js +245 -0
  836. package/src/nodes/math/Hash.js +21 -0
  837. package/src/nodes/math/MathNode.js +1202 -0
  838. package/src/nodes/math/MathUtils.js +54 -0
  839. package/src/nodes/math/OperatorNode.js +752 -0
  840. package/src/nodes/math/PackFloatNode.js +98 -0
  841. package/src/nodes/math/TriNoise3D.js +71 -0
  842. package/src/nodes/math/UnpackFloatNode.js +96 -0
  843. package/src/nodes/parsers/GLSLNodeFunction.js +168 -0
  844. package/src/nodes/parsers/GLSLNodeParser.js +25 -0
  845. package/src/nodes/pmrem/PMREMNode.js +397 -0
  846. package/src/nodes/pmrem/PMREMUtils.js +397 -0
  847. package/src/nodes/procedural/Checker.js +22 -0
  848. package/src/nodes/shapes/Shapes.js +33 -0
  849. package/src/nodes/tsl/TSLBase.js +36 -0
  850. package/src/nodes/tsl/TSLCore.js +1250 -0
  851. package/src/nodes/utils/ArrayElementNode.js +90 -0
  852. package/src/nodes/utils/ConvertNode.js +100 -0
  853. package/src/nodes/utils/CubeMapNode.js +237 -0
  854. package/src/nodes/utils/DebugNode.js +83 -0
  855. package/src/nodes/utils/Discard.js +24 -0
  856. package/src/nodes/utils/EquirectUV.js +27 -0
  857. package/src/nodes/utils/EventNode.js +148 -0
  858. package/src/nodes/utils/FlipNode.js +106 -0
  859. package/src/nodes/utils/FunctionOverloadingNode.js +170 -0
  860. package/src/nodes/utils/JoinNode.js +117 -0
  861. package/src/nodes/utils/LoopNode.js +349 -0
  862. package/src/nodes/utils/MatcapUV.js +22 -0
  863. package/src/nodes/utils/MaxMipLevelNode.js +103 -0
  864. package/src/nodes/utils/MemberNode.js +120 -0
  865. package/src/nodes/utils/Oscillators.js +41 -0
  866. package/src/nodes/utils/Packing.js +33 -0
  867. package/src/nodes/utils/PostProcessingUtils.js +154 -0
  868. package/src/nodes/utils/RTTNode.js +289 -0
  869. package/src/nodes/utils/ReflectorNode.js +629 -0
  870. package/src/nodes/utils/Remap.js +48 -0
  871. package/src/nodes/utils/RotateNode.js +103 -0
  872. package/src/nodes/utils/SampleNode.js +91 -0
  873. package/src/nodes/utils/SetNode.js +108 -0
  874. package/src/nodes/utils/SplitNode.js +179 -0
  875. package/src/nodes/utils/SpriteSheetUV.js +35 -0
  876. package/src/nodes/utils/SpriteUtils.js +63 -0
  877. package/src/nodes/utils/StorageArrayElementNode.js +143 -0
  878. package/src/nodes/utils/Timer.js +26 -0
  879. package/src/nodes/utils/TriplanarTextures.js +65 -0
  880. package/src/nodes/utils/UVUtils.js +67 -0
  881. package/src/nodes/utils/ViewportUtils.js +26 -0
  882. package/src/objects/BatchedMesh.js +1682 -0
  883. package/src/objects/Bone.js +41 -0
  884. package/src/objects/ClippingGroup.js +68 -0
  885. package/src/objects/Group.js +41 -0
  886. package/src/objects/InstancedMesh.js +422 -0
  887. package/src/objects/LOD.js +329 -0
  888. package/src/objects/Line.js +329 -0
  889. package/src/objects/LineLoop.js +37 -0
  890. package/src/objects/LineSegments.js +74 -0
  891. package/src/objects/Mesh.js +496 -0
  892. package/src/objects/Points.js +228 -0
  893. package/src/objects/Skeleton.js +392 -0
  894. package/src/objects/SkinnedMesh.js +370 -0
  895. package/src/objects/Sprite.js +245 -0
  896. package/src/renderers/WebGL3DRenderTarget.js +48 -0
  897. package/src/renderers/WebGLArrayRenderTarget.js +48 -0
  898. package/src/renderers/WebGLCubeRenderTarget.js +182 -0
  899. package/src/renderers/WebGLRenderTarget.js +34 -0
  900. package/src/renderers/WebGLRenderer.js +3699 -0
  901. package/src/renderers/common/Animation.js +159 -0
  902. package/src/renderers/common/Attributes.js +132 -0
  903. package/src/renderers/common/Backend.js +769 -0
  904. package/src/renderers/common/Background.js +225 -0
  905. package/src/renderers/common/BindGroup.js +46 -0
  906. package/src/renderers/common/Binding.js +71 -0
  907. package/src/renderers/common/Bindings.js +394 -0
  908. package/src/renderers/common/BlendMode.js +143 -0
  909. package/src/renderers/common/Buffer.js +127 -0
  910. package/src/renderers/common/BufferUtils.js +58 -0
  911. package/src/renderers/common/BundleGroup.js +83 -0
  912. package/src/renderers/common/CanvasTarget.js +341 -0
  913. package/src/renderers/common/ChainMap.js +122 -0
  914. package/src/renderers/common/ClippingContext.js +262 -0
  915. package/src/renderers/common/Color4.js +77 -0
  916. package/src/renderers/common/ComputePipeline.js +41 -0
  917. package/src/renderers/common/Constants.js +15 -0
  918. package/src/renderers/common/CubeRenderTarget.js +147 -0
  919. package/src/renderers/common/DataMap.js +90 -0
  920. package/src/renderers/common/Geometries.js +396 -0
  921. package/src/renderers/common/IndirectStorageBufferAttribute.js +38 -0
  922. package/src/renderers/common/Info.js +501 -0
  923. package/src/renderers/common/InspectorBase.js +151 -0
  924. package/src/renderers/common/Lighting.js +57 -0
  925. package/src/renderers/common/Pipeline.js +35 -0
  926. package/src/renderers/common/Pipelines.js +498 -0
  927. package/src/renderers/common/PostProcessing.js +28 -0
  928. package/src/renderers/common/ProgrammableStage.js +78 -0
  929. package/src/renderers/common/QuadMesh.js +112 -0
  930. package/src/renderers/common/ReadbackBuffer.js +78 -0
  931. package/src/renderers/common/RenderBundle.js +26 -0
  932. package/src/renderers/common/RenderBundles.js +71 -0
  933. package/src/renderers/common/RenderContext.js +281 -0
  934. package/src/renderers/common/RenderContexts.js +100 -0
  935. package/src/renderers/common/RenderList.js +404 -0
  936. package/src/renderers/common/RenderLists.js +78 -0
  937. package/src/renderers/common/RenderObject.js +915 -0
  938. package/src/renderers/common/RenderObjectPipeline.js +40 -0
  939. package/src/renderers/common/RenderObjects.js +218 -0
  940. package/src/renderers/common/RenderPipeline.js +255 -0
  941. package/src/renderers/common/Renderer.js +3654 -0
  942. package/src/renderers/common/RendererUtils.js +200 -0
  943. package/src/renderers/common/SampledTexture.js +152 -0
  944. package/src/renderers/common/Sampler.js +165 -0
  945. package/src/renderers/common/Storage3DTexture.js +100 -0
  946. package/src/renderers/common/StorageArrayTexture.js +84 -0
  947. package/src/renderers/common/StorageBuffer.js +53 -0
  948. package/src/renderers/common/StorageBufferAttribute.js +46 -0
  949. package/src/renderers/common/StorageInstancedBufferAttribute.js +46 -0
  950. package/src/renderers/common/StorageTexture.js +86 -0
  951. package/src/renderers/common/Textures.js +629 -0
  952. package/src/renderers/common/TimestampQueryPool.js +163 -0
  953. package/src/renderers/common/Uniform.js +375 -0
  954. package/src/renderers/common/UniformBuffer.js +34 -0
  955. package/src/renderers/common/UniformsGroup.js +548 -0
  956. package/src/renderers/common/XRManager.js +1684 -0
  957. package/src/renderers/common/XRRenderTarget.js +91 -0
  958. package/src/renderers/common/extras/PMREMGenerator.js +1042 -0
  959. package/src/renderers/common/nodes/NodeBuilderState.js +152 -0
  960. package/src/renderers/common/nodes/NodeLibrary.js +196 -0
  961. package/src/renderers/common/nodes/NodeManager.js +983 -0
  962. package/src/renderers/common/nodes/NodeSampledTexture.js +140 -0
  963. package/src/renderers/common/nodes/NodeSampler.js +62 -0
  964. package/src/renderers/common/nodes/NodeStorageBuffer.js +72 -0
  965. package/src/renderers/common/nodes/NodeUniform.js +418 -0
  966. package/src/renderers/common/nodes/NodeUniformBuffer.js +105 -0
  967. package/src/renderers/common/nodes/NodeUniformsGroup.js +51 -0
  968. package/src/renderers/shaders/DFGLUTData.js +49 -0
  969. package/src/renderers/shaders/ShaderChunk/alphahash_fragment.glsl.js +7 -0
  970. package/src/renderers/shaders/ShaderChunk/alphahash_pars_fragment.glsl.js +68 -0
  971. package/src/renderers/shaders/ShaderChunk/alphamap_fragment.glsl.js +7 -0
  972. package/src/renderers/shaders/ShaderChunk/alphamap_pars_fragment.glsl.js +7 -0
  973. package/src/renderers/shaders/ShaderChunk/alphatest_fragment.glsl.js +16 -0
  974. package/src/renderers/shaders/ShaderChunk/alphatest_pars_fragment.glsl.js +5 -0
  975. package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +26 -0
  976. package/src/renderers/shaders/ShaderChunk/aomap_pars_fragment.glsl.js +8 -0
  977. package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +49 -0
  978. package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +5 -0
  979. package/src/renderers/shaders/ShaderChunk/begin_vertex.glsl.js +9 -0
  980. package/src/renderers/shaders/ShaderChunk/beginnormal_vertex.glsl.js +9 -0
  981. package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +33 -0
  982. package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +43 -0
  983. package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js +7 -0
  984. package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_maps.glsl.js +10 -0
  985. package/src/renderers/shaders/ShaderChunk/clearcoat_pars_fragment.glsl.js +21 -0
  986. package/src/renderers/shaders/ShaderChunk/clipping_planes_fragment.glsl.js +78 -0
  987. package/src/renderers/shaders/ShaderChunk/clipping_planes_pars_fragment.glsl.js +9 -0
  988. package/src/renderers/shaders/ShaderChunk/clipping_planes_pars_vertex.glsl.js +7 -0
  989. package/src/renderers/shaders/ShaderChunk/clipping_planes_vertex.glsl.js +7 -0
  990. package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +7 -0
  991. package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +7 -0
  992. package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +7 -0
  993. package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +29 -0
  994. package/src/renderers/shaders/ShaderChunk/colorspace_fragment.glsl.js +3 -0
  995. package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +15 -0
  996. package/src/renderers/shaders/ShaderChunk/common.glsl.js +125 -0
  997. package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +186 -0
  998. package/src/renderers/shaders/ShaderChunk/default_fragment.glsl.js +5 -0
  999. package/src/renderers/shaders/ShaderChunk/default_vertex.glsl.js +5 -0
  1000. package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +63 -0
  1001. package/src/renderers/shaders/ShaderChunk/displacementmap_pars_vertex.glsl.js +9 -0
  1002. package/src/renderers/shaders/ShaderChunk/displacementmap_vertex.glsl.js +7 -0
  1003. package/src/renderers/shaders/ShaderChunk/dithering_fragment.glsl.js +7 -0
  1004. package/src/renderers/shaders/ShaderChunk/dithering_pars_fragment.glsl.js +20 -0
  1005. package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +17 -0
  1006. package/src/renderers/shaders/ShaderChunk/emissivemap_pars_fragment.glsl.js +7 -0
  1007. package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +14 -0
  1008. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +58 -0
  1009. package/src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js +21 -0
  1010. package/src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js +22 -0
  1011. package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +69 -0
  1012. package/src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js +37 -0
  1013. package/src/renderers/shaders/ShaderChunk/fog_fragment.glsl.js +17 -0
  1014. package/src/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl.js +19 -0
  1015. package/src/renderers/shaders/ShaderChunk/fog_pars_vertex.glsl.js +7 -0
  1016. package/src/renderers/shaders/ShaderChunk/fog_vertex.glsl.js +7 -0
  1017. package/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js +27 -0
  1018. package/src/renderers/shaders/ShaderChunk/iridescence_fragment.glsl.js +120 -0
  1019. package/src/renderers/shaders/ShaderChunk/iridescence_pars_fragment.glsl.js +14 -0
  1020. package/src/renderers/shaders/ShaderChunk/lightmap_pars_fragment.glsl.js +8 -0
  1021. package/src/renderers/shaders/ShaderChunk/lightprobes_pars_fragment.glsl.js +80 -0
  1022. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +213 -0
  1023. package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +19 -0
  1024. package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +44 -0
  1025. package/src/renderers/shaders/ShaderChunk/lights_lambert_fragment.glsl.js +5 -0
  1026. package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +28 -0
  1027. package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +216 -0
  1028. package/src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl.js +7 -0
  1029. package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +32 -0
  1030. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +161 -0
  1031. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +656 -0
  1032. package/src/renderers/shaders/ShaderChunk/lights_toon_fragment.glsl.js +4 -0
  1033. package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +26 -0
  1034. package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +9 -0
  1035. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +9 -0
  1036. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +8 -0
  1037. package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +8 -0
  1038. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +17 -0
  1039. package/src/renderers/shaders/ShaderChunk/map_pars_fragment.glsl.js +7 -0
  1040. package/src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js +27 -0
  1041. package/src/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl.js +27 -0
  1042. package/src/renderers/shaders/ShaderChunk/metalnessmap_fragment.glsl.js +12 -0
  1043. package/src/renderers/shaders/ShaderChunk/metalnessmap_pars_fragment.glsl.js +7 -0
  1044. package/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js +24 -0
  1045. package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +14 -0
  1046. package/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +16 -0
  1047. package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +26 -0
  1048. package/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js +16 -0
  1049. package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +76 -0
  1050. package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +40 -0
  1051. package/src/renderers/shaders/ShaderChunk/normal_pars_fragment.glsl.js +14 -0
  1052. package/src/renderers/shaders/ShaderChunk/normal_pars_vertex.glsl.js +14 -0
  1053. package/src/renderers/shaders/ShaderChunk/normal_vertex.glsl.js +14 -0
  1054. package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +43 -0
  1055. package/src/renderers/shaders/ShaderChunk/opaque_fragment.glsl.js +11 -0
  1056. package/src/renderers/shaders/ShaderChunk/packing.glsl.js +116 -0
  1057. package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +7 -0
  1058. package/src/renderers/shaders/ShaderChunk/project_vertex.glsl.js +19 -0
  1059. package/src/renderers/shaders/ShaderChunk/roughnessmap_fragment.glsl.js +12 -0
  1060. package/src/renderers/shaders/ShaderChunk/roughnessmap_pars_fragment.glsl.js +7 -0
  1061. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +376 -0
  1062. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +71 -0
  1063. package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +78 -0
  1064. package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +66 -0
  1065. package/src/renderers/shaders/ShaderChunk/skinbase_vertex.glsl.js +10 -0
  1066. package/src/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl.js +25 -0
  1067. package/src/renderers/shaders/ShaderChunk/skinning_vertex.glsl.js +15 -0
  1068. package/src/renderers/shaders/ShaderChunk/skinnormal_vertex.glsl.js +20 -0
  1069. package/src/renderers/shaders/ShaderChunk/specularmap_fragment.glsl.js +14 -0
  1070. package/src/renderers/shaders/ShaderChunk/specularmap_pars_fragment.glsl.js +7 -0
  1071. package/src/renderers/shaders/ShaderChunk/tonemapping_fragment.glsl.js +7 -0
  1072. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +200 -0
  1073. package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +36 -0
  1074. package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +235 -0
  1075. package/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js +119 -0
  1076. package/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js +145 -0
  1077. package/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js +122 -0
  1078. package/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js +21 -0
  1079. package/src/renderers/shaders/ShaderChunk.js +272 -0
  1080. package/src/renderers/shaders/ShaderLib/background.glsl.js +40 -0
  1081. package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +62 -0
  1082. package/src/renderers/shaders/ShaderLib/cube.glsl.js +36 -0
  1083. package/src/renderers/shaders/ShaderLib/depth.glsl.js +117 -0
  1084. package/src/renderers/shaders/ShaderLib/distance.glsl.js +77 -0
  1085. package/src/renderers/shaders/ShaderLib/equirect.glsl.js +35 -0
  1086. package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +76 -0
  1087. package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +116 -0
  1088. package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +126 -0
  1089. package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +112 -0
  1090. package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +86 -0
  1091. package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +128 -0
  1092. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +224 -0
  1093. package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +118 -0
  1094. package/src/renderers/shaders/ShaderLib/points.glsl.js +87 -0
  1095. package/src/renderers/shaders/ShaderLib/shadow.glsl.js +58 -0
  1096. package/src/renderers/shaders/ShaderLib/sprite.glsl.js +79 -0
  1097. package/src/renderers/shaders/ShaderLib/vsm.glsl.js +51 -0
  1098. package/src/renderers/shaders/ShaderLib.js +362 -0
  1099. package/src/renderers/shaders/UniformsLib.js +234 -0
  1100. package/src/renderers/shaders/UniformsUtils.js +154 -0
  1101. package/src/renderers/webgl/WebGLAnimation.js +54 -0
  1102. package/src/renderers/webgl/WebGLAttributes.js +237 -0
  1103. package/src/renderers/webgl/WebGLBackground.js +303 -0
  1104. package/src/renderers/webgl/WebGLBindingStates.js +666 -0
  1105. package/src/renderers/webgl/WebGLBufferRenderer.js +57 -0
  1106. package/src/renderers/webgl/WebGLCapabilities.js +150 -0
  1107. package/src/renderers/webgl/WebGLClipping.js +171 -0
  1108. package/src/renderers/webgl/WebGLEnvironments.js +228 -0
  1109. package/src/renderers/webgl/WebGLExtensions.js +61 -0
  1110. package/src/renderers/webgl/WebGLGeometries.js +186 -0
  1111. package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +68 -0
  1112. package/src/renderers/webgl/WebGLInfo.js +73 -0
  1113. package/src/renderers/webgl/WebGLLights.js +584 -0
  1114. package/src/renderers/webgl/WebGLMaterials.js +602 -0
  1115. package/src/renderers/webgl/WebGLMorphtargets.js +168 -0
  1116. package/src/renderers/webgl/WebGLObjects.js +94 -0
  1117. package/src/renderers/webgl/WebGLOutput.js +270 -0
  1118. package/src/renderers/webgl/WebGLProgram.js +1031 -0
  1119. package/src/renderers/webgl/WebGLPrograms.js +679 -0
  1120. package/src/renderers/webgl/WebGLProperties.js +55 -0
  1121. package/src/renderers/webgl/WebGLRenderLists.js +253 -0
  1122. package/src/renderers/webgl/WebGLRenderStates.js +124 -0
  1123. package/src/renderers/webgl/WebGLShader.js +12 -0
  1124. package/src/renderers/webgl/WebGLShaderCache.js +124 -0
  1125. package/src/renderers/webgl/WebGLShadowMap.js +600 -0
  1126. package/src/renderers/webgl/WebGLState.js +1370 -0
  1127. package/src/renderers/webgl/WebGLTextures.js +2506 -0
  1128. package/src/renderers/webgl/WebGLUniforms.js +1203 -0
  1129. package/src/renderers/webgl/WebGLUniformsGroups.js +413 -0
  1130. package/src/renderers/webgl/WebGLUtils.js +217 -0
  1131. package/src/renderers/webgl-fallback/WebGLBackend.js +2783 -0
  1132. package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +99 -0
  1133. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +1676 -0
  1134. package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +359 -0
  1135. package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +89 -0
  1136. package/src/renderers/webgl-fallback/utils/WebGLConstants.js +13 -0
  1137. package/src/renderers/webgl-fallback/utils/WebGLExtensions.js +83 -0
  1138. package/src/renderers/webgl-fallback/utils/WebGLState.js +1361 -0
  1139. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +1324 -0
  1140. package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +396 -0
  1141. package/src/renderers/webgl-fallback/utils/WebGLUtils.js +317 -0
  1142. package/src/renderers/webgpu/WebGPUBackend.js +2602 -0
  1143. package/src/renderers/webgpu/WebGPURenderer.Nodes.js +69 -0
  1144. package/src/renderers/webgpu/WebGPURenderer.js +107 -0
  1145. package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +66 -0
  1146. package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +100 -0
  1147. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +2523 -0
  1148. package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +187 -0
  1149. package/src/renderers/webgpu/nodes/WGSLNodeParser.js +25 -0
  1150. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +522 -0
  1151. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +642 -0
  1152. package/src/renderers/webgpu/utils/WebGPUCapabilities.js +48 -0
  1153. package/src/renderers/webgpu/utils/WebGPUConstants.js +354 -0
  1154. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +846 -0
  1155. package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +389 -0
  1156. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +1673 -0
  1157. package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +310 -0
  1158. package/src/renderers/webgpu/utils/WebGPUUtils.js +269 -0
  1159. package/src/renderers/webxr/WebXRController.js +440 -0
  1160. package/src/renderers/webxr/WebXRDepthSensing.js +155 -0
  1161. package/src/renderers/webxr/WebXRManager.js +1103 -0
  1162. package/src/scenes/Fog.js +98 -0
  1163. package/src/scenes/FogExp2.js +86 -0
  1164. package/src/scenes/Scene.js +165 -0
  1165. package/src/textures/CanvasTexture.js +45 -0
  1166. package/src/textures/CompressedArrayTexture.js +89 -0
  1167. package/src/textures/CompressedCubeTexture.js +48 -0
  1168. package/src/textures/CompressedTexture.js +86 -0
  1169. package/src/textures/CubeDepthTexture.js +76 -0
  1170. package/src/textures/CubeTexture.js +81 -0
  1171. package/src/textures/Data3DTexture.js +112 -0
  1172. package/src/textures/DataArrayTexture.js +134 -0
  1173. package/src/textures/DataTexture.js +87 -0
  1174. package/src/textures/DepthTexture.js +104 -0
  1175. package/src/textures/ExternalTexture.js +56 -0
  1176. package/src/textures/FramebufferTexture.js +85 -0
  1177. package/src/textures/HTMLTexture.js +74 -0
  1178. package/src/textures/Source.js +230 -0
  1179. package/src/textures/Texture.js +812 -0
  1180. package/src/textures/VideoFrameTexture.js +72 -0
  1181. package/src/textures/VideoTexture.js +127 -0
  1182. package/src/utils.js +493 -0
@@ -0,0 +1,3646 @@
1
+ import {
2
+ BackSide,
3
+ BoxGeometry,
4
+ BufferAttribute,
5
+ BufferGeometry,
6
+ ClampToEdgeWrapping,
7
+ Color,
8
+ ColorManagement,
9
+ ConeGeometry,
10
+ CylinderGeometry,
11
+ DataTexture,
12
+ DoubleSide,
13
+ FileLoader,
14
+ Float32BufferAttribute,
15
+ FrontSide,
16
+ Group,
17
+ LineBasicMaterial,
18
+ LineSegments,
19
+ Loader,
20
+ LoaderUtils,
21
+ MathUtils,
22
+ Mesh,
23
+ MeshBasicMaterial,
24
+ MeshPhongMaterial,
25
+ Object3D,
26
+ OrthographicCamera,
27
+ PerspectiveCamera,
28
+ Points,
29
+ PointsMaterial,
30
+ Quaternion,
31
+ RepeatWrapping,
32
+ Scene,
33
+ ShapeUtils,
34
+ SphereGeometry,
35
+ SRGBColorSpace,
36
+ TextureLoader,
37
+ Vector2,
38
+ Vector3
39
+ } from 'three';
40
+ import chevrotain from '../libs/chevrotain.module.min.js';
41
+
42
+ /**
43
+ * A loader for the VRML format.
44
+ *
45
+ * ```js
46
+ * const loader = new VRMLLoader();
47
+ * const object = await loader.loadAsync( 'models/vrml/house.wrl' );
48
+ * scene.add( object );
49
+ * ```
50
+ *
51
+ * @augments Loader
52
+ * @three_import import { VRMLLoader } from 'three/addons/loaders/VRMLLoader.js';
53
+ */
54
+ class VRMLLoader extends Loader {
55
+
56
+ /**
57
+ * Constructs a new VRML loader.
58
+ *
59
+ * @param {LoadingManager} [manager] - The loading manager.
60
+ */
61
+ constructor( manager ) {
62
+
63
+ super( manager );
64
+
65
+ }
66
+
67
+ /**
68
+ * Starts loading from the given URL and passes the loaded VRML asset
69
+ * to the `onLoad()` callback.
70
+ *
71
+ * @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.
72
+ * @param {function(Scene)} onLoad - Executed when the loading process has been finished.
73
+ * @param {onProgressCallback} onProgress - Executed while the loading is in progress.
74
+ * @param {onErrorCallback} onError - Executed when errors occur.
75
+ */
76
+ load( url, onLoad, onProgress, onError ) {
77
+
78
+ const scope = this;
79
+
80
+ const path = ( scope.path === '' ) ? LoaderUtils.extractUrlBase( url ) : scope.path;
81
+
82
+ const loader = new FileLoader( scope.manager );
83
+ loader.setPath( scope.path );
84
+ loader.setRequestHeader( scope.requestHeader );
85
+ loader.setWithCredentials( scope.withCredentials );
86
+ loader.load( url, function ( text ) {
87
+
88
+ try {
89
+
90
+ onLoad( scope.parse( text, path ) );
91
+
92
+ } catch ( e ) {
93
+
94
+ if ( onError ) {
95
+
96
+ onError( e );
97
+
98
+ } else {
99
+
100
+ console.error( e );
101
+
102
+ }
103
+
104
+ scope.manager.itemError( url );
105
+
106
+ }
107
+
108
+ }, onProgress, onError );
109
+
110
+ }
111
+
112
+ /**
113
+ * Parses the given VRML data and returns the resulting scene.
114
+ *
115
+ * @param {string} data - The raw VRML data as a string.
116
+ * @param {string} path - The URL base path.
117
+ * @return {Scene} The parsed scene.
118
+ */
119
+ parse( data, path ) {
120
+
121
+ const nodeMap = {};
122
+
123
+ function generateVRMLTree( data ) {
124
+
125
+ // create lexer, parser and visitor
126
+
127
+ const tokenData = createTokens();
128
+
129
+ const lexer = new VRMLLexer( tokenData.tokens );
130
+ const parser = new VRMLParser( tokenData.tokenVocabulary );
131
+ const visitor = createVisitor( parser.getBaseCstVisitorConstructor() );
132
+
133
+ // lexing
134
+
135
+ const lexingResult = lexer.lex( data );
136
+ parser.input = lexingResult.tokens;
137
+
138
+ // parsing
139
+
140
+ const cstOutput = parser.vrml();
141
+
142
+ if ( parser.errors.length > 0 ) {
143
+
144
+ console.error( parser.errors );
145
+
146
+ throw Error( 'THREE.VRMLLoader: Parsing errors detected.' );
147
+
148
+ }
149
+
150
+ // actions
151
+
152
+ const ast = visitor.visit( cstOutput );
153
+
154
+ return ast;
155
+
156
+ }
157
+
158
+ function createTokens() {
159
+
160
+ const createToken = chevrotain.createToken;
161
+
162
+ // from http://gun.teipir.gr/VRML-amgem/spec/part1/concepts.html#SyntaxBasics
163
+
164
+ const RouteIdentifier = createToken( { name: 'RouteIdentifier', 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]*[\.][^\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]*/ } );
165
+ const Identifier = createToken( { name: 'Identifier', pattern: /[^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]([^\0-\x20\x22\x27\x23\x2b\x2c\x2e\x5b\x5d\x5c\x7b\x7d])*/, longer_alt: RouteIdentifier } );
166
+
167
+ // from http://gun.teipir.gr/VRML-amgem/spec/part1/nodesRef.html
168
+
169
+ const nodeTypes = [
170
+ 'Anchor', 'Billboard', 'Collision', 'Group', 'Transform', // grouping nodes
171
+ 'Inline', 'LOD', 'Switch', // special groups
172
+ 'PerspectiveCamera', 'OrthographicCamera',
173
+ 'AudioClip', 'DirectionalLight', 'PointLight', 'Script', 'Shape', 'Sound', 'SpotLight', 'WorldInfo', // common nodes
174
+ 'CylinderSensor', 'PlaneSensor', 'ProximitySensor', 'SphereSensor', 'TimeSensor', 'TouchSensor', 'VisibilitySensor', // sensors
175
+ 'Box', 'Cone', 'Cylinder', 'ElevationGrid', 'Extrusion', 'IndexedFaceSet', 'IndexedLineSet', 'PointSet', 'Sphere', // geometries
176
+ 'Color', 'Coordinate', 'Normal', 'TextureCoordinate', // geometric properties
177
+ 'Appearance', 'FontStyle', 'ImageTexture', 'Material', 'MovieTexture', 'PixelTexture', 'TextureTransform', // appearance
178
+ 'ColorInterpolator', 'CoordinateInterpolator', 'NormalInterpolator', 'OrientationInterpolator', 'PositionInterpolator', 'ScalarInterpolator', // interpolators
179
+ 'Background', 'Fog', 'NavigationInfo', 'Viewpoint', // bindable nodes
180
+ 'Text' // Text must be placed at the end of the regex so there are no matches for TextureTransform and TextureCoordinate
181
+ ];
182
+
183
+ //
184
+
185
+ const Version = createToken( {
186
+ name: 'Version',
187
+ pattern: /#VRML.*/,
188
+ longer_alt: Identifier
189
+ } );
190
+
191
+ const NodeName = createToken( {
192
+ name: 'NodeName',
193
+ pattern: new RegExp( nodeTypes.join( '|' ) ),
194
+ longer_alt: Identifier
195
+ } );
196
+
197
+ const DEF = createToken( {
198
+ name: 'DEF',
199
+ pattern: /DEF/,
200
+ longer_alt: Identifier
201
+ } );
202
+
203
+ const USE = createToken( {
204
+ name: 'USE',
205
+ pattern: /USE/,
206
+ longer_alt: Identifier
207
+ } );
208
+
209
+ const ROUTE = createToken( {
210
+ name: 'ROUTE',
211
+ pattern: /ROUTE/,
212
+ longer_alt: Identifier
213
+ } );
214
+
215
+ const TO = createToken( {
216
+ name: 'TO',
217
+ pattern: /TO/,
218
+ longer_alt: Identifier
219
+ } );
220
+
221
+ //
222
+
223
+ const StringLiteral = createToken( { name: 'StringLiteral', pattern: /"(?:[^\\"\n\r]|\\[bfnrtv"\\/]|\\u[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])*"/ } );
224
+ const HexLiteral = createToken( { name: 'HexLiteral', pattern: /0[xX][0-9a-fA-F]+/ } );
225
+ const NumberLiteral = createToken( { name: 'NumberLiteral', pattern: /[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?/ } );
226
+ const TrueLiteral = createToken( { name: 'TrueLiteral', pattern: /TRUE/ } );
227
+ const FalseLiteral = createToken( { name: 'FalseLiteral', pattern: /FALSE/ } );
228
+ const NullLiteral = createToken( { name: 'NullLiteral', pattern: /NULL/ } );
229
+ const LSquare = createToken( { name: 'LSquare', pattern: /\[/ } );
230
+ const RSquare = createToken( { name: 'RSquare', pattern: /]/ } );
231
+ const LCurly = createToken( { name: 'LCurly', pattern: /{/ } );
232
+ const RCurly = createToken( { name: 'RCurly', pattern: /}/ } );
233
+ const Comment = createToken( {
234
+ name: 'Comment',
235
+ pattern: /#.*/,
236
+ group: chevrotain.Lexer.SKIPPED
237
+ } );
238
+
239
+ // commas, blanks, tabs, newlines and carriage returns are whitespace characters wherever they appear outside of string fields
240
+
241
+ const WhiteSpace = createToken( {
242
+ name: 'WhiteSpace',
243
+ pattern: /[ ,\s]/,
244
+ group: chevrotain.Lexer.SKIPPED
245
+ } );
246
+
247
+ const tokens = [
248
+ WhiteSpace,
249
+ // keywords appear before the Identifier
250
+ NodeName,
251
+ DEF,
252
+ USE,
253
+ ROUTE,
254
+ TO,
255
+ TrueLiteral,
256
+ FalseLiteral,
257
+ NullLiteral,
258
+ // the Identifier must appear after the keywords because all keywords are valid identifiers
259
+ Version,
260
+ Identifier,
261
+ RouteIdentifier,
262
+ StringLiteral,
263
+ HexLiteral,
264
+ NumberLiteral,
265
+ LSquare,
266
+ RSquare,
267
+ LCurly,
268
+ RCurly,
269
+ Comment
270
+ ];
271
+
272
+ const tokenVocabulary = {};
273
+
274
+ for ( let i = 0, l = tokens.length; i < l; i ++ ) {
275
+
276
+ const token = tokens[ i ];
277
+
278
+ tokenVocabulary[ token.name ] = token;
279
+
280
+ }
281
+
282
+ return { tokens: tokens, tokenVocabulary: tokenVocabulary };
283
+
284
+ }
285
+
286
+
287
+ function createVisitor( BaseVRMLVisitor ) {
288
+
289
+ // the visitor is created dynamically based on the given base class
290
+
291
+ class VRMLToASTVisitor extends BaseVRMLVisitor {
292
+
293
+ constructor() {
294
+
295
+ super();
296
+
297
+ this.validateVisitor();
298
+
299
+ }
300
+
301
+ vrml( ctx ) {
302
+
303
+ const data = {
304
+ version: this.visit( ctx.version ),
305
+ nodes: [],
306
+ routes: []
307
+ };
308
+
309
+ for ( let i = 0, l = ctx.node.length; i < l; i ++ ) {
310
+
311
+ const node = ctx.node[ i ];
312
+
313
+ data.nodes.push( this.visit( node ) );
314
+
315
+ }
316
+
317
+ if ( ctx.route ) {
318
+
319
+ for ( let i = 0, l = ctx.route.length; i < l; i ++ ) {
320
+
321
+ const route = ctx.route[ i ];
322
+
323
+ data.routes.push( this.visit( route ) );
324
+
325
+ }
326
+
327
+ }
328
+
329
+ return data;
330
+
331
+ }
332
+
333
+ version( ctx ) {
334
+
335
+ return ctx.Version[ 0 ].image;
336
+
337
+ }
338
+
339
+ node( ctx ) {
340
+
341
+ const data = {
342
+ name: ctx.NodeName[ 0 ].image,
343
+ fields: []
344
+ };
345
+
346
+ if ( ctx.field ) {
347
+
348
+ for ( let i = 0, l = ctx.field.length; i < l; i ++ ) {
349
+
350
+ const field = ctx.field[ i ];
351
+
352
+ data.fields.push( this.visit( field ) );
353
+
354
+ }
355
+
356
+ }
357
+
358
+ // DEF
359
+
360
+ if ( ctx.def ) {
361
+
362
+ data.DEF = this.visit( ctx.def[ 0 ] );
363
+
364
+ }
365
+
366
+ return data;
367
+
368
+ }
369
+
370
+ field( ctx ) {
371
+
372
+ const data = {
373
+ name: ctx.Identifier[ 0 ].image,
374
+ type: null,
375
+ values: null
376
+ };
377
+
378
+ let result;
379
+
380
+ // SFValue
381
+
382
+ if ( ctx.singleFieldValue ) {
383
+
384
+ result = this.visit( ctx.singleFieldValue[ 0 ] );
385
+
386
+ }
387
+
388
+ // MFValue
389
+
390
+ if ( ctx.multiFieldValue ) {
391
+
392
+ result = this.visit( ctx.multiFieldValue[ 0 ] );
393
+
394
+ }
395
+
396
+ data.type = result.type;
397
+ data.values = result.values;
398
+
399
+ return data;
400
+
401
+ }
402
+
403
+ def( ctx ) {
404
+
405
+ return ( ctx.Identifier || ctx.NodeName )[ 0 ].image;
406
+
407
+ }
408
+
409
+ use( ctx ) {
410
+
411
+ return { USE: ( ctx.Identifier || ctx.NodeName )[ 0 ].image };
412
+
413
+ }
414
+
415
+ singleFieldValue( ctx ) {
416
+
417
+ return processField( this, ctx );
418
+
419
+ }
420
+
421
+ multiFieldValue( ctx ) {
422
+
423
+ return processField( this, ctx );
424
+
425
+ }
426
+
427
+ route( ctx ) {
428
+
429
+ const data = {
430
+ FROM: ctx.RouteIdentifier[ 0 ].image,
431
+ TO: ctx.RouteIdentifier[ 1 ].image
432
+ };
433
+
434
+ return data;
435
+
436
+ }
437
+
438
+ }
439
+
440
+ function processField( scope, ctx ) {
441
+
442
+ const field = {
443
+ type: null,
444
+ values: []
445
+ };
446
+
447
+ if ( ctx.node ) {
448
+
449
+ field.type = 'node';
450
+
451
+ for ( let i = 0, l = ctx.node.length; i < l; i ++ ) {
452
+
453
+ const node = ctx.node[ i ];
454
+
455
+ field.values.push( scope.visit( node ) );
456
+
457
+ }
458
+
459
+ }
460
+
461
+ if ( ctx.use ) {
462
+
463
+ field.type = 'use';
464
+
465
+ for ( let i = 0, l = ctx.use.length; i < l; i ++ ) {
466
+
467
+ const use = ctx.use[ i ];
468
+
469
+ field.values.push( scope.visit( use ) );
470
+
471
+ }
472
+
473
+ }
474
+
475
+ if ( ctx.StringLiteral ) {
476
+
477
+ field.type = 'string';
478
+
479
+ for ( let i = 0, l = ctx.StringLiteral.length; i < l; i ++ ) {
480
+
481
+ const stringLiteral = ctx.StringLiteral[ i ];
482
+
483
+ field.values.push( stringLiteral.image.replace( /'|"/g, '' ) );
484
+
485
+ }
486
+
487
+ }
488
+
489
+ if ( ctx.NumberLiteral ) {
490
+
491
+ field.type = 'number';
492
+
493
+ for ( let i = 0, l = ctx.NumberLiteral.length; i < l; i ++ ) {
494
+
495
+ const numberLiteral = ctx.NumberLiteral[ i ];
496
+
497
+ field.values.push( parseFloat( numberLiteral.image ) );
498
+
499
+ }
500
+
501
+ }
502
+
503
+ if ( ctx.HexLiteral ) {
504
+
505
+ field.type = 'hex';
506
+
507
+ for ( let i = 0, l = ctx.HexLiteral.length; i < l; i ++ ) {
508
+
509
+ const hexLiteral = ctx.HexLiteral[ i ];
510
+
511
+ field.values.push( hexLiteral.image );
512
+
513
+ }
514
+
515
+ }
516
+
517
+ if ( ctx.TrueLiteral ) {
518
+
519
+ field.type = 'boolean';
520
+
521
+ for ( let i = 0, l = ctx.TrueLiteral.length; i < l; i ++ ) {
522
+
523
+ const trueLiteral = ctx.TrueLiteral[ i ];
524
+
525
+ if ( trueLiteral.image === 'TRUE' ) field.values.push( true );
526
+
527
+ }
528
+
529
+ }
530
+
531
+ if ( ctx.FalseLiteral ) {
532
+
533
+ field.type = 'boolean';
534
+
535
+ for ( let i = 0, l = ctx.FalseLiteral.length; i < l; i ++ ) {
536
+
537
+ const falseLiteral = ctx.FalseLiteral[ i ];
538
+
539
+ if ( falseLiteral.image === 'FALSE' ) field.values.push( false );
540
+
541
+ }
542
+
543
+ }
544
+
545
+ if ( ctx.NullLiteral ) {
546
+
547
+ field.type = 'null';
548
+
549
+ ctx.NullLiteral.forEach( function () {
550
+
551
+ field.values.push( null );
552
+
553
+ } );
554
+
555
+ }
556
+
557
+ return field;
558
+
559
+ }
560
+
561
+ return new VRMLToASTVisitor();
562
+
563
+ }
564
+
565
+ function parseTree( tree ) {
566
+
567
+ // console.log( JSON.stringify( tree, null, 2 ) );
568
+
569
+ const nodes = tree.nodes;
570
+ const scene = new Scene();
571
+
572
+ // first iteration: build nodemap based on DEF statements
573
+
574
+ for ( let i = 0, l = nodes.length; i < l; i ++ ) {
575
+
576
+ const node = nodes[ i ];
577
+
578
+ buildNodeMap( node );
579
+
580
+ }
581
+
582
+ // second iteration: build nodes
583
+
584
+ for ( let i = 0, l = nodes.length; i < l; i ++ ) {
585
+
586
+ const node = nodes[ i ];
587
+ const object = getNode( node );
588
+
589
+ if ( object instanceof Object3D ) scene.add( object );
590
+
591
+ if ( node.name === 'WorldInfo' ) scene.userData.worldInfo = object;
592
+
593
+ }
594
+
595
+ return scene;
596
+
597
+ }
598
+
599
+ function buildNodeMap( node ) {
600
+
601
+ if ( node.DEF ) {
602
+
603
+ nodeMap[ node.DEF ] = node;
604
+
605
+ }
606
+
607
+ const fields = node.fields;
608
+
609
+ for ( let i = 0, l = fields.length; i < l; i ++ ) {
610
+
611
+ const field = fields[ i ];
612
+
613
+ if ( field.type === 'node' ) {
614
+
615
+ const fieldValues = field.values;
616
+
617
+ for ( let j = 0, jl = fieldValues.length; j < jl; j ++ ) {
618
+
619
+ buildNodeMap( fieldValues[ j ] );
620
+
621
+ }
622
+
623
+ }
624
+
625
+
626
+ }
627
+
628
+ }
629
+
630
+
631
+ function getNode( node ) {
632
+
633
+ // handle case where a node refers to a different one
634
+
635
+ if ( node.USE ) {
636
+
637
+ return resolveUSE( node.USE );
638
+
639
+ }
640
+
641
+ if ( node.build !== undefined ) return node.build;
642
+
643
+ node.build = buildNode( node );
644
+
645
+ return node.build;
646
+
647
+ }
648
+
649
+ // node builder
650
+
651
+ function buildNode( node ) {
652
+
653
+ const nodeName = node.name;
654
+ let build;
655
+
656
+ switch ( nodeName ) {
657
+
658
+ case 'Anchor':
659
+ case 'Group':
660
+ case 'Transform':
661
+ case 'Collision':
662
+ build = buildGroupingNode( node );
663
+ break;
664
+
665
+ case 'Background':
666
+ build = buildBackgroundNode( node );
667
+ break;
668
+
669
+ case 'Shape':
670
+ build = buildShapeNode( node );
671
+ break;
672
+
673
+ case 'Appearance':
674
+ build = buildAppearanceNode( node );
675
+ break;
676
+
677
+ case 'Material':
678
+ build = buildMaterialNode( node );
679
+ break;
680
+
681
+ case 'ImageTexture':
682
+ build = buildImageTextureNode( node );
683
+ break;
684
+
685
+ case 'PixelTexture':
686
+ build = buildPixelTextureNode( node );
687
+ break;
688
+
689
+ case 'TextureTransform':
690
+ build = buildTextureTransformNode( node );
691
+ break;
692
+
693
+ case 'IndexedFaceSet':
694
+ build = buildIndexedFaceSetNode( node );
695
+ break;
696
+
697
+ case 'IndexedLineSet':
698
+ build = buildIndexedLineSetNode( node );
699
+ break;
700
+
701
+ case 'PointSet':
702
+ build = buildPointSetNode( node );
703
+ break;
704
+
705
+ case 'Box':
706
+ build = buildBoxNode( node );
707
+ break;
708
+
709
+ case 'Cone':
710
+ build = buildConeNode( node );
711
+ break;
712
+
713
+ case 'Cylinder':
714
+ build = buildCylinderNode( node );
715
+ break;
716
+
717
+ case 'Sphere':
718
+ build = buildSphereNode( node );
719
+ break;
720
+
721
+ case 'ElevationGrid':
722
+ build = buildElevationGridNode( node );
723
+ break;
724
+
725
+ case 'Extrusion':
726
+ build = buildExtrusionNode( node );
727
+ break;
728
+
729
+ case 'Color':
730
+ case 'Coordinate':
731
+ case 'Normal':
732
+ case 'TextureCoordinate':
733
+ build = buildGeometricNode( node );
734
+ break;
735
+
736
+ case 'WorldInfo':
737
+ build = buildWorldInfoNode( node );
738
+ break;
739
+
740
+ case 'OrthographicCamera':
741
+ case 'PerspectiveCamera':
742
+ build = buildCamera( node, nodeName );
743
+ break;
744
+
745
+ case 'Billboard':
746
+
747
+ case 'Inline':
748
+ case 'LOD':
749
+ case 'Switch':
750
+
751
+ case 'AudioClip':
752
+ case 'DirectionalLight':
753
+ case 'PointLight':
754
+ case 'Script':
755
+ case 'Sound':
756
+ case 'SpotLight':
757
+
758
+ case 'CylinderSensor':
759
+ case 'PlaneSensor':
760
+ case 'ProximitySensor':
761
+ case 'SphereSensor':
762
+ case 'TimeSensor':
763
+ case 'TouchSensor':
764
+ case 'VisibilitySensor':
765
+
766
+ case 'Text':
767
+
768
+ case 'FontStyle':
769
+ case 'MovieTexture':
770
+
771
+ case 'ColorInterpolator':
772
+ case 'CoordinateInterpolator':
773
+ case 'NormalInterpolator':
774
+ case 'OrientationInterpolator':
775
+ case 'PositionInterpolator':
776
+ case 'ScalarInterpolator':
777
+
778
+ case 'Fog':
779
+ case 'NavigationInfo':
780
+ case 'Viewpoint':
781
+ // node not supported yet
782
+ break;
783
+
784
+ default:
785
+ console.warn( 'THREE.VRMLLoader: Unknown node:', nodeName );
786
+ break;
787
+
788
+ }
789
+
790
+ if ( build !== undefined && node.DEF !== undefined && build.hasOwnProperty( 'name' ) === true ) {
791
+
792
+ build.name = node.DEF;
793
+
794
+ }
795
+
796
+ return build;
797
+
798
+ }
799
+
800
+ function buildGroupingNode( node ) {
801
+
802
+ const object = new Group();
803
+
804
+ //
805
+
806
+ const fields = node.fields;
807
+
808
+ for ( let i = 0, l = fields.length; i < l; i ++ ) {
809
+
810
+ const field = fields[ i ];
811
+ const fieldName = field.name;
812
+ const fieldValues = field.values;
813
+
814
+ switch ( fieldName ) {
815
+
816
+ case 'bboxCenter':
817
+ // field not supported
818
+ break;
819
+
820
+ case 'bboxSize':
821
+ // field not supported
822
+ break;
823
+
824
+ case 'center':
825
+ // field not supported
826
+ break;
827
+
828
+ case 'children':
829
+ parseFieldChildren( fieldValues, object );
830
+ break;
831
+
832
+ case 'description':
833
+ // field not supported
834
+ break;
835
+
836
+ case 'collide':
837
+ // field not supported
838
+ break;
839
+
840
+ case 'parameter':
841
+ // field not supported
842
+ break;
843
+
844
+ case 'rotation':
845
+ const axis = new Vector3( fieldValues[ 0 ], fieldValues[ 1 ], fieldValues[ 2 ] ).normalize();
846
+ const angle = fieldValues[ 3 ];
847
+ object.quaternion.setFromAxisAngle( axis, angle );
848
+ break;
849
+
850
+ case 'scale':
851
+ object.scale.set( fieldValues[ 0 ], fieldValues[ 1 ], fieldValues[ 2 ] );
852
+ break;
853
+
854
+ case 'scaleOrientation':
855
+ // field not supported
856
+ break;
857
+
858
+ case 'translation':
859
+ object.position.set( fieldValues[ 0 ], fieldValues[ 1 ], fieldValues[ 2 ] );
860
+ break;
861
+
862
+ case 'proxy':
863
+ // field not supported
864
+ break;
865
+
866
+ case 'url':
867
+ // field not supported
868
+ break;
869
+
870
+ default:
871
+ console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
872
+ break;
873
+
874
+ }
875
+
876
+ }
877
+
878
+ return object;
879
+
880
+ }
881
+
882
+ function buildBackgroundNode( node ) {
883
+
884
+ const group = new Group();
885
+
886
+ let groundAngle, groundColor;
887
+ let skyAngle, skyColor;
888
+
889
+ const fields = node.fields;
890
+
891
+ for ( let i = 0, l = fields.length; i < l; i ++ ) {
892
+
893
+ const field = fields[ i ];
894
+ const fieldName = field.name;
895
+ const fieldValues = field.values;
896
+
897
+ switch ( fieldName ) {
898
+
899
+ case 'groundAngle':
900
+ groundAngle = fieldValues;
901
+ break;
902
+
903
+ case 'groundColor':
904
+ groundColor = fieldValues;
905
+ break;
906
+
907
+ case 'backUrl':
908
+ // field not supported
909
+ break;
910
+
911
+ case 'bottomUrl':
912
+ // field not supported
913
+ break;
914
+
915
+ case 'frontUrl':
916
+ // field not supported
917
+ break;
918
+
919
+ case 'leftUrl':
920
+ // field not supported
921
+ break;
922
+
923
+ case 'rightUrl':
924
+ // field not supported
925
+ break;
926
+
927
+ case 'topUrl':
928
+ // field not supported
929
+ break;
930
+
931
+ case 'skyAngle':
932
+ skyAngle = fieldValues;
933
+ break;
934
+
935
+ case 'skyColor':
936
+ skyColor = fieldValues;
937
+ break;
938
+
939
+ default:
940
+ console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
941
+ break;
942
+
943
+ }
944
+
945
+ }
946
+
947
+ const radius = 10000;
948
+
949
+ // sky
950
+
951
+ if ( skyColor ) {
952
+
953
+ const skyGeometry = new SphereGeometry( radius, 32, 16 );
954
+ const skyMaterial = new MeshBasicMaterial( { fog: false, side: BackSide, depthWrite: false, depthTest: false } );
955
+
956
+ if ( skyColor.length > 3 ) {
957
+
958
+ paintFaces( skyGeometry, radius, skyAngle, toColorArray( skyColor ), true );
959
+ skyMaterial.vertexColors = true;
960
+
961
+ } else {
962
+
963
+ skyMaterial.color.setRGB( skyColor[ 0 ], skyColor[ 1 ], skyColor[ 2 ], SRGBColorSpace );
964
+
965
+ }
966
+
967
+ const sky = new Mesh( skyGeometry, skyMaterial );
968
+ group.add( sky );
969
+
970
+ }
971
+
972
+ // ground
973
+
974
+ if ( groundColor ) {
975
+
976
+ if ( groundColor.length > 0 ) {
977
+
978
+ const groundGeometry = new SphereGeometry( radius, 32, 16, 0, 2 * Math.PI, 0.5 * Math.PI, 1.5 * Math.PI );
979
+ const groundMaterial = new MeshBasicMaterial( { fog: false, side: BackSide, vertexColors: true, depthWrite: false, depthTest: false } );
980
+
981
+ paintFaces( groundGeometry, radius, groundAngle, toColorArray( groundColor ), false );
982
+
983
+ const ground = new Mesh( groundGeometry, groundMaterial );
984
+ group.add( ground );
985
+
986
+ }
987
+
988
+ }
989
+
990
+ // render background group first
991
+
992
+ group.renderOrder = - Infinity;
993
+
994
+ return group;
995
+
996
+ }
997
+
998
+ function buildShapeNode( node ) {
999
+
1000
+ const fields = node.fields;
1001
+
1002
+ // if the appearance field is NULL or unspecified, lighting is off and the unlit object color is (0, 0, 0)
1003
+
1004
+ let material = new MeshBasicMaterial( {
1005
+ name: Loader.DEFAULT_MATERIAL_NAME,
1006
+ color: 0x000000
1007
+ } );
1008
+ let geometry;
1009
+
1010
+ for ( let i = 0, l = fields.length; i < l; i ++ ) {
1011
+
1012
+ const field = fields[ i ];
1013
+ const fieldName = field.name;
1014
+ const fieldValues = field.values;
1015
+
1016
+ switch ( fieldName ) {
1017
+
1018
+ case 'appearance':
1019
+ if ( fieldValues[ 0 ] !== null ) {
1020
+
1021
+ material = getNode( fieldValues[ 0 ] );
1022
+
1023
+ }
1024
+
1025
+ break;
1026
+
1027
+ case 'geometry':
1028
+ if ( fieldValues[ 0 ] !== null ) {
1029
+
1030
+ geometry = getNode( fieldValues[ 0 ] );
1031
+
1032
+ }
1033
+
1034
+ break;
1035
+
1036
+ default:
1037
+ console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
1038
+ break;
1039
+
1040
+ }
1041
+
1042
+ }
1043
+
1044
+ // build 3D object
1045
+
1046
+ let object;
1047
+
1048
+ if ( geometry && geometry.attributes.position ) {
1049
+
1050
+ const type = geometry._type;
1051
+
1052
+ if ( type === 'points' ) { // points
1053
+
1054
+ const pointsMaterial = new PointsMaterial( {
1055
+ name: Loader.DEFAULT_MATERIAL_NAME,
1056
+ color: 0xffffff,
1057
+ opacity: material.opacity,
1058
+ transparent: material.transparent
1059
+ } );
1060
+
1061
+ if ( geometry.attributes.color !== undefined ) {
1062
+
1063
+ pointsMaterial.vertexColors = true;
1064
+
1065
+ } else {
1066
+
1067
+ // 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
1068
+
1069
+ if ( material.isMeshPhongMaterial ) {
1070
+
1071
+ pointsMaterial.color.copy( material.emissive );
1072
+
1073
+ }
1074
+
1075
+ }
1076
+
1077
+ object = new Points( geometry, pointsMaterial );
1078
+
1079
+ } else if ( type === 'line' ) { // lines
1080
+
1081
+ const lineMaterial = new LineBasicMaterial( {
1082
+ name: Loader.DEFAULT_MATERIAL_NAME,
1083
+ color: 0xffffff,
1084
+ opacity: material.opacity,
1085
+ transparent: material.transparent
1086
+ } );
1087
+
1088
+ if ( geometry.attributes.color !== undefined ) {
1089
+
1090
+ lineMaterial.vertexColors = true;
1091
+
1092
+ } else {
1093
+
1094
+ // 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
1095
+
1096
+ if ( material.isMeshPhongMaterial ) {
1097
+
1098
+ lineMaterial.color.copy( material.emissive );
1099
+
1100
+ }
1101
+
1102
+ }
1103
+
1104
+ object = new LineSegments( geometry, lineMaterial );
1105
+
1106
+ } else { // consider meshes
1107
+
1108
+ // check "solid" hint (it's placed in the geometry but affects the material)
1109
+
1110
+ if ( geometry._solid !== undefined ) {
1111
+
1112
+ material.side = ( geometry._solid ) ? FrontSide : DoubleSide;
1113
+
1114
+ }
1115
+
1116
+ // check for vertex colors
1117
+
1118
+ if ( geometry.attributes.color !== undefined ) {
1119
+
1120
+ material.vertexColors = true;
1121
+
1122
+ }
1123
+
1124
+ object = new Mesh( geometry, material );
1125
+
1126
+ }
1127
+
1128
+ } else {
1129
+
1130
+ object = new Object3D();
1131
+
1132
+ // if the geometry field is NULL or no vertices are defined the object is not drawn
1133
+
1134
+ object.visible = false;
1135
+
1136
+ }
1137
+
1138
+ return object;
1139
+
1140
+ }
1141
+
1142
+ function buildAppearanceNode( node ) {
1143
+
1144
+ let material = new MeshPhongMaterial();
1145
+ let transformData;
1146
+
1147
+ const fields = node.fields;
1148
+
1149
+ for ( let i = 0, l = fields.length; i < l; i ++ ) {
1150
+
1151
+ const field = fields[ i ];
1152
+ const fieldName = field.name;
1153
+ const fieldValues = field.values;
1154
+
1155
+ switch ( fieldName ) {
1156
+
1157
+ case 'material':
1158
+ if ( fieldValues[ 0 ] !== null ) {
1159
+
1160
+ const materialData = getNode( fieldValues[ 0 ] );
1161
+
1162
+ if ( materialData.diffuseColor ) material.color.copy( materialData.diffuseColor );
1163
+ if ( materialData.emissiveColor ) material.emissive.copy( materialData.emissiveColor );
1164
+ if ( materialData.shininess ) material.shininess = materialData.shininess;
1165
+ if ( materialData.specularColor ) material.specular.copy( materialData.specularColor );
1166
+ if ( materialData.transparency ) material.opacity = 1 - materialData.transparency;
1167
+ if ( materialData.transparency > 0 ) material.transparent = true;
1168
+
1169
+ } else {
1170
+
1171
+ // if the material field is NULL or unspecified, lighting is off and the unlit object color is (0, 0, 0)
1172
+
1173
+ material = new MeshBasicMaterial( {
1174
+ name: Loader.DEFAULT_MATERIAL_NAME,
1175
+ color: 0x000000
1176
+ } );
1177
+
1178
+ }
1179
+
1180
+ break;
1181
+
1182
+ case 'texture':
1183
+ const textureNode = fieldValues[ 0 ];
1184
+ if ( textureNode !== null ) {
1185
+
1186
+ if ( textureNode.name === 'ImageTexture' || textureNode.name === 'PixelTexture' ) {
1187
+
1188
+ material.map = getNode( textureNode );
1189
+
1190
+ } else {
1191
+
1192
+ // MovieTexture not supported yet
1193
+
1194
+ }
1195
+
1196
+ }
1197
+
1198
+ break;
1199
+
1200
+ case 'textureTransform':
1201
+ if ( fieldValues[ 0 ] !== null ) {
1202
+
1203
+ transformData = getNode( fieldValues[ 0 ] );
1204
+
1205
+ }
1206
+
1207
+ break;
1208
+
1209
+ default:
1210
+ console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
1211
+ break;
1212
+
1213
+ }
1214
+
1215
+ }
1216
+
1217
+ // only apply texture transform data if a texture was defined
1218
+
1219
+ if ( material.map ) {
1220
+
1221
+ // respect VRML lighting model
1222
+
1223
+ if ( material.map.__type ) {
1224
+
1225
+ switch ( material.map.__type ) {
1226
+
1227
+ case TEXTURE_TYPE.INTENSITY_ALPHA:
1228
+ material.opacity = 1; // ignore transparency
1229
+ break;
1230
+
1231
+ case TEXTURE_TYPE.RGB:
1232
+ material.color.set( 0xffffff ); // ignore material color
1233
+ break;
1234
+
1235
+ case TEXTURE_TYPE.RGBA:
1236
+ material.color.set( 0xffffff ); // ignore material color
1237
+ material.opacity = 1; // ignore transparency
1238
+ break;
1239
+
1240
+ default:
1241
+
1242
+ }
1243
+
1244
+ delete material.map.__type;
1245
+
1246
+ }
1247
+
1248
+ // apply texture transform
1249
+
1250
+ if ( transformData ) {
1251
+
1252
+ material.map.center.copy( transformData.center );
1253
+ material.map.rotation = transformData.rotation;
1254
+ material.map.repeat.copy( transformData.scale );
1255
+ material.map.offset.copy( transformData.translation );
1256
+
1257
+ }
1258
+
1259
+ }
1260
+
1261
+ return material;
1262
+
1263
+ }
1264
+
1265
+ function buildMaterialNode( node ) {
1266
+
1267
+ const materialData = {};
1268
+
1269
+ const fields = node.fields;
1270
+
1271
+ for ( let i = 0, l = fields.length; i < l; i ++ ) {
1272
+
1273
+ const field = fields[ i ];
1274
+ const fieldName = field.name;
1275
+ const fieldValues = field.values;
1276
+
1277
+ switch ( fieldName ) {
1278
+
1279
+ case 'ambientIntensity':
1280
+ // field not supported
1281
+ break;
1282
+
1283
+ case 'diffuseColor':
1284
+ materialData.diffuseColor = new Color().setRGB( fieldValues[ 0 ], fieldValues[ 1 ], fieldValues[ 2 ], SRGBColorSpace );
1285
+ break;
1286
+
1287
+ case 'emissiveColor':
1288
+ materialData.emissiveColor = new Color().setRGB( fieldValues[ 0 ], fieldValues[ 1 ], fieldValues[ 2 ], SRGBColorSpace );
1289
+ break;
1290
+
1291
+ case 'shininess':
1292
+ materialData.shininess = fieldValues[ 0 ];
1293
+ break;
1294
+
1295
+ case 'specularColor':
1296
+ materialData.specularColor = new Color().setRGB( fieldValues[ 0 ], fieldValues[ 1 ], fieldValues[ 2 ], SRGBColorSpace );
1297
+ break;
1298
+
1299
+ case 'transparency':
1300
+ materialData.transparency = fieldValues[ 0 ];
1301
+ break;
1302
+
1303
+ default:
1304
+ console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
1305
+ break;
1306
+
1307
+ }
1308
+
1309
+ }
1310
+
1311
+ return materialData;
1312
+
1313
+ }
1314
+
1315
+ function parseHexColor( hex, textureType, color ) {
1316
+
1317
+ let value;
1318
+
1319
+ switch ( textureType ) {
1320
+
1321
+ case TEXTURE_TYPE.INTENSITY:
1322
+ // Intensity texture: A one-component image specifies one-byte hexadecimal or integer values representing the intensity of the image
1323
+ value = parseInt( hex );
1324
+ color.r = value;
1325
+ color.g = value;
1326
+ color.b = value;
1327
+ color.a = 1;
1328
+ break;
1329
+
1330
+ case TEXTURE_TYPE.INTENSITY_ALPHA:
1331
+ // Intensity+Alpha texture: A two-component image specifies the intensity in the first (high) byte and the alpha opacity in the second (low) byte.
1332
+ value = parseInt( '0x' + hex.substring( 2, 4 ) );
1333
+ color.r = value;
1334
+ color.g = value;
1335
+ color.b = value;
1336
+ color.a = parseInt( '0x' + hex.substring( 4, 6 ) );
1337
+ break;
1338
+
1339
+ case TEXTURE_TYPE.RGB:
1340
+ // RGB texture: Pixels in a three-component image specify the red component in the first (high) byte, followed by the green and blue components
1341
+ color.r = parseInt( '0x' + hex.substring( 2, 4 ) );
1342
+ color.g = parseInt( '0x' + hex.substring( 4, 6 ) );
1343
+ color.b = parseInt( '0x' + hex.substring( 6, 8 ) );
1344
+ color.a = 1;
1345
+ break;
1346
+
1347
+ case TEXTURE_TYPE.RGBA:
1348
+ // RGBA texture: Four-component images specify the alpha opacity byte after red/green/blue
1349
+ color.r = parseInt( '0x' + hex.substring( 2, 4 ) );
1350
+ color.g = parseInt( '0x' + hex.substring( 4, 6 ) );
1351
+ color.b = parseInt( '0x' + hex.substring( 6, 8 ) );
1352
+ color.a = parseInt( '0x' + hex.substring( 8, 10 ) );
1353
+ break;
1354
+
1355
+ default:
1356
+
1357
+ }
1358
+
1359
+ }
1360
+
1361
+ function getTextureType( num_components ) {
1362
+
1363
+ let type;
1364
+
1365
+ switch ( num_components ) {
1366
+
1367
+ case 1:
1368
+ type = TEXTURE_TYPE.INTENSITY;
1369
+ break;
1370
+
1371
+ case 2:
1372
+ type = TEXTURE_TYPE.INTENSITY_ALPHA;
1373
+ break;
1374
+
1375
+ case 3:
1376
+ type = TEXTURE_TYPE.RGB;
1377
+ break;
1378
+
1379
+ case 4:
1380
+ type = TEXTURE_TYPE.RGBA;
1381
+ break;
1382
+
1383
+ default:
1384
+
1385
+ }
1386
+
1387
+ return type;
1388
+
1389
+ }
1390
+
1391
+ function buildPixelTextureNode( node ) {
1392
+
1393
+ let texture;
1394
+ let wrapS = RepeatWrapping;
1395
+ let wrapT = RepeatWrapping;
1396
+
1397
+ const fields = node.fields;
1398
+
1399
+ for ( let i = 0, l = fields.length; i < l; i ++ ) {
1400
+
1401
+ const field = fields[ i ];
1402
+ const fieldName = field.name;
1403
+ const fieldValues = field.values;
1404
+
1405
+ switch ( fieldName ) {
1406
+
1407
+ case 'image':
1408
+ const width = fieldValues[ 0 ];
1409
+ const height = fieldValues[ 1 ];
1410
+ const num_components = fieldValues[ 2 ];
1411
+
1412
+ const textureType = getTextureType( num_components );
1413
+
1414
+ const data = new Uint8Array( 4 * width * height );
1415
+
1416
+ const color = { r: 0, g: 0, b: 0, a: 0 };
1417
+
1418
+ for ( let j = 3, k = 0, jl = fieldValues.length; j < jl; j ++, k ++ ) {
1419
+
1420
+ parseHexColor( fieldValues[ j ], textureType, color );
1421
+
1422
+ const stride = k * 4;
1423
+
1424
+ data[ stride + 0 ] = color.r;
1425
+ data[ stride + 1 ] = color.g;
1426
+ data[ stride + 2 ] = color.b;
1427
+ data[ stride + 3 ] = color.a;
1428
+
1429
+ }
1430
+
1431
+ texture = new DataTexture( data, width, height );
1432
+ texture.colorSpace = SRGBColorSpace;
1433
+ texture.needsUpdate = true;
1434
+ texture.__type = textureType; // needed for material modifications
1435
+ break;
1436
+
1437
+ case 'repeatS':
1438
+ if ( fieldValues[ 0 ] === false ) wrapS = ClampToEdgeWrapping;
1439
+ break;
1440
+
1441
+ case 'repeatT':
1442
+ if ( fieldValues[ 0 ] === false ) wrapT = ClampToEdgeWrapping;
1443
+ break;
1444
+
1445
+ default:
1446
+ console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
1447
+ break;
1448
+
1449
+ }
1450
+
1451
+ }
1452
+
1453
+ if ( texture ) {
1454
+
1455
+ texture.wrapS = wrapS;
1456
+ texture.wrapT = wrapT;
1457
+
1458
+ }
1459
+
1460
+ return texture;
1461
+
1462
+ }
1463
+
1464
+ function buildImageTextureNode( node ) {
1465
+
1466
+ let texture;
1467
+ let wrapS = RepeatWrapping;
1468
+ let wrapT = RepeatWrapping;
1469
+
1470
+ const fields = node.fields;
1471
+
1472
+ for ( let i = 0, l = fields.length; i < l; i ++ ) {
1473
+
1474
+ const field = fields[ i ];
1475
+ const fieldName = field.name;
1476
+ const fieldValues = field.values;
1477
+
1478
+ switch ( fieldName ) {
1479
+
1480
+ case 'url':
1481
+ const url = fieldValues[ 0 ];
1482
+ if ( url ) texture = textureLoader.load( url );
1483
+ break;
1484
+
1485
+ case 'repeatS':
1486
+ if ( fieldValues[ 0 ] === false ) wrapS = ClampToEdgeWrapping;
1487
+ break;
1488
+
1489
+ case 'repeatT':
1490
+ if ( fieldValues[ 0 ] === false ) wrapT = ClampToEdgeWrapping;
1491
+ break;
1492
+
1493
+ default:
1494
+ console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
1495
+ break;
1496
+
1497
+ }
1498
+
1499
+ }
1500
+
1501
+ if ( texture ) {
1502
+
1503
+ texture.wrapS = wrapS;
1504
+ texture.wrapT = wrapT;
1505
+ texture.colorSpace = SRGBColorSpace;
1506
+
1507
+ }
1508
+
1509
+ return texture;
1510
+
1511
+ }
1512
+
1513
+ function buildTextureTransformNode( node ) {
1514
+
1515
+ const transformData = {
1516
+ center: new Vector2(),
1517
+ rotation: new Vector2(),
1518
+ scale: new Vector2(),
1519
+ translation: new Vector2()
1520
+ };
1521
+
1522
+ const fields = node.fields;
1523
+
1524
+ for ( let i = 0, l = fields.length; i < l; i ++ ) {
1525
+
1526
+ const field = fields[ i ];
1527
+ const fieldName = field.name;
1528
+ const fieldValues = field.values;
1529
+
1530
+ switch ( fieldName ) {
1531
+
1532
+ case 'center':
1533
+ transformData.center.set( fieldValues[ 0 ], fieldValues[ 1 ] );
1534
+ break;
1535
+
1536
+ case 'rotation':
1537
+ transformData.rotation = fieldValues[ 0 ];
1538
+ break;
1539
+
1540
+ case 'scale':
1541
+ transformData.scale.set( fieldValues[ 0 ], fieldValues[ 1 ] );
1542
+ break;
1543
+
1544
+ case 'translation':
1545
+ transformData.translation.set( fieldValues[ 0 ], fieldValues[ 1 ] );
1546
+ break;
1547
+
1548
+ default:
1549
+ console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
1550
+ break;
1551
+
1552
+ }
1553
+
1554
+ }
1555
+
1556
+ return transformData;
1557
+
1558
+ }
1559
+
1560
+ function buildGeometricNode( node ) {
1561
+
1562
+ return node.fields[ 0 ].values;
1563
+
1564
+ }
1565
+
1566
+ function buildWorldInfoNode( node ) {
1567
+
1568
+ const worldInfo = {};
1569
+
1570
+ const fields = node.fields;
1571
+
1572
+ for ( let i = 0, l = fields.length; i < l; i ++ ) {
1573
+
1574
+ const field = fields[ i ];
1575
+ const fieldName = field.name;
1576
+ const fieldValues = field.values;
1577
+
1578
+ switch ( fieldName ) {
1579
+
1580
+ case 'title':
1581
+ worldInfo.title = fieldValues[ 0 ];
1582
+ break;
1583
+
1584
+ case 'info':
1585
+ worldInfo.info = fieldValues;
1586
+ break;
1587
+
1588
+ default:
1589
+ console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
1590
+ break;
1591
+
1592
+ }
1593
+
1594
+ }
1595
+
1596
+ return worldInfo;
1597
+
1598
+ }
1599
+
1600
+ function buildCamera( node, type ) {
1601
+
1602
+ const camera = ( type === 'PerspectiveCamera' ) ? new PerspectiveCamera() : new OrthographicCamera();
1603
+
1604
+ const width = ( typeof window !== 'undefined' ) ? window.innerWidth : 1;
1605
+ const height = ( typeof window !== 'undefined' ) ? window.innerHeight : 1;
1606
+ const aspect = width / height;
1607
+
1608
+ const fields = node.fields;
1609
+
1610
+ for ( let i = 0, l = fields.length; i < l; i ++ ) {
1611
+
1612
+ const field = fields[ i ];
1613
+ const fieldName = field.name;
1614
+ const fieldValues = field.values;
1615
+
1616
+ switch ( fieldName ) {
1617
+
1618
+ case 'position':
1619
+ camera.position.set( fieldValues[ 0 ], fieldValues[ 1 ], fieldValues[ 0 ] );
1620
+ break;
1621
+
1622
+ case 'orientation':
1623
+ const axis = new Vector3( fieldValues[ 0 ], fieldValues[ 1 ], fieldValues[ 2 ] ).normalize();
1624
+ const angle = fieldValues[ 3 ];
1625
+ camera.quaternion.setFromAxisAngle( axis, angle );
1626
+ break;
1627
+
1628
+ case 'focalDistance':
1629
+ camera.userData.focalDistance = fieldValues[ 0 ]; // might be useful for DoF
1630
+ break;
1631
+
1632
+ case 'heightAngle':
1633
+
1634
+ // for perspective cams only
1635
+
1636
+ camera.fov = MathUtils.radToDeg( fieldValues[ 0 ] );
1637
+ camera.aspect = aspect;
1638
+ camera.updateProjectionMatrix();
1639
+
1640
+ break;
1641
+
1642
+ case 'height':
1643
+
1644
+ // for ortho cams only
1645
+
1646
+ const halfHeight = fieldValues[ 0 ] / 2;
1647
+ const halfWidth = halfHeight * aspect;
1648
+
1649
+ camera.left = - halfWidth;
1650
+ camera.right = halfWidth;
1651
+ camera.top = halfHeight;
1652
+ camera.bottom = - halfHeight;
1653
+ camera.updateProjectionMatrix();
1654
+ break;
1655
+
1656
+ default:
1657
+ console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
1658
+ break;
1659
+
1660
+ }
1661
+
1662
+ }
1663
+
1664
+ return camera;
1665
+
1666
+ }
1667
+
1668
+ function buildIndexedFaceSetNode( node ) {
1669
+
1670
+ let color, coord, normal, texCoord;
1671
+ let ccw = true, solid = true, creaseAngle = 0;
1672
+ let colorIndex, coordIndex, normalIndex, texCoordIndex;
1673
+ let colorPerVertex = true, normalPerVertex = true;
1674
+
1675
+ const fields = node.fields;
1676
+
1677
+ for ( let i = 0, l = fields.length; i < l; i ++ ) {
1678
+
1679
+ const field = fields[ i ];
1680
+ const fieldName = field.name;
1681
+ const fieldValues = field.values;
1682
+
1683
+ switch ( fieldName ) {
1684
+
1685
+ case 'color':
1686
+ const colorNode = fieldValues[ 0 ];
1687
+
1688
+ if ( colorNode !== null ) {
1689
+
1690
+ color = getNode( colorNode );
1691
+
1692
+ }
1693
+
1694
+ break;
1695
+
1696
+ case 'coord':
1697
+ const coordNode = fieldValues[ 0 ];
1698
+
1699
+ if ( coordNode !== null ) {
1700
+
1701
+ coord = getNode( coordNode );
1702
+
1703
+ }
1704
+
1705
+ break;
1706
+
1707
+ case 'normal':
1708
+ const normalNode = fieldValues[ 0 ];
1709
+
1710
+ if ( normalNode !== null ) {
1711
+
1712
+ normal = getNode( normalNode );
1713
+
1714
+ }
1715
+
1716
+ break;
1717
+
1718
+ case 'texCoord':
1719
+ const texCoordNode = fieldValues[ 0 ];
1720
+
1721
+ if ( texCoordNode !== null ) {
1722
+
1723
+ texCoord = getNode( texCoordNode );
1724
+
1725
+ }
1726
+
1727
+ break;
1728
+
1729
+ case 'ccw':
1730
+ ccw = fieldValues[ 0 ];
1731
+ break;
1732
+
1733
+ case 'colorIndex':
1734
+ colorIndex = fieldValues;
1735
+ break;
1736
+
1737
+ case 'colorPerVertex':
1738
+ colorPerVertex = fieldValues[ 0 ];
1739
+ break;
1740
+
1741
+ case 'convex':
1742
+ // field not supported
1743
+ break;
1744
+
1745
+ case 'coordIndex':
1746
+ coordIndex = fieldValues;
1747
+ break;
1748
+
1749
+ case 'creaseAngle':
1750
+ creaseAngle = fieldValues[ 0 ];
1751
+ break;
1752
+
1753
+ case 'normalIndex':
1754
+ normalIndex = fieldValues;
1755
+ break;
1756
+
1757
+ case 'normalPerVertex':
1758
+ normalPerVertex = fieldValues[ 0 ];
1759
+ break;
1760
+
1761
+ case 'solid':
1762
+ solid = fieldValues[ 0 ];
1763
+ break;
1764
+
1765
+ case 'texCoordIndex':
1766
+ texCoordIndex = fieldValues;
1767
+ break;
1768
+
1769
+ default:
1770
+ console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
1771
+ break;
1772
+
1773
+ }
1774
+
1775
+ }
1776
+
1777
+ if ( coordIndex === undefined ) {
1778
+
1779
+ console.warn( 'THREE.VRMLLoader: Missing coordIndex.' );
1780
+
1781
+ return new BufferGeometry(); // handle VRML files with incomplete geometry definition
1782
+
1783
+ }
1784
+
1785
+ const triangulatedCoordIndex = triangulateFaceIndex( coordIndex, ccw );
1786
+
1787
+ let colorAttribute;
1788
+ let normalAttribute;
1789
+ let uvAttribute;
1790
+
1791
+ if ( color ) {
1792
+
1793
+ if ( colorPerVertex === true ) {
1794
+
1795
+ if ( colorIndex && colorIndex.length > 0 ) {
1796
+
1797
+ // if the colorIndex field is not empty, then it is used to choose colors for each vertex of the IndexedFaceSet.
1798
+
1799
+ const triangulatedColorIndex = triangulateFaceIndex( colorIndex, ccw );
1800
+ colorAttribute = computeAttributeFromIndexedData( triangulatedCoordIndex, triangulatedColorIndex, color, 3 );
1801
+
1802
+ } else {
1803
+
1804
+ // if the colorIndex field is empty, then the coordIndex field is used to choose colors from the Color node
1805
+
1806
+ colorAttribute = toNonIndexedAttribute( triangulatedCoordIndex, new Float32BufferAttribute( color, 3 ) );
1807
+
1808
+ }
1809
+
1810
+ } else {
1811
+
1812
+ if ( colorIndex && colorIndex.length > 0 ) {
1813
+
1814
+ // if the colorIndex field is not empty, then they are used to choose one color for each face of the IndexedFaceSet
1815
+
1816
+ const flattenFaceColors = flattenData( color, colorIndex );
1817
+ const triangulatedFaceColors = triangulateFaceData( flattenFaceColors, coordIndex );
1818
+ colorAttribute = computeAttributeFromFaceData( triangulatedCoordIndex, triangulatedFaceColors );
1819
+
1820
+ } else {
1821
+
1822
+ // if the colorIndex field is empty, then the color are applied to each face of the IndexedFaceSet in order
1823
+
1824
+ const triangulatedFaceColors = triangulateFaceData( color, coordIndex );
1825
+ colorAttribute = computeAttributeFromFaceData( triangulatedCoordIndex, triangulatedFaceColors );
1826
+
1827
+
1828
+ }
1829
+
1830
+ }
1831
+
1832
+ convertColorsToLinearSRGB( colorAttribute );
1833
+
1834
+ }
1835
+
1836
+ if ( normal ) {
1837
+
1838
+ if ( normalPerVertex === true ) {
1839
+
1840
+ // consider vertex normals
1841
+
1842
+ if ( normalIndex && normalIndex.length > 0 ) {
1843
+
1844
+ // if the normalIndex field is not empty, then it is used to choose normals for each vertex of the IndexedFaceSet.
1845
+
1846
+ const triangulatedNormalIndex = triangulateFaceIndex( normalIndex, ccw );
1847
+ normalAttribute = computeAttributeFromIndexedData( triangulatedCoordIndex, triangulatedNormalIndex, normal, 3 );
1848
+
1849
+ } else {
1850
+
1851
+ // if the normalIndex field is empty, then the coordIndex field is used to choose normals from the Normal node
1852
+
1853
+ normalAttribute = toNonIndexedAttribute( triangulatedCoordIndex, new Float32BufferAttribute( normal, 3 ) );
1854
+
1855
+ }
1856
+
1857
+ } else {
1858
+
1859
+ // consider face normals
1860
+
1861
+ if ( normalIndex && normalIndex.length > 0 ) {
1862
+
1863
+ // if the normalIndex field is not empty, then they are used to choose one normal for each face of the IndexedFaceSet
1864
+
1865
+ const flattenFaceNormals = flattenData( normal, normalIndex );
1866
+ const triangulatedFaceNormals = triangulateFaceData( flattenFaceNormals, coordIndex );
1867
+ normalAttribute = computeAttributeFromFaceData( triangulatedCoordIndex, triangulatedFaceNormals );
1868
+
1869
+ } else {
1870
+
1871
+ // if the normalIndex field is empty, then the normals are applied to each face of the IndexedFaceSet in order
1872
+
1873
+ const triangulatedFaceNormals = triangulateFaceData( normal, coordIndex );
1874
+ normalAttribute = computeAttributeFromFaceData( triangulatedCoordIndex, triangulatedFaceNormals );
1875
+
1876
+ }
1877
+
1878
+ }
1879
+
1880
+ } else {
1881
+
1882
+ // 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
1883
+
1884
+ normalAttribute = computeNormalAttribute( triangulatedCoordIndex, coord, creaseAngle );
1885
+
1886
+ }
1887
+
1888
+ if ( texCoord ) {
1889
+
1890
+ // texture coordinates are always defined on vertex level
1891
+
1892
+ if ( texCoordIndex && texCoordIndex.length > 0 ) {
1893
+
1894
+ // if the texCoordIndex field is not empty, then it is used to choose texture coordinates for each vertex of the IndexedFaceSet.
1895
+
1896
+ const triangulatedTexCoordIndex = triangulateFaceIndex( texCoordIndex, ccw );
1897
+ uvAttribute = computeAttributeFromIndexedData( triangulatedCoordIndex, triangulatedTexCoordIndex, texCoord, 2 );
1898
+
1899
+
1900
+ } else {
1901
+
1902
+ // if the texCoordIndex field is empty, then the coordIndex array is used to choose texture coordinates from the TextureCoordinate node
1903
+
1904
+ uvAttribute = toNonIndexedAttribute( triangulatedCoordIndex, new Float32BufferAttribute( texCoord, 2 ) );
1905
+
1906
+ }
1907
+
1908
+ }
1909
+
1910
+ const geometry = new BufferGeometry();
1911
+ const positionAttribute = toNonIndexedAttribute( triangulatedCoordIndex, new Float32BufferAttribute( coord, 3 ) );
1912
+
1913
+ geometry.setAttribute( 'position', positionAttribute );
1914
+ geometry.setAttribute( 'normal', normalAttribute );
1915
+
1916
+ // optional attributes
1917
+
1918
+ if ( colorAttribute ) geometry.setAttribute( 'color', colorAttribute );
1919
+ if ( uvAttribute ) geometry.setAttribute( 'uv', uvAttribute );
1920
+
1921
+ // "solid" influences the material so let's store it for later use
1922
+
1923
+ geometry._solid = solid;
1924
+ geometry._type = 'mesh';
1925
+
1926
+ return geometry;
1927
+
1928
+ }
1929
+
1930
+ function buildIndexedLineSetNode( node ) {
1931
+
1932
+ let color, coord;
1933
+ let colorIndex, coordIndex;
1934
+ let colorPerVertex = true;
1935
+
1936
+ const fields = node.fields;
1937
+
1938
+ for ( let i = 0, l = fields.length; i < l; i ++ ) {
1939
+
1940
+ const field = fields[ i ];
1941
+ const fieldName = field.name;
1942
+ const fieldValues = field.values;
1943
+
1944
+ switch ( fieldName ) {
1945
+
1946
+ case 'color':
1947
+ const colorNode = fieldValues[ 0 ];
1948
+
1949
+ if ( colorNode !== null ) {
1950
+
1951
+ color = getNode( colorNode );
1952
+
1953
+ }
1954
+
1955
+ break;
1956
+
1957
+ case 'coord':
1958
+ const coordNode = fieldValues[ 0 ];
1959
+
1960
+ if ( coordNode !== null ) {
1961
+
1962
+ coord = getNode( coordNode );
1963
+
1964
+ }
1965
+
1966
+ break;
1967
+
1968
+ case 'colorIndex':
1969
+ colorIndex = fieldValues;
1970
+ break;
1971
+
1972
+ case 'colorPerVertex':
1973
+ colorPerVertex = fieldValues[ 0 ];
1974
+ break;
1975
+
1976
+ case 'coordIndex':
1977
+ coordIndex = fieldValues;
1978
+ break;
1979
+
1980
+ default:
1981
+ console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
1982
+ break;
1983
+
1984
+ }
1985
+
1986
+ }
1987
+
1988
+ // build lines
1989
+
1990
+ let colorAttribute;
1991
+
1992
+ const expandedLineIndex = expandLineIndex( coordIndex ); // create an index for three.js's linesegment primitive
1993
+
1994
+ if ( color ) {
1995
+
1996
+ if ( colorPerVertex === true ) {
1997
+
1998
+ if ( colorIndex.length > 0 ) {
1999
+
2000
+ // if the colorIndex field is not empty, then one color is used for each polyline of the IndexedLineSet.
2001
+
2002
+ const expandedColorIndex = expandLineIndex( colorIndex ); // compute colors for each line segment (rendering primitive)
2003
+ colorAttribute = computeAttributeFromIndexedData( expandedLineIndex, expandedColorIndex, color, 3 ); // compute data on vertex level
2004
+
2005
+ } else {
2006
+
2007
+ // if the colorIndex field is empty, then the colors are applied to each polyline of the IndexedLineSet in order.
2008
+
2009
+ colorAttribute = toNonIndexedAttribute( expandedLineIndex, new Float32BufferAttribute( color, 3 ) );
2010
+
2011
+ }
2012
+
2013
+ } else {
2014
+
2015
+ if ( colorIndex.length > 0 ) {
2016
+
2017
+ // if the colorIndex field is not empty, then colors are applied to each vertex of the IndexedLineSet
2018
+
2019
+ const flattenLineColors = flattenData( color, colorIndex ); // compute colors for each VRML primitive
2020
+ const expandedLineColors = expandLineData( flattenLineColors, coordIndex ); // compute colors for each line segment (rendering primitive)
2021
+ colorAttribute = computeAttributeFromLineData( expandedLineIndex, expandedLineColors ); // compute data on vertex level
2022
+
2023
+
2024
+ } else {
2025
+
2026
+ // if the colorIndex field is empty, then the coordIndex field is used to choose colors from the Color node
2027
+
2028
+ const expandedLineColors = expandLineData( color, coordIndex ); // compute colors for each line segment (rendering primitive)
2029
+ colorAttribute = computeAttributeFromLineData( expandedLineIndex, expandedLineColors ); // compute data on vertex level
2030
+
2031
+ }
2032
+
2033
+ }
2034
+
2035
+ convertColorsToLinearSRGB( colorAttribute );
2036
+
2037
+ }
2038
+
2039
+ //
2040
+
2041
+ const geometry = new BufferGeometry();
2042
+
2043
+ const positionAttribute = toNonIndexedAttribute( expandedLineIndex, new Float32BufferAttribute( coord, 3 ) );
2044
+ geometry.setAttribute( 'position', positionAttribute );
2045
+
2046
+ if ( colorAttribute ) geometry.setAttribute( 'color', colorAttribute );
2047
+
2048
+ geometry._type = 'line';
2049
+
2050
+ return geometry;
2051
+
2052
+ }
2053
+
2054
+ function buildPointSetNode( node ) {
2055
+
2056
+ let color, coord;
2057
+
2058
+ const fields = node.fields;
2059
+
2060
+ for ( let i = 0, l = fields.length; i < l; i ++ ) {
2061
+
2062
+ const field = fields[ i ];
2063
+ const fieldName = field.name;
2064
+ const fieldValues = field.values;
2065
+
2066
+ switch ( fieldName ) {
2067
+
2068
+ case 'color':
2069
+ const colorNode = fieldValues[ 0 ];
2070
+
2071
+ if ( colorNode !== null ) {
2072
+
2073
+ color = getNode( colorNode );
2074
+
2075
+ }
2076
+
2077
+ break;
2078
+
2079
+ case 'coord':
2080
+ const coordNode = fieldValues[ 0 ];
2081
+
2082
+ if ( coordNode !== null ) {
2083
+
2084
+ coord = getNode( coordNode );
2085
+
2086
+ }
2087
+
2088
+ break;
2089
+
2090
+
2091
+ default:
2092
+ console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
2093
+ break;
2094
+
2095
+ }
2096
+
2097
+ }
2098
+
2099
+ const geometry = new BufferGeometry();
2100
+
2101
+ geometry.setAttribute( 'position', new Float32BufferAttribute( coord, 3 ) );
2102
+
2103
+ if ( color ) {
2104
+
2105
+ const colorAttribute = new Float32BufferAttribute( color, 3 );
2106
+ convertColorsToLinearSRGB( colorAttribute );
2107
+
2108
+ geometry.setAttribute( 'color', colorAttribute );
2109
+
2110
+ }
2111
+
2112
+ geometry._type = 'points';
2113
+
2114
+ return geometry;
2115
+
2116
+ }
2117
+
2118
+ function buildBoxNode( node ) {
2119
+
2120
+ const size = new Vector3( 2, 2, 2 );
2121
+
2122
+ const fields = node.fields;
2123
+
2124
+ for ( let i = 0, l = fields.length; i < l; i ++ ) {
2125
+
2126
+ const field = fields[ i ];
2127
+ const fieldName = field.name;
2128
+ const fieldValues = field.values;
2129
+
2130
+ switch ( fieldName ) {
2131
+
2132
+ case 'size':
2133
+ size.x = fieldValues[ 0 ];
2134
+ size.y = fieldValues[ 1 ];
2135
+ size.z = fieldValues[ 2 ];
2136
+ break;
2137
+
2138
+ default:
2139
+ console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
2140
+ break;
2141
+
2142
+ }
2143
+
2144
+ }
2145
+
2146
+ const geometry = new BoxGeometry( size.x, size.y, size.z );
2147
+
2148
+ return geometry;
2149
+
2150
+ }
2151
+
2152
+ function buildConeNode( node ) {
2153
+
2154
+ let radius = 1, height = 2, openEnded = false;
2155
+
2156
+ const fields = node.fields;
2157
+
2158
+ for ( let i = 0, l = fields.length; i < l; i ++ ) {
2159
+
2160
+ const field = fields[ i ];
2161
+ const fieldName = field.name;
2162
+ const fieldValues = field.values;
2163
+
2164
+ switch ( fieldName ) {
2165
+
2166
+ case 'bottom':
2167
+ openEnded = ! fieldValues[ 0 ];
2168
+ break;
2169
+
2170
+ case 'bottomRadius':
2171
+ radius = fieldValues[ 0 ];
2172
+ break;
2173
+
2174
+ case 'height':
2175
+ height = fieldValues[ 0 ];
2176
+ break;
2177
+
2178
+ case 'side':
2179
+ // field not supported
2180
+ break;
2181
+
2182
+ default:
2183
+ console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
2184
+ break;
2185
+
2186
+ }
2187
+
2188
+ }
2189
+
2190
+ const geometry = new ConeGeometry( radius, height, 16, 1, openEnded );
2191
+
2192
+ return geometry;
2193
+
2194
+ }
2195
+
2196
+ function buildCylinderNode( node ) {
2197
+
2198
+ let radius = 1, height = 2;
2199
+
2200
+ const fields = node.fields;
2201
+
2202
+ for ( let i = 0, l = fields.length; i < l; i ++ ) {
2203
+
2204
+ const field = fields[ i ];
2205
+ const fieldName = field.name;
2206
+ const fieldValues = field.values;
2207
+
2208
+ switch ( fieldName ) {
2209
+
2210
+ case 'bottom':
2211
+ // field not supported
2212
+ break;
2213
+
2214
+ case 'radius':
2215
+ radius = fieldValues[ 0 ];
2216
+ break;
2217
+
2218
+ case 'height':
2219
+ height = fieldValues[ 0 ];
2220
+ break;
2221
+
2222
+ case 'side':
2223
+ // field not supported
2224
+ break;
2225
+
2226
+ case 'top':
2227
+ // field not supported
2228
+ break;
2229
+
2230
+ default:
2231
+ console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
2232
+ break;
2233
+
2234
+ }
2235
+
2236
+ }
2237
+
2238
+ const geometry = new CylinderGeometry( radius, radius, height, 16, 1 );
2239
+
2240
+ return geometry;
2241
+
2242
+ }
2243
+
2244
+ function buildSphereNode( node ) {
2245
+
2246
+ let radius = 1;
2247
+
2248
+ const fields = node.fields;
2249
+
2250
+ for ( let i = 0, l = fields.length; i < l; i ++ ) {
2251
+
2252
+ const field = fields[ i ];
2253
+ const fieldName = field.name;
2254
+ const fieldValues = field.values;
2255
+
2256
+ switch ( fieldName ) {
2257
+
2258
+ case 'radius':
2259
+ radius = fieldValues[ 0 ];
2260
+ break;
2261
+
2262
+ default:
2263
+ console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
2264
+ break;
2265
+
2266
+ }
2267
+
2268
+ }
2269
+
2270
+ const geometry = new SphereGeometry( radius, 16, 16 );
2271
+
2272
+ return geometry;
2273
+
2274
+ }
2275
+
2276
+ function buildElevationGridNode( node ) {
2277
+
2278
+ let color;
2279
+ let normal;
2280
+ let texCoord;
2281
+ let height;
2282
+
2283
+ let colorPerVertex = true;
2284
+ let normalPerVertex = true;
2285
+ let solid = true;
2286
+ let ccw = true;
2287
+ let creaseAngle = 0;
2288
+ let xDimension = 2;
2289
+ let zDimension = 2;
2290
+ let xSpacing = 1;
2291
+ let zSpacing = 1;
2292
+
2293
+ const fields = node.fields;
2294
+
2295
+ for ( let i = 0, l = fields.length; i < l; i ++ ) {
2296
+
2297
+ const field = fields[ i ];
2298
+ const fieldName = field.name;
2299
+ const fieldValues = field.values;
2300
+
2301
+ switch ( fieldName ) {
2302
+
2303
+ case 'color':
2304
+ const colorNode = fieldValues[ 0 ];
2305
+
2306
+ if ( colorNode !== null ) {
2307
+
2308
+ color = getNode( colorNode );
2309
+
2310
+ }
2311
+
2312
+ break;
2313
+
2314
+ case 'normal':
2315
+ const normalNode = fieldValues[ 0 ];
2316
+
2317
+ if ( normalNode !== null ) {
2318
+
2319
+ normal = getNode( normalNode );
2320
+
2321
+ }
2322
+
2323
+ break;
2324
+
2325
+ case 'texCoord':
2326
+ const texCoordNode = fieldValues[ 0 ];
2327
+
2328
+ if ( texCoordNode !== null ) {
2329
+
2330
+ texCoord = getNode( texCoordNode );
2331
+
2332
+ }
2333
+
2334
+ break;
2335
+
2336
+ case 'height':
2337
+ height = fieldValues;
2338
+ break;
2339
+
2340
+ case 'ccw':
2341
+ ccw = fieldValues[ 0 ];
2342
+ break;
2343
+
2344
+ case 'colorPerVertex':
2345
+ colorPerVertex = fieldValues[ 0 ];
2346
+ break;
2347
+
2348
+ case 'creaseAngle':
2349
+ creaseAngle = fieldValues[ 0 ];
2350
+ break;
2351
+
2352
+ case 'normalPerVertex':
2353
+ normalPerVertex = fieldValues[ 0 ];
2354
+ break;
2355
+
2356
+ case 'solid':
2357
+ solid = fieldValues[ 0 ];
2358
+ break;
2359
+
2360
+ case 'xDimension':
2361
+ xDimension = fieldValues[ 0 ];
2362
+ break;
2363
+
2364
+ case 'xSpacing':
2365
+ xSpacing = fieldValues[ 0 ];
2366
+ break;
2367
+
2368
+ case 'zDimension':
2369
+ zDimension = fieldValues[ 0 ];
2370
+ break;
2371
+
2372
+ case 'zSpacing':
2373
+ zSpacing = fieldValues[ 0 ];
2374
+ break;
2375
+
2376
+ default:
2377
+ console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
2378
+ break;
2379
+
2380
+ }
2381
+
2382
+ }
2383
+
2384
+ // vertex data
2385
+
2386
+ const vertices = [];
2387
+ const normals = [];
2388
+ const colors = [];
2389
+ const uvs = [];
2390
+
2391
+ for ( let i = 0; i < zDimension; i ++ ) {
2392
+
2393
+ for ( let j = 0; j < xDimension; j ++ ) {
2394
+
2395
+ // compute a row major index
2396
+
2397
+ const index = ( i * xDimension ) + j;
2398
+
2399
+ // vertices
2400
+
2401
+ const x = xSpacing * i;
2402
+ const y = height[ index ];
2403
+ const z = zSpacing * j;
2404
+
2405
+ vertices.push( x, y, z );
2406
+
2407
+ // colors
2408
+
2409
+ if ( color && colorPerVertex === true ) {
2410
+
2411
+ const r = color[ index * 3 + 0 ];
2412
+ const g = color[ index * 3 + 1 ];
2413
+ const b = color[ index * 3 + 2 ];
2414
+
2415
+ colors.push( r, g, b );
2416
+
2417
+ }
2418
+
2419
+ // normals
2420
+
2421
+ if ( normal && normalPerVertex === true ) {
2422
+
2423
+ const xn = normal[ index * 3 + 0 ];
2424
+ const yn = normal[ index * 3 + 1 ];
2425
+ const zn = normal[ index * 3 + 2 ];
2426
+
2427
+ normals.push( xn, yn, zn );
2428
+
2429
+ }
2430
+
2431
+ // uvs
2432
+
2433
+ if ( texCoord ) {
2434
+
2435
+ const s = texCoord[ index * 2 + 0 ];
2436
+ const t = texCoord[ index * 2 + 1 ];
2437
+
2438
+ uvs.push( s, t );
2439
+
2440
+
2441
+ } else {
2442
+
2443
+ uvs.push( i / ( xDimension - 1 ), j / ( zDimension - 1 ) );
2444
+
2445
+ }
2446
+
2447
+ }
2448
+
2449
+ }
2450
+
2451
+ // indices
2452
+
2453
+ const indices = [];
2454
+
2455
+ for ( let i = 0; i < xDimension - 1; i ++ ) {
2456
+
2457
+ for ( let j = 0; j < zDimension - 1; j ++ ) {
2458
+
2459
+ // from https://tecfa.unige.ch/guides/vrml/vrml97/spec/part1/nodesRef.html#ElevationGrid
2460
+
2461
+ const a = i + j * xDimension;
2462
+ const b = i + ( j + 1 ) * xDimension;
2463
+ const c = ( i + 1 ) + ( j + 1 ) * xDimension;
2464
+ const d = ( i + 1 ) + j * xDimension;
2465
+
2466
+ // faces
2467
+
2468
+ if ( ccw === true ) {
2469
+
2470
+ indices.push( a, c, b );
2471
+ indices.push( c, a, d );
2472
+
2473
+ } else {
2474
+
2475
+ indices.push( a, b, c );
2476
+ indices.push( c, d, a );
2477
+
2478
+ }
2479
+
2480
+ }
2481
+
2482
+ }
2483
+
2484
+ //
2485
+
2486
+ const positionAttribute = toNonIndexedAttribute( indices, new Float32BufferAttribute( vertices, 3 ) );
2487
+ const uvAttribute = toNonIndexedAttribute( indices, new Float32BufferAttribute( uvs, 2 ) );
2488
+ let colorAttribute;
2489
+ let normalAttribute;
2490
+
2491
+ // color attribute
2492
+
2493
+ if ( color ) {
2494
+
2495
+ if ( colorPerVertex === false ) {
2496
+
2497
+ for ( let i = 0; i < xDimension - 1; i ++ ) {
2498
+
2499
+ for ( let j = 0; j < zDimension - 1; j ++ ) {
2500
+
2501
+ const index = i + j * ( xDimension - 1 );
2502
+
2503
+ const r = color[ index * 3 + 0 ];
2504
+ const g = color[ index * 3 + 1 ];
2505
+ const b = color[ index * 3 + 2 ];
2506
+
2507
+ // one color per quad
2508
+
2509
+ colors.push( r, g, b ); colors.push( r, g, b ); colors.push( r, g, b );
2510
+ colors.push( r, g, b ); colors.push( r, g, b ); colors.push( r, g, b );
2511
+
2512
+ }
2513
+
2514
+ }
2515
+
2516
+ colorAttribute = new Float32BufferAttribute( colors, 3 );
2517
+
2518
+ } else {
2519
+
2520
+ colorAttribute = toNonIndexedAttribute( indices, new Float32BufferAttribute( colors, 3 ) );
2521
+
2522
+ }
2523
+
2524
+ convertColorsToLinearSRGB( colorAttribute );
2525
+
2526
+ }
2527
+
2528
+ // normal attribute
2529
+
2530
+ if ( normal ) {
2531
+
2532
+ if ( normalPerVertex === false ) {
2533
+
2534
+ for ( let i = 0; i < xDimension - 1; i ++ ) {
2535
+
2536
+ for ( let j = 0; j < zDimension - 1; j ++ ) {
2537
+
2538
+ const index = i + j * ( xDimension - 1 );
2539
+
2540
+ const xn = normal[ index * 3 + 0 ];
2541
+ const yn = normal[ index * 3 + 1 ];
2542
+ const zn = normal[ index * 3 + 2 ];
2543
+
2544
+ // one normal per quad
2545
+
2546
+ normals.push( xn, yn, zn ); normals.push( xn, yn, zn ); normals.push( xn, yn, zn );
2547
+ normals.push( xn, yn, zn ); normals.push( xn, yn, zn ); normals.push( xn, yn, zn );
2548
+
2549
+ }
2550
+
2551
+ }
2552
+
2553
+ normalAttribute = new Float32BufferAttribute( normals, 3 );
2554
+
2555
+ } else {
2556
+
2557
+ normalAttribute = toNonIndexedAttribute( indices, new Float32BufferAttribute( normals, 3 ) );
2558
+
2559
+ }
2560
+
2561
+ } else {
2562
+
2563
+ normalAttribute = computeNormalAttribute( indices, vertices, creaseAngle );
2564
+
2565
+ }
2566
+
2567
+ // build geometry
2568
+
2569
+ const geometry = new BufferGeometry();
2570
+ geometry.setAttribute( 'position', positionAttribute );
2571
+ geometry.setAttribute( 'normal', normalAttribute );
2572
+ geometry.setAttribute( 'uv', uvAttribute );
2573
+
2574
+ if ( colorAttribute ) geometry.setAttribute( 'color', colorAttribute );
2575
+
2576
+ // "solid" influences the material so let's store it for later use
2577
+
2578
+ geometry._solid = solid;
2579
+ geometry._type = 'mesh';
2580
+
2581
+ return geometry;
2582
+
2583
+ }
2584
+
2585
+ function buildExtrusionNode( node ) {
2586
+
2587
+ let crossSection = [ 1, 1, 1, - 1, - 1, - 1, - 1, 1, 1, 1 ];
2588
+ let spine = [ 0, 0, 0, 0, 1, 0 ];
2589
+ let scale;
2590
+ let orientation;
2591
+
2592
+ let beginCap = true;
2593
+ let ccw = true;
2594
+ let creaseAngle = 0;
2595
+ let endCap = true;
2596
+ let solid = true;
2597
+
2598
+ const fields = node.fields;
2599
+
2600
+ for ( let i = 0, l = fields.length; i < l; i ++ ) {
2601
+
2602
+ const field = fields[ i ];
2603
+ const fieldName = field.name;
2604
+ const fieldValues = field.values;
2605
+
2606
+ switch ( fieldName ) {
2607
+
2608
+ case 'beginCap':
2609
+ beginCap = fieldValues[ 0 ];
2610
+ break;
2611
+
2612
+ case 'ccw':
2613
+ ccw = fieldValues[ 0 ];
2614
+ break;
2615
+
2616
+ case 'convex':
2617
+ // field not supported
2618
+ break;
2619
+
2620
+ case 'creaseAngle':
2621
+ creaseAngle = fieldValues[ 0 ];
2622
+ break;
2623
+
2624
+ case 'crossSection':
2625
+ crossSection = fieldValues;
2626
+ break;
2627
+
2628
+ case 'endCap':
2629
+ endCap = fieldValues[ 0 ];
2630
+ break;
2631
+
2632
+ case 'orientation':
2633
+ orientation = fieldValues;
2634
+ break;
2635
+
2636
+ case 'scale':
2637
+ scale = fieldValues;
2638
+ break;
2639
+
2640
+ case 'solid':
2641
+ solid = fieldValues[ 0 ];
2642
+ break;
2643
+
2644
+ case 'spine':
2645
+ spine = fieldValues; // only extrusion along the Y-axis are supported so far
2646
+ break;
2647
+
2648
+ default:
2649
+ console.warn( 'THREE.VRMLLoader: Unknown field:', fieldName );
2650
+ break;
2651
+
2652
+ }
2653
+
2654
+ }
2655
+
2656
+ const crossSectionClosed = ( crossSection[ 0 ] === crossSection[ crossSection.length - 2 ] && crossSection[ 1 ] === crossSection[ crossSection.length - 1 ] );
2657
+
2658
+ // vertices
2659
+
2660
+ const vertices = [];
2661
+ const spineVector = new Vector3();
2662
+ const scaling = new Vector3();
2663
+
2664
+ const axis = new Vector3();
2665
+ const vertex = new Vector3();
2666
+ const quaternion = new Quaternion();
2667
+
2668
+ for ( let i = 0, j = 0, o = 0, il = spine.length; i < il; i += 3, j += 2, o += 4 ) {
2669
+
2670
+ spineVector.fromArray( spine, i );
2671
+
2672
+ scaling.x = scale ? scale[ j + 0 ] : 1;
2673
+ scaling.y = 1;
2674
+ scaling.z = scale ? scale[ j + 1 ] : 1;
2675
+
2676
+ axis.x = orientation ? orientation[ o + 0 ] : 0;
2677
+ axis.y = orientation ? orientation[ o + 1 ] : 0;
2678
+ axis.z = orientation ? orientation[ o + 2 ] : 1;
2679
+ const angle = orientation ? orientation[ o + 3 ] : 0;
2680
+
2681
+ for ( let k = 0, kl = crossSection.length; k < kl; k += 2 ) {
2682
+
2683
+ vertex.x = crossSection[ k + 0 ];
2684
+ vertex.y = 0;
2685
+ vertex.z = crossSection[ k + 1 ];
2686
+
2687
+ // scale
2688
+
2689
+ vertex.multiply( scaling );
2690
+
2691
+ // rotate
2692
+
2693
+ quaternion.setFromAxisAngle( axis, angle );
2694
+ vertex.applyQuaternion( quaternion );
2695
+
2696
+ // translate
2697
+
2698
+ vertex.add( spineVector );
2699
+
2700
+ vertices.push( vertex.x, vertex.y, vertex.z );
2701
+
2702
+ }
2703
+
2704
+ }
2705
+
2706
+ // indices
2707
+
2708
+ const indices = [];
2709
+
2710
+ const spineCount = spine.length / 3;
2711
+ const crossSectionCount = crossSection.length / 2;
2712
+
2713
+ for ( let i = 0; i < spineCount - 1; i ++ ) {
2714
+
2715
+ for ( let j = 0; j < crossSectionCount - 1; j ++ ) {
2716
+
2717
+ const a = j + i * crossSectionCount;
2718
+ let b = ( j + 1 ) + i * crossSectionCount;
2719
+ const c = j + ( i + 1 ) * crossSectionCount;
2720
+ let d = ( j + 1 ) + ( i + 1 ) * crossSectionCount;
2721
+
2722
+ if ( ( j === crossSectionCount - 2 ) && ( crossSectionClosed === true ) ) {
2723
+
2724
+ b = i * crossSectionCount;
2725
+ d = ( i + 1 ) * crossSectionCount;
2726
+
2727
+ }
2728
+
2729
+ if ( ccw === true ) {
2730
+
2731
+ indices.push( a, b, c );
2732
+ indices.push( c, b, d );
2733
+
2734
+ } else {
2735
+
2736
+ indices.push( a, c, b );
2737
+ indices.push( c, d, b );
2738
+
2739
+ }
2740
+
2741
+ }
2742
+
2743
+ }
2744
+
2745
+ // triangulate cap
2746
+
2747
+ if ( beginCap === true || endCap === true ) {
2748
+
2749
+ const contour = [];
2750
+
2751
+ for ( let i = 0, l = crossSection.length; i < l; i += 2 ) {
2752
+
2753
+ contour.push( new Vector2( crossSection[ i ], crossSection[ i + 1 ] ) );
2754
+
2755
+ }
2756
+
2757
+ const faces = ShapeUtils.triangulateShape( contour, [] );
2758
+ const capIndices = [];
2759
+
2760
+ for ( let i = 0, l = faces.length; i < l; i ++ ) {
2761
+
2762
+ const face = faces[ i ];
2763
+
2764
+ capIndices.push( face[ 0 ], face[ 1 ], face[ 2 ] );
2765
+
2766
+ }
2767
+
2768
+ // begin cap
2769
+
2770
+ if ( beginCap === true ) {
2771
+
2772
+ for ( let i = 0, l = capIndices.length; i < l; i += 3 ) {
2773
+
2774
+ if ( ccw === true ) {
2775
+
2776
+ indices.push( capIndices[ i + 0 ], capIndices[ i + 1 ], capIndices[ i + 2 ] );
2777
+
2778
+ } else {
2779
+
2780
+ indices.push( capIndices[ i + 0 ], capIndices[ i + 2 ], capIndices[ i + 1 ] );
2781
+
2782
+ }
2783
+
2784
+ }
2785
+
2786
+ }
2787
+
2788
+ // end cap
2789
+
2790
+ if ( endCap === true ) {
2791
+
2792
+ const indexOffset = crossSectionCount * ( spineCount - 1 ); // references to the first vertex of the last cross section
2793
+
2794
+ for ( let i = 0, l = capIndices.length; i < l; i += 3 ) {
2795
+
2796
+ if ( ccw === true ) {
2797
+
2798
+ indices.push( indexOffset + capIndices[ i + 0 ], indexOffset + capIndices[ i + 2 ], indexOffset + capIndices[ i + 1 ] );
2799
+
2800
+ } else {
2801
+
2802
+ indices.push( indexOffset + capIndices[ i + 0 ], indexOffset + capIndices[ i + 1 ], indexOffset + capIndices[ i + 2 ] );
2803
+
2804
+ }
2805
+
2806
+ }
2807
+
2808
+ }
2809
+
2810
+ }
2811
+
2812
+ const positionAttribute = toNonIndexedAttribute( indices, new Float32BufferAttribute( vertices, 3 ) );
2813
+ const normalAttribute = computeNormalAttribute( indices, vertices, creaseAngle );
2814
+
2815
+ const geometry = new BufferGeometry();
2816
+ geometry.setAttribute( 'position', positionAttribute );
2817
+ geometry.setAttribute( 'normal', normalAttribute );
2818
+ // no uvs yet
2819
+
2820
+ // "solid" influences the material so let's store it for later use
2821
+
2822
+ geometry._solid = solid;
2823
+ geometry._type = 'mesh';
2824
+
2825
+ return geometry;
2826
+
2827
+ }
2828
+
2829
+ // helper functions
2830
+
2831
+ function resolveUSE( identifier ) {
2832
+
2833
+ const node = nodeMap[ identifier ];
2834
+ const build = getNode( node );
2835
+
2836
+ // because the same 3D objects can have different transformations, it's necessary to clone them.
2837
+ // materials can be influenced by the geometry (e.g. vertex normals). cloning is necessary to avoid
2838
+ // any side effects
2839
+
2840
+ return ( build.isObject3D || build.isMaterial ) ? build.clone() : build;
2841
+
2842
+ }
2843
+
2844
+ function parseFieldChildren( children, owner ) {
2845
+
2846
+ for ( let i = 0, l = children.length; i < l; i ++ ) {
2847
+
2848
+ const object = getNode( children[ i ] );
2849
+
2850
+ if ( object instanceof Object3D ) owner.add( object );
2851
+
2852
+ }
2853
+
2854
+ }
2855
+
2856
+ function triangulateFaceIndex( index, ccw ) {
2857
+
2858
+ const indices = [];
2859
+
2860
+ // since face definitions can have more than three vertices, it's necessary to
2861
+ // perform a simple triangulation
2862
+
2863
+ let start = 0;
2864
+
2865
+ for ( let i = 0, l = index.length; i < l; i ++ ) {
2866
+
2867
+ const i1 = index[ start ];
2868
+ const i2 = index[ i + ( ccw ? 1 : 2 ) ];
2869
+ const i3 = index[ i + ( ccw ? 2 : 1 ) ];
2870
+
2871
+ indices.push( i1, i2, i3 );
2872
+
2873
+ // an index of -1 indicates that the current face has ended and the next one begins
2874
+
2875
+ if ( index[ i + 3 ] === - 1 || i + 3 >= l ) {
2876
+
2877
+ i += 3;
2878
+ start = i + 1;
2879
+
2880
+ }
2881
+
2882
+ }
2883
+
2884
+ return indices;
2885
+
2886
+ }
2887
+
2888
+ function triangulateFaceData( data, index ) {
2889
+
2890
+ const triangulatedData = [];
2891
+
2892
+ let start = 0;
2893
+
2894
+ for ( let i = 0, l = index.length; i < l; i ++ ) {
2895
+
2896
+ const stride = start * 3;
2897
+
2898
+ const x = data[ stride ];
2899
+ const y = data[ stride + 1 ];
2900
+ const z = data[ stride + 2 ];
2901
+
2902
+ triangulatedData.push( x, y, z );
2903
+
2904
+ // an index of -1 indicates that the current face has ended and the next one begins
2905
+
2906
+ if ( index[ i + 3 ] === - 1 || i + 3 >= l ) {
2907
+
2908
+ i += 3;
2909
+ start ++;
2910
+
2911
+ }
2912
+
2913
+ }
2914
+
2915
+ return triangulatedData;
2916
+
2917
+ }
2918
+
2919
+ function flattenData( data, index ) {
2920
+
2921
+ const flattenData = [];
2922
+
2923
+ for ( let i = 0, l = index.length; i < l; i ++ ) {
2924
+
2925
+ const i1 = index[ i ];
2926
+
2927
+ const stride = i1 * 3;
2928
+
2929
+ const x = data[ stride ];
2930
+ const y = data[ stride + 1 ];
2931
+ const z = data[ stride + 2 ];
2932
+
2933
+ flattenData.push( x, y, z );
2934
+
2935
+ }
2936
+
2937
+ return flattenData;
2938
+
2939
+ }
2940
+
2941
+ function expandLineIndex( index ) {
2942
+
2943
+ const indices = [];
2944
+
2945
+ for ( let i = 0, l = index.length; i < l; i ++ ) {
2946
+
2947
+ const i1 = index[ i ];
2948
+ const i2 = index[ i + 1 ];
2949
+
2950
+ indices.push( i1, i2 );
2951
+
2952
+ // an index of -1 indicates that the current line has ended and the next one begins
2953
+
2954
+ if ( index[ i + 2 ] === - 1 || i + 2 >= l ) {
2955
+
2956
+ i += 2;
2957
+
2958
+ }
2959
+
2960
+ }
2961
+
2962
+ return indices;
2963
+
2964
+ }
2965
+
2966
+ function expandLineData( data, index ) {
2967
+
2968
+ const triangulatedData = [];
2969
+
2970
+ let start = 0;
2971
+
2972
+ for ( let i = 0, l = index.length; i < l; i ++ ) {
2973
+
2974
+ const stride = start * 3;
2975
+
2976
+ const x = data[ stride ];
2977
+ const y = data[ stride + 1 ];
2978
+ const z = data[ stride + 2 ];
2979
+
2980
+ triangulatedData.push( x, y, z );
2981
+
2982
+ // an index of -1 indicates that the current line has ended and the next one begins
2983
+
2984
+ if ( index[ i + 2 ] === - 1 || i + 2 >= l ) {
2985
+
2986
+ i += 2;
2987
+ start ++;
2988
+
2989
+ }
2990
+
2991
+ }
2992
+
2993
+ return triangulatedData;
2994
+
2995
+ }
2996
+
2997
+ const vA = new Vector3();
2998
+ const vB = new Vector3();
2999
+ const vC = new Vector3();
3000
+
3001
+ const uvA = new Vector2();
3002
+ const uvB = new Vector2();
3003
+ const uvC = new Vector2();
3004
+
3005
+ function computeAttributeFromIndexedData( coordIndex, index, data, itemSize ) {
3006
+
3007
+ const array = [];
3008
+
3009
+ // we use the coordIndex.length as delimiter since normalIndex must contain at least as many indices
3010
+
3011
+ for ( let i = 0, l = coordIndex.length; i < l; i += 3 ) {
3012
+
3013
+ const a = index[ i ];
3014
+ const b = index[ i + 1 ];
3015
+ const c = index[ i + 2 ];
3016
+
3017
+ if ( itemSize === 2 ) {
3018
+
3019
+ uvA.fromArray( data, a * itemSize );
3020
+ uvB.fromArray( data, b * itemSize );
3021
+ uvC.fromArray( data, c * itemSize );
3022
+
3023
+ array.push( uvA.x, uvA.y );
3024
+ array.push( uvB.x, uvB.y );
3025
+ array.push( uvC.x, uvC.y );
3026
+
3027
+ } else {
3028
+
3029
+ vA.fromArray( data, a * itemSize );
3030
+ vB.fromArray( data, b * itemSize );
3031
+ vC.fromArray( data, c * itemSize );
3032
+
3033
+ array.push( vA.x, vA.y, vA.z );
3034
+ array.push( vB.x, vB.y, vB.z );
3035
+ array.push( vC.x, vC.y, vC.z );
3036
+
3037
+ }
3038
+
3039
+ }
3040
+
3041
+ return new Float32BufferAttribute( array, itemSize );
3042
+
3043
+ }
3044
+
3045
+ function computeAttributeFromFaceData( index, faceData ) {
3046
+
3047
+ const array = [];
3048
+
3049
+ for ( let i = 0, j = 0, l = index.length; i < l; i += 3, j ++ ) {
3050
+
3051
+ vA.fromArray( faceData, j * 3 );
3052
+
3053
+ array.push( vA.x, vA.y, vA.z );
3054
+ array.push( vA.x, vA.y, vA.z );
3055
+ array.push( vA.x, vA.y, vA.z );
3056
+
3057
+ }
3058
+
3059
+ return new Float32BufferAttribute( array, 3 );
3060
+
3061
+ }
3062
+
3063
+ function computeAttributeFromLineData( index, lineData ) {
3064
+
3065
+ const array = [];
3066
+
3067
+ for ( let i = 0, j = 0, l = index.length; i < l; i += 2, j ++ ) {
3068
+
3069
+ vA.fromArray( lineData, j * 3 );
3070
+
3071
+ array.push( vA.x, vA.y, vA.z );
3072
+ array.push( vA.x, vA.y, vA.z );
3073
+
3074
+ }
3075
+
3076
+ return new Float32BufferAttribute( array, 3 );
3077
+
3078
+ }
3079
+
3080
+ function toNonIndexedAttribute( indices, attribute ) {
3081
+
3082
+ const array = attribute.array;
3083
+ const itemSize = attribute.itemSize;
3084
+
3085
+ const array2 = new array.constructor( indices.length * itemSize );
3086
+
3087
+ let index = 0, index2 = 0;
3088
+
3089
+ for ( let i = 0, l = indices.length; i < l; i ++ ) {
3090
+
3091
+ index = indices[ i ] * itemSize;
3092
+
3093
+ for ( let j = 0; j < itemSize; j ++ ) {
3094
+
3095
+ array2[ index2 ++ ] = array[ index ++ ];
3096
+
3097
+ }
3098
+
3099
+ }
3100
+
3101
+ return new Float32BufferAttribute( array2, itemSize );
3102
+
3103
+ }
3104
+
3105
+ const ab = new Vector3();
3106
+ const cb = new Vector3();
3107
+
3108
+ function computeNormalAttribute( index, coord, creaseAngle ) {
3109
+
3110
+ const faces = [];
3111
+ const vertexNormals = {};
3112
+
3113
+ // prepare face and raw vertex normals
3114
+
3115
+ for ( let i = 0, l = index.length; i < l; i += 3 ) {
3116
+
3117
+ const a = index[ i ];
3118
+ const b = index[ i + 1 ];
3119
+ const c = index[ i + 2 ];
3120
+
3121
+ const face = new Face( a, b, c );
3122
+
3123
+ vA.fromArray( coord, a * 3 );
3124
+ vB.fromArray( coord, b * 3 );
3125
+ vC.fromArray( coord, c * 3 );
3126
+
3127
+ cb.subVectors( vC, vB );
3128
+ ab.subVectors( vA, vB );
3129
+ cb.cross( ab );
3130
+
3131
+ cb.normalize();
3132
+
3133
+ face.normal.copy( cb );
3134
+
3135
+ if ( vertexNormals[ a ] === undefined ) vertexNormals[ a ] = [];
3136
+ if ( vertexNormals[ b ] === undefined ) vertexNormals[ b ] = [];
3137
+ if ( vertexNormals[ c ] === undefined ) vertexNormals[ c ] = [];
3138
+
3139
+ vertexNormals[ a ].push( face.normal );
3140
+ vertexNormals[ b ].push( face.normal );
3141
+ vertexNormals[ c ].push( face.normal );
3142
+
3143
+ faces.push( face );
3144
+
3145
+ }
3146
+
3147
+ // compute vertex normals and build final geometry
3148
+
3149
+ const normals = [];
3150
+
3151
+ for ( let i = 0, l = faces.length; i < l; i ++ ) {
3152
+
3153
+ const face = faces[ i ];
3154
+
3155
+ const nA = weightedNormal( vertexNormals[ face.a ], face.normal, creaseAngle );
3156
+ const nB = weightedNormal( vertexNormals[ face.b ], face.normal, creaseAngle );
3157
+ const nC = weightedNormal( vertexNormals[ face.c ], face.normal, creaseAngle );
3158
+
3159
+ vA.fromArray( coord, face.a * 3 );
3160
+ vB.fromArray( coord, face.b * 3 );
3161
+ vC.fromArray( coord, face.c * 3 );
3162
+
3163
+ normals.push( nA.x, nA.y, nA.z );
3164
+ normals.push( nB.x, nB.y, nB.z );
3165
+ normals.push( nC.x, nC.y, nC.z );
3166
+
3167
+ }
3168
+
3169
+ return new Float32BufferAttribute( normals, 3 );
3170
+
3171
+ }
3172
+
3173
+ function weightedNormal( normals, vector, creaseAngle ) {
3174
+
3175
+ const normal = new Vector3();
3176
+
3177
+ if ( creaseAngle === 0 ) {
3178
+
3179
+ normal.copy( vector );
3180
+
3181
+ } else {
3182
+
3183
+ for ( let i = 0, l = normals.length; i < l; i ++ ) {
3184
+
3185
+ if ( normals[ i ].angleTo( vector ) < creaseAngle ) {
3186
+
3187
+ normal.add( normals[ i ] );
3188
+
3189
+ }
3190
+
3191
+ }
3192
+
3193
+ }
3194
+
3195
+ return normal.normalize();
3196
+
3197
+ }
3198
+
3199
+ function toColorArray( colors ) {
3200
+
3201
+ const array = [];
3202
+
3203
+ for ( let i = 0, l = colors.length; i < l; i += 3 ) {
3204
+
3205
+ array.push( new Color( colors[ i ], colors[ i + 1 ], colors[ i + 2 ] ) );
3206
+
3207
+ }
3208
+
3209
+ return array;
3210
+
3211
+ }
3212
+
3213
+ function convertColorsToLinearSRGB( attribute ) {
3214
+
3215
+ const color = new Color();
3216
+
3217
+ for ( let i = 0; i < attribute.count; i ++ ) {
3218
+
3219
+ color.fromBufferAttribute( attribute, i );
3220
+
3221
+ ColorManagement.colorSpaceToWorking( color, SRGBColorSpace );
3222
+
3223
+ attribute.setXYZ( i, color.r, color.g, color.b );
3224
+
3225
+ }
3226
+
3227
+ }
3228
+
3229
+ /**
3230
+ * Vertically paints the faces interpolating between the
3231
+ * specified colors at the specified angels. This is used for the Background
3232
+ * node, but could be applied to other nodes with multiple faces as well.
3233
+ *
3234
+ * When used with the Background node, default is directionIsDown is true if
3235
+ * interpolating the skyColor down from the Zenith. When interpolating up from
3236
+ * the Nadir i.e. interpolating the groundColor, the directionIsDown is false.
3237
+ *
3238
+ * The first angle is never specified, it is the Zenith (0 rad). Angles are specified
3239
+ * in radians. The geometry is thought a sphere, but could be anything. The color interpolation
3240
+ * is linear along the Y axis in any case.
3241
+ *
3242
+ * You must specify one more color than you have angles at the beginning of the colors array.
3243
+ * This is the color of the Zenith (the top of the shape).
3244
+ *
3245
+ * @param {BufferGeometry} geometry
3246
+ * @param {number} radius
3247
+ * @param {Array} angles
3248
+ * @param {Array} colors
3249
+ * @param {boolean} topDown - Whether to work top down or bottom up.
3250
+ */
3251
+ function paintFaces( geometry, radius, angles, colors, topDown ) {
3252
+
3253
+ // compute threshold values
3254
+
3255
+ const thresholds = [];
3256
+ const startAngle = ( topDown === true ) ? 0 : Math.PI;
3257
+
3258
+ for ( let i = 0, l = colors.length; i < l; i ++ ) {
3259
+
3260
+ let angle = ( i === 0 ) ? 0 : angles[ i - 1 ];
3261
+ angle = ( topDown === true ) ? angle : ( startAngle - angle );
3262
+
3263
+ const point = new Vector3();
3264
+ point.setFromSphericalCoords( radius, angle, 0 );
3265
+
3266
+ thresholds.push( point );
3267
+
3268
+ }
3269
+
3270
+ // generate vertex colors
3271
+
3272
+ const indices = geometry.index;
3273
+ const positionAttribute = geometry.attributes.position;
3274
+ const colorAttribute = new BufferAttribute( new Float32Array( geometry.attributes.position.count * 3 ), 3 );
3275
+
3276
+ const position = new Vector3();
3277
+ const color = new Color();
3278
+
3279
+ for ( let i = 0; i < indices.count; i ++ ) {
3280
+
3281
+ const index = indices.getX( i );
3282
+ position.fromBufferAttribute( positionAttribute, index );
3283
+
3284
+ let thresholdIndexA, thresholdIndexB;
3285
+ let t = 1;
3286
+
3287
+ for ( let j = 1; j < thresholds.length; j ++ ) {
3288
+
3289
+ thresholdIndexA = j - 1;
3290
+ thresholdIndexB = j;
3291
+
3292
+ const thresholdA = thresholds[ thresholdIndexA ];
3293
+ const thresholdB = thresholds[ thresholdIndexB ];
3294
+
3295
+ if ( topDown === true ) {
3296
+
3297
+ // interpolation for sky color
3298
+
3299
+ if ( position.y <= thresholdA.y && position.y > thresholdB.y ) {
3300
+
3301
+ t = Math.abs( thresholdA.y - position.y ) / Math.abs( thresholdA.y - thresholdB.y );
3302
+
3303
+ break;
3304
+
3305
+ }
3306
+
3307
+ } else {
3308
+
3309
+ // interpolation for ground color
3310
+
3311
+ if ( position.y >= thresholdA.y && position.y < thresholdB.y ) {
3312
+
3313
+ t = Math.abs( thresholdA.y - position.y ) / Math.abs( thresholdA.y - thresholdB.y );
3314
+
3315
+ break;
3316
+
3317
+ }
3318
+
3319
+ }
3320
+
3321
+ }
3322
+
3323
+ const colorA = colors[ thresholdIndexA ];
3324
+ const colorB = colors[ thresholdIndexB ];
3325
+
3326
+ color.copy( colorA ).lerp( colorB, t );
3327
+
3328
+ ColorManagement.colorSpaceToWorking( color, SRGBColorSpace );
3329
+
3330
+ colorAttribute.setXYZ( index, color.r, color.g, color.b );
3331
+
3332
+ }
3333
+
3334
+ geometry.setAttribute( 'color', colorAttribute );
3335
+
3336
+ }
3337
+
3338
+ //
3339
+
3340
+ const textureLoader = new TextureLoader( this.manager );
3341
+ textureLoader.setPath( this.resourcePath || path ).setCrossOrigin( this.crossOrigin );
3342
+
3343
+ // check version (only 2.0 is supported)
3344
+
3345
+ if ( data.indexOf( '#VRML V2.0' ) === - 1 ) {
3346
+
3347
+ throw Error( 'THREE.VRMLLexer: Version of VRML asset not supported.' );
3348
+
3349
+ }
3350
+
3351
+ // create JSON representing the tree structure of the VRML asset
3352
+
3353
+ const tree = generateVRMLTree( data );
3354
+
3355
+ // parse the tree structure to a three.js scene
3356
+
3357
+ const scene = parseTree( tree );
3358
+
3359
+ return scene;
3360
+
3361
+ }
3362
+
3363
+ }
3364
+
3365
+ class VRMLLexer {
3366
+
3367
+ constructor( tokens ) {
3368
+
3369
+ this.lexer = new chevrotain.Lexer( tokens );
3370
+
3371
+ }
3372
+
3373
+ lex( inputText ) {
3374
+
3375
+ const lexingResult = this.lexer.tokenize( inputText );
3376
+
3377
+ if ( lexingResult.errors.length > 0 ) {
3378
+
3379
+ console.error( lexingResult.errors );
3380
+
3381
+ throw Error( 'THREE.VRMLLexer: Lexing errors detected.' );
3382
+
3383
+ }
3384
+
3385
+ return lexingResult;
3386
+
3387
+ }
3388
+
3389
+ }
3390
+
3391
+ const CstParser = chevrotain.CstParser;
3392
+
3393
+ class VRMLParser extends CstParser {
3394
+
3395
+ constructor( tokenVocabulary ) {
3396
+
3397
+ super( tokenVocabulary );
3398
+
3399
+ const $ = this;
3400
+
3401
+ const Version = tokenVocabulary[ 'Version' ];
3402
+ const LCurly = tokenVocabulary[ 'LCurly' ];
3403
+ const RCurly = tokenVocabulary[ 'RCurly' ];
3404
+ const LSquare = tokenVocabulary[ 'LSquare' ];
3405
+ const RSquare = tokenVocabulary[ 'RSquare' ];
3406
+ const Identifier = tokenVocabulary[ 'Identifier' ];
3407
+ const RouteIdentifier = tokenVocabulary[ 'RouteIdentifier' ];
3408
+ const StringLiteral = tokenVocabulary[ 'StringLiteral' ];
3409
+ const HexLiteral = tokenVocabulary[ 'HexLiteral' ];
3410
+ const NumberLiteral = tokenVocabulary[ 'NumberLiteral' ];
3411
+ const TrueLiteral = tokenVocabulary[ 'TrueLiteral' ];
3412
+ const FalseLiteral = tokenVocabulary[ 'FalseLiteral' ];
3413
+ const NullLiteral = tokenVocabulary[ 'NullLiteral' ];
3414
+ const DEF = tokenVocabulary[ 'DEF' ];
3415
+ const USE = tokenVocabulary[ 'USE' ];
3416
+ const ROUTE = tokenVocabulary[ 'ROUTE' ];
3417
+ const TO = tokenVocabulary[ 'TO' ];
3418
+ const NodeName = tokenVocabulary[ 'NodeName' ];
3419
+
3420
+ $.RULE( 'vrml', function () {
3421
+
3422
+ $.SUBRULE( $.version );
3423
+ $.AT_LEAST_ONE( function () {
3424
+
3425
+ $.SUBRULE( $.node );
3426
+
3427
+ } );
3428
+ $.MANY( function () {
3429
+
3430
+ $.SUBRULE( $.route );
3431
+
3432
+ } );
3433
+
3434
+ } );
3435
+
3436
+ $.RULE( 'version', function () {
3437
+
3438
+ $.CONSUME( Version );
3439
+
3440
+ } );
3441
+
3442
+ $.RULE( 'node', function () {
3443
+
3444
+ $.OPTION( function () {
3445
+
3446
+ $.SUBRULE( $.def );
3447
+
3448
+ } );
3449
+
3450
+ $.CONSUME( NodeName );
3451
+ $.CONSUME( LCurly );
3452
+ $.MANY( function () {
3453
+
3454
+ $.SUBRULE( $.field );
3455
+
3456
+ } );
3457
+ $.CONSUME( RCurly );
3458
+
3459
+ } );
3460
+
3461
+ $.RULE( 'field', function () {
3462
+
3463
+ $.CONSUME( Identifier );
3464
+
3465
+ $.OR2( [
3466
+ { ALT: function () {
3467
+
3468
+ $.SUBRULE( $.singleFieldValue );
3469
+
3470
+ } },
3471
+ { ALT: function () {
3472
+
3473
+ $.SUBRULE( $.multiFieldValue );
3474
+
3475
+ } }
3476
+ ] );
3477
+
3478
+ } );
3479
+
3480
+ $.RULE( 'def', function () {
3481
+
3482
+ $.CONSUME( DEF );
3483
+ $.OR( [
3484
+ { ALT: function () {
3485
+
3486
+ $.CONSUME( Identifier );
3487
+
3488
+ } },
3489
+ { ALT: function () {
3490
+
3491
+ $.CONSUME( NodeName );
3492
+
3493
+ } }
3494
+ ] );
3495
+
3496
+ } );
3497
+
3498
+ $.RULE( 'use', function () {
3499
+
3500
+ $.CONSUME( USE );
3501
+ $.OR( [
3502
+ { ALT: function () {
3503
+
3504
+ $.CONSUME( Identifier );
3505
+
3506
+ } },
3507
+ { ALT: function () {
3508
+
3509
+ $.CONSUME( NodeName );
3510
+
3511
+ } }
3512
+ ] );
3513
+
3514
+ } );
3515
+
3516
+ $.RULE( 'singleFieldValue', function () {
3517
+
3518
+ $.AT_LEAST_ONE( function () {
3519
+
3520
+ $.OR( [
3521
+ { ALT: function () {
3522
+
3523
+ $.SUBRULE( $.node );
3524
+
3525
+ } },
3526
+ { ALT: function () {
3527
+
3528
+ $.SUBRULE( $.use );
3529
+
3530
+ } },
3531
+ { ALT: function () {
3532
+
3533
+ $.CONSUME( StringLiteral );
3534
+
3535
+ } },
3536
+ { ALT: function () {
3537
+
3538
+ $.CONSUME( HexLiteral );
3539
+
3540
+ } },
3541
+ { ALT: function () {
3542
+
3543
+ $.CONSUME( NumberLiteral );
3544
+
3545
+ } },
3546
+ { ALT: function () {
3547
+
3548
+ $.CONSUME( TrueLiteral );
3549
+
3550
+ } },
3551
+ { ALT: function () {
3552
+
3553
+ $.CONSUME( FalseLiteral );
3554
+
3555
+ } },
3556
+ { ALT: function () {
3557
+
3558
+ $.CONSUME( NullLiteral );
3559
+
3560
+ } }
3561
+ ] );
3562
+
3563
+
3564
+ } );
3565
+
3566
+ } );
3567
+
3568
+ $.RULE( 'multiFieldValue', function () {
3569
+
3570
+ $.CONSUME( LSquare );
3571
+ $.MANY( function () {
3572
+
3573
+ $.OR( [
3574
+ { ALT: function () {
3575
+
3576
+ $.SUBRULE( $.node );
3577
+
3578
+ } },
3579
+ { ALT: function () {
3580
+
3581
+ $.SUBRULE( $.use );
3582
+
3583
+ } },
3584
+ { ALT: function () {
3585
+
3586
+ $.CONSUME( StringLiteral );
3587
+
3588
+ } },
3589
+ { ALT: function () {
3590
+
3591
+ $.CONSUME( HexLiteral );
3592
+
3593
+ } },
3594
+ { ALT: function () {
3595
+
3596
+ $.CONSUME( NumberLiteral );
3597
+
3598
+ } },
3599
+ { ALT: function () {
3600
+
3601
+ $.CONSUME( NullLiteral );
3602
+
3603
+ } }
3604
+ ] );
3605
+
3606
+ } );
3607
+ $.CONSUME( RSquare );
3608
+
3609
+ } );
3610
+
3611
+ $.RULE( 'route', function () {
3612
+
3613
+ $.CONSUME( ROUTE );
3614
+ $.CONSUME( RouteIdentifier );
3615
+ $.CONSUME( TO );
3616
+ $.CONSUME2( RouteIdentifier );
3617
+
3618
+ } );
3619
+
3620
+ this.performSelfAnalysis();
3621
+
3622
+ }
3623
+
3624
+ }
3625
+
3626
+ class Face {
3627
+
3628
+ constructor( a, b, c ) {
3629
+
3630
+ this.a = a;
3631
+ this.b = b;
3632
+ this.c = c;
3633
+ this.normal = new Vector3();
3634
+
3635
+ }
3636
+
3637
+ }
3638
+
3639
+ const TEXTURE_TYPE = {
3640
+ INTENSITY: 1,
3641
+ INTENSITY_ALPHA: 2,
3642
+ RGB: 3,
3643
+ RGBA: 4
3644
+ };
3645
+
3646
+ export { VRMLLoader };