@anov/3d 0.0.4-alpha.1 → 0.0.4-alpha13

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