x_ite 8.4.3 → 8.5.3
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/.vscode/settings.json +5 -1
- package/Makefile +0 -3
- package/build/bin/components.js +173 -0
- package/build/bin/tags.pl +28 -0
- package/build/bin/tests.pl +80 -2
- package/build/bin/version.pl +12 -7
- package/dist/assets/components/Annotation.js +13 -13
- package/dist/assets/components/Annotation.min.js +1 -1
- package/dist/assets/components/CADGeometry.js +13 -13
- package/dist/assets/components/CADGeometry.min.js +1 -1
- package/dist/assets/components/CubeMapTexturing.js +28 -29
- package/dist/assets/components/CubeMapTexturing.min.js +1 -1
- package/dist/assets/components/DIS.js +13 -13
- package/dist/assets/components/DIS.min.js +1 -1
- package/dist/assets/components/EventUtilities.js +9 -9
- package/dist/assets/components/EventUtilities.min.js +1 -1
- package/dist/assets/components/Geometry2D.js +19 -19
- package/dist/assets/components/Geometry2D.min.js +1 -1
- package/dist/assets/components/Geospatial.js +33 -33
- package/dist/assets/components/Geospatial.min.js +1 -1
- package/dist/assets/components/HAnim.js +63 -42
- package/dist/assets/components/HAnim.min.js +1 -1
- package/dist/assets/components/KeyDeviceSensor.js +8 -8
- package/dist/assets/components/KeyDeviceSensor.min.js +1 -1
- package/dist/assets/components/Layout.js +37 -29
- package/dist/assets/components/Layout.min.js +1 -1
- package/dist/assets/components/NURBS.js +29 -31
- package/dist/assets/components/NURBS.min.js +1 -1
- package/dist/assets/components/ParticleSystems.js +23 -23
- package/dist/assets/components/ParticleSystems.min.js +1 -1
- package/dist/assets/components/Picking.js +19 -19
- package/dist/assets/components/Picking.min.js +1 -1
- package/dist/assets/components/RigidBodyPhysics.js +24 -19
- package/dist/assets/components/RigidBodyPhysics.min.js +1 -1
- package/dist/assets/components/Scripting.js +30 -30
- package/dist/assets/components/Scripting.min.js +1 -1
- package/dist/assets/components/Text.js +172 -594
- package/dist/assets/components/Text.min.js +1 -1
- package/dist/assets/components/TextureProjector.js +31 -47
- package/dist/assets/components/TextureProjector.min.js +1 -1
- package/dist/assets/components/Texturing3D.js +367 -346
- package/dist/assets/components/Texturing3D.min.js +1 -1
- package/dist/assets/components/VolumeRendering.js +19 -19
- package/dist/assets/components/VolumeRendering.min.js +1 -1
- package/dist/assets/components/X_ITE.js +9 -9
- package/dist/assets/components/X_ITE.min.js +1 -1
- package/dist/x_ite.css +1 -1
- package/dist/x_ite.js +12174 -3553
- package/dist/x_ite.min.js +1 -1
- package/dist/x_ite.zip +0 -0
- package/docs/_config.yml +5 -136
- package/docs/_data/nav/components-CADGeometry.yml +14 -0
- package/docs/_data/nav/components-Core.yml +16 -0
- package/docs/_data/nav/components-CubeMapTexturing.yml +8 -0
- package/docs/_data/nav/components-DIS.yml +14 -0
- package/docs/_data/nav/components-EnvironmentalEffects.yml +12 -0
- package/docs/_data/nav/components-EnvironmentalSensor.yml +8 -0
- package/docs/_data/nav/components-EventUtilities.yml +16 -0
- package/docs/_data/nav/components-Followers.yml +30 -0
- package/docs/_data/nav/components-Geometry2D.yml +18 -0
- package/docs/_data/nav/components-Geometry3D.yml +16 -0
- package/docs/_data/nav/components-Geospatial.yml +24 -0
- package/docs/_data/nav/components-Grouping.yml +10 -0
- package/docs/_data/nav/components-HAnim.yml +14 -0
- package/docs/_data/nav/components-Interpolation.yml +28 -0
- package/docs/_data/nav/components-KeyDeviceSensor.yml +6 -0
- package/docs/_data/nav/components-Layering.yml +8 -0
- package/docs/_data/nav/components-Layout.yml +12 -0
- package/docs/_data/nav/components-Lighting.yml +10 -0
- package/docs/_data/nav/components-NURBS.yml +30 -0
- package/docs/_data/nav/components-Navigation.yml +16 -0
- package/docs/_data/nav/components-Networking.yml +8 -0
- package/docs/_data/nav/components-ParticleSystems.yml +22 -0
- package/docs/_data/nav/components-Picking.yml +12 -0
- package/docs/_data/nav/components-PointingDeviceSensor.yml +10 -0
- package/docs/_data/nav/components-Rendering.yml +30 -0
- package/docs/_data/nav/components-RigidBodyPhysics.yml +30 -0
- package/docs/_data/nav/components-Scripting.yml +4 -0
- package/docs/_data/nav/components-Shaders.yml +18 -0
- package/docs/_data/nav/components-Shape.yml +22 -0
- package/docs/_data/nav/components-Sound.yml +44 -0
- package/docs/_data/nav/components-Text.yml +6 -0
- package/docs/_data/nav/components-TextureProjector.yml +6 -0
- package/docs/_data/nav/components-Texturing.yml +22 -0
- package/docs/_data/nav/components-Texturing3D.yml +18 -0
- package/docs/_data/nav/components-Time.yml +4 -0
- package/docs/_data/nav/components-VolumeRendering.yml +28 -0
- package/docs/_data/nav/components-X_ITE.yml +4 -0
- package/docs/_data/nav/main.yml +26 -0
- package/docs/_data/nav/reference.yml +18 -0
- package/docs/_data/nav/tutorials-animation-sensors-and-geometry.yml +18 -0
- package/docs/_data/nav/tutorials-basic.yml +6 -0
- package/docs/_data/nav/tutorials-optimize-your-scene.yml +6 -0
- package/docs/_data/nav/tutorials-scripts-and-prototypes.yml +12 -0
- package/docs/_data/nav/tutorials-shapes-geometry-and-appearance.yml +16 -0
- package/docs/_data/nav/tutorials-textures-lights-and-environment.yml +20 -0
- package/docs/_includes/nav.html +2 -2
- package/docs/_includes/scripts.html +2 -1
- package/docs/_posts/accessing-the-external-browser.md +1 -1
- package/docs/_posts/browser-support.md +1 -1
- package/docs/_posts/components/CADGeometry/CADAssembly.md +83 -0
- package/docs/_posts/components/CADGeometry/CADFace.md +70 -0
- package/docs/_posts/components/CADGeometry/CADLayer.md +84 -0
- package/docs/_posts/components/CADGeometry/CADPart.md +117 -0
- package/docs/_posts/components/CADGeometry/IndexedQuadSet.md +125 -0
- package/docs/_posts/components/CADGeometry/QuadSet.md +113 -0
- package/docs/_posts/components/Core/MetadataBoolean.md +90 -0
- package/docs/_posts/components/Core/MetadataDouble.md +67 -0
- package/docs/_posts/components/Core/MetadataFloat.md +67 -0
- package/docs/_posts/components/Core/MetadataInteger.md +66 -0
- package/docs/_posts/components/Core/MetadataSet.md +63 -0
- package/docs/_posts/components/Core/MetadataString.md +66 -0
- package/docs/_posts/components/Core/WorldInfo.md +54 -0
- package/docs/_posts/components/CubeMapTexturing/ComposedCubeMapTexture.md +76 -0
- package/docs/_posts/components/CubeMapTexturing/GeneratedCubeMapTexture.md +65 -0
- package/docs/_posts/components/CubeMapTexturing/ImageCubeMapTexture.md +66 -0
- package/docs/_posts/components/DIS/DISEntityManager.md +73 -0
- package/docs/_posts/components/DIS/DISEntityTypeMapping.md +88 -0
- package/docs/_posts/components/DIS/EspduTransform.md +416 -0
- package/docs/_posts/components/DIS/ReceiverPdu.md +168 -0
- package/docs/_posts/components/DIS/SignalPdu.md +168 -0
- package/docs/_posts/components/DIS/TransmitterPdu.md +232 -0
- package/docs/_posts/components/EnvironmentalEffects/Background.md +189 -0
- package/docs/_posts/components/EnvironmentalEffects/Fog.md +97 -0
- package/docs/_posts/components/EnvironmentalEffects/FogCoordinate.md +40 -0
- package/docs/_posts/components/EnvironmentalEffects/LocalFog.md +84 -0
- package/docs/_posts/components/EnvironmentalEffects/TextureBackground.md +142 -0
- package/docs/_posts/components/EnvironmentalSensor/ProximitySensor.md +90 -0
- package/docs/_posts/components/EnvironmentalSensor/TransformSensor.md +91 -0
- package/docs/_posts/components/EnvironmentalSensor/VisibilitySensor.md +73 -0
- package/docs/_posts/components/EventUtilities/BooleanFilter.md +62 -0
- package/docs/_posts/components/EventUtilities/BooleanSequencer.md +86 -0
- package/docs/_posts/components/EventUtilities/BooleanToggle.md +46 -0
- package/docs/_posts/components/EventUtilities/BooleanTrigger.md +47 -0
- package/docs/_posts/components/EventUtilities/IntegerSequencer.md +90 -0
- package/docs/_posts/components/EventUtilities/IntegerTrigger.md +51 -0
- package/docs/_posts/components/EventUtilities/TimeTrigger.md +47 -0
- package/docs/_posts/components/Followers/ColorChaser.md +77 -0
- package/docs/_posts/components/Followers/ColorDamper.md +85 -0
- package/docs/_posts/components/Followers/CoordinateChaser.md +76 -0
- package/docs/_posts/components/Followers/CoordinateDamper.md +80 -0
- package/docs/_posts/components/Followers/OrientationChaser.md +72 -0
- package/docs/_posts/components/Followers/OrientationDamper.md +80 -0
- package/docs/_posts/components/Followers/PositionChaser.md +72 -0
- package/docs/_posts/components/Followers/PositionChaser2D.md +72 -0
- package/docs/_posts/components/Followers/PositionDamper.md +80 -0
- package/docs/_posts/components/Followers/PositionDamper2D.md +80 -0
- package/docs/_posts/components/Followers/ScalarChaser.md +76 -0
- package/docs/_posts/components/Followers/ScalarDamper.md +80 -0
- package/docs/_posts/components/Followers/TexCoordChaser2D.md +72 -0
- package/docs/_posts/components/Followers/TexCoordDamper2D.md +80 -0
- package/docs/_posts/components/Geometry2D/Arc2D.md +71 -0
- package/docs/_posts/components/Geometry2D/ArcClose2D.md +91 -0
- package/docs/_posts/components/Geometry2D/Circle2D.md +55 -0
- package/docs/_posts/components/Geometry2D/Disk2D.md +75 -0
- package/docs/_posts/components/Geometry2D/Polyline2D.md +54 -0
- package/docs/_posts/components/Geometry2D/Polypoint2D.md +54 -0
- package/docs/_posts/components/Geometry2D/Rectangle2D.md +66 -0
- package/docs/_posts/components/Geometry2D/TriangleSet2D.md +66 -0
- package/docs/_posts/components/Geometry3D/Box.md +66 -0
- package/docs/_posts/components/Geometry3D/Cone.md +90 -0
- package/docs/_posts/components/Geometry3D/Cylinder.md +98 -0
- package/docs/_posts/components/Geometry3D/ElevationGrid.md +162 -0
- package/docs/_posts/components/Geometry3D/Extrusion.md +170 -0
- package/docs/_posts/components/Geometry3D/IndexedFaceSet.md +208 -0
- package/docs/_posts/components/Geometry3D/Sphere.md +66 -0
- package/docs/_posts/components/Geospatial/GeoCoordinate.md +65 -0
- package/docs/_posts/components/Geospatial/GeoElevationGrid.md +180 -0
- package/docs/_posts/components/Geospatial/GeoLOD.md +128 -0
- package/docs/_posts/components/Geospatial/GeoLocation.md +93 -0
- package/docs/_posts/components/Geospatial/GeoMetadata.md +75 -0
- package/docs/_posts/components/Geospatial/GeoOrigin.md +69 -0
- package/docs/_posts/components/Geospatial/GeoPositionInterpolator.md +95 -0
- package/docs/_posts/components/Geospatial/GeoProximitySensor.md +109 -0
- package/docs/_posts/components/Geospatial/GeoTouchSensor.md +108 -0
- package/docs/_posts/components/Geospatial/GeoTransform.md +121 -0
- package/docs/_posts/components/Geospatial/GeoViewpoint.md +126 -0
- package/docs/_posts/components/Grouping/Group.md +75 -0
- package/docs/_posts/components/Grouping/StaticGroup.md +65 -0
- package/docs/_posts/components/Grouping/Switch.md +89 -0
- package/docs/_posts/components/Grouping/Transform.md +126 -0
- package/docs/_posts/components/HAnim/HAnimDisplacer.md +89 -0
- package/docs/_posts/components/HAnim/HAnimHumanoid.md +136 -0
- package/docs/_posts/components/HAnim/HAnimJoint.md +165 -0
- package/docs/_posts/components/HAnim/HAnimMotion.md +68 -0
- package/docs/_posts/components/HAnim/HAnimSegment.md +107 -0
- package/docs/_posts/components/HAnim/HAnimSite.md +108 -0
- package/docs/_posts/components/Interpolation/ColorInterpolator.md +73 -0
- package/docs/_posts/components/Interpolation/CoordinateInterpolator.md +76 -0
- package/docs/_posts/components/Interpolation/CoordinateInterpolator2D.md +73 -0
- package/docs/_posts/components/Interpolation/EaseInEaseOut.md +67 -0
- package/docs/_posts/components/Interpolation/NormalInterpolator.md +68 -0
- package/docs/_posts/components/Interpolation/OrientationInterpolator.md +72 -0
- package/docs/_posts/components/Interpolation/PositionInterpolator.md +72 -0
- package/docs/_posts/components/Interpolation/PositionInterpolator2D.md +77 -0
- package/docs/_posts/components/Interpolation/ScalarInterpolator.md +76 -0
- package/docs/_posts/components/Interpolation/SplinePositionInterpolator.md +93 -0
- package/docs/_posts/components/Interpolation/SplinePositionInterpolator2D.md +93 -0
- package/docs/_posts/components/Interpolation/SplineScalarInterpolator.md +106 -0
- package/docs/_posts/components/Interpolation/SquadOrientationInterpolator.md +78 -0
- package/docs/_posts/components/KeyDeviceSensor/KeySensor.md +78 -0
- package/docs/_posts/components/KeyDeviceSensor/StringSensor.md +70 -0
- package/docs/_posts/components/Layering/Layer.md +67 -0
- package/docs/_posts/components/Layering/LayerSet.md +78 -0
- package/docs/_posts/components/Layering/Viewport.md +80 -0
- package/docs/_posts/components/Layout/Layout.md +107 -0
- package/docs/_posts/components/Layout/LayoutGroup.md +85 -0
- package/docs/_posts/components/Layout/LayoutLayer.md +74 -0
- package/docs/_posts/components/Layout/ScreenFontStyle.md +137 -0
- package/docs/_posts/components/Layout/ScreenGroup.md +71 -0
- package/docs/_posts/components/Lighting/DirectionalLight.md +100 -0
- package/docs/_posts/components/Lighting/EnvironmentLight.md +91 -0
- package/docs/_posts/components/Lighting/PointLight.md +103 -0
- package/docs/_posts/components/Lighting/SpotLight.md +132 -0
- package/docs/_posts/components/NURBS/Contour2D.md +57 -0
- package/docs/_posts/components/NURBS/ContourPolyline2D.md +46 -0
- package/docs/_posts/components/NURBS/CoordinateDouble.md +47 -0
- package/docs/_posts/components/NURBS/NurbsCurve.md +71 -0
- package/docs/_posts/components/NURBS/NurbsCurve2D.md +66 -0
- package/docs/_posts/components/NURBS/NurbsOrientationInterpolator.md +70 -0
- package/docs/_posts/components/NURBS/NurbsPatchSurface.md +106 -0
- package/docs/_posts/components/NURBS/NurbsPositionInterpolator.md +70 -0
- package/docs/_posts/components/NURBS/NurbsSet.md +66 -0
- package/docs/_posts/components/NURBS/NurbsSurfaceInterpolator.md +90 -0
- package/docs/_posts/components/NURBS/NurbsSweptSurface.md +69 -0
- package/docs/_posts/components/NURBS/NurbsSwungSurface.md +65 -0
- package/docs/_posts/components/NURBS/NurbsTextureCoordinate.md +77 -0
- package/docs/_posts/components/NURBS/NurbsTrimmedSurface.md +114 -0
- package/docs/_posts/components/Navigation/Billboard.md +88 -0
- package/docs/_posts/components/Navigation/Collision.md +102 -0
- package/docs/_posts/components/Navigation/LOD.md +99 -0
- package/docs/_posts/components/Navigation/NavigationInfo.md +122 -0
- package/docs/_posts/components/Navigation/OrthoViewpoint.md +117 -0
- package/docs/_posts/components/Navigation/Viewpoint.md +117 -0
- package/docs/_posts/components/Navigation/ViewpointGroup.md +80 -0
- package/docs/_posts/components/Networking/Anchor.md +111 -0
- package/docs/_posts/components/Networking/Inline.md +115 -0
- package/docs/_posts/components/Networking/LoadSensor.md +91 -0
- package/docs/_posts/components/ParticleSystems/BoundedPhysicsModel.md +54 -0
- package/docs/_posts/components/ParticleSystems/ConeEmitter.md +76 -0
- package/docs/_posts/components/ParticleSystems/ExplosionEmitter.md +72 -0
- package/docs/_posts/components/ParticleSystems/ForcePhysicsModel.md +58 -0
- package/docs/_posts/components/ParticleSystems/ParticleSystem.md +177 -0
- package/docs/_posts/components/ParticleSystems/PointEmitter.md +76 -0
- package/docs/_posts/components/ParticleSystems/PolylineEmitter.md +94 -0
- package/docs/_posts/components/ParticleSystems/SurfaceEmitter.md +90 -0
- package/docs/_posts/components/ParticleSystems/VolumeEmitter.md +90 -0
- package/docs/_posts/components/ParticleSystems/WindPhysicsModel.md +68 -0
- package/docs/_posts/components/Picking/LinePickSensor.md +125 -0
- package/docs/_posts/components/Picking/PickableGroup.md +93 -0
- package/docs/_posts/components/Picking/PointPickSensor.md +112 -0
- package/docs/_posts/components/Picking/PrimitivePickSensor.md +114 -0
- package/docs/_posts/components/Picking/VolumePickSensor.md +107 -0
- package/docs/_posts/components/PointingDeviceSensor/CylinderSensor.md +122 -0
- package/docs/_posts/components/PointingDeviceSensor/PlaneSensor.md +114 -0
- package/docs/_posts/components/PointingDeviceSensor/SphereSensor.md +89 -0
- package/docs/_posts/components/PointingDeviceSensor/TouchSensor.md +87 -0
- package/docs/_posts/components/Rendering/ClipPlane.md +67 -0
- package/docs/_posts/components/Rendering/Color.md +56 -0
- package/docs/_posts/components/Rendering/ColorRGBA.md +61 -0
- package/docs/_posts/components/Rendering/Coordinate.md +45 -0
- package/docs/_posts/components/Rendering/IndexedLineSet.md +128 -0
- package/docs/_posts/components/Rendering/IndexedTriangleFanSet.md +128 -0
- package/docs/_posts/components/Rendering/IndexedTriangleSet.md +128 -0
- package/docs/_posts/components/Rendering/IndexedTriangleStripSet.md +116 -0
- package/docs/_posts/components/Rendering/LineSet.md +85 -0
- package/docs/_posts/components/Rendering/Normal.md +41 -0
- package/docs/_posts/components/Rendering/PointSet.md +76 -0
- package/docs/_posts/components/Rendering/TriangleFanSet.md +112 -0
- package/docs/_posts/components/Rendering/TriangleSet.md +108 -0
- package/docs/_posts/components/Rendering/TriangleStripSet.md +116 -0
- package/docs/_posts/components/RigidBodyPhysics/BallJoint.md +78 -0
- package/docs/_posts/components/RigidBodyPhysics/CollidableOffset.md +75 -0
- package/docs/_posts/components/RigidBodyPhysics/CollidableShape.md +83 -0
- package/docs/_posts/components/RigidBodyPhysics/CollisionCollection.md +90 -0
- package/docs/_posts/components/RigidBodyPhysics/CollisionSensor.md +65 -0
- package/docs/_posts/components/RigidBodyPhysics/CollisionSpace.md +70 -0
- package/docs/_posts/components/RigidBodyPhysics/Contact.md +117 -0
- package/docs/_posts/components/RigidBodyPhysics/DoubleAxisHingeJoint.md +162 -0
- package/docs/_posts/components/RigidBodyPhysics/MotorJoint.md +183 -0
- package/docs/_posts/components/RigidBodyPhysics/RigidBody.md +175 -0
- package/docs/_posts/components/RigidBodyPhysics/RigidBodyCollection.md +120 -0
- package/docs/_posts/components/RigidBodyPhysics/SingleAxisHingeJoint.md +108 -0
- package/docs/_posts/components/RigidBodyPhysics/SliderJoint.md +106 -0
- package/docs/_posts/components/RigidBodyPhysics/UniversalJoint.md +119 -0
- package/docs/_posts/components/Scripting/Script.md +81 -0
- package/docs/_posts/components/Shaders/ComposedShader.md +81 -0
- package/docs/_posts/components/Shaders/FloatVertexAttribute.md +65 -0
- package/docs/_posts/components/Shaders/Matrix3VertexAttribute.md +53 -0
- package/docs/_posts/components/Shaders/Matrix4VertexAttribute.md +53 -0
- package/docs/_posts/components/Shaders/PackagedShader.md +77 -0
- package/docs/_posts/components/Shaders/ProgramShader.md +71 -0
- package/docs/_posts/components/Shaders/ShaderPart.md +76 -0
- package/docs/_posts/components/Shaders/ShaderProgram.md +68 -0
- package/docs/_posts/components/Shape/AcousticProperties.md +52 -0
- package/docs/_posts/components/Shape/Appearance.md +123 -0
- package/docs/_posts/components/Shape/FillProperties.md +67 -0
- package/docs/_posts/components/Shape/LineProperties.md +63 -0
- package/docs/_posts/components/Shape/Material.md +217 -0
- package/docs/_posts/components/Shape/PhysicalMaterial.md +173 -0
- package/docs/_posts/components/Shape/PointProperties.md +84 -0
- package/docs/_posts/components/Shape/Shape.md +63 -0
- package/docs/_posts/components/Shape/TwoSidedMaterial.md +149 -0
- package/docs/_posts/components/Shape/UnlitMaterial.md +115 -0
- package/docs/_posts/components/Sound/Analyser.md +72 -0
- package/docs/_posts/components/Sound/AudioClip.md +139 -0
- package/docs/_posts/components/Sound/AudioDestination.md +52 -0
- package/docs/_posts/components/Sound/BiquadFilter.md +70 -0
- package/docs/_posts/components/Sound/BufferAudioSource.md +86 -0
- package/docs/_posts/components/Sound/ChannelMerger.md +46 -0
- package/docs/_posts/components/Sound/ChannelSelector.md +48 -0
- package/docs/_posts/components/Sound/ChannelSplitter.md +48 -0
- package/docs/_posts/components/Sound/Convolver.md +66 -0
- package/docs/_posts/components/Sound/Delay.md +66 -0
- package/docs/_posts/components/Sound/DynamicsCompressor.md +74 -0
- package/docs/_posts/components/Sound/Gain.md +62 -0
- package/docs/_posts/components/Sound/ListenerPointSource.md +62 -0
- package/docs/_posts/components/Sound/MicrophoneSource.md +54 -0
- package/docs/_posts/components/Sound/OscillatorSource.md +58 -0
- package/docs/_posts/components/Sound/PeriodicWave.md +42 -0
- package/docs/_posts/components/Sound/Sound.md +92 -0
- package/docs/_posts/components/Sound/SpatialSound.md +68 -0
- package/docs/_posts/components/Sound/StreamAudioDestination.md +52 -0
- package/docs/_posts/components/Sound/StreamAudioSource.md +54 -0
- package/docs/_posts/components/Sound/WaveShaper.md +66 -0
- package/docs/_posts/components/Text/FontStyle.md +145 -0
- package/docs/_posts/components/Text/Text.md +102 -0
- package/docs/_posts/components/TextureProjector/TextureProjector.md +52 -0
- package/docs/_posts/components/TextureProjector/TextureProjectorParallel.md +52 -0
- package/docs/_posts/components/Texturing/ImageTexture.md +134 -0
- package/docs/_posts/components/Texturing/MovieTexture.md +221 -0
- package/docs/_posts/components/Texturing/MultiTexture.md +100 -0
- package/docs/_posts/components/Texturing/MultiTextureCoordinate.md +47 -0
- package/docs/_posts/components/Texturing/MultiTextureTransform.md +47 -0
- package/docs/_posts/components/Texturing/PixelTexture.md +80 -0
- package/docs/_posts/components/Texturing/TextureCoordinate.md +52 -0
- package/docs/_posts/components/Texturing/TextureCoordinateGenerator.md +64 -0
- package/docs/_posts/components/Texturing/TextureProperties.md +137 -0
- package/docs/_posts/components/Texturing/TextureTransform.md +73 -0
- package/docs/_posts/components/Texturing3D/ComposedTexture3D.md +76 -0
- package/docs/_posts/components/Texturing3D/ImageTexture3D.md +132 -0
- package/docs/_posts/components/Texturing3D/ImageTextureAtlas.md +131 -0
- package/docs/_posts/components/Texturing3D/PixelTexture3D.md +75 -0
- package/docs/_posts/components/Texturing3D/TextureCoordinate3D.md +53 -0
- package/docs/_posts/components/Texturing3D/TextureCoordinate4D.md +52 -0
- package/docs/_posts/components/Texturing3D/TextureTransform3D.md +69 -0
- package/docs/_posts/components/Texturing3D/TextureTransformMatrix3D.md +57 -0
- package/docs/_posts/components/Time/TimeSensor.md +136 -0
- package/docs/_posts/components/VolumeRendering/BlendedVolumeStyle.md +92 -0
- package/docs/_posts/components/VolumeRendering/BoundaryEnhancementVolumeStyle.md +53 -0
- package/docs/_posts/components/VolumeRendering/CartoonVolumeStyle.md +83 -0
- package/docs/_posts/components/VolumeRendering/ComposedVolumeStyle.md +51 -0
- package/docs/_posts/components/VolumeRendering/EdgeEnhancementVolumeStyle.md +67 -0
- package/docs/_posts/components/VolumeRendering/IsoSurfaceVolumeData.md +99 -0
- package/docs/_posts/components/VolumeRendering/OpacityMapVolumeStyle.md +51 -0
- package/docs/_posts/components/VolumeRendering/ProjectionVolumeStyle.md +48 -0
- package/docs/_posts/components/VolumeRendering/SegmentedVolumeData.md +80 -0
- package/docs/_posts/components/VolumeRendering/ShadedVolumeStyle.md +75 -0
- package/docs/_posts/components/VolumeRendering/SilhouetteEnhancementVolumeStyle.md +63 -0
- package/docs/_posts/components/VolumeRendering/ToneMappedVolumeStyle.md +71 -0
- package/docs/_posts/components/VolumeRendering/VolumeData.md +71 -0
- package/docs/_posts/components/X_ITE/BlendMode.md +94 -0
- package/docs/_posts/custom-shaders.md +9 -4
- package/docs/_posts/dom-integration.md +1 -6
- package/docs/_posts/features.md +2 -2
- package/docs/_posts/getting-started.md +100 -57
- package/docs/_posts/glossary.md +1 -1
- package/docs/_posts/how-to-configure-your-web-server.md +1 -1
- package/docs/_posts/reference/browser-services.md +78 -18
- package/docs/_posts/reference/constants-services.md +1 -1
- package/docs/_posts/reference/ecmascript-object-and-function-definitions.md +1 -1
- package/docs/_posts/reference/field-services-and-objects.md +8 -8
- package/docs/_posts/reference/prototype-services.md +7 -7
- package/docs/_posts/reference/route-services.md +1 -1
- package/docs/_posts/reference/scene-services.md +5 -5
- package/docs/_posts/reference/script-node-authoring-interface.md +1 -1
- package/docs/_posts/report-a-bug.md +1 -1
- package/docs/_posts/setup-a-localhost-server.md +5 -1
- package/docs/_posts/supported-nodes.md +239 -238
- package/docs/_posts/tutorials/adding-backgrounds.md +3 -3
- package/docs/_posts/tutorials/adding-fog.md +2 -2
- package/docs/_posts/tutorials/adding-sound.md +19 -19
- package/docs/_posts/tutorials/animating-transforms.md +17 -17
- package/docs/_posts/tutorials/basic-nodes.md +30 -30
- package/docs/_posts/tutorials/building-a-x3d-world.md +3 -3
- package/docs/_posts/tutorials/building-elevation-grids.md +7 -7
- package/docs/_posts/tutorials/building-extruded-shapes.md +7 -7
- package/docs/_posts/tutorials/building-primitive-shapes.md +13 -13
- package/docs/_posts/tutorials/building-shapes-out-of-points-lines-and-faces.md +21 -21
- package/docs/_posts/tutorials/controlling-appearance-with-materials.md +7 -7
- package/docs/_posts/tutorials/controlling-color-on-coordinate-based-geometry.md +11 -11
- package/docs/_posts/tutorials/controlling-detail.md +4 -4
- package/docs/_posts/tutorials/controlling-how-textures-are-mapped.md +7 -7
- package/docs/_posts/tutorials/controlling-navigation.md +3 -3
- package/docs/_posts/tutorials/controlling-shading-on-coordinate-based-geometry.md +13 -13
- package/docs/_posts/tutorials/controlling-the-viewpoint.md +3 -3
- package/docs/_posts/tutorials/creating-new-node-types.md +4 -4
- package/docs/_posts/tutorials/grouping-nodes.md +13 -13
- package/docs/_posts/tutorials/hello-world.md +1 -1
- package/docs/_posts/tutorials/improving-performance.md +1 -1
- package/docs/_posts/tutorials/increasing-rendering-speed.md +1 -1
- package/docs/_posts/tutorials/introducing-animation.md +10 -10
- package/docs/_posts/tutorials/introducing-script-use.md +3 -3
- package/docs/_posts/tutorials/introducing-x3d.md +1 -1
- package/docs/_posts/tutorials/lighting-your-world.md +4 -4
- package/docs/_posts/tutorials/mapping-textures.md +7 -7
- package/docs/_posts/tutorials/naming-nodes.md +1 -1
- package/docs/_posts/tutorials/overview.md +1 -1
- package/docs/_posts/tutorials/providing-information-about-your-world.md +2 -2
- package/docs/_posts/tutorials/sensing-the-viewer.md +15 -15
- package/docs/_posts/tutorials/sensing-viewer-actions.md +10 -10
- package/docs/_posts/tutorials/transforming-shapes.md +4 -4
- package/docs/_posts/tutorials/writing-program-scripts-with-ecmascript.md +5 -5
- package/docs/_posts/what's-new.md +40 -2
- package/docs/_tabs/components.md +383 -0
- package/docs/_tabs/imprint.md +1 -1
- package/docs/_tabs/laboratory.md +38 -6
- package/docs/_tabs/playground.html +22 -66
- package/docs/_tabs/reference.md +2 -1
- package/docs/_tabs/tags.md +1 -1
- package/docs/_tabs/tutorials.md +1 -1
- package/docs/assets/X3D/Michroma-Regular.ttf +0 -0
- package/docs/assets/X3D/peakpx.jpg +0 -0
- package/docs/assets/X3D/teaser.x3d +55 -0
- package/docs/assets/css/style.scss +120 -11
- package/docs/assets/img/laboratory/blend-mode.png +0 -0
- package/docs/assets/img/laboratory/dicom-nrrd.png +0 -0
- package/docs/assets/img/laboratory/earthquake.png +0 -0
- package/docs/assets/img/laboratory/gltf.png +0 -0
- package/docs/assets/img/laboratory/l-system.png +0 -0
- package/docs/assets/js/autoupdate.js +25 -0
- package/docs/laboratory/gltf-sample-viewer.html +318 -0
- package/docs/laboratory/x3d-visual-blend-mode-editor.html +1 -0
- package/package.json +9 -2
- package/src/assets/components/Texturing3D.js +5 -3
- package/src/assets/shaders/Types.glsl.js +5 -5
- package/src/assets/shaders/webgl1/PBR.fs.js +1 -1
- package/src/assets/shaders/webgl1/include/Colors.glsl.js +5 -7
- package/src/assets/shaders/webgl1/include/Fragment.glsl.js +4 -0
- package/src/assets/shaders/webgl1/include/Hatch.glsl.js +1 -1
- package/src/assets/shaders/webgl1/include/Texture.glsl.js +3 -3
- package/src/assets/shaders/webgl2/include/Colors.glsl.js +5 -7
- package/src/assets/shaders/webgl2/include/Hatch.glsl.js +1 -1
- package/src/assets/shaders/webgl2/include/Particle.glsl.js +2 -2
- package/src/assets/shaders/webgl2/include/Texture.glsl.js +2 -2
- package/src/bookmarks.js +12 -8
- package/src/examples.js +3 -0
- package/src/lib/jquery.js +20 -0
- package/src/lib/libgif/libgif.js +1004 -0
- package/src/lib/libtess.js +1 -0
- package/src/lib/nurbs/extras/sample.js +5 -7
- package/src/standard/Math/Algorithms/Bezier.js +175 -33
- package/src/standard/Math/Geometry/Box2.js +15 -55
- package/src/standard/Math/Geometry/Box3.js +19 -66
- package/src/standard/Math/Geometry/Triangle3.js +14 -79
- package/src/standard/Math/Numbers/Color3.js +4 -0
- package/src/standard/Math/Numbers/Color4.js +4 -0
- package/src/standard/Math/Numbers/Matrix3.js +11 -3
- package/src/standard/Math/Numbers/Matrix4.js +9 -6
- package/src/standard/Math/Numbers/Rotation4.js +72 -65
- package/src/tests.js +3 -0
- package/src/x_ite/Base/X3DArrayField.js +0 -2
- package/src/x_ite/Base/X3DInfoArray.js +2 -2
- package/src/x_ite/Base/X3DObjectArrayField.js +19 -0
- package/src/x_ite/Base/X3DTypedArrayField.js +149 -0
- package/src/x_ite/Browser/Core/BrowserOptions.js +108 -64
- package/src/x_ite/Browser/Core/Context.js +1 -1
- package/src/x_ite/Browser/Core/ContextMenu.js +2 -2
- package/src/x_ite/Browser/Core/Notification.js +1 -1
- package/src/x_ite/Browser/Core/RenderingProperties.js +4 -0
- package/src/x_ite/Browser/Core/X3DCoreContext.js +99 -54
- package/src/x_ite/Browser/Navigation/ExamineViewer.js +4 -14
- package/src/x_ite/Browser/Navigation/LookAtViewer.js +3 -13
- package/src/x_ite/Browser/Navigation/PlaneViewer.js +3 -12
- package/src/x_ite/Browser/Navigation/X3DFlyViewer.js +25 -22
- package/src/x_ite/Browser/Navigation/X3DViewer.js +12 -3
- package/src/x_ite/Browser/Networking/X3DNetworkingContext.js +2 -2
- package/src/x_ite/Browser/PointingDeviceSensor/PointingDevice.js +19 -15
- package/src/x_ite/Browser/Rendering/X3DRenderingContext.js +30 -10
- package/src/x_ite/Browser/Shaders/X3DShadersContext.js +1 -1
- package/src/x_ite/Browser/Shape/X3DShapeContext.js +30 -3
- package/src/x_ite/Browser/Text/PolygonText.js +137 -134
- package/src/x_ite/Browser/Texturing/GifMedia.js +113 -0
- package/src/x_ite/Browser/Texturing3D/DICOMParser.js +1 -6
- package/src/x_ite/Browser/Texturing3D/NRRDParser.js +81 -310
- package/src/x_ite/Browser/VERSION.js +1 -1
- package/src/x_ite/Browser/X3DBrowser.js +162 -122
- package/src/x_ite/Browser/X3DBrowserContext.js +7 -5
- package/src/x_ite/Components/Core/WorldInfo.js +3 -3
- package/src/x_ite/Components/Core/X3DNode.js +7 -7
- package/src/x_ite/Components/Core/X3DPrototypeInstance.js +1 -1
- package/src/x_ite/Components/CubeMapTexturing/ImageCubeMapTexture.js +2 -3
- package/src/x_ite/Components/Geometry3D/Extrusion.js +27 -23
- package/src/x_ite/Components/Geometry3D/IndexedFaceSet.js +10 -19
- package/src/x_ite/Components/Grouping/X3DBoundedObject.js +1 -3
- package/src/x_ite/Components/HAnim/HAnimHumanoid.js +39 -15
- package/src/x_ite/Components/HAnim/HAnimJoint.js +6 -9
- package/src/x_ite/Components/Layering/X3DLayerNode.js +21 -2
- package/src/x_ite/Components/Layout/Layout.js +4 -2
- package/src/x_ite/Components/Layout/ScreenFontStyle.js +6 -0
- package/src/x_ite/Components/Lighting/DirectionalLight.js +4 -11
- package/src/x_ite/Components/Lighting/EnvironmentLight.js +1 -1
- package/src/x_ite/Components/Lighting/PointLight.js +4 -11
- package/src/x_ite/Components/Lighting/SpotLight.js +4 -11
- package/src/x_ite/Components/Lighting/X3DLightNode.js +7 -9
- package/src/x_ite/Components/Navigation/OrthoViewpoint.js +2 -2
- package/src/x_ite/Components/Navigation/X3DViewpointNode.js +14 -6
- package/src/x_ite/Components/Networking/Inline.js +48 -59
- package/src/x_ite/Components/Networking/X3DUrlObject.js +1 -1
- package/src/x_ite/Components/PointingDeviceSensor/CylinderSensor.js +2 -2
- package/src/x_ite/Components/Rendering/X3DLineGeometryNode.js +7 -13
- package/src/x_ite/Components/Rendering/X3DPointGeometryNode.js +4 -2
- package/src/x_ite/Components/RigidBodyPhysics/RigidBody.js +4 -2
- package/src/x_ite/Components/Scripting/Script.js +2 -2
- package/src/x_ite/Components/Shaders/ShaderPart.js +1 -1
- package/src/x_ite/Components/Shaders/X3DProgrammableShaderObject.js +1 -3
- package/src/x_ite/Components/Shape/Appearance.js +27 -1
- package/src/x_ite/Components/Shape/FillProperties.js +1 -0
- package/src/x_ite/Components/Shape/LineProperties.js +15 -9
- package/src/x_ite/Components/Shape/Material.js +33 -22
- package/src/x_ite/Components/Shape/PhysicalMaterial.js +22 -15
- package/src/x_ite/Components/Shape/PointProperties.js +23 -7
- package/src/x_ite/Components/Shape/UnlitMaterial.js +3 -2
- package/src/x_ite/Components/Shape/X3DOneSidedMaterialNode.js +25 -19
- package/src/x_ite/Components/Sound/AudioClip.js +5 -5
- package/src/x_ite/Components/Sound/X3DSoundSourceNode.js +26 -34
- package/src/x_ite/Components/Text/X3DFontStyleNode.js +1 -1
- package/src/x_ite/Components/TextureProjector/TextureProjector.js +4 -12
- package/src/x_ite/Components/TextureProjector/TextureProjectorParallel.js +6 -14
- package/src/x_ite/Components/TextureProjector/X3DTextureProjectorNode.js +7 -7
- package/src/x_ite/Components/Texturing/ImageTexture.js +15 -10
- package/src/x_ite/Components/Texturing/MovieTexture.js +51 -11
- package/src/x_ite/Components/Texturing3D/ImageTexture3D.js +2 -2
- package/src/x_ite/Components/Texturing3D/ImageTextureAtlas.js +230 -0
- package/src/x_ite/Components/Time/X3DTimeDependentNode.js +12 -10
- package/src/x_ite/Execution/BindableList.js +35 -37
- package/src/x_ite/Execution/BindableStack.js +25 -7
- package/src/x_ite/Execution/X3DScene.js +2 -2
- package/src/x_ite/Execution/X3DWorld.js +1 -1
- package/src/x_ite/Fields/SFRotation.js +2 -1
- package/src/x_ite/Fields/SFString.js +1 -1
- package/src/x_ite/InputOutput/FileLoader.js +105 -236
- package/src/x_ite/InputOutput/Generator.js +12 -8
- package/src/x_ite/Parser/Expressions.js +85 -0
- package/src/x_ite/Parser/GLB2Parser.js +147 -0
- package/src/x_ite/Parser/GLTF2Parser.js +2221 -0
- package/src/x_ite/Parser/GoldenGate.js +64 -13
- package/src/x_ite/Parser/JSONParser.js +7 -36
- package/src/x_ite/Parser/OBJParser.js +1076 -0
- package/src/x_ite/Parser/STLAParser.js +376 -0
- package/src/x_ite/Parser/STLBParser.js +156 -0
- package/src/x_ite/Parser/SVGParser.js +2476 -0
- package/src/x_ite/Parser/VRMLParser.js +127 -183
- package/src/x_ite/Parser/X3DOptimizer.js +191 -0
- package/src/x_ite/Parser/X3DParser.js +34 -0
- package/src/x_ite/Parser/XMLParser.js +11 -109
- package/src/x_ite/Prototype/X3DExternProtoDeclaration.js +2 -2
- package/src/x_ite/Prototype/X3DProtoDeclaration.js +3 -3
- package/src/x_ite/Rendering/DependentRenderer.js +1 -1
- package/src/x_ite/Rendering/MultiSampleFrameBuffer.js +150 -0
- package/src/x_ite/Rendering/TextureBuffer.js +3 -5
- package/src/x_ite/Rendering/X3DRenderObject.js +2 -7
- package/src/x_ite/X3D.js +1 -0
- package/src/x_ite/X3DCanvas.js +10 -0
- package/src/x_ite.html +39 -17
- package/webpack.config.js +1 -0
- package/x_ite.min.html +38 -17
- package/src/standard/Networking/BinaryTransport.js +0 -116
|
@@ -0,0 +1,1076 @@
|
|
|
1
|
+
/*******************************************************************************
|
|
2
|
+
*
|
|
3
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4
|
+
*
|
|
5
|
+
* Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011 - 2022.
|
|
6
|
+
*
|
|
7
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
8
|
+
*
|
|
9
|
+
* The copyright notice above does not evidence any actual of intended
|
|
10
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
11
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
12
|
+
* create3000.
|
|
13
|
+
*
|
|
14
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
15
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
16
|
+
* permission of create3000.
|
|
17
|
+
*
|
|
18
|
+
* NON-MILITARY USE ONLY
|
|
19
|
+
*
|
|
20
|
+
* All create3000 software are effectively free software with a non-military use
|
|
21
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
22
|
+
* source in any way you please with the exception anything that uses it must be
|
|
23
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
24
|
+
*
|
|
25
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
26
|
+
*
|
|
27
|
+
* Copyright 2011 - 2022, Holger Seelig <holger.seelig@yahoo.de>.
|
|
28
|
+
*
|
|
29
|
+
* This file is part of the X_ITE Project.
|
|
30
|
+
*
|
|
31
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
32
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
33
|
+
* Free Software Foundation.
|
|
34
|
+
*
|
|
35
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
36
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
37
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
38
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
39
|
+
*
|
|
40
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
41
|
+
* along with X_ITE. If not, see <https://www.gnu.org/licenses/gpl.html> for a
|
|
42
|
+
* copy of the GPLv3 License.
|
|
43
|
+
*
|
|
44
|
+
* For Silvio, Joy and Adi.
|
|
45
|
+
*
|
|
46
|
+
******************************************************************************/
|
|
47
|
+
|
|
48
|
+
import X3DParser from "./X3DParser.js";
|
|
49
|
+
import X3DOptimizer from "./X3DOptimizer.js";
|
|
50
|
+
import Expressions from "./Expressions.js";
|
|
51
|
+
import Vector2 from "../../standard/Math/Numbers/Vector2.js";
|
|
52
|
+
import Vector3 from "../../standard/Math/Numbers/Vector3.js";
|
|
53
|
+
import Color3 from "../../standard/Math/Numbers/Color3.js";
|
|
54
|
+
import DEBUG from "../DEBUG.js";
|
|
55
|
+
|
|
56
|
+
// http://paulbourke.net/dataformats/obj/
|
|
57
|
+
// https://people.sc.fsu.edu/~jburkardt/data/obj/obj.html
|
|
58
|
+
|
|
59
|
+
/*
|
|
60
|
+
* Grammar
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
// Lexical elements
|
|
64
|
+
const Grammar = Expressions ({
|
|
65
|
+
// General
|
|
66
|
+
whitespaces: /[\x20\n\t\r]+/gy,
|
|
67
|
+
whitespacesNoLineTerminator: /[\x20\t]+/gy,
|
|
68
|
+
comment: /#.*?(?=[\n\r])/gy,
|
|
69
|
+
untilEndOfLine: /([^\r\n]+)/gy,
|
|
70
|
+
|
|
71
|
+
// Keywords
|
|
72
|
+
mtllib: /\bmtllib\b/gy,
|
|
73
|
+
usemtl: /\busemtl\b/gy,
|
|
74
|
+
newmtl: /\bnewmtl\b/gy,
|
|
75
|
+
Ka: /\bKa\b/gy,
|
|
76
|
+
Kd: /\bKd\b/gy,
|
|
77
|
+
Ks: /\bKs\b/gy,
|
|
78
|
+
Ns: /\bNs\b/gy,
|
|
79
|
+
d: /\bd\b/gy,
|
|
80
|
+
Tr: /\bTr\b/gy,
|
|
81
|
+
illum: /\billum\b/gy,
|
|
82
|
+
map_Kd: /\bmap_Kd\b/gy,
|
|
83
|
+
o: /\bo\b/gy,
|
|
84
|
+
v: /\bv\b/gy,
|
|
85
|
+
vt: /\bvt\b/gy,
|
|
86
|
+
vn: /\bvn\b/gy,
|
|
87
|
+
g: /\bg\b/gy,
|
|
88
|
+
s: /\bs\b/gy,
|
|
89
|
+
off: /\boff\b/gy,
|
|
90
|
+
f: /\bf\b/gy,
|
|
91
|
+
slash: /\//gy,
|
|
92
|
+
|
|
93
|
+
// Values
|
|
94
|
+
int32: /((?:0[xX][\da-fA-F]+)|(?:[+-]?\d+))/gy,
|
|
95
|
+
double: /([+-]?(?:(?:(?:\d*\.\d+)|(?:\d+(?:\.)?))(?:[eE][+-]?\d+)?))/gy,
|
|
96
|
+
constants: /([+-])((?:NAN|INF|INFINITY))/igy,
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
/*
|
|
100
|
+
* Parser
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
function OBJParser (scene)
|
|
104
|
+
{
|
|
105
|
+
X3DParser .call (this, scene);
|
|
106
|
+
X3DOptimizer .call (this);
|
|
107
|
+
|
|
108
|
+
// Optimizer
|
|
109
|
+
|
|
110
|
+
this .removeGroups = true;
|
|
111
|
+
this .removeEmptyGroups = true;
|
|
112
|
+
this .combineGroupingNodes = false;
|
|
113
|
+
|
|
114
|
+
// Globals
|
|
115
|
+
|
|
116
|
+
this .smoothingGroup = 0;
|
|
117
|
+
this .smoothingGroups = new Map ();
|
|
118
|
+
this .groups = new Map ();
|
|
119
|
+
this .materials = new Map ();
|
|
120
|
+
this .textures = new Map ();
|
|
121
|
+
this .point2 = new Vector2 ();
|
|
122
|
+
this .point3 = new Vector3 ();
|
|
123
|
+
this .lastIndex = 0;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
OBJParser .prototype = Object .assign (Object .create (X3DParser .prototype),
|
|
127
|
+
X3DOptimizer .prototype,
|
|
128
|
+
{
|
|
129
|
+
constructor: OBJParser,
|
|
130
|
+
CONSTANTS: new Map ([
|
|
131
|
+
["NAN", NaN],
|
|
132
|
+
["INF", Infinity],
|
|
133
|
+
["INFINITY", Infinity],
|
|
134
|
+
]),
|
|
135
|
+
getEncoding: function ()
|
|
136
|
+
{
|
|
137
|
+
return "STRING";
|
|
138
|
+
},
|
|
139
|
+
isValid: function ()
|
|
140
|
+
{
|
|
141
|
+
if (!(typeof this .input === "string"))
|
|
142
|
+
return false;
|
|
143
|
+
|
|
144
|
+
return !! this .input .match (/^(?:[\x20\n\t\r]+|#.*?[\r\n])*\b(?:mtllib|usemtl|o|g|s|vt|vn|v|f)\b/);
|
|
145
|
+
},
|
|
146
|
+
setInput: function (string)
|
|
147
|
+
{
|
|
148
|
+
this .input = string;
|
|
149
|
+
},
|
|
150
|
+
parseIntoScene: function (success, error)
|
|
151
|
+
{
|
|
152
|
+
this .obj ()
|
|
153
|
+
.then (success)
|
|
154
|
+
.catch (error);
|
|
155
|
+
},
|
|
156
|
+
obj: async function ()
|
|
157
|
+
{
|
|
158
|
+
// Set profile and components.
|
|
159
|
+
|
|
160
|
+
const
|
|
161
|
+
browser = this .getBrowser (),
|
|
162
|
+
scene = this .getScene ();
|
|
163
|
+
|
|
164
|
+
scene .setEncoding ("OBJ");
|
|
165
|
+
scene .setProfile (browser .getProfile ("Interchange"));
|
|
166
|
+
|
|
167
|
+
await this .loadComponents ();
|
|
168
|
+
|
|
169
|
+
// Init nodes.
|
|
170
|
+
|
|
171
|
+
this .object = scene .createNode ("Transform");
|
|
172
|
+
this .group = scene .createNode ("Group");
|
|
173
|
+
this .defaultMaterial = scene .createNode ("Material");
|
|
174
|
+
this .texCoord = scene .createNode ("TextureCoordinate");
|
|
175
|
+
this .normal = scene .createNode ("Normal");
|
|
176
|
+
this .coord = scene .createNode ("Coordinate");
|
|
177
|
+
|
|
178
|
+
this .object .children .push (this .group);
|
|
179
|
+
|
|
180
|
+
scene .getRootNodes () .push (this .object);
|
|
181
|
+
|
|
182
|
+
// Parse scene.
|
|
183
|
+
|
|
184
|
+
await this .statements ();
|
|
185
|
+
|
|
186
|
+
this .optimizeSceneGraph (scene .getRootNodes ());
|
|
187
|
+
|
|
188
|
+
return this .getScene ();
|
|
189
|
+
},
|
|
190
|
+
comments: function ()
|
|
191
|
+
{
|
|
192
|
+
while (this .comment ())
|
|
193
|
+
;
|
|
194
|
+
},
|
|
195
|
+
comment: function ()
|
|
196
|
+
{
|
|
197
|
+
this .whitespaces ();
|
|
198
|
+
|
|
199
|
+
if (Grammar .comment .parse (this))
|
|
200
|
+
return true;
|
|
201
|
+
|
|
202
|
+
return false;
|
|
203
|
+
},
|
|
204
|
+
whitespaces: function ()
|
|
205
|
+
{
|
|
206
|
+
Grammar .whitespaces .parse (this);
|
|
207
|
+
},
|
|
208
|
+
whitespacesNoLineTerminator: function ()
|
|
209
|
+
{
|
|
210
|
+
Grammar .whitespacesNoLineTerminator .parse (this);
|
|
211
|
+
},
|
|
212
|
+
statements: async function ()
|
|
213
|
+
{
|
|
214
|
+
while (await this .statement ())
|
|
215
|
+
;
|
|
216
|
+
},
|
|
217
|
+
statement: async function ()
|
|
218
|
+
{
|
|
219
|
+
if (await this .mtllibs ())
|
|
220
|
+
return true;
|
|
221
|
+
|
|
222
|
+
if (this .usemtl ())
|
|
223
|
+
return true;
|
|
224
|
+
|
|
225
|
+
if (this .o ())
|
|
226
|
+
return true;
|
|
227
|
+
|
|
228
|
+
if (this .g ())
|
|
229
|
+
return true;
|
|
230
|
+
|
|
231
|
+
if (this .s ())
|
|
232
|
+
return true;
|
|
233
|
+
|
|
234
|
+
if (this .vts ())
|
|
235
|
+
return true;
|
|
236
|
+
|
|
237
|
+
if (this .vns ())
|
|
238
|
+
return true;
|
|
239
|
+
|
|
240
|
+
if (this .vs ())
|
|
241
|
+
return true;
|
|
242
|
+
|
|
243
|
+
if (this .fs ())
|
|
244
|
+
return true;
|
|
245
|
+
|
|
246
|
+
// Skip empty and unknown lines.
|
|
247
|
+
|
|
248
|
+
if (Grammar .untilEndOfLine .parse (this))
|
|
249
|
+
return true;
|
|
250
|
+
|
|
251
|
+
return false;
|
|
252
|
+
},
|
|
253
|
+
mtllibs: async function ()
|
|
254
|
+
{
|
|
255
|
+
this .comments ();
|
|
256
|
+
|
|
257
|
+
if (Grammar .mtllib .parse (this))
|
|
258
|
+
{
|
|
259
|
+
this .whitespacesNoLineTerminator ();
|
|
260
|
+
|
|
261
|
+
if (Grammar .untilEndOfLine .parse (this))
|
|
262
|
+
{
|
|
263
|
+
const mtllibs = this .result [1] .trim () .split (/\s+/);
|
|
264
|
+
|
|
265
|
+
await Promise .all (mtllibs .map (path => this .mtllib (path)));
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return true;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
return false;
|
|
272
|
+
},
|
|
273
|
+
mtllib: async function (path)
|
|
274
|
+
{
|
|
275
|
+
const
|
|
276
|
+
scene = this .getExecutionContext (),
|
|
277
|
+
url = new URL (path, scene .getWorldURL ());
|
|
278
|
+
|
|
279
|
+
const input = await fetch (url)
|
|
280
|
+
.then (response => response .arrayBuffer ())
|
|
281
|
+
.then (arrayBuffer => $.decodeText ($.ungzip (arrayBuffer)))
|
|
282
|
+
.catch (Function .prototype);
|
|
283
|
+
|
|
284
|
+
const parser = new MaterialParser (scene, input);
|
|
285
|
+
|
|
286
|
+
parser .parse ();
|
|
287
|
+
|
|
288
|
+
for (const [name, material] of parser .materials)
|
|
289
|
+
{
|
|
290
|
+
const nodeName = this .sanitizeName (name);
|
|
291
|
+
|
|
292
|
+
if (nodeName)
|
|
293
|
+
scene .addNamedNode (scene .getUniqueName (nodeName), material);
|
|
294
|
+
|
|
295
|
+
this .materials .set (name, material);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
for (const [name, texture] of parser .textures)
|
|
299
|
+
{
|
|
300
|
+
const nodeName = this .sanitizeName (name);
|
|
301
|
+
|
|
302
|
+
if (nodeName)
|
|
303
|
+
scene .addNamedNode (scene .getUniqueName (nodeName), texture);
|
|
304
|
+
|
|
305
|
+
this .textures .set (name, texture);
|
|
306
|
+
}
|
|
307
|
+
},
|
|
308
|
+
usemtl: function ()
|
|
309
|
+
{
|
|
310
|
+
this .comments ();
|
|
311
|
+
|
|
312
|
+
if (Grammar .usemtl .parse (this))
|
|
313
|
+
{
|
|
314
|
+
this .whitespacesNoLineTerminator ();
|
|
315
|
+
|
|
316
|
+
if (Grammar .untilEndOfLine .parse (this))
|
|
317
|
+
{
|
|
318
|
+
const name = this .result [1];
|
|
319
|
+
|
|
320
|
+
this .material = this .materials .get (name) || this .defaultMaterial;
|
|
321
|
+
this .texture = this .textures .get (name);
|
|
322
|
+
|
|
323
|
+
const smoothingGroup = this .smoothingGroups .get (this .group .getNodeName ());
|
|
324
|
+
|
|
325
|
+
if (smoothingGroup)
|
|
326
|
+
smoothingGroup .delete (this .smoothingGroup);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
return true;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
return false;
|
|
333
|
+
},
|
|
334
|
+
o: function ()
|
|
335
|
+
{
|
|
336
|
+
this .comments ();
|
|
337
|
+
|
|
338
|
+
if (Grammar .o .parse (this))
|
|
339
|
+
{
|
|
340
|
+
this .whitespacesNoLineTerminator ();
|
|
341
|
+
|
|
342
|
+
if (Grammar .untilEndOfLine .parse (this))
|
|
343
|
+
{
|
|
344
|
+
const
|
|
345
|
+
scene = this .getExecutionContext (),
|
|
346
|
+
nodeName = this .sanitizeName (this .result [1]);
|
|
347
|
+
|
|
348
|
+
if (this .group .children .length)
|
|
349
|
+
{
|
|
350
|
+
this .object = scene .createNode("Transform");
|
|
351
|
+
this .group = scene .createNode ("Group");
|
|
352
|
+
|
|
353
|
+
this .object .children .push (this .group);
|
|
354
|
+
scene .getRootNodes () .push (this .object);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
if (nodeName)
|
|
358
|
+
scene .addNamedNode (scene .getUniqueName (nodeName), this .object);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
return true;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
return false;
|
|
365
|
+
},
|
|
366
|
+
g: function ()
|
|
367
|
+
{
|
|
368
|
+
this .comments ();
|
|
369
|
+
|
|
370
|
+
if (Grammar .g .parse (this))
|
|
371
|
+
{
|
|
372
|
+
this .whitespacesNoLineTerminator ();
|
|
373
|
+
|
|
374
|
+
if (Grammar .untilEndOfLine .parse (this))
|
|
375
|
+
{
|
|
376
|
+
const
|
|
377
|
+
scene = this .getExecutionContext (),
|
|
378
|
+
name = this .result [1],
|
|
379
|
+
nodeName = this .sanitizeName (name),
|
|
380
|
+
group = this .groups .get (name);
|
|
381
|
+
|
|
382
|
+
if (group)
|
|
383
|
+
{
|
|
384
|
+
this .group = group;
|
|
385
|
+
}
|
|
386
|
+
else
|
|
387
|
+
{
|
|
388
|
+
if (this .group .children .length)
|
|
389
|
+
{
|
|
390
|
+
this .group = scene .createNode ("Group");
|
|
391
|
+
|
|
392
|
+
this .object .children .push (this .group);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
this .groups .set (name, this .group);
|
|
397
|
+
|
|
398
|
+
if (nodeName)
|
|
399
|
+
scene .addNamedNode (scene .getUniqueName (nodeName), this .group);
|
|
400
|
+
|
|
401
|
+
this .smoothingGroup = 0;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
return true;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
return false;
|
|
408
|
+
},
|
|
409
|
+
s: function ()
|
|
410
|
+
{
|
|
411
|
+
this .comments ();
|
|
412
|
+
|
|
413
|
+
if (Grammar .s .parse (this))
|
|
414
|
+
{
|
|
415
|
+
this .whitespacesNoLineTerminator ();
|
|
416
|
+
|
|
417
|
+
if (Grammar .off .parse (this))
|
|
418
|
+
{
|
|
419
|
+
this .smoothingGroup = 0;
|
|
420
|
+
return true;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
if (this .int32 ())
|
|
424
|
+
{
|
|
425
|
+
this .smoothingGroup = this .value;
|
|
426
|
+
return true;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
return true;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
return false;
|
|
433
|
+
},
|
|
434
|
+
vts: function ()
|
|
435
|
+
{
|
|
436
|
+
const point = this .texCoord .point;
|
|
437
|
+
|
|
438
|
+
let result = false;
|
|
439
|
+
|
|
440
|
+
while (this .vt (point))
|
|
441
|
+
result = true;
|
|
442
|
+
|
|
443
|
+
return result;
|
|
444
|
+
},
|
|
445
|
+
vt: function (point)
|
|
446
|
+
{
|
|
447
|
+
this .comments ();
|
|
448
|
+
|
|
449
|
+
if (Grammar .vt .parse (this))
|
|
450
|
+
{
|
|
451
|
+
if (this .vec2 ())
|
|
452
|
+
{
|
|
453
|
+
point .push (this .point2);
|
|
454
|
+
|
|
455
|
+
return true;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
throw new Error ("Expected a texture coordinate.");
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
return false;
|
|
462
|
+
},
|
|
463
|
+
vns: function ()
|
|
464
|
+
{
|
|
465
|
+
const vector = this .normal .vector;
|
|
466
|
+
|
|
467
|
+
let result = false;
|
|
468
|
+
|
|
469
|
+
while (this .vn (vector))
|
|
470
|
+
result = true;
|
|
471
|
+
|
|
472
|
+
return result;
|
|
473
|
+
},
|
|
474
|
+
vn: function (vector)
|
|
475
|
+
{
|
|
476
|
+
this .comments ();
|
|
477
|
+
|
|
478
|
+
if (Grammar .vn .parse (this))
|
|
479
|
+
{
|
|
480
|
+
if (this .vec3 ())
|
|
481
|
+
{
|
|
482
|
+
vector .push (this .point3);
|
|
483
|
+
|
|
484
|
+
return true;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
throw new Error ("Expected a normal vector.");
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
return false;
|
|
491
|
+
},
|
|
492
|
+
vs: function ()
|
|
493
|
+
{
|
|
494
|
+
const point = this .coord .point;
|
|
495
|
+
|
|
496
|
+
let result = false;
|
|
497
|
+
|
|
498
|
+
while (this .v (point))
|
|
499
|
+
result = true;
|
|
500
|
+
|
|
501
|
+
return result;
|
|
502
|
+
},
|
|
503
|
+
v: function (point)
|
|
504
|
+
{
|
|
505
|
+
this .comments ();
|
|
506
|
+
|
|
507
|
+
if (Grammar .v .parse (this))
|
|
508
|
+
{
|
|
509
|
+
if (this .vec3 ())
|
|
510
|
+
{
|
|
511
|
+
point .push (this .point3);
|
|
512
|
+
|
|
513
|
+
return true;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
throw new Error ("Expected a vertex coordinate.");
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
return false;
|
|
520
|
+
},
|
|
521
|
+
fs: function ()
|
|
522
|
+
{
|
|
523
|
+
this .comments ();
|
|
524
|
+
|
|
525
|
+
if (Grammar .f .lookahead (this))
|
|
526
|
+
{
|
|
527
|
+
try
|
|
528
|
+
{
|
|
529
|
+
this .shape = this .smoothingGroups .get (this .group .getNodeName ()) .get (this .smoothingGroup);
|
|
530
|
+
this .geometry = this .shape .geometry;
|
|
531
|
+
}
|
|
532
|
+
catch (error)
|
|
533
|
+
{
|
|
534
|
+
const
|
|
535
|
+
scene = this .getExecutionContext (),
|
|
536
|
+
appearance = scene .createNode ("Appearance");
|
|
537
|
+
|
|
538
|
+
this .geometry = scene .createNode ("IndexedFaceSet");
|
|
539
|
+
this .shape = scene .createNode ("Shape");
|
|
540
|
+
|
|
541
|
+
appearance .material = this .material;
|
|
542
|
+
appearance .texture = this .texture;
|
|
543
|
+
this .geometry .creaseAngle = this .smoothingGroup ? Math .PI : 0;
|
|
544
|
+
this .shape .appearance = appearance;
|
|
545
|
+
this .shape .geometry = this .geometry;
|
|
546
|
+
|
|
547
|
+
this .group .children .push (this .shape);
|
|
548
|
+
|
|
549
|
+
if (!this .smoothingGroups .has (this .group .getNodeName ()))
|
|
550
|
+
this .smoothingGroups .set (this .group .getNodeName (), new Map ());
|
|
551
|
+
|
|
552
|
+
this .smoothingGroups .get (this .group .getNodeName ()) .set (this .smoothingGroup, this .shape);
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
while (this .f ())
|
|
556
|
+
;
|
|
557
|
+
|
|
558
|
+
if (this .geometry .texCoordIndex .length)
|
|
559
|
+
this .geometry .texCoord = this .texCoord;
|
|
560
|
+
|
|
561
|
+
if (this .geometry .normalIndex .length)
|
|
562
|
+
this .geometry .normal = this .normal;
|
|
563
|
+
|
|
564
|
+
this .geometry .coord = this .coord;
|
|
565
|
+
|
|
566
|
+
return true;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
return false;
|
|
570
|
+
},
|
|
571
|
+
f: function ()
|
|
572
|
+
{
|
|
573
|
+
this .comments ();
|
|
574
|
+
|
|
575
|
+
if (Grammar .f .parse (this))
|
|
576
|
+
{
|
|
577
|
+
const
|
|
578
|
+
geometry = this .geometry,
|
|
579
|
+
texCoordIndex = geometry .texCoordIndex,
|
|
580
|
+
normalIndex = geometry .normalIndex,
|
|
581
|
+
coordIndex = geometry .coordIndex,
|
|
582
|
+
numTexCoordIndices = texCoordIndex .length,
|
|
583
|
+
numNormalIndices = normalIndex .length,
|
|
584
|
+
numTexCoords = this .texCoord .point .length,
|
|
585
|
+
numNormals = this .normal .vector .length,
|
|
586
|
+
numCoords = this .coord .point .length;
|
|
587
|
+
|
|
588
|
+
while (this .indices (texCoordIndex, normalIndex, coordIndex, numTexCoords, numNormals, numCoords))
|
|
589
|
+
;
|
|
590
|
+
|
|
591
|
+
if (texCoordIndex .length !== numTexCoordIndices)
|
|
592
|
+
texCoordIndex .push (-1);
|
|
593
|
+
|
|
594
|
+
if (normalIndex .length !== numNormalIndices)
|
|
595
|
+
normalIndex .push (-1);
|
|
596
|
+
|
|
597
|
+
coordIndex .push (-1);
|
|
598
|
+
|
|
599
|
+
return true;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
return false;
|
|
603
|
+
},
|
|
604
|
+
indices: function (texCoordIndex, normalIndex, coordIndex, numTexCoords, numNormals, numCoords)
|
|
605
|
+
{
|
|
606
|
+
if (this .int32 ())
|
|
607
|
+
{
|
|
608
|
+
coordIndex .push (this .index (this .value, numCoords));
|
|
609
|
+
|
|
610
|
+
if (Grammar .slash .parse (this))
|
|
611
|
+
{
|
|
612
|
+
if (this .int32 ())
|
|
613
|
+
{
|
|
614
|
+
texCoordIndex .push (this .index (this .value, numTexCoords));
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
if (Grammar .slash .parse (this))
|
|
618
|
+
{
|
|
619
|
+
if (this .int32 ())
|
|
620
|
+
{
|
|
621
|
+
normalIndex .push (this .index (this .value, numNormals));
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
return true;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
return false;
|
|
630
|
+
},
|
|
631
|
+
index: function (index, length)
|
|
632
|
+
{
|
|
633
|
+
if (index === 0)
|
|
634
|
+
throw new Error ("Invalid index.");
|
|
635
|
+
|
|
636
|
+
if (index < 0)
|
|
637
|
+
return length + index;
|
|
638
|
+
|
|
639
|
+
return index - 1;
|
|
640
|
+
},
|
|
641
|
+
int32: function ()
|
|
642
|
+
{
|
|
643
|
+
this .whitespaces ();
|
|
644
|
+
|
|
645
|
+
if (Grammar .int32 .parse (this))
|
|
646
|
+
{
|
|
647
|
+
this .value = parseInt (this .result [1]);
|
|
648
|
+
|
|
649
|
+
return true;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
return false;
|
|
653
|
+
},
|
|
654
|
+
double: function ()
|
|
655
|
+
{
|
|
656
|
+
this .whitespaces ();
|
|
657
|
+
|
|
658
|
+
if (Grammar .double .parse (this))
|
|
659
|
+
{
|
|
660
|
+
this .value = parseFloat (this .result [1]);
|
|
661
|
+
|
|
662
|
+
return true;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
if (Grammar .constants .parse (this))
|
|
666
|
+
{
|
|
667
|
+
this .value = this .CONSTANTS .get (this .result [2] .toUpperCase ());
|
|
668
|
+
|
|
669
|
+
if (this .result [1] === "-")
|
|
670
|
+
this .value = - this .value;
|
|
671
|
+
|
|
672
|
+
return true;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
return false;
|
|
676
|
+
},
|
|
677
|
+
vec2: function ()
|
|
678
|
+
{
|
|
679
|
+
if (this .double ())
|
|
680
|
+
{
|
|
681
|
+
this .point2 .x = this .value;
|
|
682
|
+
|
|
683
|
+
if (this .double ())
|
|
684
|
+
{
|
|
685
|
+
this .point2 .y = this .value;
|
|
686
|
+
|
|
687
|
+
return true;
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
return false;
|
|
692
|
+
},
|
|
693
|
+
vec3: function ()
|
|
694
|
+
{
|
|
695
|
+
if (this .double ())
|
|
696
|
+
{
|
|
697
|
+
this .point3 .x = this .value;
|
|
698
|
+
|
|
699
|
+
if (this .double ())
|
|
700
|
+
{
|
|
701
|
+
this .point3 .y = this .value;
|
|
702
|
+
|
|
703
|
+
if (this .double ())
|
|
704
|
+
{
|
|
705
|
+
this .point3 .z = this .value;
|
|
706
|
+
|
|
707
|
+
return true;
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
return false;
|
|
713
|
+
},
|
|
714
|
+
});
|
|
715
|
+
|
|
716
|
+
function MaterialParser (scene, input)
|
|
717
|
+
{
|
|
718
|
+
this .executionContext = scene;
|
|
719
|
+
this .input = input;
|
|
720
|
+
this .material = scene .createNode ("Material");
|
|
721
|
+
this .materials = new Map ();
|
|
722
|
+
this .textures = new Map ();
|
|
723
|
+
this .color3 = new Color3 ();
|
|
724
|
+
this .name = "";
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
MaterialParser .prototype =
|
|
728
|
+
{
|
|
729
|
+
CONSTANTS: new Map ([
|
|
730
|
+
["NAN", NaN],
|
|
731
|
+
["INF", Infinity],
|
|
732
|
+
["INFINITY", Infinity],
|
|
733
|
+
]),
|
|
734
|
+
parse: function ()
|
|
735
|
+
{
|
|
736
|
+
try
|
|
737
|
+
{
|
|
738
|
+
this .statements ();
|
|
739
|
+
}
|
|
740
|
+
catch (error)
|
|
741
|
+
{
|
|
742
|
+
if (DEBUG)
|
|
743
|
+
console .log (error);
|
|
744
|
+
}
|
|
745
|
+
},
|
|
746
|
+
comments: function ()
|
|
747
|
+
{
|
|
748
|
+
while (this .comment ())
|
|
749
|
+
;
|
|
750
|
+
},
|
|
751
|
+
comment: function ()
|
|
752
|
+
{
|
|
753
|
+
this .whitespaces ();
|
|
754
|
+
|
|
755
|
+
if (Grammar .comment .parse (this))
|
|
756
|
+
return true;
|
|
757
|
+
|
|
758
|
+
return false;
|
|
759
|
+
},
|
|
760
|
+
whitespaces: function ()
|
|
761
|
+
{
|
|
762
|
+
Grammar .whitespaces .parse (this);
|
|
763
|
+
},
|
|
764
|
+
whitespacesNoLineTerminator: function ()
|
|
765
|
+
{
|
|
766
|
+
Grammar .whitespacesNoLineTerminator .parse (this);
|
|
767
|
+
},
|
|
768
|
+
statements: function ()
|
|
769
|
+
{
|
|
770
|
+
while (this .statement ())
|
|
771
|
+
;
|
|
772
|
+
},
|
|
773
|
+
statement: function ()
|
|
774
|
+
{
|
|
775
|
+
if (this .newmtl ())
|
|
776
|
+
return true;
|
|
777
|
+
|
|
778
|
+
if (this .Ka ())
|
|
779
|
+
return true;
|
|
780
|
+
|
|
781
|
+
if (this .Kd ())
|
|
782
|
+
return true;
|
|
783
|
+
|
|
784
|
+
if (this .Ks ())
|
|
785
|
+
return true;
|
|
786
|
+
|
|
787
|
+
if (this .Ns ())
|
|
788
|
+
return true;
|
|
789
|
+
|
|
790
|
+
if (this .d ())
|
|
791
|
+
return true;
|
|
792
|
+
|
|
793
|
+
if (this .Tr ())
|
|
794
|
+
return true;
|
|
795
|
+
|
|
796
|
+
if (this .illum ())
|
|
797
|
+
return true;
|
|
798
|
+
|
|
799
|
+
if (this .map_Kd ())
|
|
800
|
+
return true;
|
|
801
|
+
|
|
802
|
+
// Skip empty and unknown lines.
|
|
803
|
+
|
|
804
|
+
if (Grammar .untilEndOfLine .parse (this))
|
|
805
|
+
return true;
|
|
806
|
+
|
|
807
|
+
return false;
|
|
808
|
+
},
|
|
809
|
+
newmtl: function ()
|
|
810
|
+
{
|
|
811
|
+
this .comments ();
|
|
812
|
+
|
|
813
|
+
if (Grammar .newmtl .parse (this))
|
|
814
|
+
{
|
|
815
|
+
this .whitespacesNoLineTerminator ();
|
|
816
|
+
|
|
817
|
+
this .name = "";
|
|
818
|
+
|
|
819
|
+
if (Grammar .untilEndOfLine .parse (this))
|
|
820
|
+
{
|
|
821
|
+
this .name = this .result [1];
|
|
822
|
+
|
|
823
|
+
this .material = this .executionContext .createNode ("Material");
|
|
824
|
+
|
|
825
|
+
this .materials .set (this .name, this .material);
|
|
826
|
+
|
|
827
|
+
return true;
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
Grammar .untilEndOfLine .parse (this);
|
|
831
|
+
|
|
832
|
+
return true;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
return false;
|
|
836
|
+
},
|
|
837
|
+
Ka: function ()
|
|
838
|
+
{
|
|
839
|
+
this .comments ();
|
|
840
|
+
|
|
841
|
+
if (Grammar .Ka .parse (this))
|
|
842
|
+
{
|
|
843
|
+
if (this .col3 ())
|
|
844
|
+
{
|
|
845
|
+
const hsv = this .color3 .getHSV ([ ]);
|
|
846
|
+
|
|
847
|
+
this .material .ambientIntensity = hsv [2];
|
|
848
|
+
|
|
849
|
+
return true;
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
Grammar .untilEndOfLine .parse (this);
|
|
853
|
+
|
|
854
|
+
return true;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
return false;
|
|
858
|
+
},
|
|
859
|
+
Kd: function ()
|
|
860
|
+
{
|
|
861
|
+
this .comments ();
|
|
862
|
+
|
|
863
|
+
if (Grammar .Kd .parse (this))
|
|
864
|
+
{
|
|
865
|
+
if (this .col3 ())
|
|
866
|
+
{
|
|
867
|
+
this .material .diffuseColor = this .color3;
|
|
868
|
+
|
|
869
|
+
return true;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
Grammar .untilEndOfLine .parse (this);
|
|
873
|
+
|
|
874
|
+
return true;
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
return false;
|
|
878
|
+
},
|
|
879
|
+
Ks: function ()
|
|
880
|
+
{
|
|
881
|
+
this .comments ();
|
|
882
|
+
|
|
883
|
+
if (Grammar .Ks .parse (this))
|
|
884
|
+
{
|
|
885
|
+
if (this .col3 ())
|
|
886
|
+
{
|
|
887
|
+
this .material .specularColor = this .color3;
|
|
888
|
+
|
|
889
|
+
return true;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
Grammar .untilEndOfLine .parse (this);
|
|
893
|
+
|
|
894
|
+
return true;
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
return false;
|
|
898
|
+
},
|
|
899
|
+
Ns: function ()
|
|
900
|
+
{
|
|
901
|
+
this .comments ();
|
|
902
|
+
|
|
903
|
+
if (Grammar .Ns .parse (this))
|
|
904
|
+
{
|
|
905
|
+
if (this .double ())
|
|
906
|
+
{
|
|
907
|
+
this .material .shininess = this .value / 1000;
|
|
908
|
+
|
|
909
|
+
return true;
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
Grammar .untilEndOfLine .parse (this);
|
|
913
|
+
|
|
914
|
+
return true;
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
return false;
|
|
918
|
+
},
|
|
919
|
+
d: function ()
|
|
920
|
+
{
|
|
921
|
+
this .comments ();
|
|
922
|
+
|
|
923
|
+
if (Grammar .d .parse (this))
|
|
924
|
+
{
|
|
925
|
+
if (this .double ())
|
|
926
|
+
{
|
|
927
|
+
this .material .transparency = 1 - this .value;
|
|
928
|
+
|
|
929
|
+
return true;
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
Grammar .untilEndOfLine .parse (this);
|
|
933
|
+
|
|
934
|
+
return true;
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
return false;
|
|
938
|
+
},
|
|
939
|
+
Tr: function ()
|
|
940
|
+
{
|
|
941
|
+
this .comments ();
|
|
942
|
+
|
|
943
|
+
if (Grammar .Tr .parse (this))
|
|
944
|
+
{
|
|
945
|
+
if (this .double ())
|
|
946
|
+
{
|
|
947
|
+
this .material .transparency = this .value;
|
|
948
|
+
|
|
949
|
+
return true;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
Grammar .untilEndOfLine .parse (this);
|
|
953
|
+
|
|
954
|
+
return true;
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
return false;
|
|
958
|
+
},
|
|
959
|
+
illum: function ()
|
|
960
|
+
{
|
|
961
|
+
this .comments ();
|
|
962
|
+
|
|
963
|
+
if (Grammar .illum .parse (this))
|
|
964
|
+
{
|
|
965
|
+
if (this .int32 ())
|
|
966
|
+
{
|
|
967
|
+
// Don't know what to do with illum value in X3D.
|
|
968
|
+
return true;
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
Grammar .untilEndOfLine .parse (this);
|
|
972
|
+
|
|
973
|
+
return true;
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
return false;
|
|
977
|
+
},
|
|
978
|
+
map_Kd: function ()
|
|
979
|
+
{
|
|
980
|
+
this .comments ();
|
|
981
|
+
|
|
982
|
+
if (Grammar .map_Kd .parse (this))
|
|
983
|
+
{
|
|
984
|
+
this .whitespacesNoLineTerminator ();
|
|
985
|
+
|
|
986
|
+
if (Grammar .untilEndOfLine .parse (this))
|
|
987
|
+
{
|
|
988
|
+
const string = this .result [1];
|
|
989
|
+
|
|
990
|
+
if (string .length && this .name .length)
|
|
991
|
+
{
|
|
992
|
+
const paths = string .trim () .split (/\s+/);
|
|
993
|
+
|
|
994
|
+
if (paths .length)
|
|
995
|
+
{
|
|
996
|
+
const
|
|
997
|
+
scene = this .executionContext,
|
|
998
|
+
texture = scene .createNode ("ImageTexture"),
|
|
999
|
+
path = paths .at (-1) .replace (/\\/g, "/");
|
|
1000
|
+
|
|
1001
|
+
texture .url = [path];
|
|
1002
|
+
|
|
1003
|
+
this .textures .set (this .name, texture);
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
return true;
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
Grammar .untilEndOfLine .parse (this);
|
|
1011
|
+
|
|
1012
|
+
return true;
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
return false;
|
|
1016
|
+
},
|
|
1017
|
+
int32: function ()
|
|
1018
|
+
{
|
|
1019
|
+
this .whitespaces ();
|
|
1020
|
+
|
|
1021
|
+
if (Grammar .int32 .parse (this))
|
|
1022
|
+
{
|
|
1023
|
+
this .value = parseInt (this .result [1]);
|
|
1024
|
+
|
|
1025
|
+
return true;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
return false;
|
|
1029
|
+
},
|
|
1030
|
+
double: function ()
|
|
1031
|
+
{
|
|
1032
|
+
this .whitespaces ();
|
|
1033
|
+
|
|
1034
|
+
if (Grammar .double .parse (this))
|
|
1035
|
+
{
|
|
1036
|
+
this .value = parseFloat (this .result [1]);
|
|
1037
|
+
|
|
1038
|
+
return true;
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
if (Grammar .constants .parse (this))
|
|
1042
|
+
{
|
|
1043
|
+
this .value = this .CONSTANTS .get (this .result [2] .toUpperCase ());
|
|
1044
|
+
|
|
1045
|
+
if (this .result [1] === "-")
|
|
1046
|
+
this .value = - this .value;
|
|
1047
|
+
|
|
1048
|
+
return true;
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
return false;
|
|
1052
|
+
},
|
|
1053
|
+
col3: function ()
|
|
1054
|
+
{
|
|
1055
|
+
if (this .double ())
|
|
1056
|
+
{
|
|
1057
|
+
this .color3 .r = this .value;
|
|
1058
|
+
|
|
1059
|
+
if (this .double ())
|
|
1060
|
+
{
|
|
1061
|
+
this .color3 .g = this .value;
|
|
1062
|
+
|
|
1063
|
+
if (this .double ())
|
|
1064
|
+
{
|
|
1065
|
+
this .color3 .b = this .value;
|
|
1066
|
+
|
|
1067
|
+
return true;
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
return false;
|
|
1073
|
+
},
|
|
1074
|
+
};
|
|
1075
|
+
|
|
1076
|
+
export default OBJParser;
|