three-stdlib 2.25.0 → 2.25.1

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 (539) hide show
  1. package/index.cjs +116401 -611
  2. package/index.js +116037 -263
  3. package/package.json +17 -4
  4. package/_polyfill/CapsuleGeometry.cjs +0 -22
  5. package/_polyfill/CapsuleGeometry.js +0 -22
  6. package/_polyfill/CompressedArrayTexture.cjs +0 -12
  7. package/_polyfill/CompressedArrayTexture.js +0 -12
  8. package/_polyfill/Data3DTexture.cjs +0 -17
  9. package/_polyfill/Data3DTexture.js +0 -17
  10. package/animation/AnimationClipCreator.cjs +0 -56
  11. package/animation/AnimationClipCreator.js +0 -56
  12. package/animation/CCDIKSolver.cjs +0 -269
  13. package/animation/CCDIKSolver.js +0 -269
  14. package/animation/MMDAnimationHelper.cjs +0 -688
  15. package/animation/MMDAnimationHelper.js +0 -688
  16. package/animation/MMDPhysics.cjs +0 -830
  17. package/animation/MMDPhysics.js +0 -830
  18. package/cameras/CinematicCamera.cjs +0 -131
  19. package/cameras/CinematicCamera.js +0 -131
  20. package/controls/ArcballControls.cjs +0 -2033
  21. package/controls/ArcballControls.js +0 -2033
  22. package/controls/DeviceOrientationControls.cjs +0 -85
  23. package/controls/DeviceOrientationControls.js +0 -85
  24. package/controls/DragControls.cjs +0 -182
  25. package/controls/DragControls.js +0 -182
  26. package/controls/FirstPersonControls.cjs +0 -229
  27. package/controls/FirstPersonControls.js +0 -229
  28. package/controls/FlyControls.cjs +0 -248
  29. package/controls/FlyControls.js +0 -248
  30. package/controls/OrbitControls.cjs +0 -791
  31. package/controls/OrbitControls.js +0 -791
  32. package/controls/PointerLockControls.cjs +0 -103
  33. package/controls/PointerLockControls.js +0 -103
  34. package/controls/TrackballControls.cjs +0 -502
  35. package/controls/TrackballControls.js +0 -502
  36. package/controls/TransformControls.cjs +0 -1089
  37. package/controls/TransformControls.js +0 -1089
  38. package/controls/experimental/CameraControls.cjs +0 -736
  39. package/controls/experimental/CameraControls.js +0 -736
  40. package/csm/CSM.cjs +0 -244
  41. package/csm/CSM.js +0 -244
  42. package/csm/CSMFrustum.cjs +0 -75
  43. package/csm/CSMFrustum.js +0 -75
  44. package/csm/CSMHelper.cjs +0 -114
  45. package/csm/CSMHelper.js +0 -114
  46. package/csm/CSMShader.cjs +0 -261
  47. package/csm/CSMShader.js +0 -261
  48. package/curves/CurveExtras.cjs +0 -214
  49. package/curves/CurveExtras.js +0 -214
  50. package/curves/NURBSCurve.cjs +0 -35
  51. package/curves/NURBSCurve.js +0 -35
  52. package/curves/NURBSSurface.cjs +0 -28
  53. package/curves/NURBSSurface.js +0 -28
  54. package/curves/NURBSUtils.cjs +0 -226
  55. package/curves/NURBSUtils.js +0 -226
  56. package/deprecated/Geometry.cjs +0 -971
  57. package/deprecated/Geometry.js +0 -971
  58. package/effects/AnaglyphEffect.cjs +0 -102
  59. package/effects/AnaglyphEffect.js +0 -102
  60. package/effects/AsciiEffect.cjs +0 -155
  61. package/effects/AsciiEffect.js +0 -155
  62. package/effects/OutlineEffect.cjs +0 -275
  63. package/effects/OutlineEffect.js +0 -275
  64. package/effects/ParallaxBarrierEffect.cjs +0 -65
  65. package/effects/ParallaxBarrierEffect.js +0 -65
  66. package/effects/PeppersGhostEffect.cjs +0 -88
  67. package/effects/PeppersGhostEffect.js +0 -88
  68. package/effects/StereoEffect.cjs +0 -35
  69. package/effects/StereoEffect.js +0 -35
  70. package/environments/RoomEnvironment.cjs +0 -95
  71. package/environments/RoomEnvironment.js +0 -78
  72. package/exporters/ColladaExporter.cjs +0 -331
  73. package/exporters/ColladaExporter.js +0 -331
  74. package/exporters/DRACOExporter.cjs +0 -141
  75. package/exporters/DRACOExporter.js +0 -141
  76. package/exporters/GLTFExporter.cjs +0 -1909
  77. package/exporters/GLTFExporter.js +0 -1909
  78. package/exporters/MMDExporter.cjs +0 -131
  79. package/exporters/MMDExporter.js +0 -131
  80. package/exporters/OBJExporter.cjs +0 -181
  81. package/exporters/OBJExporter.js +0 -181
  82. package/exporters/PLYExporter.cjs +0 -280
  83. package/exporters/PLYExporter.js +0 -280
  84. package/exporters/STLExporter.cjs +0 -146
  85. package/exporters/STLExporter.js +0 -146
  86. package/exporters/USDZExporter.cjs +0 -340
  87. package/exporters/USDZExporter.js +0 -340
  88. package/geometries/BoxLineGeometry.cjs +0 -45
  89. package/geometries/BoxLineGeometry.js +0 -45
  90. package/geometries/ConvexGeometry.cjs +0 -26
  91. package/geometries/ConvexGeometry.js +0 -26
  92. package/geometries/DecalGeometry.cjs +0 -184
  93. package/geometries/DecalGeometry.js +0 -184
  94. package/geometries/LightningStrike.cjs +0 -553
  95. package/geometries/LightningStrike.js +0 -553
  96. package/geometries/ParametricGeometries.cjs +0 -130
  97. package/geometries/ParametricGeometries.js +0 -130
  98. package/geometries/ParametricGeometry.cjs +0 -63
  99. package/geometries/ParametricGeometry.js +0 -63
  100. package/geometries/RoundedBoxGeometry.cjs +0 -91
  101. package/geometries/RoundedBoxGeometry.js +0 -91
  102. package/geometries/TeapotGeometry.cjs +0 -1563
  103. package/geometries/TeapotGeometry.js +0 -1563
  104. package/geometries/TextGeometry.cjs +0 -27
  105. package/geometries/TextGeometry.js +0 -27
  106. package/helpers/LightProbeHelper.cjs +0 -73
  107. package/helpers/LightProbeHelper.js +0 -73
  108. package/helpers/PositionalAudioHelper.cjs +0 -68
  109. package/helpers/PositionalAudioHelper.js +0 -68
  110. package/helpers/RectAreaLightHelper.cjs +0 -44
  111. package/helpers/RectAreaLightHelper.js +0 -44
  112. package/helpers/VertexNormalsHelper.cjs +0 -47
  113. package/helpers/VertexNormalsHelper.js +0 -47
  114. package/helpers/VertexTangentsHelper.cjs +0 -43
  115. package/helpers/VertexTangentsHelper.js +0 -43
  116. package/interactive/HTMLMesh.cjs +0 -325
  117. package/interactive/HTMLMesh.js +0 -325
  118. package/interactive/InteractiveGroup.cjs +0 -68
  119. package/interactive/InteractiveGroup.js +0 -68
  120. package/interactive/SelectionBox.cjs +0 -134
  121. package/interactive/SelectionBox.js +0 -134
  122. package/interactive/SelectionHelper.cjs +0 -51
  123. package/interactive/SelectionHelper.js +0 -51
  124. package/libs/MeshoptDecoder.cjs +0 -221
  125. package/libs/MeshoptDecoder.js +0 -221
  126. package/libs/MotionControllers.cjs +0 -325
  127. package/libs/MotionControllers.js +0 -325
  128. package/lights/LightProbeGenerator.cjs +0 -145
  129. package/lights/LightProbeGenerator.js +0 -145
  130. package/lights/RectAreaLightUniformsLib.cjs +0 -32846
  131. package/lights/RectAreaLightUniformsLib.js +0 -32846
  132. package/lines/Line2.cjs +0 -13
  133. package/lines/Line2.js +0 -13
  134. package/lines/LineGeometry.cjs +0 -44
  135. package/lines/LineGeometry.js +0 -44
  136. package/lines/LineMaterial.cjs +0 -547
  137. package/lines/LineMaterial.js +0 -547
  138. package/lines/LineSegments2.cjs +0 -203
  139. package/lines/LineSegments2.js +0 -203
  140. package/lines/LineSegmentsGeometry.cjs +0 -124
  141. package/lines/LineSegmentsGeometry.js +0 -124
  142. package/lines/Wireframe.cjs +0 -32
  143. package/lines/Wireframe.js +0 -32
  144. package/lines/WireframeGeometry2.cjs +0 -13
  145. package/lines/WireframeGeometry2.js +0 -13
  146. package/loaders/3DMLoader.cjs +0 -803
  147. package/loaders/3DMLoader.js +0 -803
  148. package/loaders/3MFLoader.cjs +0 -854
  149. package/loaders/3MFLoader.js +0 -854
  150. package/loaders/AMFLoader.cjs +0 -284
  151. package/loaders/AMFLoader.js +0 -284
  152. package/loaders/AssimpLoader.cjs +0 -1434
  153. package/loaders/AssimpLoader.js +0 -1434
  154. package/loaders/BVHLoader.cjs +0 -207
  155. package/loaders/BVHLoader.js +0 -207
  156. package/loaders/BasisTextureLoader.cjs +0 -489
  157. package/loaders/BasisTextureLoader.js +0 -489
  158. package/loaders/ColladaLoader.cjs +0 -2405
  159. package/loaders/ColladaLoader.js +0 -2405
  160. package/loaders/DDSLoader.cjs +0 -148
  161. package/loaders/DDSLoader.js +0 -148
  162. package/loaders/DRACOLoader.cjs +0 -341
  163. package/loaders/DRACOLoader.js +0 -341
  164. package/loaders/EXRLoader.cjs +0 -1356
  165. package/loaders/EXRLoader.js +0 -1356
  166. package/loaders/FBXLoader.cjs +0 -2457
  167. package/loaders/FBXLoader.js +0 -2457
  168. package/loaders/FontLoader.cjs +0 -123
  169. package/loaders/FontLoader.js +0 -123
  170. package/loaders/GCodeLoader.cjs +0 -141
  171. package/loaders/GCodeLoader.js +0 -141
  172. package/loaders/GLTFLoader.cjs +0 -2504
  173. package/loaders/GLTFLoader.js +0 -2504
  174. package/loaders/HDRCubeTextureLoader.cjs +0 -75
  175. package/loaders/HDRCubeTextureLoader.js +0 -75
  176. package/loaders/KMZLoader.cjs +0 -75
  177. package/loaders/KMZLoader.js +0 -75
  178. package/loaders/KTX2Loader.cjs +0 -480
  179. package/loaders/KTX2Loader.js +0 -480
  180. package/loaders/KTXLoader.cjs +0 -93
  181. package/loaders/KTXLoader.js +0 -93
  182. package/loaders/LDrawLoader.cjs +0 -1424
  183. package/loaders/LDrawLoader.js +0 -1424
  184. package/loaders/LUT3dlLoader.cjs +0 -103
  185. package/loaders/LUT3dlLoader.js +0 -103
  186. package/loaders/LUTCubeLoader.cjs +0 -107
  187. package/loaders/LUTCubeLoader.js +0 -107
  188. package/loaders/LWOLoader.cjs +0 -645
  189. package/loaders/LWOLoader.js +0 -645
  190. package/loaders/LottieLoader.cjs +0 -47
  191. package/loaders/LottieLoader.js +0 -47
  192. package/loaders/MD2Loader.cjs +0 -359
  193. package/loaders/MD2Loader.js +0 -359
  194. package/loaders/MDDLoader.cjs +0 -58
  195. package/loaders/MDDLoader.js +0 -58
  196. package/loaders/MMDLoader.cjs +0 -1121
  197. package/loaders/MMDLoader.js +0 -1121
  198. package/loaders/MTLLoader.cjs +0 -304
  199. package/loaders/MTLLoader.js +0 -304
  200. package/loaders/NRRDLoader.cjs +0 -401
  201. package/loaders/NRRDLoader.js +0 -401
  202. package/loaders/OBJLoader.cjs +0 -487
  203. package/loaders/OBJLoader.js +0 -487
  204. package/loaders/PCDLoader.cjs +0 -248
  205. package/loaders/PCDLoader.js +0 -248
  206. package/loaders/PDBLoader.cjs +0 -247
  207. package/loaders/PDBLoader.js +0 -247
  208. package/loaders/PLYLoader.cjs +0 -317
  209. package/loaders/PLYLoader.js +0 -317
  210. package/loaders/PRWMLoader.cjs +0 -160
  211. package/loaders/PRWMLoader.js +0 -160
  212. package/loaders/PVRLoader.cjs +0 -131
  213. package/loaders/PVRLoader.js +0 -131
  214. package/loaders/RGBELoader.cjs +0 -252
  215. package/loaders/RGBELoader.js +0 -252
  216. package/loaders/RGBMLoader.cjs +0 -1004
  217. package/loaders/RGBMLoader.js +0 -1004
  218. package/loaders/STLLoader.cjs +0 -190
  219. package/loaders/STLLoader.js +0 -190
  220. package/loaders/SVGLoader.cjs +0 -1712
  221. package/loaders/SVGLoader.js +0 -1712
  222. package/loaders/TDSLoader.cjs +0 -650
  223. package/loaders/TDSLoader.js +0 -650
  224. package/loaders/TGALoader.cjs +0 -285
  225. package/loaders/TGALoader.js +0 -285
  226. package/loaders/TTFLoader.cjs +0 -131
  227. package/loaders/TTFLoader.js +0 -131
  228. package/loaders/TiltLoader.cjs +0 -375
  229. package/loaders/TiltLoader.js +0 -375
  230. package/loaders/VOXLoader.cjs +0 -432
  231. package/loaders/VOXLoader.js +0 -432
  232. package/loaders/VRMLLoader.cjs +0 -2105
  233. package/loaders/VRMLLoader.js +0 -2105
  234. package/loaders/VRMLoader.cjs +0 -38
  235. package/loaders/VRMLoader.js +0 -38
  236. package/loaders/VTKLoader.cjs +0 -648
  237. package/loaders/VTKLoader.js +0 -648
  238. package/loaders/XLoader.cjs +0 -1258
  239. package/loaders/XLoader.js +0 -1258
  240. package/loaders/XYZLoader.cjs +0 -60
  241. package/loaders/XYZLoader.js +0 -60
  242. package/loaders/lwo/IFFParser.cjs +0 -743
  243. package/loaders/lwo/IFFParser.js +0 -743
  244. package/loaders/lwo/LWO2Parser.cjs +0 -312
  245. package/loaders/lwo/LWO2Parser.js +0 -312
  246. package/loaders/lwo/LWO3Parser.cjs +0 -282
  247. package/loaders/lwo/LWO3Parser.js +0 -282
  248. package/math/Capsule.cjs +0 -98
  249. package/math/Capsule.js +0 -98
  250. package/math/ColorConverter.cjs +0 -42
  251. package/math/ColorConverter.js +0 -42
  252. package/math/ConvexHull.cjs +0 -596
  253. package/math/ConvexHull.js +0 -596
  254. package/math/ImprovedNoise.cjs +0 -304
  255. package/math/ImprovedNoise.js +0 -304
  256. package/math/Lut.cjs +0 -137
  257. package/math/Lut.js +0 -137
  258. package/math/MeshSurfaceSampler.cjs +0 -103
  259. package/math/MeshSurfaceSampler.js +0 -103
  260. package/math/OBB.cjs +0 -242
  261. package/math/OBB.js +0 -242
  262. package/math/Octree.cjs +0 -273
  263. package/math/Octree.js +0 -273
  264. package/math/SimplexNoise.cjs +0 -440
  265. package/math/SimplexNoise.js +0 -440
  266. package/misc/ConvexObjectBreaker.cjs +0 -292
  267. package/misc/ConvexObjectBreaker.js +0 -292
  268. package/misc/GPUComputationRenderer.cjs +0 -205
  269. package/misc/GPUComputationRenderer.js +0 -205
  270. package/misc/Gyroscope.cjs +0 -33
  271. package/misc/Gyroscope.js +0 -33
  272. package/misc/MD2Character.cjs +0 -167
  273. package/misc/MD2Character.js +0 -167
  274. package/misc/MD2CharacterComplex.cjs +0 -332
  275. package/misc/MD2CharacterComplex.js +0 -332
  276. package/misc/MorphAnimMesh.cjs +0 -40
  277. package/misc/MorphAnimMesh.js +0 -40
  278. package/misc/MorphBlendMesh.cjs +0 -179
  279. package/misc/MorphBlendMesh.js +0 -179
  280. package/misc/ProgressiveLightmap.cjs +0 -186
  281. package/misc/ProgressiveLightmap.js +0 -186
  282. package/misc/RollerCoaster.cjs +0 -353
  283. package/misc/RollerCoaster.js +0 -353
  284. package/misc/Timer.cjs +0 -101
  285. package/misc/Timer.js +0 -101
  286. package/misc/TubePainter.cjs +0 -123
  287. package/misc/TubePainter.js +0 -123
  288. package/misc/Volume.cjs +0 -305
  289. package/misc/Volume.js +0 -305
  290. package/misc/VolumeSlice.cjs +0 -114
  291. package/misc/VolumeSlice.js +0 -114
  292. package/misc/WebGL.cjs +0 -74
  293. package/misc/WebGL.js +0 -74
  294. package/modifiers/CurveModifier.cjs +0 -232
  295. package/modifiers/CurveModifier.js +0 -232
  296. package/modifiers/EdgeSplitModifier.cjs +0 -167
  297. package/modifiers/EdgeSplitModifier.js +0 -168
  298. package/modifiers/SimplifyModifier.cjs +0 -301
  299. package/modifiers/SimplifyModifier.js +0 -301
  300. package/modifiers/TessellateModifier.cjs +0 -214
  301. package/modifiers/TessellateModifier.js +0 -214
  302. package/objects/GroundProjectedEnv.cjs +0 -134
  303. package/objects/GroundProjectedEnv.js +0 -134
  304. package/objects/Lensflare.cjs +0 -291
  305. package/objects/Lensflare.js +0 -291
  306. package/objects/LightningStorm.cjs +0 -110
  307. package/objects/LightningStorm.js +0 -110
  308. package/objects/MarchingCubes.cjs +0 -4809
  309. package/objects/MarchingCubes.js +0 -4809
  310. package/objects/Reflector.cjs +0 -202
  311. package/objects/Reflector.js +0 -202
  312. package/objects/ReflectorForSSRPass.cjs +0 -260
  313. package/objects/ReflectorForSSRPass.js +0 -260
  314. package/objects/ReflectorRTT.cjs +0 -10
  315. package/objects/ReflectorRTT.js +0 -10
  316. package/objects/Refractor.cjs +0 -215
  317. package/objects/Refractor.js +0 -215
  318. package/objects/ShadowMesh.cjs +0 -45
  319. package/objects/ShadowMesh.js +0 -45
  320. package/objects/Sky.cjs +0 -200
  321. package/objects/Sky.js +0 -200
  322. package/objects/Water.cjs +0 -242
  323. package/objects/Water.js +0 -242
  324. package/objects/Water2.cjs +0 -256
  325. package/objects/Water2.js +0 -256
  326. package/physics/AmmoPhysics.cjs +0 -166
  327. package/physics/AmmoPhysics.js +0 -166
  328. package/postprocessing/AdaptiveToneMappingPass.cjs +0 -218
  329. package/postprocessing/AdaptiveToneMappingPass.js +0 -218
  330. package/postprocessing/AfterimagePass.cjs +0 -68
  331. package/postprocessing/AfterimagePass.js +0 -68
  332. package/postprocessing/BloomPass.cjs +0 -109
  333. package/postprocessing/BloomPass.js +0 -109
  334. package/postprocessing/BokehPass.cjs +0 -90
  335. package/postprocessing/BokehPass.js +0 -90
  336. package/postprocessing/ClearPass.cjs +0 -36
  337. package/postprocessing/ClearPass.js +0 -36
  338. package/postprocessing/CubeTexturePass.cjs +0 -53
  339. package/postprocessing/CubeTexturePass.js +0 -53
  340. package/postprocessing/DotScreenPass.cjs +0 -49
  341. package/postprocessing/DotScreenPass.js +0 -49
  342. package/postprocessing/EffectComposer.cjs +0 -157
  343. package/postprocessing/EffectComposer.js +0 -157
  344. package/postprocessing/FilmPass.cjs +0 -51
  345. package/postprocessing/FilmPass.js +0 -51
  346. package/postprocessing/GlitchPass.cjs +0 -84
  347. package/postprocessing/GlitchPass.js +0 -84
  348. package/postprocessing/HalftonePass.cjs +0 -53
  349. package/postprocessing/HalftonePass.js +0 -53
  350. package/postprocessing/LUTPass.cjs +0 -142
  351. package/postprocessing/LUTPass.js +0 -142
  352. package/postprocessing/MaskPass.cjs +0 -69
  353. package/postprocessing/MaskPass.js +0 -69
  354. package/postprocessing/OutlinePass.cjs +0 -479
  355. package/postprocessing/OutlinePass.js +0 -479
  356. package/postprocessing/Pass.cjs +0 -48
  357. package/postprocessing/Pass.js +0 -48
  358. package/postprocessing/RenderPass.cjs +0 -59
  359. package/postprocessing/RenderPass.js +0 -59
  360. package/postprocessing/RenderPixelatedPass.cjs +0 -199
  361. package/postprocessing/RenderPixelatedPass.js +0 -199
  362. package/postprocessing/SAOPass.cjs +0 -288
  363. package/postprocessing/SAOPass.js +0 -288
  364. package/postprocessing/SMAAPass.cjs +0 -112
  365. package/postprocessing/SMAAPass.js +0 -112
  366. package/postprocessing/SSAARenderPass.cjs +0 -189
  367. package/postprocessing/SSAARenderPass.js +0 -189
  368. package/postprocessing/SSAOPass.cjs +0 -272
  369. package/postprocessing/SSAOPass.js +0 -272
  370. package/postprocessing/SSRPass.cjs +0 -411
  371. package/postprocessing/SSRPass.js +0 -411
  372. package/postprocessing/SavePass.cjs +0 -38
  373. package/postprocessing/SavePass.js +0 -38
  374. package/postprocessing/ShaderPass.cjs +0 -49
  375. package/postprocessing/ShaderPass.js +0 -49
  376. package/postprocessing/TAARenderPass.cjs +0 -174
  377. package/postprocessing/TAARenderPass.js +0 -174
  378. package/postprocessing/TexturePass.cjs +0 -42
  379. package/postprocessing/TexturePass.js +0 -42
  380. package/postprocessing/UnrealBloomPass.cjs +0 -277
  381. package/postprocessing/UnrealBloomPass.js +0 -277
  382. package/postprocessing/WaterPass.cjs +0 -72
  383. package/postprocessing/WaterPass.js +0 -72
  384. package/renderers/CSS2DRenderer.cjs +0 -122
  385. package/renderers/CSS2DRenderer.js +0 -122
  386. package/renderers/CSS3DRenderer.cjs +0 -167
  387. package/renderers/CSS3DRenderer.js +0 -167
  388. package/renderers/Projector.cjs +0 -499
  389. package/renderers/Projector.js +0 -499
  390. package/renderers/SVGRenderer.cjs +0 -311
  391. package/renderers/SVGRenderer.js +0 -311
  392. package/shaders/ACESFilmicToneMappingShader.cjs +0 -55
  393. package/shaders/ACESFilmicToneMappingShader.js +0 -55
  394. package/shaders/AfterimageShader.cjs +0 -32
  395. package/shaders/AfterimageShader.js +0 -32
  396. package/shaders/BasicShader.cjs +0 -12
  397. package/shaders/BasicShader.js +0 -12
  398. package/shaders/BleachBypassShader.cjs +0 -35
  399. package/shaders/BleachBypassShader.js +0 -35
  400. package/shaders/BlendShader.cjs +0 -30
  401. package/shaders/BlendShader.js +0 -30
  402. package/shaders/BokehShader.cjs +0 -109
  403. package/shaders/BokehShader.js +0 -109
  404. package/shaders/BokehShader2.cjs +0 -269
  405. package/shaders/BokehShader2.js +0 -269
  406. package/shaders/BrightnessContrastShader.cjs +0 -32
  407. package/shaders/BrightnessContrastShader.js +0 -32
  408. package/shaders/ColorCorrectionShader.cjs +0 -30
  409. package/shaders/ColorCorrectionShader.js +0 -30
  410. package/shaders/ColorifyShader.cjs +0 -28
  411. package/shaders/ColorifyShader.js +0 -28
  412. package/shaders/ConvolutionShader.cjs +0 -55
  413. package/shaders/ConvolutionShader.js +0 -55
  414. package/shaders/CopyShader.cjs +0 -25
  415. package/shaders/CopyShader.js +0 -25
  416. package/shaders/DOFMipMapShader.cjs +0 -32
  417. package/shaders/DOFMipMapShader.js +0 -32
  418. package/shaders/DepthLimitedBlurShader.cjs +0 -114
  419. package/shaders/DepthLimitedBlurShader.js +0 -114
  420. package/shaders/DigitalGlitch.cjs +0 -85
  421. package/shaders/DigitalGlitch.js +0 -85
  422. package/shaders/DotScreenShader.cjs +0 -39
  423. package/shaders/DotScreenShader.js +0 -39
  424. package/shaders/FXAAShader.cjs +0 -1098
  425. package/shaders/FXAAShader.js +0 -1098
  426. package/shaders/FilmShader.cjs +0 -53
  427. package/shaders/FilmShader.js +0 -53
  428. package/shaders/FocusShader.cjs +0 -55
  429. package/shaders/FocusShader.js +0 -55
  430. package/shaders/FreiChenShader.cjs +0 -64
  431. package/shaders/FreiChenShader.js +0 -64
  432. package/shaders/FresnelShader.cjs +0 -47
  433. package/shaders/FresnelShader.js +0 -47
  434. package/shaders/GammaCorrectionShader.cjs +0 -23
  435. package/shaders/GammaCorrectionShader.js +0 -23
  436. package/shaders/GodRaysShader.cjs +0 -183
  437. package/shaders/GodRaysShader.js +0 -183
  438. package/shaders/HalftoneShader.cjs +0 -228
  439. package/shaders/HalftoneShader.js +0 -228
  440. package/shaders/HorizontalBlurShader.cjs +0 -49
  441. package/shaders/HorizontalBlurShader.js +0 -49
  442. package/shaders/HorizontalTiltShiftShader.cjs +0 -37
  443. package/shaders/HorizontalTiltShiftShader.js +0 -37
  444. package/shaders/HueSaturationShader.cjs +0 -43
  445. package/shaders/HueSaturationShader.js +0 -43
  446. package/shaders/KaleidoShader.cjs +0 -34
  447. package/shaders/KaleidoShader.js +0 -34
  448. package/shaders/LuminosityHighPassShader.cjs +0 -37
  449. package/shaders/LuminosityHighPassShader.js +0 -37
  450. package/shaders/LuminosityShader.cjs +0 -25
  451. package/shaders/LuminosityShader.js +0 -25
  452. package/shaders/MirrorShader.cjs +0 -35
  453. package/shaders/MirrorShader.js +0 -35
  454. package/shaders/NormalMapShader.cjs +0 -31
  455. package/shaders/NormalMapShader.js +0 -31
  456. package/shaders/ParallaxShader.cjs +0 -133
  457. package/shaders/ParallaxShader.js +0 -133
  458. package/shaders/PixelShader.cjs +0 -28
  459. package/shaders/PixelShader.js +0 -28
  460. package/shaders/RGBShiftShader.cjs +0 -30
  461. package/shaders/RGBShiftShader.js +0 -30
  462. package/shaders/SAOShader.cjs +0 -144
  463. package/shaders/SAOShader.js +0 -144
  464. package/shaders/SMAAShader.cjs +0 -358
  465. package/shaders/SMAAShader.js +0 -358
  466. package/shaders/SSAOShader.cjs +0 -182
  467. package/shaders/SSAOShader.js +0 -182
  468. package/shaders/SSRShader.cjs +0 -342
  469. package/shaders/SSRShader.js +0 -342
  470. package/shaders/SepiaShader.cjs +0 -29
  471. package/shaders/SepiaShader.js +0 -29
  472. package/shaders/SobelOperatorShader.cjs +0 -54
  473. package/shaders/SobelOperatorShader.js +0 -54
  474. package/shaders/SubsurfaceScatteringShader.cjs +0 -98
  475. package/shaders/SubsurfaceScatteringShader.js +0 -98
  476. package/shaders/TechnicolorShader.cjs +0 -24
  477. package/shaders/TechnicolorShader.js +0 -24
  478. package/shaders/ToneMapShader.cjs +0 -51
  479. package/shaders/ToneMapShader.js +0 -51
  480. package/shaders/ToonShader.cjs +0 -188
  481. package/shaders/ToonShader.js +0 -188
  482. package/shaders/TriangleBlurShader.cjs +0 -37
  483. package/shaders/TriangleBlurShader.js +0 -37
  484. package/shaders/UnpackDepthRGBAShader.cjs +0 -26
  485. package/shaders/UnpackDepthRGBAShader.js +0 -26
  486. package/shaders/VerticalBlurShader.cjs +0 -50
  487. package/shaders/VerticalBlurShader.js +0 -50
  488. package/shaders/VerticalTiltShiftShader.cjs +0 -37
  489. package/shaders/VerticalTiltShiftShader.js +0 -37
  490. package/shaders/VignetteShader.cjs +0 -38
  491. package/shaders/VignetteShader.js +0 -38
  492. package/shaders/VolumeShader.cjs +0 -225
  493. package/shaders/VolumeShader.js +0 -225
  494. package/shaders/WaterRefractionShader.cjs +0 -59
  495. package/shaders/WaterRefractionShader.js +0 -59
  496. package/shaders/types.cjs +0 -1
  497. package/shaders/types.js +0 -1
  498. package/textures/FlakesTexture.cjs +0 -30
  499. package/textures/FlakesTexture.js +0 -30
  500. package/types/helpers.cjs +0 -4
  501. package/types/helpers.js +0 -4
  502. package/utils/BufferGeometryUtils.cjs +0 -636
  503. package/utils/BufferGeometryUtils.js +0 -636
  504. package/utils/GeometryCompressionUtils.cjs +0 -573
  505. package/utils/GeometryCompressionUtils.js +0 -573
  506. package/utils/GeometryUtils.cjs +0 -109
  507. package/utils/GeometryUtils.js +0 -109
  508. package/utils/RoughnessMipmapper.cjs +0 -223
  509. package/utils/RoughnessMipmapper.js +0 -223
  510. package/utils/SceneUtils.cjs +0 -36
  511. package/utils/SceneUtils.js +0 -36
  512. package/utils/ShadowMapViewer.cjs +0 -111
  513. package/utils/ShadowMapViewer.js +0 -111
  514. package/utils/SkeletonUtils.cjs +0 -211
  515. package/utils/SkeletonUtils.js +0 -211
  516. package/utils/UVsDebug.cjs +0 -80
  517. package/utils/UVsDebug.js +0 -80
  518. package/utils/WorkerPool.cjs +0 -62
  519. package/utils/WorkerPool.js +0 -62
  520. package/webxr/ARButton.cjs +0 -119
  521. package/webxr/ARButton.js +0 -119
  522. package/webxr/OculusHandModel.cjs +0 -82
  523. package/webxr/OculusHandModel.js +0 -82
  524. package/webxr/OculusHandPointerModel.cjs +0 -241
  525. package/webxr/OculusHandPointerModel.js +0 -224
  526. package/webxr/Text2D.cjs +0 -48
  527. package/webxr/Text2D.js +0 -31
  528. package/webxr/VRButton.cjs +0 -111
  529. package/webxr/VRButton.js +0 -111
  530. package/webxr/XRControllerModelFactory.cjs +0 -174
  531. package/webxr/XRControllerModelFactory.js +0 -174
  532. package/webxr/XREstimatedLight.cjs +0 -126
  533. package/webxr/XREstimatedLight.js +0 -126
  534. package/webxr/XRHandMeshModel.cjs +0 -82
  535. package/webxr/XRHandMeshModel.js +0 -82
  536. package/webxr/XRHandModelFactory.cjs +0 -61
  537. package/webxr/XRHandModelFactory.js +0 -61
  538. package/webxr/XRHandPrimitiveModel.cjs +0 -68
  539. package/webxr/XRHandPrimitiveModel.js +0 -68
