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