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