@@ -1,2105 +0,0 @@
1
- import { Loader, LoaderUtils, FileLoader, Scene, Object3D, Group, Vector3, SphereGeometry, MeshBasicMaterial, BackSide, Mesh, PointsMaterial, Points, LineBasicMaterial, LineSegments, FrontSide, DoubleSide, MeshPhongMaterial, Color, RepeatWrapping, ClampToEdgeWrapping, DataTexture, Vector2, BufferGeometry, Float32BufferAttribute, BoxGeometry, ConeGeometry, CylinderGeometry, Quaternion, ShapeUtils, BufferAttribute, TextureLoader } from "three";
2
- import { createToken, Lexer, CstParser } from "chevrotain";
3
- class VRMLLoader extends Loader {
4
- constructor(manager) {
5
- super(manager);
6
- }
7
- load(url, onLoad, onProgress, onError) {
8
- const scope = this;
9
- const path = scope.path === "" ? LoaderUtils.extractUrlBase(url) : scope.path;
10
- const loader = new FileLoader(scope.manager);
11
- loader.setPath(scope.path);
12
- loader.setRequestHeader(scope.requestHeader);
13
- loader.setWithCredentials(scope.withCredentials);
14
- loader.load(
15
- url,
16
- function(text) {
17
- try {
18
- onLoad(scope.parse(text, path));
19
- } catch (e) {
20
- if (onError) {
21
- onError(e);
22
- } else {
23
- console.error(e);
24
- }
25
- scope.manager.itemError(url);
26
- }
27
- },
28
- onProgress,
29
- onError
30
- );
31
- }
32
- parse(data, path) {
33
- const nodeMap = {};
34
- function generateVRMLTree(data2) {
35
- const tokenData = createTokens();
36
- const lexer = new VRMLLexer(tokenData.tokens);
37
- const parser = new VRMLParser(tokenData.tokenVocabulary);
38
- const visitor = createVisitor(parser.getBaseCstVisitorConstructor());
39
- const lexingResult = lexer.lex(data2);
40
- parser.input = lexingResult.tokens;
41
- const cstOutput = parser.vrml();
42
- if (parser.errors.length > 0) {
43
- console.error(parser.errors);
44
- throw Error("THREE.VRMLLoader: Parsing errors detected.");
45
- }
46
- const ast = visitor.visit(cstOutput);
47
- return ast;
48
- }
49
- function createTokens() {
50
- const RouteIdentifier = createToken({
51
- name: "RouteIdentifier",
52
- 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]*/
53
- });
54
- const Identifier = createToken({
55
- name: "Identifier",
56
- 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]*/,
57
- longer_alt: RouteIdentifier
58
- });
59
- const nodeTypes = [
60
- "Anchor",
61
- "Billboard",
62
- "Collision",
63
- "Group",
64
- "Transform",
65
- // grouping nodes
66
- "Inline",
67
- "LOD",
68
- "Switch",
69
- // special groups
70
- "AudioClip",
71
- "DirectionalLight",
72
- "PointLight",
73
- "Script",
74
- "Shape",
75
- "Sound",
76
- "SpotLight",
77
- "WorldInfo",
78
- // common nodes
79
- "CylinderSensor",
80
- "PlaneSensor",
81
- "ProximitySensor",
82
- "SphereSensor",
83
- "TimeSensor",
84
- "TouchSensor",
85
- "VisibilitySensor",
86
- // sensors
87
- "Box",
88
- "Cone",
89
- "Cylinder",
90
- "ElevationGrid",
91
- "Extrusion",
92
- "IndexedFaceSet",
93
- "IndexedLineSet",
94
- "PointSet",
95
- "Sphere",
96
- // geometries
97
- "Color",
98
- "Coordinate",
99
- "Normal",
100
- "TextureCoordinate",
101
- // geometric properties
102
- "Appearance",
103
- "FontStyle",
104
- "ImageTexture",
105
- "Material",
106
- "MovieTexture",
107
- "PixelTexture",
108
- "TextureTransform",
109
- // appearance
110
- "ColorInterpolator",
111
- "CoordinateInterpolator",
112
- "NormalInterpolator",
113
- "OrientationInterpolator",
114
- "PositionInterpolator",
115
- "ScalarInterpolator",
116
- // interpolators
117
- "Background",
118
- "Fog",
119
- "NavigationInfo",
120
- "Viewpoint",
121
- // bindable nodes
122
- "Text"
123
- // Text must be placed at the end of the regex so there are no matches for TextureTransform and TextureCoordinate
124
- ];
125
- const Version = createToken({
126
- name: "Version",
127
- pattern: /#VRML.*/,
128
- longer_alt: Identifier
129
- });
130
- const NodeName = createToken({
131
- name: "NodeName",
132
- pattern: new RegExp(nodeTypes.join("|")),
133
- longer_alt: Identifier
134
- });
135
- const DEF = createToken({
136
- name: "DEF",
137
- pattern: /DEF/,
138
- longer_alt: Identifier
139
- });
140
- const USE = createToken({
141
- name: "USE",
142
- pattern: /USE/,
143
- longer_alt: Identifier
144
- });
145
- const ROUTE = createToken({
146
- name: "ROUTE",
147
- pattern: /ROUTE/,
148
- longer_alt: Identifier
149
- });
150
- const TO = createToken({
151
- name: "TO",
152
- pattern: /TO/,
153
- longer_alt: Identifier
154
- });
155
- const StringLiteral = createToken({
156
- name: "StringLiteral",
157
- pattern: /"(?:[^\\"\n\r]|\\[bfnrtv"\\/]|\\u[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])*"/
158
- });
159
- const HexLiteral = createToken({ name: "HexLiteral", pattern: /0[xX][0-9a-fA-F]+/ });
160
- const NumberLiteral = createToken({ name: "NumberLiteral", pattern: /[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?/ });
161
- const TrueLiteral = createToken({ name: "TrueLiteral", pattern: /TRUE/ });
162
- const FalseLiteral = createToken({ name: "FalseLiteral", pattern: /FALSE/ });
163
- const NullLiteral = createToken({ name: "NullLiteral", pattern: /NULL/ });
164
- const LSquare = createToken({ name: "LSquare", pattern: /\[/ });
165
- const RSquare = createToken({ name: "RSquare", pattern: /]/ });
166
- const LCurly = createToken({ name: "LCurly", pattern: /{/ });
167
- const RCurly = createToken({ name: "RCurly", pattern: /}/ });
168
- const Comment = createToken({
169
- name: "Comment",
170
- pattern: /#.*/,
171
- group: Lexer.SKIPPED
172
- });
173
- const WhiteSpace = createToken({
174
- name: "WhiteSpace",
175
- pattern: /[ ,\s]/,
176
- group: Lexer.SKIPPED
177
- });
178
- const tokens = [
179
- WhiteSpace,
180
- // keywords appear before the Identifier
181
- NodeName,
182
- DEF,
183
- USE,
184
- ROUTE,
185
- TO,
186
- TrueLiteral,
187
- FalseLiteral,
188
- NullLiteral,
189
- // the Identifier must appear after the keywords because all keywords are valid identifiers
190
- Version,
191
- Identifier,
192
- RouteIdentifier,
193
- StringLiteral,
194
- HexLiteral,
195
- NumberLiteral,
196
- LSquare,
197
- RSquare,
198
- LCurly,
199
- RCurly,
200
- Comment
201
- ];
202
- const tokenVocabulary = {};
203
- for (let i = 0, l = tokens.length; i < l; i++) {
204
- const token = tokens[i];
205
- tokenVocabulary[token.name] = token;
206
- }
207
- return { tokens, tokenVocabulary };
208
- }
209
- function createVisitor(BaseVRMLVisitor) {
210
- function VRMLToASTVisitor() {
211
- BaseVRMLVisitor.call(this);
212
- this.validateVisitor();
213
- }
214
- VRMLToASTVisitor.prototype = Object.assign(Object.create(BaseVRMLVisitor.prototype), {
215
- constructor: VRMLToASTVisitor,
216
- vrml: function(ctx) {
217
- const data2 = {
218
- version: this.visit(ctx.version),
219
- nodes: [],
220
- routes: []
221
- };
222
- for (let i = 0, l = ctx.node.length; i < l; i++) {
223
- const node = ctx.node[i];
224
- data2.nodes.push(this.visit(node));
225
- }
226
- if (ctx.route) {
227
- for (let i = 0, l = ctx.route.length; i < l; i++) {
228
- const route = ctx.route[i];
229
- data2.routes.push(this.visit(route));
230
- }
231
- }
232
- return data2;
233
- },
234
- version: function(ctx) {
235
- return ctx.Version[0].image;
236
- },
237
- node: function(ctx) {
238
- const data2 = {
239
- name: ctx.NodeName[0].image,
240
- fields: []
241
- };
242
- if (ctx.field) {
243
- for (let i = 0, l = ctx.field.length; i < l; i++) {
244
- const field = ctx.field[i];
245
- data2.fields.push(this.visit(field));
246
- }
247
- }
248
- if (ctx.def) {
249
- data2.DEF = this.visit(ctx.def[0]);
250
- }
251
- return data2;
252
- },
253
- field: function(ctx) {
254
- const data2 = {
255
- name: ctx.Identifier[0].image,
256
- type: null,
257
- values: null
258
- };
259
- let result;
260
- if (ctx.singleFieldValue) {
261
- result = this.visit(ctx.singleFieldValue[0]);
262
- }
263
- if (ctx.multiFieldValue) {
264
- result = this.visit(ctx.multiFieldValue[0]);
265
- }
266
- data2.type = result.type;
267
- data2.values = result.values;
268
- return data2;
269
- },
270
- def: function(ctx) {
271
- return (ctx.Identifier || ctx.NodeName)[0].image;
272
- },
273
- use: function(ctx) {
274
- return { USE: (ctx.Identifier || ctx.NodeName)[0].image };
275
- },
276
- singleFieldValue: function(ctx) {
277
- return processField(this, ctx);
278
- },
279
- multiFieldValue: function(ctx) {
280
- return processField(this, ctx);
281
- },
282
- route: function(ctx) {
283
- const data2 = {
284
- FROM: ctx.RouteIdentifier[0].image,
285
- TO: ctx.RouteIdentifier[1].image
286
- };
287
- return data2;
288
- }
289
- });
290
- function processField(scope, ctx) {
291
- const field = {
292
- type: null,
293
- values: []
294
- };
295
- if (ctx.node) {
296
- field.type = "node";
297
- for (let i = 0, l = ctx.node.length; i < l; i++) {
298
- const node = ctx.node[i];
299
- field.values.push(scope.visit(node));
300
- }
301
- }
302
- if (ctx.use) {
303
- field.type = "use";
304
- for (let i = 0, l = ctx.use.length; i < l; i++) {
305
- const use = ctx.use[i];
306
- field.values.push(scope.visit(use));
307
- }
308
- }
309
- if (ctx.StringLiteral) {
310
- field.type = "string";
311
- for (let i = 0, l = ctx.StringLiteral.length; i < l; i++) {
312
- const stringLiteral = ctx.StringLiteral[i];
313
- field.values.push(stringLiteral.image.replace(/'|"/g, ""));
314
- }
315
- }
316
- if (ctx.NumberLiteral) {
317
- field.type = "number";
318
- for (let i = 0, l = ctx.NumberLiteral.length; i < l; i++) {
319
- const numberLiteral = ctx.NumberLiteral[i];
320
- field.values.push(parseFloat(numberLiteral.image));
321
- }
322
- }
323
- if (ctx.HexLiteral) {
324
- field.type = "hex";
325
- for (let i = 0, l = ctx.HexLiteral.length; i < l; i++) {
326
- const hexLiteral = ctx.HexLiteral[i];
327
- field.values.push(hexLiteral.image);
328
- }
329
- }
330
- if (ctx.TrueLiteral) {
331
- field.type = "boolean";
332
- for (let i = 0, l = ctx.TrueLiteral.length; i < l; i++) {
333
- const trueLiteral = ctx.TrueLiteral[i];
334
- if (trueLiteral.image === "TRUE")
335
- field.values.push(true);
336
- }
337
- }
338
- if (ctx.FalseLiteral) {
339
- field.type = "boolean";
340
- for (let i = 0, l = ctx.FalseLiteral.length; i < l; i++) {
341
- const falseLiteral = ctx.FalseLiteral[i];
342
- if (falseLiteral.image === "FALSE")
343
- field.values.push(false);
344
- }
345
- }
346
- if (ctx.NullLiteral) {
347
- field.type = "null";
348
- ctx.NullLiteral.forEach(function() {
349
- field.values.push(null);
350
- });
351
- }
352
- return field;
353
- }
354
- return new VRMLToASTVisitor();
355
- }
356
- function parseTree(tree2) {
357
- const nodes = tree2.nodes;
358
- const scene2 = new Scene();
359
- for (let i = 0, l = nodes.length; i < l; i++) {
360
- const node = nodes[i];
361
- buildNodeMap(node);
362
- }
363
- for (let i = 0, l = nodes.length; i < l; i++) {
364
- const node = nodes[i];
365
- const object = getNode(node);
366
- if (object instanceof Object3D)
367
- scene2.add(object);
368
- if (node.name === "WorldInfo")
369
- scene2.userData.worldInfo = object;
370
- }
371
- return scene2;
372
- }
373
- function buildNodeMap(node) {
374
- if (node.DEF) {
375
- nodeMap[node.DEF] = node;
376
- }
377
- const fields = node.fields;
378
- for (let i = 0, l = fields.length; i < l; i++) {
379
- const field = fields[i];
380
- if (field.type === "node") {
381
- const fieldValues = field.values;
382
- for (let j = 0, jl = fieldValues.length; j < jl; j++) {
383
- buildNodeMap(fieldValues[j]);
384
- }
385
- }
386
- }
387
- }
388
- function getNode(node) {
389
- if (node.USE) {
390
- return resolveUSE(node.USE);
391
- }
392
- if (node.build !== void 0)
393
- return node.build;
394
- node.build = buildNode(node);
395
- return node.build;
396
- }
397
- function buildNode(node) {
398
- const nodeName = node.name;
399
- let build;
400
- switch (nodeName) {
401
- case "Group":
402
- case "Transform":
403
- case "Collision":
404
- build = buildGroupingNode(node);
405
- break;
406
- case "Background":
407
- build = buildBackgroundNode(node);
408
- break;
409
- case "Shape":
410
- build = buildShapeNode(node);
411
- break;
412
- case "Appearance":
413
- build = buildAppearanceNode(node);
414
- break;
415
- case "Material":
416
- build = buildMaterialNode(node);
417
- break;
418
- case "ImageTexture":
419
- build = buildImageTextureNode(node);
420
- break;
421
- case "PixelTexture":
422
- build = buildPixelTextureNode(node);
423
- break;
424
- case "TextureTransform":
425
- build = buildTextureTransformNode(node);
426
- break;
427
- case "IndexedFaceSet":
428
- build = buildIndexedFaceSetNode(node);
429
- break;
430
- case "IndexedLineSet":
431
- build = buildIndexedLineSetNode(node);
432
- break;
433
- case "PointSet":
434
- build = buildPointSetNode(node);
435
- break;
436
- case "Box":
437
- build = buildBoxNode(node);
438
- break;
439
- case "Cone":
440
- build = buildConeNode(node);
441
- break;
442
- case "Cylinder":
443
- build = buildCylinderNode(node);
444
- break;
445
- case "Sphere":
446
- build = buildSphereNode(node);
447
- break;
448
- case "ElevationGrid":
449
- build = buildElevationGridNode(node);
450
- break;
451
- case "Extrusion":
452
- build = buildExtrusionNode(node);
453
- break;
454
- case "Color":
455
- case "Coordinate":
456
- case "Normal":
457
- case "TextureCoordinate":
458
- build = buildGeometricNode(node);
459
- break;
460
- case "WorldInfo":
461
- build = buildWorldInfoNode(node);
462
- break;
463
- case "Anchor":
464
- case "Billboard":
465
- case "Inline":
466
- case "LOD":
467
- case "Switch":
468
- case "AudioClip":
469
- case "DirectionalLight":
470
- case "PointLight":
471
- case "Script":
472
- case "Sound":
473
- case "SpotLight":
474
- case "CylinderSensor":
475
- case "PlaneSensor":
476
- case "ProximitySensor":
477
- case "SphereSensor":
478
- case "TimeSensor":
479
- case "TouchSensor":
480
- case "VisibilitySensor":
481
- case "Text":
482
- case "FontStyle":
483
- case "MovieTexture":
484
- case "ColorInterpolator":
485
- case "CoordinateInterpolator":
486
- case "NormalInterpolator":
487
- case "OrientationInterpolator":
488
- case "PositionInterpolator":
489
- case "ScalarInterpolator":
490
- case "Fog":
491
- case "NavigationInfo":
492
- case "Viewpoint":
493
- break;
494
- default:
495
- console.warn("THREE.VRMLLoader: Unknown node:", nodeName);
496
- break;
497
- }
498
- if (build !== void 0 && node.DEF !== void 0 && build.hasOwnProperty("name") === true) {
499
- build.name = node.DEF;
500
- }
501
- return build;
502
- }
503
- function buildGroupingNode(node) {
504
- const object = new Group();
505
- const fields = node.fields;
506
- for (let i = 0, l = fields.length; i < l; i++) {
507
- const field = fields[i];
508
- const fieldName = field.name;
509
- const fieldValues = field.values;
510
- switch (fieldName) {
511
- case "bboxCenter":
512
- break;
513
- case "bboxSize":
514
- break;
515
- case "center":
516
- break;
517
- case "children":
518
- parseFieldChildren(fieldValues, object);
519
- break;
520
- case "collide":
521
- break;
522
- case "rotation":
523
- const axis = new Vector3(fieldValues[0], fieldValues[1], fieldValues[2]);
524
- const angle = fieldValues[3];
525
- object.quaternion.setFromAxisAngle(axis, angle);
526
- break;
527
- case "scale":
528
- object.scale.set(fieldValues[0], fieldValues[1], fieldValues[2]);
529
- break;
530
- case "scaleOrientation":
531
- break;
532
- case "translation":
533
- object.position.set(fieldValues[0], fieldValues[1], fieldValues[2]);
534
- break;
535
- case "proxy":
536
- break;
537
- default:
538
- console.warn("THREE.VRMLLoader: Unknown field:", fieldName);
539
- break;
540
- }
541
- }
542
- return object;
543
- }
544
- function buildBackgroundNode(node) {
545
- const group = new Group();
546
- let groundAngle, groundColor;
547
- let skyAngle, skyColor;
548
- const fields = node.fields;
549
- for (let i = 0, l = fields.length; i < l; i++) {
550
- const field = fields[i];
551
- const fieldName = field.name;
552
- const fieldValues = field.values;
553
- switch (fieldName) {
554
- case "groundAngle":
555
- groundAngle = fieldValues;
556
- break;
557
- case "groundColor":
558
- groundColor = fieldValues;
559
- break;
560
- case "backUrl":
561
- break;
562
- case "bottomUrl":
563
- break;
564
- case "frontUrl":
565
- break;
566
- case "leftUrl":
567
- break;
568
- case "rightUrl":
569
- break;
570
- case "topUrl":
571
- break;
572
- case "skyAngle":
573
- skyAngle = fieldValues;
574
- break;
575
- case "skyColor":
576
- skyColor = fieldValues;
577
- break;
578
- default:
579
- console.warn("THREE.VRMLLoader: Unknown field:", fieldName);
580
- break;
581
- }
582
- }
583
- const radius = 1e4;
584
- if (skyColor) {
585
- const skyGeometry = new SphereGeometry(radius, 32, 16);
586
- const skyMaterial = new MeshBasicMaterial({ fog: false, side: BackSide, depthWrite: false, depthTest: false });
587
- if (skyColor.length > 3) {
588
- paintFaces(skyGeometry, radius, skyAngle, toColorArray(skyColor), true);
589
- skyMaterial.vertexColors = true;
590
- } else {
591
- skyMaterial.color.setRGB(skyColor[0], skyColor[1], skyColor[2]);
592
- }
593
- const sky = new Mesh(skyGeometry, skyMaterial);
594
- group.add(sky);
595
- }
596
- if (groundColor) {
597
- if (groundColor.length > 0) {
598
- const groundGeometry = new SphereGeometry(radius, 32, 16, 0, 2 * Math.PI, 0.5 * Math.PI, 1.5 * Math.PI);
599
- const groundMaterial = new MeshBasicMaterial({
600
- fog: false,
601
- side: BackSide,
602
- vertexColors: true,
603
- depthWrite: false,
604
- depthTest: false
605
- });
606
- paintFaces(groundGeometry, radius, groundAngle, toColorArray(groundColor), false);
607
- const ground = new Mesh(groundGeometry, groundMaterial);
608
- group.add(ground);
609
- }
610
- }
611
- group.renderOrder = -Infinity;
612
- return group;
613
- }
614
- function buildShapeNode(node) {
615
- const fields = node.fields;
616
- let material = new MeshBasicMaterial({ color: 0 });
617
- let geometry;
618
- for (let i = 0, l = fields.length; i < l; i++) {
619
- const field = fields[i];
620
- const fieldName = field.name;
621
- const fieldValues = field.values;
622
- switch (fieldName) {
623
- case "appearance":
624
- if (fieldValues[0] !== null) {
625
- material = getNode(fieldValues[0]);
626
- }
627
- break;
628
- case "geometry":
629
- if (fieldValues[0] !== null) {
630
- geometry = getNode(fieldValues[0]);
631
- }
632
- break;
633
- default:
634
- console.warn("THREE.VRMLLoader: Unknown field:", fieldName);
635
- break;
636
- }
637
- }
638
- let object;
639
- if (geometry && geometry.attributes.position) {
640
- const type = geometry._type;
641
- if (type === "points") {
642
- const pointsMaterial = new PointsMaterial({ color: 16777215 });
643
- if (geometry.attributes.color !== void 0) {
644
- pointsMaterial.vertexColors = true;
645
- } else {
646
- if (material.isMeshPhongMaterial) {
647
- pointsMaterial.color.copy(material.emissive);
648
- }
649
- }
650
- object = new Points(geometry, pointsMaterial);
651
- } else if (type === "line") {
652
- const lineMaterial = new LineBasicMaterial({ color: 16777215 });
653
- if (geometry.attributes.color !== void 0) {
654
- lineMaterial.vertexColors = true;
655
- } else {
656
- if (material.isMeshPhongMaterial) {
657
- lineMaterial.color.copy(material.emissive);
658
- }
659
- }
660
- object = new LineSegments(geometry, lineMaterial);
661
- } else {
662
- if (geometry._solid !== void 0) {
663
- material.side = geometry._solid ? FrontSide : DoubleSide;
664
- }
665
- if (geometry.attributes.color !== void 0) {
666
- material.vertexColors = true;
667
- }
668
- object = new Mesh(geometry, material);
669
- }
670
- } else {
671
- object = new Object3D();
672
- object.visible = false;
673
- }
674
- return object;
675
- }
676
- function buildAppearanceNode(node) {
677
- let material = new MeshPhongMaterial();
678
- let transformData;
679
- const fields = node.fields;
680
- for (let i = 0, l = fields.length; i < l; i++) {
681
- const field = fields[i];
682
- const fieldName = field.name;
683
- const fieldValues = field.values;
684
- switch (fieldName) {
685
- case "material":
686
- if (fieldValues[0] !== null) {
687
- const materialData = getNode(fieldValues[0]);
688
- if (materialData.diffuseColor)
689
- material.color.copy(materialData.diffuseColor);
690
- if (materialData.emissiveColor)
691
- material.emissive.copy(materialData.emissiveColor);
692
- if (materialData.shininess)
693
- material.shininess = materialData.shininess;
694
- if (materialData.specularColor)
695
- material.specular.copy(materialData.specularColor);
696
- if (materialData.transparency)
697
- material.opacity = 1 - materialData.transparency;
698
- if (materialData.transparency > 0)
699
- material.transparent = true;
700
- } else {
701
- material = new MeshBasicMaterial({ color: 0 });
702
- }
703
- break;
704
- case "texture":
705
- const textureNode = fieldValues[0];
706
- if (textureNode !== null) {
707
- if (textureNode.name === "ImageTexture" || textureNode.name === "PixelTexture") {
708
- material.map = getNode(textureNode);
709
- } else {
710
- }
711
- }
712
- break;
713
- case "textureTransform":
714
- if (fieldValues[0] !== null) {
715
- transformData = getNode(fieldValues[0]);
716
- }
717
- break;
718
- default:
719
- console.warn("THREE.VRMLLoader: Unknown field:", fieldName);
720
- break;
721
- }
722
- }
723
- if (material.map) {
724
- if (material.map.__type) {
725
- switch (material.map.__type) {
726
- case TEXTURE_TYPE.INTENSITY_ALPHA:
727
- material.opacity = 1;
728
- break;
729
- case TEXTURE_TYPE.RGB:
730
- material.color.set(16777215);
731
- break;
732
- case TEXTURE_TYPE.RGBA:
733
- material.color.set(16777215);
734
- material.opacity = 1;
735
- break;
736
- default:
737
- }
738
- delete material.map.__type;
739
- }
740
- if (transformData) {
741
- material.map.center.copy(transformData.center);
742
- material.map.rotation = transformData.rotation;
743
- material.map.repeat.copy(transformData.scale);
744
- material.map.offset.copy(transformData.translation);
745
- }
746
- }
747
- return material;
748
- }
749
- function buildMaterialNode(node) {
750
- const materialData = {};
751
- const fields = node.fields;
752
- for (let i = 0, l = fields.length; i < l; i++) {
753
- const field = fields[i];
754
- const fieldName = field.name;
755
- const fieldValues = field.values;
756
- switch (fieldName) {
757
- case "ambientIntensity":
758
- break;
759
- case "diffuseColor":
760
- materialData.diffuseColor = new Color(fieldValues[0], fieldValues[1], fieldValues[2]);
761
- break;
762
- case "emissiveColor":
763
- materialData.emissiveColor = new Color(fieldValues[0], fieldValues[1], fieldValues[2]);
764
- break;
765
- case "shininess":
766
- materialData.shininess = fieldValues[0];
767
- break;
768
- case "specularColor":
769
- materialData.emissiveColor = new Color(fieldValues[0], fieldValues[1], fieldValues[2]);
770
- break;
771
- case "transparency":
772
- materialData.transparency = fieldValues[0];
773
- break;
774
- default:
775
- console.warn("THREE.VRMLLoader: Unknown field:", fieldName);
776
- break;
777
- }
778
- }
779
- return materialData;
780
- }
781
- function parseHexColor(hex, textureType, color) {
782
- let value;
783
- switch (textureType) {
784
- case TEXTURE_TYPE.INTENSITY:
785
- value = parseInt(hex);
786
- color.r = value;
787
- color.g = value;
788
- color.b = value;
789
- color.a = 1;
790
- break;
791
- case TEXTURE_TYPE.INTENSITY_ALPHA:
792
- value = parseInt("0x" + hex.substring(2, 4));
793
- color.r = value;
794
- color.g = value;
795
- color.b = value;
796
- color.a = parseInt("0x" + hex.substring(4, 6));
797
- break;
798
- case TEXTURE_TYPE.RGB:
799
- color.r = parseInt("0x" + hex.substring(2, 4));
800
- color.g = parseInt("0x" + hex.substring(4, 6));
801
- color.b = parseInt("0x" + hex.substring(6, 8));
802
- color.a = 1;
803
- break;
804
- case TEXTURE_TYPE.RGBA:
805
- color.r = parseInt("0x" + hex.substring(2, 4));
806
- color.g = parseInt("0x" + hex.substring(4, 6));
807
- color.b = parseInt("0x" + hex.substring(6, 8));
808
- color.a = parseInt("0x" + hex.substring(8, 10));
809
- break;
810
- default:
811
- }
812
- }
813
- function getTextureType(num_components) {
814
- let type;
815
- switch (num_components) {
816
- case 1:
817
- type = TEXTURE_TYPE.INTENSITY;
818
- break;
819
- case 2:
820
- type = TEXTURE_TYPE.INTENSITY_ALPHA;
821
- break;
822
- case 3:
823
- type = TEXTURE_TYPE.RGB;
824
- break;
825
- case 4:
826
- type = TEXTURE_TYPE.RGBA;
827
- break;
828
- default:
829
- }
830
- return type;
831
- }
832
- function buildPixelTextureNode(node) {
833
- let texture;
834
- let wrapS = RepeatWrapping;
835
- let wrapT = RepeatWrapping;
836
- const fields = node.fields;
837
- for (let i = 0, l = fields.length; i < l; i++) {
838
- const field = fields[i];
839
- const fieldName = field.name;
840
- const fieldValues = field.values;
841
- switch (fieldName) {
842
- case "image":
843
- const width = fieldValues[0];
844
- const height = fieldValues[1];
845
- const num_components = fieldValues[2];
846
- const textureType = getTextureType(num_components);
847
- const data2 = new Uint8Array(4 * width * height);
848
- const color = { r: 0, g: 0, b: 0, a: 0 };
849
- for (let j = 3, k = 0, jl = fieldValues.length; j < jl; j++, k++) {
850
- parseHexColor(fieldValues[j], textureType, color);
851
- const stride = k * 4;
852
- data2[stride + 0] = color.r;
853
- data2[stride + 1] = color.g;
854
- data2[stride + 2] = color.b;
855
- data2[stride + 3] = color.a;
856
- }
857
- texture = new DataTexture(data2, width, height);
858
- texture.needsUpdate = true;
859
- texture.__type = textureType;
860
- break;
861
- case "repeatS":
862
- if (fieldValues[0] === false)
863
- wrapS = ClampToEdgeWrapping;
864
- break;
865
- case "repeatT":
866
- if (fieldValues[0] === false)
867
- wrapT = ClampToEdgeWrapping;
868
- break;
869
- default:
870
- console.warn("THREE.VRMLLoader: Unknown field:", fieldName);
871
- break;
872
- }
873
- }
874
- if (texture) {
875
- texture.wrapS = wrapS;
876
- texture.wrapT = wrapT;
877
- }
878
- return texture;
879
- }
880
- function buildImageTextureNode(node) {
881
- let texture;
882
- let wrapS = RepeatWrapping;
883
- let wrapT = RepeatWrapping;
884
- const fields = node.fields;
885
- for (let i = 0, l = fields.length; i < l; i++) {
886
- const field = fields[i];
887
- const fieldName = field.name;
888
- const fieldValues = field.values;
889
- switch (fieldName) {
890
- case "url":
891
- const url = fieldValues[0];
892
- if (url)
893
- texture = textureLoader.load(url);
894
- break;
895
- case "repeatS":
896
- if (fieldValues[0] === false)
897
- wrapS = ClampToEdgeWrapping;
898
- break;
899
- case "repeatT":
900
- if (fieldValues[0] === false)
901
- wrapT = ClampToEdgeWrapping;
902
- break;
903
- default:
904
- console.warn("THREE.VRMLLoader: Unknown field:", fieldName);
905
- break;
906
- }
907
- }
908
- if (texture) {
909
- texture.wrapS = wrapS;
910
- texture.wrapT = wrapT;
911
- }
912
- return texture;
913
- }
914
- function buildTextureTransformNode(node) {
915
- const transformData = {
916
- center: new Vector2(),
917
- rotation: new Vector2(),
918
- scale: new Vector2(),
919
- translation: new Vector2()
920
- };
921
- const fields = node.fields;
922
- for (let i = 0, l = fields.length; i < l; i++) {
923
- const field = fields[i];
924
- const fieldName = field.name;
925
- const fieldValues = field.values;
926
- switch (fieldName) {
927
- case "center":
928
- transformData.center.set(fieldValues[0], fieldValues[1]);
929
- break;
930
- case "rotation":
931
- transformData.rotation = fieldValues[0];
932
- break;
933
- case "scale":
934
- transformData.scale.set(fieldValues[0], fieldValues[1]);
935
- break;
936
- case "translation":
937
- transformData.translation.set(fieldValues[0], fieldValues[1]);
938
- break;
939
- default:
940
- console.warn("THREE.VRMLLoader: Unknown field:", fieldName);
941
- break;
942
- }
943
- }
944
- return transformData;
945
- }
946
- function buildGeometricNode(node) {
947
- return node.fields[0].values;
948
- }
949
- function buildWorldInfoNode(node) {
950
- const worldInfo = {};
951
- const fields = node.fields;
952
- for (let i = 0, l = fields.length; i < l; i++) {
953
- const field = fields[i];
954
- const fieldName = field.name;
955
- const fieldValues = field.values;
956
- switch (fieldName) {
957
- case "title":
958
- worldInfo.title = fieldValues[0];
959
- break;
960
- case "info":
961
- worldInfo.info = fieldValues;
962
- break;
963
- default:
964
- console.warn("THREE.VRMLLoader: Unknown field:", fieldName);
965
- break;
966
- }
967
- }
968
- return worldInfo;
969
- }
970
- function buildIndexedFaceSetNode(node) {
971
- let color, coord, normal, texCoord;
972
- let ccw = true, solid = true, creaseAngle = 0;
973
- let colorIndex, coordIndex, normalIndex, texCoordIndex;
974
- let colorPerVertex = true, normalPerVertex = true;
975
- const fields = node.fields;
976
- for (let i = 0, l = fields.length; i < l; i++) {
977
- const field = fields[i];
978
- const fieldName = field.name;
979
- const fieldValues = field.values;
980
- switch (fieldName) {
981
- case "color":
982
- const colorNode = fieldValues[0];
983
- if (colorNode !== null) {
984
- color = getNode(colorNode);
985
- }
986
- break;
987
- case "coord":
988
- const coordNode = fieldValues[0];
989
- if (coordNode !== null) {
990
- coord = getNode(coordNode);
991
- }
992
- break;
993
- case "normal":
994
- const normalNode = fieldValues[0];
995
- if (normalNode !== null) {
996
- normal = getNode(normalNode);
997
- }
998
- break;
999
- case "texCoord":
1000
- const texCoordNode = fieldValues[0];
1001
- if (texCoordNode !== null) {
1002
- texCoord = getNode(texCoordNode);
1003
- }
1004
- break;
1005
- case "ccw":
1006
- ccw = fieldValues[0];
1007
- break;
1008
- case "colorIndex":
1009
- colorIndex = fieldValues;
1010
- break;
1011
- case "colorPerVertex":
1012
- colorPerVertex = fieldValues[0];
1013
- break;
1014
- case "convex":
1015
- break;
1016
- case "coordIndex":
1017
- coordIndex = fieldValues;
1018
- break;
1019
- case "creaseAngle":
1020
- creaseAngle = fieldValues[0];
1021
- break;
1022
- case "normalIndex":
1023
- normalIndex = fieldValues;
1024
- break;
1025
- case "normalPerVertex":
1026
- normalPerVertex = fieldValues[0];
1027
- break;
1028
- case "solid":
1029
- solid = fieldValues[0];
1030
- break;
1031
- case "texCoordIndex":
1032
- texCoordIndex = fieldValues;
1033
- break;
1034
- default:
1035
- console.warn("THREE.VRMLLoader: Unknown field:", fieldName);
1036
- break;
1037
- }
1038
- }
1039
- if (coordIndex === void 0) {
1040
- console.warn("THREE.VRMLLoader: Missing coordIndex.");
1041
- return new BufferGeometry();
1042
- }
1043
- const triangulatedCoordIndex = triangulateFaceIndex(coordIndex, ccw);
1044
- let colorAttribute;
1045
- let normalAttribute;
1046
- let uvAttribute;
1047
- if (color) {
1048
- if (colorPerVertex === true) {
1049
- if (colorIndex && colorIndex.length > 0) {
1050
- const triangulatedColorIndex = triangulateFaceIndex(colorIndex, ccw);
1051
- colorAttribute = computeAttributeFromIndexedData(triangulatedCoordIndex, triangulatedColorIndex, color, 3);
1052
- } else {
1053
- colorAttribute = toNonIndexedAttribute(triangulatedCoordIndex, new Float32BufferAttribute(color, 3));
1054
- }
1055
- } else {
1056
- if (colorIndex && colorIndex.length > 0) {
1057
- const flattenFaceColors = flattenData(color, colorIndex);
1058
- const triangulatedFaceColors = triangulateFaceData(flattenFaceColors, coordIndex);
1059
- colorAttribute = computeAttributeFromFaceData(triangulatedCoordIndex, triangulatedFaceColors);
1060
- } else {
1061
- const triangulatedFaceColors = triangulateFaceData(color, coordIndex);
1062
- colorAttribute = computeAttributeFromFaceData(triangulatedCoordIndex, triangulatedFaceColors);
1063
- }
1064
- }
1065
- }
1066
- if (normal) {
1067
- if (normalPerVertex === true) {
1068
- if (normalIndex && normalIndex.length > 0) {
1069
- const triangulatedNormalIndex = triangulateFaceIndex(normalIndex, ccw);
1070
- normalAttribute = computeAttributeFromIndexedData(
1071
- triangulatedCoordIndex,
1072
- triangulatedNormalIndex,
1073
- normal,
1074
- 3
1075
- );
1076
- } else {
1077
- normalAttribute = toNonIndexedAttribute(triangulatedCoordIndex, new Float32BufferAttribute(normal, 3));
1078
- }
1079
- } else {
1080
- if (normalIndex && normalIndex.length > 0) {
1081
- const flattenFaceNormals = flattenData(normal, normalIndex);
1082
- const triangulatedFaceNormals = triangulateFaceData(flattenFaceNormals, coordIndex);
1083
- normalAttribute = computeAttributeFromFaceData(triangulatedCoordIndex, triangulatedFaceNormals);
1084
- } else {
1085
- const triangulatedFaceNormals = triangulateFaceData(normal, coordIndex);
1086
- normalAttribute = computeAttributeFromFaceData(triangulatedCoordIndex, triangulatedFaceNormals);
1087
- }
1088
- }
1089
- } else {
1090
- normalAttribute = computeNormalAttribute(triangulatedCoordIndex, coord, creaseAngle);
1091
- }
1092
- if (texCoord) {
1093
- if (texCoordIndex && texCoordIndex.length > 0) {
1094
- const triangulatedTexCoordIndex = triangulateFaceIndex(texCoordIndex, ccw);
1095
- uvAttribute = computeAttributeFromIndexedData(triangulatedCoordIndex, triangulatedTexCoordIndex, texCoord, 2);
1096
- } else {
1097
- uvAttribute = toNonIndexedAttribute(triangulatedCoordIndex, new Float32BufferAttribute(texCoord, 2));
1098
- }
1099
- }
1100
- const geometry = new BufferGeometry();
1101
- const positionAttribute = toNonIndexedAttribute(triangulatedCoordIndex, new Float32BufferAttribute(coord, 3));
1102
- geometry.setAttribute("position", positionAttribute);
1103
- geometry.setAttribute("normal", normalAttribute);
1104
- if (colorAttribute)
1105
- geometry.setAttribute("color", colorAttribute);
1106
- if (uvAttribute)
1107
- geometry.setAttribute("uv", uvAttribute);
1108
- geometry._solid = solid;
1109
- geometry._type = "mesh";
1110
- return geometry;
1111
- }
1112
- function buildIndexedLineSetNode(node) {
1113
- let color, coord;
1114
- let colorIndex, coordIndex;
1115
- let colorPerVertex = true;
1116
- const fields = node.fields;
1117
- for (let i = 0, l = fields.length; i < l; i++) {
1118
- const field = fields[i];
1119
- const fieldName = field.name;
1120
- const fieldValues = field.values;
1121
- switch (fieldName) {
1122
- case "color":
1123
- const colorNode = fieldValues[0];
1124
- if (colorNode !== null) {
1125
- color = getNode(colorNode);
1126
- }
1127
- break;
1128
- case "coord":
1129
- const coordNode = fieldValues[0];
1130
- if (coordNode !== null) {
1131
- coord = getNode(coordNode);
1132
- }
1133
- break;
1134
- case "colorIndex":
1135
- colorIndex = fieldValues;
1136
- break;
1137
- case "colorPerVertex":
1138
- colorPerVertex = fieldValues[0];
1139
- break;
1140
- case "coordIndex":
1141
- coordIndex = fieldValues;
1142
- break;
1143
- default:
1144
- console.warn("THREE.VRMLLoader: Unknown field:", fieldName);
1145
- break;
1146
- }
1147
- }
1148
- let colorAttribute;
1149
- const expandedLineIndex = expandLineIndex(coordIndex);
1150
- if (color) {
1151
- if (colorPerVertex === true) {
1152
- if (colorIndex.length > 0) {
1153
- const expandedColorIndex = expandLineIndex(colorIndex);
1154
- colorAttribute = computeAttributeFromIndexedData(expandedLineIndex, expandedColorIndex, color, 3);
1155
- } else {
1156
- colorAttribute = toNonIndexedAttribute(expandedLineIndex, new Float32BufferAttribute(color, 3));
1157
- }
1158
- } else {
1159
- if (colorIndex.length > 0) {
1160
- const flattenLineColors = flattenData(color, colorIndex);
1161
- const expandedLineColors = expandLineData(flattenLineColors, coordIndex);
1162
- colorAttribute = computeAttributeFromLineData(expandedLineIndex, expandedLineColors);
1163
- } else {
1164
- const expandedLineColors = expandLineData(color, coordIndex);
1165
- colorAttribute = computeAttributeFromLineData(expandedLineIndex, expandedLineColors);
1166
- }
1167
- }
1168
- }
1169
- const geometry = new BufferGeometry();
1170
- const positionAttribute = toNonIndexedAttribute(expandedLineIndex, new Float32BufferAttribute(coord, 3));
1171
- geometry.setAttribute("position", positionAttribute);
1172
- if (colorAttribute)
1173
- geometry.setAttribute("color", colorAttribute);
1174
- geometry._type = "line";
1175
- return geometry;
1176
- }
1177
- function buildPointSetNode(node) {
1178
- let color, coord;
1179
- const fields = node.fields;
1180
- for (let i = 0, l = fields.length; i < l; i++) {
1181
- const field = fields[i];
1182
- const fieldName = field.name;
1183
- const fieldValues = field.values;
1184
- switch (fieldName) {
1185
- case "color":
1186
- const colorNode = fieldValues[0];
1187
- if (colorNode !== null) {
1188
- color = getNode(colorNode);
1189
- }
1190
- break;
1191
- case "coord":
1192
- const coordNode = fieldValues[0];
1193
- if (coordNode !== null) {
1194
- coord = getNode(coordNode);
1195
- }
1196
- break;
1197
- default:
1198
- console.warn("THREE.VRMLLoader: Unknown field:", fieldName);
1199
- break;
1200
- }
1201
- }
1202
- const geometry = new BufferGeometry();
1203
- geometry.setAttribute("position", new Float32BufferAttribute(coord, 3));
1204
- if (color)
1205
- geometry.setAttribute("color", new Float32BufferAttribute(color, 3));
1206
- geometry._type = "points";
1207
- return geometry;
1208
- }
1209
- function buildBoxNode(node) {
1210
- const size = new Vector3(2, 2, 2);
1211
- const fields = node.fields;
1212
- for (let i = 0, l = fields.length; i < l; i++) {
1213
- const field = fields[i];
1214
- const fieldName = field.name;
1215
- const fieldValues = field.values;
1216
- switch (fieldName) {
1217
- case "size":
1218
- size.x = fieldValues[0];
1219
- size.y = fieldValues[1];
1220
- size.z = fieldValues[2];
1221
- break;
1222
- default:
1223
- console.warn("THREE.VRMLLoader: Unknown field:", fieldName);
1224
- break;
1225
- }
1226
- }
1227
- const geometry = new BoxGeometry(size.x, size.y, size.z);
1228
- return geometry;
1229
- }
1230
- function buildConeNode(node) {
1231
- let radius = 1, height = 2, openEnded = false;
1232
- const fields = node.fields;
1233
- for (let i = 0, l = fields.length; i < l; i++) {
1234
- const field = fields[i];
1235
- const fieldName = field.name;
1236
- const fieldValues = field.values;
1237
- switch (fieldName) {
1238
- case "bottom":
1239
- openEnded = !fieldValues[0];
1240
- break;
1241
- case "bottomRadius":
1242
- radius = fieldValues[0];
1243
- break;
1244
- case "height":
1245
- height = fieldValues[0];
1246
- break;
1247
- case "side":
1248
- break;
1249
- default:
1250
- console.warn("THREE.VRMLLoader: Unknown field:", fieldName);
1251
- break;
1252
- }
1253
- }
1254
- const geometry = new ConeGeometry(radius, height, 16, 1, openEnded);
1255
- return geometry;
1256
- }
1257
- function buildCylinderNode(node) {
1258
- let radius = 1, height = 2;
1259
- const fields = node.fields;
1260
- for (let i = 0, l = fields.length; i < l; i++) {
1261
- const field = fields[i];
1262
- const fieldName = field.name;
1263
- const fieldValues = field.values;
1264
- switch (fieldName) {
1265
- case "bottom":
1266
- break;
1267
- case "radius":
1268
- radius = fieldValues[0];
1269
- break;
1270
- case "height":
1271
- height = fieldValues[0];
1272
- break;
1273
- case "side":
1274
- break;
1275
- case "top":
1276
- break;
1277
- default:
1278
- console.warn("THREE.VRMLLoader: Unknown field:", fieldName);
1279
- break;
1280
- }
1281
- }
1282
- const geometry = new CylinderGeometry(radius, radius, height, 16, 1);
1283
- return geometry;
1284
- }
1285
- function buildSphereNode(node) {
1286
- let radius = 1;
1287
- const fields = node.fields;
1288
- for (let i = 0, l = fields.length; i < l; i++) {
1289
- const field = fields[i];
1290
- const fieldName = field.name;
1291
- const fieldValues = field.values;
1292
- switch (fieldName) {
1293
- case "radius":
1294
- radius = fieldValues[0];
1295
- break;
1296
- default:
1297
- console.warn("THREE.VRMLLoader: Unknown field:", fieldName);
1298
- break;
1299
- }
1300
- }
1301
- const geometry = new SphereGeometry(radius, 16, 16);
1302
- return geometry;
1303
- }
1304
- function buildElevationGridNode(node) {
1305
- let color;
1306
- let normal;
1307
- let texCoord;
1308
- let height;
1309
- let colorPerVertex = true;
1310
- let normalPerVertex = true;
1311
- let solid = true;
1312
- let ccw = true;
1313
- let creaseAngle = 0;
1314
- let xDimension = 2;
1315
- let zDimension = 2;
1316
- let xSpacing = 1;
1317
- let zSpacing = 1;
1318
- const fields = node.fields;
1319
- for (let i = 0, l = fields.length; i < l; i++) {
1320
- const field = fields[i];
1321
- const fieldName = field.name;
1322
- const fieldValues = field.values;
1323
- switch (fieldName) {
1324
- case "color":
1325
- const colorNode = fieldValues[0];
1326
- if (colorNode !== null) {
1327
- color = getNode(colorNode);
1328
- }
1329
- break;
1330
- case "normal":
1331
- const normalNode = fieldValues[0];
1332
- if (normalNode !== null) {
1333
- normal = getNode(normalNode);
1334
- }
1335
- break;
1336
- case "texCoord":
1337
- const texCoordNode = fieldValues[0];
1338
- if (texCoordNode !== null) {
1339
- texCoord = getNode(texCoordNode);
1340
- }
1341
- break;
1342
- case "height":
1343
- height = fieldValues;
1344
- break;
1345
- case "ccw":
1346
- ccw = fieldValues[0];
1347
- break;
1348
- case "colorPerVertex":
1349
- colorPerVertex = fieldValues[0];
1350
- break;
1351
- case "creaseAngle":
1352
- creaseAngle = fieldValues[0];
1353
- break;
1354
- case "normalPerVertex":
1355
- normalPerVertex = fieldValues[0];
1356
- break;
1357
- case "solid":
1358
- solid = fieldValues[0];
1359
- break;
1360
- case "xDimension":
1361
- xDimension = fieldValues[0];
1362
- break;
1363
- case "xSpacing":
1364
- xSpacing = fieldValues[0];
1365
- break;
1366
- case "zDimension":
1367
- zDimension = fieldValues[0];
1368
- break;
1369
- case "zSpacing":
1370
- zSpacing = fieldValues[0];
1371
- break;
1372
- default:
1373
- console.warn("THREE.VRMLLoader: Unknown field:", fieldName);
1374
- break;
1375
- }
1376
- }
1377
- const vertices = [];
1378
- const normals = [];
1379
- const colors = [];
1380
- const uvs = [];
1381
- for (let i = 0; i < zDimension; i++) {
1382
- for (let j = 0; j < xDimension; j++) {
1383
- const index = i * xDimension + j;
1384
- const x = xSpacing * i;
1385
- const y = height[index];
1386
- const z = zSpacing * j;
1387
- vertices.push(x, y, z);
1388
- if (color && colorPerVertex === true) {
1389
- const r = color[index * 3 + 0];
1390
- const g = color[index * 3 + 1];
1391
- const b = color[index * 3 + 2];
1392
- colors.push(r, g, b);
1393
- }
1394
- if (normal && normalPerVertex === true) {
1395
- const xn = normal[index * 3 + 0];
1396
- const yn = normal[index * 3 + 1];
1397
- const zn = normal[index * 3 + 2];
1398
- normals.push(xn, yn, zn);
1399
- }
1400
- if (texCoord) {
1401
- const s = texCoord[index * 2 + 0];
1402
- const t = texCoord[index * 2 + 1];
1403
- uvs.push(s, t);
1404
- } else {
1405
- uvs.push(i / (xDimension - 1), j / (zDimension - 1));
1406
- }
1407
- }
1408
- }
1409
- const indices = [];
1410
- for (let i = 0; i < xDimension - 1; i++) {
1411
- for (let j = 0; j < zDimension - 1; j++) {
1412
- const a = i + j * xDimension;
1413
- const b = i + (j + 1) * xDimension;
1414
- const c = i + 1 + (j + 1) * xDimension;
1415
- const d = i + 1 + j * xDimension;
1416
- if (ccw === true) {
1417
- indices.push(a, c, b);
1418
- indices.push(c, a, d);
1419
- } else {
1420
- indices.push(a, b, c);
1421
- indices.push(c, d, a);
1422
- }
1423
- }
1424
- }
1425
- const positionAttribute = toNonIndexedAttribute(indices, new Float32BufferAttribute(vertices, 3));
1426
- const uvAttribute = toNonIndexedAttribute(indices, new Float32BufferAttribute(uvs, 2));
1427
- let colorAttribute;
1428
- let normalAttribute;
1429
- if (color) {
1430
- if (colorPerVertex === false) {
1431
- for (let i = 0; i < xDimension - 1; i++) {
1432
- for (let j = 0; j < zDimension - 1; j++) {
1433
- const index = i + j * (xDimension - 1);
1434
- const r = color[index * 3 + 0];
1435
- const g = color[index * 3 + 1];
1436
- const b = color[index * 3 + 2];
1437
- colors.push(r, g, b);
1438
- colors.push(r, g, b);
1439
- colors.push(r, g, b);
1440
- colors.push(r, g, b);
1441
- colors.push(r, g, b);
1442
- colors.push(r, g, b);
1443
- }
1444
- }
1445
- colorAttribute = new Float32BufferAttribute(colors, 3);
1446
- } else {
1447
- colorAttribute = toNonIndexedAttribute(indices, new Float32BufferAttribute(colors, 3));
1448
- }
1449
- }
1450
- if (normal) {
1451
- if (normalPerVertex === false) {
1452
- for (let i = 0; i < xDimension - 1; i++) {
1453
- for (let j = 0; j < zDimension - 1; j++) {
1454
- const index = i + j * (xDimension - 1);
1455
- const xn = normal[index * 3 + 0];
1456
- const yn = normal[index * 3 + 1];
1457
- const zn = normal[index * 3 + 2];
1458
- normals.push(xn, yn, zn);
1459
- normals.push(xn, yn, zn);
1460
- normals.push(xn, yn, zn);
1461
- normals.push(xn, yn, zn);
1462
- normals.push(xn, yn, zn);
1463
- normals.push(xn, yn, zn);
1464
- }
1465
- }
1466
- normalAttribute = new Float32BufferAttribute(normals, 3);
1467
- } else {
1468
- normalAttribute = toNonIndexedAttribute(indices, new Float32BufferAttribute(normals, 3));
1469
- }
1470
- } else {
1471
- normalAttribute = computeNormalAttribute(indices, vertices, creaseAngle);
1472
- }
1473
- const geometry = new BufferGeometry();
1474
- geometry.setAttribute("position", positionAttribute);
1475
- geometry.setAttribute("normal", normalAttribute);
1476
- geometry.setAttribute("uv", uvAttribute);
1477
- if (colorAttribute)
1478
- geometry.setAttribute("color", colorAttribute);
1479
- geometry._solid = solid;
1480
- geometry._type = "mesh";
1481
- return geometry;
1482
- }
1483
- function buildExtrusionNode(node) {
1484
- let crossSection = [1, 1, 1, -1, -1, -1, -1, 1, 1, 1];
1485
- let spine = [0, 0, 0, 0, 1, 0];
1486
- let scale;
1487
- let orientation;
1488
- let beginCap = true;
1489
- let ccw = true;
1490
- let creaseAngle = 0;
1491
- let endCap = true;
1492
- let solid = true;
1493
- const fields = node.fields;
1494
- for (let i = 0, l = fields.length; i < l; i++) {
1495
- const field = fields[i];
1496
- const fieldName = field.name;
1497
- const fieldValues = field.values;
1498
- switch (fieldName) {
1499
- case "beginCap":
1500
- beginCap = fieldValues[0];
1501
- break;
1502
- case "ccw":
1503
- ccw = fieldValues[0];
1504
- break;
1505
- case "convex":
1506
- break;
1507
- case "creaseAngle":
1508
- creaseAngle = fieldValues[0];
1509
- break;
1510
- case "crossSection":
1511
- crossSection = fieldValues;
1512
- break;
1513
- case "endCap":
1514
- endCap = fieldValues[0];
1515
- break;
1516
- case "orientation":
1517
- orientation = fieldValues;
1518
- break;
1519
- case "scale":
1520
- scale = fieldValues;
1521
- break;
1522
- case "solid":
1523
- solid = fieldValues[0];
1524
- break;
1525
- case "spine":
1526
- spine = fieldValues;
1527
- break;
1528
- default:
1529
- console.warn("THREE.VRMLLoader: Unknown field:", fieldName);
1530
- break;
1531
- }
1532
- }
1533
- const crossSectionClosed = crossSection[0] === crossSection[crossSection.length - 2] && crossSection[1] === crossSection[crossSection.length - 1];
1534
- const vertices = [];
1535
- const spineVector = new Vector3();
1536
- const scaling = new Vector3();
1537
- const axis = new Vector3();
1538
- const vertex = new Vector3();
1539
- const quaternion = new Quaternion();
1540
- for (let i = 0, j = 0, o = 0, il = spine.length; i < il; i += 3, j += 2, o += 4) {
1541
- spineVector.fromArray(spine, i);
1542
- scaling.x = scale ? scale[j + 0] : 1;
1543
- scaling.y = 1;
1544
- scaling.z = scale ? scale[j + 1] : 1;
1545
- axis.x = orientation ? orientation[o + 0] : 0;
1546
- axis.y = orientation ? orientation[o + 1] : 0;
1547
- axis.z = orientation ? orientation[o + 2] : 1;
1548
- const angle = orientation ? orientation[o + 3] : 0;
1549
- for (let k = 0, kl = crossSection.length; k < kl; k += 2) {
1550
- vertex.x = crossSection[k + 0];
1551
- vertex.y = 0;
1552
- vertex.z = crossSection[k + 1];
1553
- vertex.multiply(scaling);
1554
- quaternion.setFromAxisAngle(axis, angle);
1555
- vertex.applyQuaternion(quaternion);
1556
- vertex.add(spineVector);
1557
- vertices.push(vertex.x, vertex.y, vertex.z);
1558
- }
1559
- }
1560
- const indices = [];
1561
- const spineCount = spine.length / 3;
1562
- const crossSectionCount = crossSection.length / 2;
1563
- for (let i = 0; i < spineCount - 1; i++) {
1564
- for (let j = 0; j < crossSectionCount - 1; j++) {
1565
- const a = j + i * crossSectionCount;
1566
- let b = j + 1 + i * crossSectionCount;
1567
- const c = j + (i + 1) * crossSectionCount;
1568
- let d = j + 1 + (i + 1) * crossSectionCount;
1569
- if (j === crossSectionCount - 2 && crossSectionClosed === true) {
1570
- b = i * crossSectionCount;
1571
- d = (i + 1) * crossSectionCount;
1572
- }
1573
- if (ccw === true) {
1574
- indices.push(a, b, c);
1575
- indices.push(c, b, d);
1576
- } else {
1577
- indices.push(a, c, b);
1578
- indices.push(c, d, b);
1579
- }
1580
- }
1581
- }
1582
- if (beginCap === true || endCap === true) {
1583
- const contour = [];
1584
- for (let i = 0, l = crossSection.length; i < l; i += 2) {
1585
- contour.push(new Vector2(crossSection[i], crossSection[i + 1]));
1586
- }
1587
- const faces = ShapeUtils.triangulateShape(contour, []);
1588
- const capIndices = [];
1589
- for (let i = 0, l = faces.length; i < l; i++) {
1590
- const face = faces[i];
1591
- capIndices.push(face[0], face[1], face[2]);
1592
- }
1593
- if (beginCap === true) {
1594
- for (let i = 0, l = capIndices.length; i < l; i += 3) {
1595
- if (ccw === true) {
1596
- indices.push(capIndices[i + 0], capIndices[i + 1], capIndices[i + 2]);
1597
- } else {
1598
- indices.push(capIndices[i + 0], capIndices[i + 2], capIndices[i + 1]);
1599
- }
1600
- }
1601
- }
1602
- if (endCap === true) {
1603
- const indexOffset = crossSectionCount * (spineCount - 1);
1604
- for (let i = 0, l = capIndices.length; i < l; i += 3) {
1605
- if (ccw === true) {
1606
- indices.push(
1607
- indexOffset + capIndices[i + 0],
1608
- indexOffset + capIndices[i + 2],
1609
- indexOffset + capIndices[i + 1]
1610
- );
1611
- } else {
1612
- indices.push(
1613
- indexOffset + capIndices[i + 0],
1614
- indexOffset + capIndices[i + 1],
1615
- indexOffset + capIndices[i + 2]
1616
- );
1617
- }
1618
- }
1619
- }
1620
- }
1621
- const positionAttribute = toNonIndexedAttribute(indices, new Float32BufferAttribute(vertices, 3));
1622
- const normalAttribute = computeNormalAttribute(indices, vertices, creaseAngle);
1623
- const geometry = new BufferGeometry();
1624
- geometry.setAttribute("position", positionAttribute);
1625
- geometry.setAttribute("normal", normalAttribute);
1626
- geometry._solid = solid;
1627
- geometry._type = "mesh";
1628
- return geometry;
1629
- }
1630
- function resolveUSE(identifier) {
1631
- const node = nodeMap[identifier];
1632
- const build = getNode(node);
1633
- return build.isObject3D || build.isMaterial ? build.clone() : build;
1634
- }
1635
- function parseFieldChildren(children, owner) {
1636
- for (let i = 0, l = children.length; i < l; i++) {
1637
- const object = getNode(children[i]);
1638
- if (object instanceof Object3D)
1639
- owner.add(object);
1640
- }
1641
- }
1642
- function triangulateFaceIndex(index, ccw) {
1643
- const indices = [];
1644
- let start = 0;
1645
- for (let i = 0, l = index.length; i < l; i++) {
1646
- const i1 = index[start];
1647
- const i2 = index[i + (ccw ? 1 : 2)];
1648
- const i3 = index[i + (ccw ? 2 : 1)];
1649
- indices.push(i1, i2, i3);
1650
- if (index[i + 3] === -1 || i + 3 >= l) {
1651
- i += 3;
1652
- start = i + 1;
1653
- }
1654
- }
1655
- return indices;
1656
- }
1657
- function triangulateFaceData(data2, index) {
1658
- const triangulatedData = [];
1659
- let start = 0;
1660
- for (let i = 0, l = index.length; i < l; i++) {
1661
- const stride = start * 3;
1662
- const x = data2[stride];
1663
- const y = data2[stride + 1];
1664
- const z = data2[stride + 2];
1665
- triangulatedData.push(x, y, z);
1666
- if (index[i + 3] === -1 || i + 3 >= l) {
1667
- i += 3;
1668
- start++;
1669
- }
1670
- }
1671
- return triangulatedData;
1672
- }
1673
- function flattenData(data2, index) {
1674
- const flattenData2 = [];
1675
- for (let i = 0, l = index.length; i < l; i++) {
1676
- const i1 = index[i];
1677
- const stride = i1 * 3;
1678
- const x = data2[stride];
1679
- const y = data2[stride + 1];
1680
- const z = data2[stride + 2];
1681
- flattenData2.push(x, y, z);
1682
- }
1683
- return flattenData2;
1684
- }
1685
- function expandLineIndex(index) {
1686
- const indices = [];
1687
- for (let i = 0, l = index.length; i < l; i++) {
1688
- const i1 = index[i];
1689
- const i2 = index[i + 1];
1690
- indices.push(i1, i2);
1691
- if (index[i + 2] === -1 || i + 2 >= l) {
1692
- i += 2;
1693
- }
1694
- }
1695
- return indices;
1696
- }
1697
- function expandLineData(data2, index) {
1698
- const triangulatedData = [];
1699
- let start = 0;
1700
- for (let i = 0, l = index.length; i < l; i++) {
1701
- const stride = start * 3;
1702
- const x = data2[stride];
1703
- const y = data2[stride + 1];
1704
- const z = data2[stride + 2];
1705
- triangulatedData.push(x, y, z);
1706
- if (index[i + 2] === -1 || i + 2 >= l) {
1707
- i += 2;
1708
- start++;
1709
- }
1710
- }
1711
- return triangulatedData;
1712
- }
1713
- const vA = new Vector3();
1714
- const vB = new Vector3();
1715
- const vC = new Vector3();
1716
- const uvA = new Vector2();
1717
- const uvB = new Vector2();
1718
- const uvC = new Vector2();
1719
- function computeAttributeFromIndexedData(coordIndex, index, data2, itemSize) {
1720
- const array = [];
1721
- for (let i = 0, l = coordIndex.length; i < l; i += 3) {
1722
- const a = index[i];
1723
- const b = index[i + 1];
1724
- const c = index[i + 2];
1725
- if (itemSize === 2) {
1726
- uvA.fromArray(data2, a * itemSize);
1727
- uvB.fromArray(data2, b * itemSize);
1728
- uvC.fromArray(data2, c * itemSize);
1729
- array.push(uvA.x, uvA.y);
1730
- array.push(uvB.x, uvB.y);
1731
- array.push(uvC.x, uvC.y);
1732
- } else {
1733
- vA.fromArray(data2, a * itemSize);
1734
- vB.fromArray(data2, b * itemSize);
1735
- vC.fromArray(data2, c * itemSize);
1736
- array.push(vA.x, vA.y, vA.z);
1737
- array.push(vB.x, vB.y, vB.z);
1738
- array.push(vC.x, vC.y, vC.z);
1739
- }
1740
- }
1741
- return new Float32BufferAttribute(array, itemSize);
1742
- }
1743
- function computeAttributeFromFaceData(index, faceData) {
1744
- const array = [];
1745
- for (let i = 0, j = 0, l = index.length; i < l; i += 3, j++) {
1746
- vA.fromArray(faceData, j * 3);
1747
- array.push(vA.x, vA.y, vA.z);
1748
- array.push(vA.x, vA.y, vA.z);
1749
- array.push(vA.x, vA.y, vA.z);
1750
- }
1751
- return new Float32BufferAttribute(array, 3);
1752
- }
1753
- function computeAttributeFromLineData(index, lineData) {
1754
- const array = [];
1755
- for (let i = 0, j = 0, l = index.length; i < l; i += 2, j++) {
1756
- vA.fromArray(lineData, j * 3);
1757
- array.push(vA.x, vA.y, vA.z);
1758
- array.push(vA.x, vA.y, vA.z);
1759
- }
1760
- return new Float32BufferAttribute(array, 3);
1761
- }
1762
- function toNonIndexedAttribute(indices, attribute) {
1763
- const array = attribute.array;
1764
- const itemSize = attribute.itemSize;
1765
- const array2 = new array.constructor(indices.length * itemSize);
1766
- let index = 0, index2 = 0;
1767
- for (let i = 0, l = indices.length; i < l; i++) {
1768
- index = indices[i] * itemSize;
1769
- for (let j = 0; j < itemSize; j++) {
1770
- array2[index2++] = array[index++];
1771
- }
1772
- }
1773
- return new Float32BufferAttribute(array2, itemSize);
1774
- }
1775
- const ab = new Vector3();
1776
- const cb = new Vector3();
1777
- function computeNormalAttribute(index, coord, creaseAngle) {
1778
- const faces = [];
1779
- const vertexNormals = {};
1780
- for (let i = 0, l = index.length; i < l; i += 3) {
1781
- const a = index[i];
1782
- const b = index[i + 1];
1783
- const c = index[i + 2];
1784
- const face = new Face(a, b, c);
1785
- vA.fromArray(coord, a * 3);
1786
- vB.fromArray(coord, b * 3);
1787
- vC.fromArray(coord, c * 3);
1788
- cb.subVectors(vC, vB);
1789
- ab.subVectors(vA, vB);
1790
- cb.cross(ab);
1791
- cb.normalize();
1792
- face.normal.copy(cb);
1793
- if (vertexNormals[a] === void 0)
1794
- vertexNormals[a] = [];
1795
- if (vertexNormals[b] === void 0)
1796
- vertexNormals[b] = [];
1797
- if (vertexNormals[c] === void 0)
1798
- vertexNormals[c] = [];
1799
- vertexNormals[a].push(face.normal);
1800
- vertexNormals[b].push(face.normal);
1801
- vertexNormals[c].push(face.normal);
1802
- faces.push(face);
1803
- }
1804
- const normals = [];
1805
- for (let i = 0, l = faces.length; i < l; i++) {
1806
- const face = faces[i];
1807
- const nA = weightedNormal(vertexNormals[face.a], face.normal, creaseAngle);
1808
- const nB = weightedNormal(vertexNormals[face.b], face.normal, creaseAngle);
1809
- const nC = weightedNormal(vertexNormals[face.c], face.normal, creaseAngle);
1810
- vA.fromArray(coord, face.a * 3);
1811
- vB.fromArray(coord, face.b * 3);
1812
- vC.fromArray(coord, face.c * 3);
1813
- normals.push(nA.x, nA.y, nA.z);
1814
- normals.push(nB.x, nB.y, nB.z);
1815
- normals.push(nC.x, nC.y, nC.z);
1816
- }
1817
- return new Float32BufferAttribute(normals, 3);
1818
- }
1819
- function weightedNormal(normals, vector, creaseAngle) {
1820
- const normal = new Vector3();
1821
- if (creaseAngle === 0) {
1822
- normal.copy(vector);
1823
- } else {
1824
- for (let i = 0, l = normals.length; i < l; i++) {
1825
- if (normals[i].angleTo(vector) < creaseAngle) {
1826
- normal.add(normals[i]);
1827
- }
1828
- }
1829
- }
1830
- return normal.normalize();
1831
- }
1832
- function toColorArray(colors) {
1833
- const array = [];
1834
- for (let i = 0, l = colors.length; i < l; i += 3) {
1835
- array.push(new Color(colors[i], colors[i + 1], colors[i + 2]));
1836
- }
1837
- return array;
1838
- }
1839
- function paintFaces(geometry, radius, angles, colors, topDown) {
1840
- const thresholds = [];
1841
- const startAngle = topDown === true ? 0 : Math.PI;
1842
- for (let i = 0, l = colors.length; i < l; i++) {
1843
- let angle = i === 0 ? 0 : angles[i - 1];
1844
- angle = topDown === true ? angle : startAngle - angle;
1845
- const point = new Vector3();
1846
- point.setFromSphericalCoords(radius, angle, 0);
1847
- thresholds.push(point);
1848
- }
1849
- const indices = geometry.index;
1850
- const positionAttribute = geometry.attributes.position;
1851
- const colorAttribute = new BufferAttribute(new Float32Array(geometry.attributes.position.count * 3), 3);
1852
- const position = new Vector3();
1853
- const color = new Color();
1854
- for (let i = 0; i < indices.count; i++) {
1855
- const index = indices.getX(i);
1856
- position.fromBufferAttribute(positionAttribute, index);
1857
- let thresholdIndexA, thresholdIndexB;
1858
- let t = 1;
1859
- for (let j = 1; j < thresholds.length; j++) {
1860
- thresholdIndexA = j - 1;
1861
- thresholdIndexB = j;
1862
- const thresholdA = thresholds[thresholdIndexA];
1863
- const thresholdB = thresholds[thresholdIndexB];
1864
- if (topDown === true) {
1865
- if (position.y <= thresholdA.y && position.y > thresholdB.y) {
1866
- t = Math.abs(thresholdA.y - position.y) / Math.abs(thresholdA.y - thresholdB.y);
1867
- break;
1868
- }
1869
- } else {
1870
- if (position.y >= thresholdA.y && position.y < thresholdB.y) {
1871
- t = Math.abs(thresholdA.y - position.y) / Math.abs(thresholdA.y - thresholdB.y);
1872
- break;
1873
- }
1874
- }
1875
- }
1876
- const colorA = colors[thresholdIndexA];
1877
- const colorB = colors[thresholdIndexB];
1878
- color.copy(colorA).lerp(colorB, t);
1879
- colorAttribute.setXYZ(index, color.r, color.g, color.b);
1880
- }
1881
- geometry.setAttribute("color", colorAttribute);
1882
- }
1883
- const textureLoader = new TextureLoader(this.manager);
1884
- textureLoader.setPath(this.resourcePath || path).setCrossOrigin(this.crossOrigin);
1885
- if (data.indexOf("#VRML V2.0") === -1) {
1886
- throw Error("THREE.VRMLLexer: Version of VRML asset not supported.");
1887
- }
1888
- const tree = generateVRMLTree(data);
1889
- const scene = parseTree(tree);
1890
- return scene;
1891
- }
1892
- }
1893
- class VRMLLexer {
1894
- constructor(tokens) {
1895
- this.lexer = new Lexer(tokens);
1896
- }
1897
- lex(inputText) {
1898
- const lexingResult = this.lexer.tokenize(inputText);
1899
- if (lexingResult.errors.length > 0) {
1900
- console.error(lexingResult.errors);
1901
- throw Error("THREE.VRMLLexer: Lexing errors detected.");
1902
- }
1903
- return lexingResult;
1904
- }
1905
- }
1906
- class VRMLParser extends CstParser {
1907
- constructor(tokenVocabulary) {
1908
- super(tokenVocabulary);
1909
- const $ = this;
1910
- const Version = tokenVocabulary["Version"];
1911
- const LCurly = tokenVocabulary["LCurly"];
1912
- const RCurly = tokenVocabulary["RCurly"];
1913
- const LSquare = tokenVocabulary["LSquare"];
1914
- const RSquare = tokenVocabulary["RSquare"];
1915
- const Identifier = tokenVocabulary["Identifier"];
1916
- const RouteIdentifier = tokenVocabulary["RouteIdentifier"];
1917
- const StringLiteral = tokenVocabulary["StringLiteral"];
1918
- const HexLiteral = tokenVocabulary["HexLiteral"];
1919
- const NumberLiteral = tokenVocabulary["NumberLiteral"];
1920
- const TrueLiteral = tokenVocabulary["TrueLiteral"];
1921
- const FalseLiteral = tokenVocabulary["FalseLiteral"];
1922
- const NullLiteral = tokenVocabulary["NullLiteral"];
1923
- const DEF = tokenVocabulary["DEF"];
1924
- const USE = tokenVocabulary["USE"];
1925
- const ROUTE = tokenVocabulary["ROUTE"];
1926
- const TO = tokenVocabulary["TO"];
1927
- const NodeName = tokenVocabulary["NodeName"];
1928
- $.RULE("vrml", function() {
1929
- $.SUBRULE($.version);
1930
- $.AT_LEAST_ONE(function() {
1931
- $.SUBRULE($.node);
1932
- });
1933
- $.MANY(function() {
1934
- $.SUBRULE($.route);
1935
- });
1936
- });
1937
- $.RULE("version", function() {
1938
- $.CONSUME(Version);
1939
- });
1940
- $.RULE("node", function() {
1941
- $.OPTION(function() {
1942
- $.SUBRULE($.def);
1943
- });
1944
- $.CONSUME(NodeName);
1945
- $.CONSUME(LCurly);
1946
- $.MANY(function() {
1947
- $.SUBRULE($.field);
1948
- });
1949
- $.CONSUME(RCurly);
1950
- });
1951
- $.RULE("field", function() {
1952
- $.CONSUME(Identifier);
1953
- $.OR2([
1954
- {
1955
- ALT: function() {
1956
- $.SUBRULE($.singleFieldValue);
1957
- }
1958
- },
1959
- {
1960
- ALT: function() {
1961
- $.SUBRULE($.multiFieldValue);
1962
- }
1963
- }
1964
- ]);
1965
- });
1966
- $.RULE("def", function() {
1967
- $.CONSUME(DEF);
1968
- $.OR([
1969
- {
1970
- ALT: function() {
1971
- $.CONSUME(Identifier);
1972
- }
1973
- },
1974
- {
1975
- ALT: function() {
1976
- $.CONSUME(NodeName);
1977
- }
1978
- }
1979
- ]);
1980
- });
1981
- $.RULE("use", function() {
1982
- $.CONSUME(USE);
1983
- $.OR([
1984
- {
1985
- ALT: function() {
1986
- $.CONSUME(Identifier);
1987
- }
1988
- },
1989
- {
1990
- ALT: function() {
1991
- $.CONSUME(NodeName);
1992
- }
1993
- }
1994
- ]);
1995
- });
1996
- $.RULE("singleFieldValue", function() {
1997
- $.AT_LEAST_ONE(function() {
1998
- $.OR([
1999
- {
2000
- ALT: function() {
2001
- $.SUBRULE($.node);
2002
- }
2003
- },
2004
- {
2005
- ALT: function() {
2006
- $.SUBRULE($.use);
2007
- }
2008
- },
2009
- {
2010
- ALT: function() {
2011
- $.CONSUME(StringLiteral);
2012
- }
2013
- },
2014
- {
2015
- ALT: function() {
2016
- $.CONSUME(HexLiteral);
2017
- }
2018
- },
2019
- {
2020
- ALT: function() {
2021
- $.CONSUME(NumberLiteral);
2022
- }
2023
- },
2024
- {
2025
- ALT: function() {
2026
- $.CONSUME(TrueLiteral);
2027
- }
2028
- },
2029
- {
2030
- ALT: function() {
2031
- $.CONSUME(FalseLiteral);
2032
- }
2033
- },
2034
- {
2035
- ALT: function() {
2036
- $.CONSUME(NullLiteral);
2037
- }
2038
- }
2039
- ]);
2040
- });
2041
- });
2042
- $.RULE("multiFieldValue", function() {
2043
- $.CONSUME(LSquare);
2044
- $.MANY(function() {
2045
- $.OR([
2046
- {
2047
- ALT: function() {
2048
- $.SUBRULE($.node);
2049
- }
2050
- },
2051
- {
2052
- ALT: function() {
2053
- $.SUBRULE($.use);
2054
- }
2055
- },
2056
- {
2057
- ALT: function() {
2058
- $.CONSUME(StringLiteral);
2059
- }
2060
- },
2061
- {
2062
- ALT: function() {
2063
- $.CONSUME(HexLiteral);
2064
- }
2065
- },
2066
- {
2067
- ALT: function() {
2068
- $.CONSUME(NumberLiteral);
2069
- }
2070
- },
2071
- {
2072
- ALT: function() {
2073
- $.CONSUME(NullLiteral);
2074
- }
2075
- }
2076
- ]);
2077
- });
2078
- $.CONSUME(RSquare);
2079
- });
2080
- $.RULE("route", function() {
2081
- $.CONSUME(ROUTE);
2082
- $.CONSUME(RouteIdentifier);
2083
- $.CONSUME(TO);
2084
- $.CONSUME2(RouteIdentifier);
2085
- });
2086
- this.performSelfAnalysis();
2087
- }
2088
- }
2089
- class Face {
2090
- constructor(a, b, c) {
2091
- this.a = a;
2092
- this.b = b;
2093
- this.c = c;
2094
- this.normal = new Vector3();
2095
- }
2096
- }
2097
- const TEXTURE_TYPE = {
2098
- INTENSITY: 1,
2099
- INTENSITY_ALPHA: 2,
2100
- RGB: 3,
2101
- RGBA: 4
2102
- };
2103
- export {
2104
- VRMLLoader
2105
- };