three-stdlib 2.16.0 → 2.16.2
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/BufferGeometryUtils-1a7a235c.js +655 -0
- package/BufferGeometryUtils-971dfde3.js +1 -0
- package/Nodes-4f766d71.js +471 -0
- package/Nodes-9aa16d74.js +1 -0
- package/animation/AnimationClipCreator.cjs.js +1 -0
- package/animation/AnimationClipCreator.js +52 -32
- package/animation/CCDIKSolver.cjs.js +1 -0
- package/animation/CCDIKSolver.js +143 -64
- package/animation/MMDAnimationHelper.cjs.js +1 -0
- package/animation/MMDAnimationHelper.js +341 -150
- package/animation/MMDPhysics.cjs.js +1 -0
- package/animation/MMDPhysics.js +361 -154
- package/cameras/CinematicCamera.cjs.js +1 -0
- package/cameras/CinematicCamera.js +77 -67
- package/controls/ArcballControls.cjs.js +1 -0
- package/controls/ArcballControls.js +1449 -544
- package/controls/DeviceOrientationControls.cjs.js +1 -0
- package/controls/DeviceOrientationControls.js +97 -52
- package/controls/DragControls.cjs.js +1 -0
- package/controls/DragControls.js +187 -85
- package/controls/FirstPersonControls.cjs.js +1 -0
- package/controls/FirstPersonControls.js +193 -123
- package/controls/FlyControls.cjs.js +1 -0
- package/controls/FlyControls.d.ts +5 -4
- package/controls/FlyControls.js +160 -90
- package/controls/OrbitControls.cjs.js +1 -0
- package/controls/OrbitControls.js +481 -232
- package/controls/PointerLockControls.cjs.js +1 -0
- package/controls/PointerLockControls.js +99 -63
- package/controls/TrackballControls.cjs.js +1 -0
- package/controls/TrackballControls.js +383 -211
- package/controls/TransformControls.cjs.js +1 -0
- package/controls/TransformControls.js +782 -575
- package/controls/experimental/CameraControls.cjs.js +1 -0
- package/controls/experimental/CameraControls.js +609 -329
- package/csm/CSM.cjs.js +1 -0
- package/csm/CSM.js +108 -47
- package/csm/CSMFrustum.cjs.js +1 -0
- package/csm/CSMFrustum.js +29 -14
- package/csm/CSMHelper.cjs.js +1 -0
- package/csm/CSMHelper.js +34 -20
- package/csm/CSMShader.cjs.js +1 -0
- package/csm/CSMShader.js +11 -7
- package/curves/CurveExtras.cjs.js +1 -0
- package/curves/CurveExtras.js +115 -73
- package/curves/NURBSCurve.cjs.js +1 -0
- package/curves/NURBSCurve.js +43 -15
- package/curves/NURBSSurface.cjs.js +1 -0
- package/curves/NURBSSurface.js +27 -11
- package/curves/NURBSUtils.cjs.js +1 -0
- package/curves/NURBSUtils.js +203 -54
- package/custom.d.cjs.js +1 -0
- package/{shaders/types.mjs → custom.d.js} +0 -0
- package/deprecated/Geometry.cjs.js +1 -0
- package/deprecated/Geometry.js +486 -191
- package/effects/AnaglyphEffect.cjs.js +1 -0
- package/effects/AnaglyphEffect.js +60 -95
- package/effects/AsciiEffect.cjs.js +1 -0
- package/effects/AsciiEffect.js +110 -80
- package/effects/OutlineEffect.cjs.js +1 -0
- package/effects/OutlineEffect.js +204 -121
- package/effects/ParallaxBarrierEffect.cjs.js +1 -0
- package/effects/ParallaxBarrierEffect.js +38 -39
- package/effects/PeppersGhostEffect.cjs.js +1 -0
- package/effects/PeppersGhostEffect.js +68 -19
- package/effects/StereoEffect.cjs.js +1 -0
- package/effects/StereoEffect.js +16 -12
- package/environments/RoomEnvironment.cjs.js +1 -0
- package/environments/RoomEnvironment.js +47 -52
- package/exporters/ColladaExporter.cjs.js +1 -0
- package/exporters/ColladaExporter.js +241 -115
- package/exporters/DRACOExporter.cjs.js +1 -0
- package/exporters/DRACOExporter.js +121 -67
- package/exporters/GLTFExporter.cjs.js +1 -0
- package/exporters/GLTFExporter.js +1014 -463
- package/exporters/MMDExporter.cjs.js +1 -0
- package/exporters/MMDExporter.js +102 -44
- package/exporters/OBJExporter.cjs.js +1 -0
- package/exporters/OBJExporter.js +140 -78
- package/exporters/PLYExporter.cjs.js +1 -0
- package/exporters/PLYExporter.js +154 -93
- package/exporters/STLExporter.cjs.js +1 -0
- package/exporters/STLExporter.js +81 -30
- package/exporters/USDZExporter.cjs.js +1 -0
- package/exporters/USDZExporter.js +144 -84
- package/geometries/BoxLineGeometry.cjs.js +1 -0
- package/geometries/BoxLineGeometry.js +14 -7
- package/geometries/ConvexGeometry.cjs.js +1 -0
- package/geometries/ConvexGeometry.js +23 -14
- package/geometries/DecalGeometry.cjs.js +1 -0
- package/geometries/DecalGeometry.js +162 -108
- package/geometries/LightningStrike.cjs.js +1 -0
- package/geometries/LightningStrike.js +294 -101
- package/geometries/ParametricGeometries.cjs.js +1 -0
- package/geometries/ParametricGeometries.js +76 -26
- package/geometries/ParametricGeometry.cjs.js +1 -0
- package/geometries/ParametricGeometry.js +48 -24
- package/geometries/RoundedBoxGeometry.cjs.js +1 -0
- package/geometries/RoundedBoxGeometry.js +64 -33
- package/geometries/TeapotGeometry.cjs.js +1 -0
- package/geometries/TeapotGeometry.js +174 -1434
- package/geometries/TextGeometry.cjs.js +1 -0
- package/geometries/TextGeometry.js +17 -9
- package/helpers/LightProbeHelper.cjs.js +1 -0
- package/helpers/LightProbeHelper.js +21 -53
- package/helpers/PositionalAudioHelper.cjs.js +1 -0
- package/helpers/PositionalAudioHelper.js +30 -23
- package/helpers/RectAreaLightHelper.cjs.js +1 -0
- package/helpers/RectAreaLightHelper.js +33 -17
- package/helpers/VertexNormalsHelper.cjs.js +1 -0
- package/helpers/VertexNormalsHelper.js +41 -20
- package/helpers/VertexTangentsHelper.cjs.js +1 -0
- package/helpers/VertexTangentsHelper.js +36 -18
- package/index.cjs.js +1 -0
- package/index.js +333 -969
- package/interactive/InteractiveGroup.cjs.js +1 -0
- package/interactive/InteractiveGroup.d.ts +5 -0
- package/interactive/InteractiveGroup.js +87 -0
- package/interactive/SelectionBox.cjs.js +1 -0
- package/interactive/SelectionBox.js +46 -31
- package/interactive/SelectionHelper.cjs.js +1 -0
- package/interactive/SelectionHelper.js +21 -16
- package/libs/MeshoptDecoder.cjs.js +1 -0
- package/libs/MeshoptDecoder.js +58 -147
- package/libs/MotionControllers.cjs.js +1 -0
- package/libs/MotionControllers.js +208 -66
- package/lights/LightProbeGenerator.cjs.js +1 -0
- package/lights/LightProbeGenerator.js +96 -40
- package/lights/RectAreaLightUniformsLib.cjs.js +1 -0
- package/lights/RectAreaLightUniformsLib.js +9 -32842
- package/lines/Line2.cjs.js +1 -0
- package/lines/Line2.js +12 -9
- package/lines/LineGeometry.cjs.js +1 -0
- package/lines/LineGeometry.js +19 -7
- package/lines/LineMaterial.cjs.js +1 -0
- package/lines/LineMaterial.js +89 -51
- package/lines/LineSegments2.cjs.js +1 -0
- package/lines/LineSegments2.js +165 -56
- package/lines/LineSegmentsGeometry.cjs.js +1 -0
- package/lines/LineSegmentsGeometry.js +71 -29
- package/lines/Wireframe.cjs.js +1 -0
- package/lines/Wireframe.js +29 -15
- package/lines/WireframeGeometry2.cjs.js +1 -0
- package/lines/WireframeGeometry2.js +9 -8
- package/loaders/3DMLoader.cjs.js +1 -0
- package/loaders/3DMLoader.js +469 -234
- package/loaders/3MFLoader.cjs.js +1 -0
- package/loaders/3MFLoader.js +555 -340
- package/loaders/AMFLoader.cjs.js +1 -0
- package/loaders/AMFLoader.js +219 -114
- package/loaders/AssimpLoader.cjs.js +1 -0
- package/loaders/AssimpLoader.js +725 -328
- package/loaders/BVHLoader.cjs.js +1 -0
- package/loaders/BVHLoader.js +200 -94
- package/loaders/BasisTextureLoader.cjs.js +1 -0
- package/loaders/BasisTextureLoader.js +357 -229
- package/loaders/ColladaLoader.cjs.js +1 -0
- package/loaders/ColladaLoader.js +1522 -932
- package/loaders/DDSLoader.cjs.js +1 -0
- package/loaders/DDSLoader.js +108 -42
- package/loaders/DRACOLoader.cjs.js +1 -0
- package/loaders/DRACOLoader.js +210 -103
- package/loaders/EXRLoader.cjs.js +1 -0
- package/loaders/EXRLoader.js +809 -461
- package/loaders/FBXLoader.cjs.js +1 -0
- package/loaders/FBXLoader.js +1397 -842
- package/loaders/FontLoader.cjs.js +1 -0
- package/loaders/FontLoader.js +66 -33
- package/loaders/GCodeLoader.cjs.js +1 -0
- package/loaders/GCodeLoader.js +111 -63
- package/loaders/GLTFLoader.cjs.js +1 -0
- package/loaders/GLTFLoader.js +1484 -771
- package/loaders/HDRCubeTextureLoader.cjs.js +1 -0
- package/loaders/HDRCubeTextureLoader.js +50 -45
- package/loaders/KMZLoader.cjs.js +1 -0
- package/loaders/KMZLoader.js +55 -42
- package/loaders/KTX2Loader.cjs.js +1 -0
- package/loaders/KTX2Loader.js +362 -229
- package/loaders/KTXLoader.cjs.js +1 -0
- package/loaders/KTXLoader.js +99 -37
- package/loaders/LDrawLoader.cjs.js +1 -0
- package/loaders/LDrawLoader.js +746 -313
- package/loaders/LUT3dlLoader.cjs.js +1 -0
- package/loaders/LUT3dlLoader.js +62 -50
- package/loaders/LUTCubeLoader.cjs.js +1 -0
- package/loaders/LUTCubeLoader.js +56 -45
- package/loaders/LWOLoader.cjs.js +1 -0
- package/loaders/LWOLoader.js +339 -227
- package/loaders/LottieLoader.cjs.js +1 -0
- package/loaders/LottieLoader.js +38 -36
- package/loaders/MD2Loader.cjs.js +1 -0
- package/loaders/MD2Loader.js +91 -248
- package/loaders/MDDLoader.cjs.js +1 -0
- package/loaders/MDDLoader.js +45 -25
- package/loaders/MMDLoader.cjs.js +1 -0
- package/loaders/MMDLoader.js +795 -359
- package/loaders/MTLLoader.cjs.js +1 -0
- package/loaders/MTLLoader.js +201 -91
- package/loaders/NRRDLoader.cjs.js +1 -0
- package/loaders/NRRDLoader.js +263 -182
- package/loaders/NodeMaterialLoader.cjs.js +1 -0
- package/loaders/NodeMaterialLoader.js +14 -121
- package/loaders/OBJLoader.cjs.js +1 -0
- package/loaders/OBJLoader.js +283 -161
- package/loaders/PCDLoader.cjs.js +1 -0
- package/loaders/PCDLoader.js +164 -145
- package/loaders/PDBLoader.cjs.js +1 -0
- package/loaders/PDBLoader.js +63 -45
- package/loaders/PLYLoader.cjs.js +1 -0
- package/loaders/PLYLoader.js +203 -106
- package/loaders/PRWMLoader.cjs.js +1 -0
- package/loaders/PRWMLoader.js +110 -73
- package/loaders/PVRLoader.cjs.js +1 -0
- package/loaders/PVRLoader.js +93 -32
- package/loaders/RGBELoader.cjs.js +1 -0
- package/loaders/RGBELoader.js +233 -96
- package/loaders/RGBMLoader.cjs.js +1 -0
- package/loaders/RGBMLoader.js +514 -344
- package/loaders/STLLoader.cjs.js +1 -0
- package/loaders/STLLoader.js +165 -59
- package/loaders/SVGLoader.cjs.js +1 -0
- package/loaders/SVGLoader.js +851 -481
- package/loaders/TDSLoader.cjs.js +1 -0
- package/loaders/TDSLoader.js +527 -137
- package/loaders/TGALoader.cjs.js +1 -0
- package/loaders/TGALoader.js +205 -94
- package/loaders/TTFLoader.cjs.js +1 -0
- package/loaders/TTFLoader.js +79 -58
- package/loaders/TiltLoader.cjs.js +1 -0
- package/loaders/TiltLoader.js +167 -129
- package/loaders/VOXLoader.cjs.js +1 -0
- package/loaders/VOXLoader.js +84 -320
- package/loaders/VRMLLoader.cjs.js +1 -0
- package/loaders/VRMLLoader.js +1268 -786
- package/loaders/VRMLoader.cjs.js +1 -0
- package/loaders/VRMLoader.js +31 -23
- package/loaders/VTKLoader.cjs.js +1 -0
- package/loaders/VTKLoader.js +407 -219
- package/loaders/XLoader.cjs.js +1 -0
- package/loaders/XLoader.js +1259 -1083
- package/loaders/XYZLoader.cjs.js +1 -0
- package/loaders/XYZLoader.js +34 -28
- package/loaders/lwo/IFFParser.cjs.js +1 -0
- package/loaders/lwo/IFFParser.js +492 -238
- package/loaders/lwo/LWO2Parser.cjs.js +1 -0
- package/loaders/lwo/LWO2Parser.js +279 -176
- package/loaders/lwo/LWO3Parser.cjs.js +1 -0
- package/loaders/lwo/LWO3Parser.js +247 -160
- package/math/Capsule.cjs.js +1 -0
- package/math/Capsule.js +43 -56
- package/math/ColorConverter.cjs.js +1 -0
- package/math/ColorConverter.js +32 -18
- package/math/ConvexHull.cjs.js +1 -0
- package/math/ConvexHull.js +357 -97
- package/math/ImprovedNoise.cjs.js +1 -0
- package/math/ImprovedNoise.js +32 -282
- package/math/Lut.cjs.js +1 -0
- package/math/Lut.js +35 -51
- package/math/MeshSurfaceSampler.cjs.js +1 -0
- package/math/MeshSurfaceSampler.js +68 -25
- package/math/OBB.cjs.js +1 -0
- package/math/OBB.js +152 -91
- package/math/Octree.cjs.js +1 -0
- package/math/Octree.js +139 -76
- package/math/SimplexNoise.cjs.js +1 -0
- package/math/SimplexNoise.js +238 -217
- package/misc/ConvexObjectBreaker.cjs.js +1 -0
- package/misc/ConvexObjectBreaker.js +185 -79
- package/misc/GPUComputationRenderer.cjs.js +1 -0
- package/misc/GPUComputationRenderer.js +194 -69
- package/misc/Gyroscope.cjs.js +1 -0
- package/misc/Gyroscope.js +22 -16
- package/misc/MD2Character.cjs.js +1 -0
- package/misc/MD2Character.js +74 -52
- package/misc/MD2CharacterComplex.cjs.js +1 -0
- package/misc/MD2CharacterComplex.js +163 -112
- package/misc/MorphAnimMesh.cjs.js +1 -0
- package/misc/MorphAnimMesh.js +28 -20
- package/misc/MorphBlendMesh.cjs.js +1 -0
- package/misc/MorphBlendMesh.js +69 -45
- package/misc/ProgressiveLightmap.cjs.js +1 -0
- package/misc/ProgressiveLightmap.js +187 -70
- package/misc/RollerCoaster.cjs.js +1 -0
- package/misc/RollerCoaster.js +135 -106
- package/misc/TubePainter.cjs.js +1 -0
- package/misc/TubePainter.js +92 -74
- package/misc/Volume.cjs.js +1 -0
- package/misc/Volume.js +270 -108
- package/misc/VolumeSlice.cjs.js +1 -0
- package/misc/VolumeSlice.js +122 -34
- package/misc/WebGL.cjs.js +1 -0
- package/misc/WebGL.js +34 -37
- package/modifiers/CurveModifier.cjs.js +1 -0
- package/modifiers/CurveModifier.js +151 -46
- package/modifiers/EdgeSplitModifier.cjs.js +1 -0
- package/modifiers/EdgeSplitModifier.js +90 -46
- package/modifiers/SimplifyModifier.cjs.js +1 -0
- package/modifiers/SimplifyModifier.js +202 -77
- package/modifiers/TessellateModifier.cjs.js +1 -0
- package/modifiers/TessellateModifier.js +90 -65
- package/nodes/Nodes.cjs.js +1 -0
- package/nodes/Nodes.js +140 -274
- package/nodes/ShaderNode.cjs.js +1 -0
- package/nodes/ShaderNode.js +196 -296
- package/nodes/accessors/BufferNode.cjs.js +1 -0
- package/nodes/accessors/BufferNode.js +8 -4
- package/nodes/accessors/CameraNode.cjs.js +1 -0
- package/nodes/accessors/CameraNode.js +25 -20
- package/nodes/accessors/CubeTextureNode.cjs.js +1 -0
- package/nodes/accessors/CubeTextureNode.js +26 -14
- package/nodes/accessors/MaterialNode.cjs.js +1 -0
- package/nodes/accessors/MaterialNode.js +53 -43
- package/nodes/accessors/MaterialReferenceNode.cjs.js +1 -0
- package/nodes/accessors/MaterialReferenceNode.js +6 -3
- package/nodes/accessors/ModelNode.cjs.js +1 -0
- package/nodes/accessors/ModelNode.js +5 -3
- package/nodes/accessors/ModelViewProjectionNode.cjs.js +1 -0
- package/nodes/accessors/ModelViewProjectionNode.js +13 -14
- package/nodes/accessors/NormalNode.cjs.js +1 -0
- package/nodes/accessors/NormalNode.js +39 -40
- package/nodes/accessors/Object3DNode.cjs.js +1 -0
- package/nodes/accessors/Object3DNode.js +50 -40
- package/nodes/accessors/PointUVNode.cjs.js +1 -0
- package/nodes/accessors/PointUVNode.js +9 -5
- package/nodes/accessors/PositionNode.cjs.js +1 -0
- package/nodes/accessors/PositionNode.js +41 -42
- package/nodes/accessors/ReferenceNode.cjs.js +1 -0
- package/nodes/accessors/ReferenceNode.js +17 -10
- package/nodes/accessors/ReflectNode.cjs.js +1 -0
- package/nodes/accessors/ReflectNode.js +26 -23
- package/nodes/accessors/SkinningNode.cjs.js +1 -0
- package/nodes/accessors/SkinningNode.js +48 -46
- package/nodes/accessors/TextureNode.cjs.js +1 -0
- package/nodes/accessors/TextureNode.js +29 -14
- package/nodes/accessors/UVNode.cjs.js +1 -0
- package/nodes/accessors/UVNode.js +11 -5
- package/nodes/core/ArrayUniformNode.cjs.js +1 -0
- package/nodes/core/ArrayUniformNode.js +7 -3
- package/nodes/core/AttributeNode.cjs.js +1 -0
- package/nodes/core/AttributeNode.js +12 -5
- package/nodes/core/BypassNode.cjs.js +1 -0
- package/nodes/core/BypassNode.js +12 -5
- package/nodes/core/CodeNode.cjs.js +1 -0
- package/nodes/core/CodeNode.js +12 -4
- package/nodes/core/ConstNode.cjs.js +1 -0
- package/nodes/core/ConstNode.js +7 -3
- package/nodes/core/ContextNode.cjs.js +1 -0
- package/nodes/core/ContextNode.js +8 -3
- package/nodes/core/ExpressionNode.cjs.js +1 -0
- package/nodes/core/ExpressionNode.js +9 -5
- package/nodes/core/FunctionCallNode.cjs.js +1 -0
- package/nodes/core/FunctionCallNode.js +15 -6
- package/nodes/core/FunctionNode.cjs.js +1 -0
- package/nodes/core/FunctionNode.js +25 -10
- package/nodes/core/InputNode.cjs.js +1 -0
- package/nodes/core/InputNode.js +23 -12
- package/nodes/core/Node.cjs.js +1 -0
- package/nodes/core/Node.js +75 -35
- package/nodes/core/NodeAttribute.cjs.js +1 -0
- package/nodes/core/NodeAttribute.js +4 -2
- package/nodes/core/NodeBuilder.cjs.js +1 -0
- package/nodes/core/NodeBuilder.js +224 -110
- package/nodes/core/NodeCode.cjs.js +1 -0
- package/nodes/core/NodeCode.js +7 -4
- package/nodes/core/NodeFrame.cjs.js +1 -0
- package/nodes/core/NodeFrame.js +12 -9
- package/nodes/core/NodeFunction.cjs.js +1 -0
- package/nodes/core/NodeFunction.js +17 -0
- package/nodes/core/NodeFunctionInput.cjs.js +1 -0
- package/nodes/core/NodeFunctionInput.js +5 -3
- package/nodes/core/NodeKeywords.cjs.js +1 -0
- package/nodes/core/NodeKeywords.js +16 -5
- package/nodes/core/NodeParser.cjs.js +1 -0
- package/nodes/core/NodeParser.js +8 -0
- package/nodes/core/NodeUniform.cjs.js +1 -0
- package/nodes/core/NodeUniform.js +7 -3
- package/nodes/core/NodeUtils.cjs.js +1 -0
- package/nodes/core/NodeUtils.js +43 -39
- package/nodes/core/NodeVar.cjs.js +1 -0
- package/nodes/core/NodeVar.js +4 -2
- package/nodes/core/NodeVary.cjs.js +1 -0
- package/nodes/core/NodeVary.js +4 -2
- package/nodes/core/PropertyNode.cjs.js +1 -0
- package/nodes/core/PropertyNode.js +10 -4
- package/nodes/core/TempNode.cjs.js +1 -0
- package/nodes/core/TempNode.js +11 -5
- package/nodes/core/UniformNode.cjs.js +1 -0
- package/nodes/core/UniformNode.js +10 -4
- package/nodes/core/VarNode.cjs.js +1 -0
- package/nodes/core/VarNode.js +11 -3
- package/nodes/core/VaryNode.cjs.js +1 -0
- package/nodes/core/VaryNode.js +15 -6
- package/nodes/core/constants.cjs.js +1 -0
- package/nodes/core/constants.js +7 -20
- package/nodes/display/ColorSpaceNode.cjs.js +1 -0
- package/nodes/display/ColorSpaceNode.js +38 -34
- package/nodes/display/NormalMapNode.cjs.js +1 -0
- package/nodes/display/NormalMapNode.js +53 -35
- package/nodes/fog/FogNode.cjs.js +1 -0
- package/nodes/fog/FogNode.js +9 -5
- package/nodes/fog/FogRangeNode.cjs.js +1 -0
- package/nodes/fog/FogRangeNode.js +9 -5
- package/nodes/functions/BSDFs.cjs.js +1 -0
- package/nodes/functions/BSDFs.js +118 -61
- package/nodes/functions/PhysicalMaterialFunctions.cjs.js +1 -0
- package/nodes/functions/PhysicalMaterialFunctions.js +57 -0
- package/nodes/lights/LightContextNode.cjs.js +1 -0
- package/nodes/lights/LightContextNode.js +23 -14
- package/nodes/lights/LightNode.cjs.js +1 -0
- package/nodes/lights/LightNode.js +31 -27
- package/nodes/lights/LightsNode.cjs.js +1 -0
- package/nodes/lights/LightsNode.js +28 -9
- package/nodes/loaders/NodeLoader.cjs.js +1 -0
- package/nodes/loaders/NodeLoader.js +42 -27
- package/nodes/loaders/NodeMaterialLoader.cjs.js +1 -0
- package/nodes/loaders/NodeMaterialLoader.js +10 -4
- package/nodes/loaders/NodeObjectLoader.cjs.js +1 -0
- package/nodes/loaders/NodeObjectLoader.js +19 -9
- package/nodes/materials/LineBasicNodeMaterial.cjs.js +1 -0
- package/nodes/materials/LineBasicNodeMaterial.js +10 -5
- package/nodes/materials/Materials.cjs.js +1 -0
- package/nodes/materials/Materials.js +17 -14
- package/nodes/materials/MeshBasicNodeMaterial.cjs.js +1 -0
- package/nodes/materials/MeshBasicNodeMaterial.js +10 -5
- package/nodes/materials/MeshStandardNodeMaterial.cjs.js +1 -0
- package/nodes/materials/MeshStandardNodeMaterial.js +8 -5
- package/nodes/materials/NodeMaterial.cjs.js +1 -0
- package/nodes/materials/NodeMaterial.js +36 -20
- package/nodes/materials/PointsNodeMaterial.cjs.js +1 -0
- package/nodes/materials/PointsNodeMaterial.js +10 -5
- package/nodes/math/CondNode.cjs.js +1 -0
- package/nodes/math/CondNode.js +23 -11
- package/nodes/math/MathNode.cjs.js +1 -0
- package/nodes/math/MathNode.js +142 -98
- package/nodes/math/OperatorNode.cjs.js +1 -0
- package/nodes/math/OperatorNode.js +46 -24
- package/nodes/parsers/GLSLNodeFunction.cjs.js +1 -0
- package/nodes/parsers/GLSLNodeFunction.js +101 -0
- package/nodes/parsers/GLSLNodeParser.cjs.js +1 -0
- package/nodes/parsers/GLSLNodeParser.js +13 -0
- package/nodes/parsers/WGSLNodeFunction.cjs.js +1 -0
- package/nodes/parsers/WGSLNodeFunction.js +71 -0
- package/nodes/parsers/WGSLNodeParser.cjs.js +1 -0
- package/nodes/parsers/WGSLNodeParser.js +13 -0
- package/nodes/procedural/CheckerNode.cjs.js +1 -0
- package/nodes/procedural/CheckerNode.js +19 -13
- package/nodes/utils/ArrayElementNode.cjs.js +1 -0
- package/nodes/utils/ArrayElementNode.js +8 -4
- package/nodes/utils/ConvertNode.cjs.js +1 -0
- package/nodes/utils/ConvertNode.js +8 -3
- package/nodes/utils/JoinNode.cjs.js +1 -0
- package/nodes/utils/JoinNode.js +11 -7
- package/nodes/utils/MatcapUVNode.cjs.js +1 -0
- package/nodes/utils/MatcapUVNode.js +11 -8
- package/nodes/utils/OscNode.cjs.js +1 -0
- package/nodes/utils/OscNode.js +33 -27
- package/nodes/utils/SplitNode.cjs.js +1 -0
- package/nodes/utils/SplitNode.js +20 -6
- package/nodes/utils/SpriteSheetUVNode.cjs.js +1 -0
- package/nodes/utils/SpriteSheetUVNode.js +23 -23
- package/nodes/utils/TimerNode.cjs.js +1 -0
- package/nodes/utils/TimerNode.js +24 -20
- package/objects/GroundProjectedEnv.cjs.js +1 -0
- package/objects/GroundProjectedEnv.js +37 -22
- package/objects/Lensflare.cjs.js +1 -0
- package/objects/Lensflare.js +156 -86
- package/objects/LightningStorm.cjs.js +1 -0
- package/objects/LightningStorm.js +102 -38
- package/objects/MarchingCubes.cjs.js +1 -0
- package/objects/MarchingCubes.js +303 -150
- package/objects/Reflector.cjs.js +1 -0
- package/objects/Reflector.js +72 -50
- package/objects/ReflectorForSSRPass.cjs.js +1 -0
- package/objects/ReflectorForSSRPass.js +131 -80
- package/objects/ReflectorRTT.cjs.js +1 -0
- package/objects/ReflectorRTT.js +7 -6
- package/objects/Refractor.cjs.js +1 -0
- package/objects/Refractor.js +106 -64
- package/objects/ShadowMesh.cjs.js +1 -0
- package/objects/ShadowMesh.js +17 -8
- package/objects/Sky.cjs.js +1 -0
- package/objects/Sky.js +80 -119
- package/objects/Water.cjs.js +1 -0
- package/objects/Water.js +127 -83
- package/objects/Water2.cjs.js +1 -0
- package/objects/Water2.js +108 -72
- package/offscreen/jank.cjs.js +1 -0
- package/offscreen/jank.js +14 -10
- package/offscreen/offscreen.cjs.js +1 -0
- package/offscreen/offscreen.js +5 -4
- package/offscreen/scene.cjs.js +1 -0
- package/offscreen/scene.js +48 -45
- package/package.json +3 -3
- package/physics/AmmoPhysics.cjs.js +1 -0
- package/physics/AmmoPhysics.js +71 -30
- package/postprocessing/AdaptiveToneMappingPass.cjs.js +1 -0
- package/postprocessing/AdaptiveToneMappingPass.js +123 -97
- package/postprocessing/AfterimagePass.cjs.js +1 -0
- package/postprocessing/AfterimagePass.js +49 -28
- package/postprocessing/BloomPass.cjs.js +1 -0
- package/postprocessing/BloomPass.js +69 -43
- package/postprocessing/BokehPass.cjs.js +1 -0
- package/postprocessing/BokehPass.js +69 -39
- package/postprocessing/ClearPass.cjs.js +1 -0
- package/postprocessing/ClearPass.js +25 -10
- package/postprocessing/CubeTexturePass.cjs.js +1 -0
- package/postprocessing/CubeTexturePass.js +27 -28
- package/postprocessing/DotScreenPass.cjs.js +1 -0
- package/postprocessing/DotScreenPass.js +32 -24
- package/postprocessing/EffectComposer.cjs.js +1 -0
- package/postprocessing/EffectComposer.js +86 -39
- package/postprocessing/FilmPass.cjs.js +1 -0
- package/postprocessing/FilmPass.js +30 -25
- package/postprocessing/GlitchPass.cjs.js +1 -0
- package/postprocessing/GlitchPass.js +61 -38
- package/postprocessing/HalftonePass.cjs.js +1 -0
- package/postprocessing/HalftonePass.js +39 -19
- package/postprocessing/LUTPass.cjs.js +1 -0
- package/postprocessing/LUTPass.js +38 -13
- package/postprocessing/MaskPass.cjs.js +1 -0
- package/postprocessing/MaskPass.js +38 -19
- package/postprocessing/OutlinePass.cjs.js +1 -0
- package/postprocessing/OutlinePass.js +277 -135
- package/postprocessing/Pass.cjs.js +1 -0
- package/postprocessing/Pass.js +44 -20
- package/postprocessing/RenderPass.cjs.js +1 -0
- package/postprocessing/RenderPass.js +36 -13
- package/postprocessing/RenderPixelatedPass.cjs.js +1 -0
- package/postprocessing/RenderPixelatedPass.js +58 -44
- package/postprocessing/SAOPass.cjs.js +1 -0
- package/postprocessing/SAOPass.js +189 -154
- package/postprocessing/SMAAPass.cjs.js +1 -0
- package/postprocessing/SMAAPass.js +84 -64
- package/postprocessing/SSAARenderPass.cjs.js +1 -0
- package/postprocessing/SSAARenderPass.js +69 -121
- package/postprocessing/SSAOPass.cjs.js +1 -0
- package/postprocessing/SSAOPass.js +172 -123
- package/postprocessing/SSRPass.cjs.js +1 -0
- package/postprocessing/SSRPass.js +280 -211
- package/postprocessing/SavePass.cjs.js +1 -0
- package/postprocessing/SavePass.js +25 -20
- package/postprocessing/ShaderPass.cjs.js +1 -0
- package/postprocessing/ShaderPass.js +30 -14
- package/postprocessing/TAARenderPass.cjs.js +1 -0
- package/postprocessing/TAARenderPass.js +61 -42
- package/postprocessing/TexturePass.cjs.js +1 -0
- package/postprocessing/TexturePass.js +22 -21
- package/postprocessing/UnrealBloomPass.cjs.js +1 -0
- package/postprocessing/UnrealBloomPass.js +213 -105
- package/renderers/CSS2DRenderer.cjs.js +1 -0
- package/renderers/CSS2DRenderer.js +56 -44
- package/renderers/CSS3DRenderer.cjs.js +1 -0
- package/renderers/CSS3DRenderer.js +86 -53
- package/renderers/Projector.cjs.js +1 -0
- package/renderers/Projector.js +274 -107
- package/renderers/SVGRenderer.cjs.js +1 -0
- package/renderers/SVGRenderer.js +182 -72
- package/renderers/nodes/accessors/CameraNode.cjs.js +1 -0
- package/renderers/nodes/accessors/CameraNode.js +40 -29
- package/renderers/nodes/accessors/ModelNode.cjs.js +1 -0
- package/renderers/nodes/accessors/ModelNode.js +37 -28
- package/renderers/nodes/accessors/ModelViewProjectionNode.cjs.js +1 -0
- package/renderers/nodes/accessors/ModelViewProjectionNode.js +23 -10
- package/renderers/nodes/accessors/NormalNode.cjs.js +1 -0
- package/renderers/nodes/accessors/NormalNode.js +45 -35
- package/renderers/nodes/accessors/PositionNode.cjs.js +1 -0
- package/renderers/nodes/accessors/PositionNode.js +19 -18
- package/renderers/nodes/accessors/UVNode.cjs.js +1 -0
- package/renderers/nodes/accessors/UVNode.js +10 -5
- package/renderers/nodes/core/AttributeNode.cjs.js +1 -0
- package/renderers/nodes/core/AttributeNode.js +14 -5
- package/renderers/nodes/core/InputNode.cjs.js +1 -0
- package/renderers/nodes/core/InputNode.js +14 -4
- package/renderers/nodes/core/Node.cjs.js +1 -0
- package/renderers/nodes/core/Node.js +17 -7
- package/renderers/nodes/core/NodeAttribute.cjs.js +1 -0
- package/renderers/nodes/core/NodeAttribute.js +6 -3
- package/renderers/nodes/core/NodeBuilder.cjs.js +1 -0
- package/renderers/nodes/core/NodeBuilder.js +154 -87
- package/renderers/nodes/core/NodeFrame.cjs.js +1 -0
- package/renderers/nodes/core/NodeFrame.js +12 -9
- package/renderers/nodes/core/NodeSlot.cjs.js +1 -0
- package/renderers/nodes/core/NodeSlot.js +3 -2
- package/renderers/nodes/core/NodeUniform.cjs.js +1 -0
- package/renderers/nodes/core/NodeUniform.js +9 -4
- package/renderers/nodes/core/NodeVary.cjs.js +1 -0
- package/renderers/nodes/core/NodeVary.js +7 -4
- package/renderers/nodes/core/VaryNode.cjs.js +1 -0
- package/renderers/nodes/core/VaryNode.js +12 -6
- package/renderers/nodes/core/constants.cjs.js +1 -0
- package/renderers/nodes/core/constants.js +13 -16
- package/renderers/nodes/inputs/ColorNode.cjs.js +1 -0
- package/renderers/nodes/inputs/ColorNode.js +11 -5
- package/renderers/nodes/inputs/FloatNode.cjs.js +1 -0
- package/renderers/nodes/inputs/FloatNode.js +11 -5
- package/renderers/nodes/inputs/Matrix3Node.cjs.js +1 -0
- package/renderers/nodes/inputs/Matrix3Node.js +13 -7
- package/renderers/nodes/inputs/Matrix4Node.cjs.js +1 -0
- package/renderers/nodes/inputs/Matrix4Node.js +13 -7
- package/renderers/nodes/inputs/TextureNode.cjs.js +1 -0
- package/renderers/nodes/inputs/TextureNode.js +15 -7
- package/renderers/nodes/inputs/Vector2Node.cjs.js +1 -0
- package/renderers/nodes/inputs/Vector2Node.js +11 -5
- package/renderers/nodes/inputs/Vector3Node.cjs.js +1 -0
- package/renderers/nodes/inputs/Vector3Node.js +13 -7
- package/renderers/nodes/inputs/Vector4Node.cjs.js +1 -0
- package/renderers/nodes/inputs/Vector4Node.js +13 -7
- package/renderers/nodes/math/MathNode.cjs.js +1 -0
- package/renderers/nodes/math/MathNode.js +30 -20
- package/renderers/nodes/math/OperatorNode.cjs.js +1 -0
- package/renderers/nodes/math/OperatorNode.js +20 -4
- package/renderers/nodes/utils/SwitchNode.cjs.js +1 -0
- package/renderers/nodes/utils/SwitchNode.js +9 -4
- package/renderers/nodes/utils/TimerNode.cjs.js +1 -0
- package/renderers/nodes/utils/TimerNode.js +10 -5
- package/renderers/webgpu/WebGPU.cjs.js +1 -0
- package/renderers/webgpu/WebGPU.js +16 -14
- package/renderers/webgpu/WebGPUAttributes.cjs.js +1 -0
- package/renderers/webgpu/WebGPUAttributes.js +23 -16
- package/renderers/webgpu/WebGPUBackground.cjs.js +1 -0
- package/renderers/webgpu/WebGPUBackground.js +30 -13
- package/renderers/webgpu/WebGPUBinding.cjs.js +1 -0
- package/renderers/webgpu/WebGPUBinding.js +7 -4
- package/renderers/webgpu/WebGPUBindings.cjs.js +1 -0
- package/renderers/webgpu/WebGPUBindings.js +57 -21
- package/renderers/webgpu/WebGPUComputePipelines.cjs.js +1 -0
- package/renderers/webgpu/WebGPUComputePipelines.js +25 -14
- package/renderers/webgpu/WebGPUGeometries.cjs.js +1 -0
- package/renderers/webgpu/WebGPUGeometries.js +15 -5
- package/renderers/webgpu/WebGPUInfo.cjs.js +1 -0
- package/renderers/webgpu/WebGPUInfo.js +8 -3
- package/renderers/webgpu/WebGPUObjects.cjs.js +1 -0
- package/renderers/webgpu/WebGPUObjects.js +10 -5
- package/renderers/webgpu/WebGPUProperties.cjs.js +1 -0
- package/renderers/webgpu/WebGPUProperties.js +11 -5
- package/renderers/webgpu/WebGPURenderLists.cjs.js +1 -0
- package/renderers/webgpu/WebGPURenderLists.js +36 -20
- package/renderers/webgpu/WebGPURenderPipelines.cjs.js +1 -0
- package/renderers/webgpu/WebGPURenderPipelines.js +387 -260
- package/renderers/webgpu/WebGPURenderer.cjs.js +1 -0
- package/renderers/webgpu/WebGPURenderer.js +262 -124
- package/renderers/webgpu/WebGPUSampledTexture.cjs.js +1 -0
- package/renderers/webgpu/WebGPUSampledTexture.js +31 -18
- package/renderers/webgpu/WebGPUSampler.cjs.js +1 -0
- package/renderers/webgpu/WebGPUSampler.js +12 -7
- package/renderers/webgpu/WebGPUStorageBuffer.cjs.js +1 -0
- package/renderers/webgpu/WebGPUStorageBuffer.js +12 -7
- package/renderers/webgpu/WebGPUTextureRenderer.cjs.js +1 -0
- package/renderers/webgpu/WebGPUTextureRenderer.js +11 -5
- package/renderers/webgpu/WebGPUTextureUtils.cjs.js +1 -0
- package/renderers/webgpu/WebGPUTextureUtils.js +40 -29
- package/renderers/webgpu/WebGPUTextures.cjs.js +1 -0
- package/renderers/webgpu/WebGPUTextures.js +333 -186
- package/renderers/webgpu/WebGPUUniform.cjs.js +1 -0
- package/renderers/webgpu/WebGPUUniform.js +51 -25
- package/renderers/webgpu/WebGPUUniformsGroup.cjs.js +1 -0
- package/renderers/webgpu/WebGPUUniformsGroup.js +72 -32
- package/renderers/webgpu/constants.cjs.js +1 -0
- package/renderers/webgpu/constants.js +181 -190
- package/renderers/webgpu/nodes/ShaderLib.cjs.js +1 -0
- package/renderers/webgpu/nodes/ShaderLib.js +2 -2
- package/renderers/webgpu/nodes/WebGPUNodeBuilder.cjs.js +1 -0
- package/renderers/webgpu/nodes/WebGPUNodeBuilder.js +124 -53
- package/renderers/webgpu/nodes/WebGPUNodeUniform.cjs.js +1 -0
- package/renderers/webgpu/nodes/WebGPUNodeUniform.js +31 -17
- package/renderers/webgpu/nodes/WebGPUNodeUniformsGroup.cjs.js +1 -0
- package/renderers/webgpu/nodes/WebGPUNodeUniformsGroup.js +9 -8
- package/renderers/webgpu/nodes/WebGPUNodes.cjs.js +1 -0
- package/renderers/webgpu/nodes/WebGPUNodes.js +45 -7
- package/shaders/ACESFilmicToneMappingShader.cjs.js +1 -0
- package/shaders/ACESFilmicToneMappingShader.js +24 -44
- package/shaders/AfterimageShader.cjs.js +1 -0
- package/shaders/AfterimageShader.js +18 -28
- package/shaders/BasicShader.cjs.js +1 -0
- package/shaders/BasicShader.js +7 -9
- package/shaders/BleachBypassShader.cjs.js +1 -0
- package/shaders/BleachBypassShader.js +15 -31
- package/shaders/BlendShader.cjs.js +1 -0
- package/shaders/BlendShader.js +19 -26
- package/shaders/BokehShader.cjs.js +1 -0
- package/shaders/BokehShader.js +36 -98
- package/shaders/BokehShader2.cjs.js +1 -0
- package/shaders/BokehShader2.js +90 -261
- package/shaders/BrightnessContrastShader.cjs.js +1 -0
- package/shaders/BrightnessContrastShader.js +19 -28
- package/shaders/ColorCorrectionShader.cjs.js +1 -0
- package/shaders/ColorCorrectionShader.js +22 -26
- package/shaders/ColorifyShader.cjs.js +1 -0
- package/shaders/ColorifyShader.js +16 -24
- package/shaders/ConvolutionShader.cjs.js +1 -0
- package/shaders/ConvolutionShader.js +36 -40
- package/shaders/CopyShader.cjs.js +1 -0
- package/shaders/CopyShader.js +13 -21
- package/shaders/DOFMipMapShader.cjs.js +1 -0
- package/shaders/DOFMipMapShader.js +21 -28
- package/shaders/DepthLimitedBlurShader.cjs.js +1 -0
- package/shaders/DepthLimitedBlurShader.js +40 -85
- package/shaders/DigitalGlitch.cjs.js +1 -0
- package/shaders/DigitalGlitch.js +46 -74
- package/shaders/DotScreenShader.cjs.js +1 -0
- package/shaders/DotScreenShader.js +27 -35
- package/shaders/FXAAShader.cjs.js +1 -0
- package/shaders/FXAAShader.js +19 -1094
- package/shaders/FilmShader.cjs.js +1 -0
- package/shaders/FilmShader.js +52 -38
- package/shaders/FocusShader.cjs.js +1 -0
- package/shaders/FocusShader.js +24 -51
- package/shaders/FreiChenShader.cjs.js +1 -0
- package/shaders/FreiChenShader.js +24 -57
- package/shaders/FresnelShader.cjs.js +1 -0
- package/shaders/FresnelShader.js +22 -43
- package/shaders/GammaCorrectionShader.cjs.js +1 -0
- package/shaders/GammaCorrectionShader.js +11 -19
- package/shaders/GodRaysShader.cjs.js +1 -0
- package/shaders/GodRaysShader.js +94 -103
- package/shaders/HalftoneShader.cjs.js +1 -0
- package/shaders/HalftoneShader.js +65 -208
- package/shaders/HorizontalBlurShader.cjs.js +1 -0
- package/shaders/HorizontalBlurShader.js +23 -7
- package/shaders/HorizontalTiltShiftShader.cjs.js +1 -0
- package/shaders/HorizontalTiltShiftShader.js +21 -33
- package/shaders/HueSaturationShader.cjs.js +1 -0
- package/shaders/HueSaturationShader.js +21 -37
- package/shaders/KaleidoShader.cjs.js +1 -0
- package/shaders/KaleidoShader.js +22 -30
- package/shaders/LuminosityHighPassShader.cjs.js +1 -0
- package/shaders/LuminosityHighPassShader.js +27 -33
- package/shaders/LuminosityShader.cjs.js +1 -0
- package/shaders/LuminosityShader.js +11 -21
- package/shaders/MirrorShader.cjs.js +1 -0
- package/shaders/MirrorShader.js +16 -31
- package/shaders/NormalMapShader.cjs.js +1 -0
- package/shaders/NormalMapShader.js +23 -27
- package/shaders/ParallaxShader.cjs.js +1 -0
- package/shaders/ParallaxShader.js +48 -107
- package/shaders/PixelShader.cjs.js +1 -0
- package/shaders/PixelShader.js +16 -24
- package/shaders/RGBShiftShader.cjs.js +1 -0
- package/shaders/RGBShiftShader.js +22 -26
- package/shaders/SAOShader.cjs.js +1 -0
- package/shaders/SAOShader.js +48 -132
- package/shaders/SMAAShader.cjs.js +1 -0
- package/shaders/SMAAShader.js +135 -256
- package/shaders/SSAOShader.cjs.js +1 -0
- package/shaders/SSAOShader.js +81 -153
- package/shaders/SSRShader.cjs.js +1 -0
- package/shaders/SSRShader.js +87 -32
- package/shaders/SepiaShader.cjs.js +1 -0
- package/shaders/SepiaShader.js +15 -25
- package/shaders/SobelOperatorShader.cjs.js +1 -0
- package/shaders/SobelOperatorShader.js +29 -40
- package/shaders/SubsurfaceScatteringShader.cjs.js +1 -0
- package/shaders/SubsurfaceScatteringShader.js +39 -53
- package/shaders/TechnicolorShader.cjs.js +1 -0
- package/shaders/TechnicolorShader.js +13 -20
- package/shaders/ToneMapShader.cjs.js +1 -0
- package/shaders/ToneMapShader.js +28 -44
- package/shaders/ToonShader.cjs.js +1 -0
- package/shaders/ToonShader.js +96 -172
- package/shaders/TriangleBlurShader.cjs.js +1 -0
- package/shaders/TriangleBlurShader.js +23 -32
- package/shaders/UnpackDepthRGBAShader.cjs.js +1 -0
- package/shaders/UnpackDepthRGBAShader.js +14 -22
- package/shaders/VerticalBlurShader.cjs.js +1 -0
- package/shaders/VerticalBlurShader.js +23 -7
- package/shaders/VerticalTiltShiftShader.cjs.js +1 -0
- package/shaders/VerticalTiltShiftShader.js +21 -33
- package/shaders/VignetteShader.cjs.js +1 -0
- package/shaders/VignetteShader.js +28 -24
- package/shaders/VolumeShader.cjs.js +1 -0
- package/shaders/VolumeShader.js +77 -174
- package/shaders/WaterRefractionShader.cjs.js +1 -0
- package/shaders/WaterRefractionShader.js +6 -38
- package/shaders/types.cjs.js +1 -0
- package/shaders/types.js +1 -1
- package/textures/FlakesTexture.cjs.js +1 -0
- package/textures/FlakesTexture.js +10 -8
- package/types/helpers.cjs.js +1 -0
- package/types/helpers.js +2 -3
- package/types/shared.cjs.js +1 -0
- package/types/shared.js +1 -0
- package/types/utils.cjs.js +1 -0
- package/types/utils.js +1 -0
- package/utils/BufferGeometryUtils.cjs.js +1 -0
- package/utils/BufferGeometryUtils.js +325 -251
- package/utils/GeometryCompressionUtils.cjs.js +1 -0
- package/utils/GeometryCompressionUtils.js +239 -241
- package/utils/GeometryUtils.cjs.js +1 -0
- package/utils/GeometryUtils.js +94 -41
- package/utils/LDrawUtils.cjs.js +1 -0
- package/utils/LDrawUtils.d.ts +5 -0
- package/utils/LDrawUtils.js +144 -0
- package/utils/RoughnessMipmapper.cjs.js +1 -0
- package/utils/RoughnessMipmapper.js +82 -38
- package/utils/SceneUtils.cjs.js +1 -0
- package/utils/SceneUtils.js +20 -15
- package/utils/ShadowMapViewer.cjs.js +1 -0
- package/utils/ShadowMapViewer.js +95 -49
- package/utils/SkeletonUtils.cjs.js +1 -0
- package/utils/SkeletonUtils.js +165 -74
- package/utils/UVsDebug.cjs.js +1 -0
- package/utils/UVsDebug.js +62 -32
- package/utils/WorkerPool.cjs.js +1 -0
- package/utils/WorkerPool.js +33 -13
- package/webxr/ARButton.cjs.js +1 -0
- package/webxr/ARButton.js +98 -72
- package/webxr/OculusHandModel.cjs.js +1 -0
- package/webxr/OculusHandModel.js +37 -18
- package/webxr/OculusHandPointerModel.cjs.js +1 -0
- package/webxr/OculusHandPointerModel.js +80 -58
- package/webxr/Text2D.cjs.js +1 -0
- package/webxr/Text2D.js +19 -37
- package/webxr/VRButton.cjs.js +1 -0
- package/webxr/VRButton.js +90 -59
- package/webxr/XRControllerModelFactory.cjs.js +1 -0
- package/webxr/XRControllerModelFactory.js +116 -58
- package/webxr/XREstimatedLight.cjs.js +1 -0
- package/webxr/XREstimatedLight.js +66 -39
- package/webxr/XRHandMeshModel.cjs.js +1 -0
- package/webxr/XRHandMeshModel.js +29 -40
- package/webxr/XRHandModelFactory.cjs.js +1 -0
- package/webxr/XRHandModelFactory.js +31 -28
- package/webxr/XRHandPrimitiveModel.cjs.js +1 -0
- package/webxr/XRHandPrimitiveModel.js +27 -41
- package/animation/AnimationClipCreator.mjs +0 -57
- package/animation/CCDIKSolver.mjs +0 -223
- package/animation/MMDAnimationHelper.mjs +0 -514
- package/animation/MMDPhysics.mjs +0 -769
- package/cameras/CinematicCamera.mjs +0 -129
- package/controls/ArcballControls.mjs +0 -1737
- package/controls/DeviceOrientationControls.mjs +0 -74
- package/controls/DragControls.mjs +0 -172
- package/controls/FirstPersonControls.mjs +0 -220
- package/controls/FlyControls.mjs +0 -239
- package/controls/OrbitControls.mjs +0 -731
- package/controls/PointerLockControls.mjs +0 -88
- package/controls/TrackballControls.mjs +0 -481
- package/controls/TransformControls.mjs +0 -1068
- package/controls/experimental/CameraControls.mjs +0 -673
- package/csm/CSM.mjs +0 -244
- package/csm/CSMFrustum.mjs +0 -75
- package/csm/CSMHelper.mjs +0 -114
- package/csm/CSMShader.mjs +0 -251
- package/curves/CurveExtras.mjs +0 -224
- package/curves/NURBSCurve.mjs +0 -35
- package/curves/NURBSSurface.mjs +0 -28
- package/curves/NURBSUtils.mjs +0 -226
- package/deprecated/Geometry.mjs +0 -966
- package/effects/AnaglyphEffect.mjs +0 -120
- package/effects/AsciiEffect.mjs +0 -173
- package/effects/OutlineEffect.mjs +0 -295
- package/effects/ParallaxBarrierEffect.mjs +0 -64
- package/effects/PeppersGhostEffect.mjs +0 -85
- package/effects/StereoEffect.mjs +0 -32
- package/environments/RoomEnvironment.mjs +0 -78
- package/exporters/ColladaExporter.mjs +0 -299
- package/exporters/DRACOExporter.mjs +0 -132
- package/exporters/GLTFExporter.mjs +0 -1381
- package/exporters/MMDExporter.mjs +0 -102
- package/exporters/OBJExporter.mjs +0 -166
- package/exporters/PLYExporter.mjs +0 -278
- package/exporters/STLExporter.mjs +0 -129
- package/exporters/USDZExporter.mjs +0 -328
- package/geometries/BoxLineGeometry.mjs +0 -45
- package/geometries/ConvexGeometry.mjs +0 -29
- package/geometries/DecalGeometry.mjs +0 -184
- package/geometries/LightningStrike.mjs +0 -547
- package/geometries/ParametricGeometries.mjs +0 -129
- package/geometries/ParametricGeometry.mjs +0 -63
- package/geometries/RoundedBoxGeometry.mjs +0 -91
- package/geometries/TeapotGeometry.mjs +0 -1557
- package/geometries/TextGeometry.mjs +0 -23
- package/helpers/LightProbeHelper.mjs +0 -72
- package/helpers/PositionalAudioHelper.mjs +0 -68
- package/helpers/RectAreaLightHelper.mjs +0 -44
- package/helpers/VertexNormalsHelper.mjs +0 -54
- package/helpers/VertexTangentsHelper.mjs +0 -45
- package/index.mjs +0 -969
- package/interactive/SelectionBox.mjs +0 -137
- package/interactive/SelectionHelper.mjs +0 -54
- package/libs/MeshoptDecoder.mjs +0 -210
- package/libs/MotionControllers.mjs +0 -261
- package/lights/LightProbeGenerator.mjs +0 -145
- package/lights/RectAreaLightUniformsLib.mjs +0 -32842
- package/lines/Line2.mjs +0 -13
- package/lines/LineGeometry.mjs +0 -44
- package/lines/LineMaterial.mjs +0 -539
- package/lines/LineSegments2.mjs +0 -202
- package/lines/LineSegmentsGeometry.mjs +0 -124
- package/lines/Wireframe.mjs +0 -31
- package/lines/WireframeGeometry2.mjs +0 -13
- package/loaders/3DMLoader.mjs +0 -802
- package/loaders/3MFLoader.mjs +0 -837
- package/loaders/AMFLoader.mjs +0 -284
- package/loaders/AssimpLoader.mjs +0 -1396
- package/loaders/BVHLoader.mjs +0 -207
- package/loaders/BasisTextureLoader.mjs +0 -474
- package/loaders/ColladaLoader.mjs +0 -2403
- package/loaders/DDSLoader.mjs +0 -148
- package/loaders/DRACOLoader.mjs +0 -340
- package/loaders/EXRLoader.mjs +0 -1351
- package/loaders/FBXLoader.mjs +0 -2362
- package/loaders/FontLoader.mjs +0 -111
- package/loaders/GCodeLoader.mjs +0 -141
- package/loaders/GLTFLoader.mjs +0 -2316
- package/loaders/HDRCubeTextureLoader.mjs +0 -77
- package/loaders/KMZLoader.mjs +0 -75
- package/loaders/KTX2Loader.mjs +0 -427
- package/loaders/KTXLoader.mjs +0 -87
- package/loaders/LDrawLoader.mjs +0 -1409
- package/loaders/LUT3dlLoader.mjs +0 -100
- package/loaders/LUTCubeLoader.mjs +0 -104
- package/loaders/LWOLoader.mjs +0 -625
- package/loaders/LottieLoader.mjs +0 -47
- package/loaders/MD2Loader.mjs +0 -359
- package/loaders/MDDLoader.mjs +0 -58
- package/loaders/MMDLoader.mjs +0 -998
- package/loaders/MTLLoader.mjs +0 -280
- package/loaders/NRRDLoader.mjs +0 -401
- package/loaders/NodeMaterialLoader.mjs +0 -146
- package/loaders/OBJLoader.mjs +0 -487
- package/loaders/PCDLoader.mjs +0 -248
- package/loaders/PDBLoader.mjs +0 -246
- package/loaders/PLYLoader.mjs +0 -317
- package/loaders/PRWMLoader.mjs +0 -160
- package/loaders/PVRLoader.mjs +0 -131
- package/loaders/RGBELoader.mjs +0 -244
- package/loaders/RGBMLoader.mjs +0 -998
- package/loaders/STLLoader.mjs +0 -190
- package/loaders/SVGLoader.mjs +0 -1709
- package/loaders/TDSLoader.mjs +0 -480
- package/loaders/TGALoader.mjs +0 -285
- package/loaders/TTFLoader.mjs +0 -131
- package/loaders/TiltLoader.mjs +0 -373
- package/loaders/VOXLoader.mjs +0 -431
- package/loaders/VRMLLoader.mjs +0 -2093
- package/loaders/VRMLoader.mjs +0 -38
- package/loaders/VTKLoader.mjs +0 -646
- package/loaders/XLoader.mjs +0 -1258
- package/loaders/XYZLoader.mjs +0 -60
- package/loaders/lwo/IFFParser.mjs +0 -697
- package/loaders/lwo/LWO2Parser.mjs +0 -327
- package/loaders/lwo/LWO3Parser.mjs +0 -298
- package/math/Capsule.mjs +0 -100
- package/math/ColorConverter.mjs +0 -51
- package/math/ConvexHull.mjs +0 -574
- package/math/ImprovedNoise.mjs +0 -302
- package/math/Lut.mjs +0 -135
- package/math/MeshSurfaceSampler.mjs +0 -107
- package/math/OBB.mjs +0 -235
- package/math/Octree.mjs +0 -278
- package/math/SimplexNoise.mjs +0 -425
- package/misc/ConvexObjectBreaker.mjs +0 -292
- package/misc/GPUComputationRenderer.mjs +0 -171
- package/misc/Gyroscope.mjs +0 -35
- package/misc/MD2Character.mjs +0 -162
- package/misc/MD2CharacterComplex.mjs +0 -328
- package/misc/MorphAnimMesh.mjs +0 -40
- package/misc/MorphBlendMesh.mjs +0 -179
- package/misc/ProgressiveLightmap.mjs +0 -166
- package/misc/RollerCoaster.mjs +0 -346
- package/misc/TubePainter.mjs +0 -123
- package/misc/Volume.mjs +0 -244
- package/misc/VolumeSlice.mjs +0 -106
- package/misc/WebGL.mjs +0 -74
- package/modifiers/CurveModifier.mjs +0 -182
- package/modifiers/EdgeSplitModifier.mjs +0 -162
- package/modifiers/SimplifyModifier.mjs +0 -282
- package/modifiers/TessellateModifier.mjs +0 -206
- package/nodes/Nodes.mjs +0 -400
- package/nodes/ShaderNode.mjs +0 -408
- package/nodes/accessors/BufferNode.mjs +0 -15
- package/nodes/accessors/CameraNode.mjs +0 -44
- package/nodes/accessors/CubeTextureNode.mjs +0 -42
- package/nodes/accessors/MaterialNode.mjs +0 -71
- package/nodes/accessors/MaterialReferenceNode.mjs +0 -14
- package/nodes/accessors/ModelNode.mjs +0 -9
- package/nodes/accessors/ModelViewProjectionNode.mjs +0 -24
- package/nodes/accessors/NormalNode.mjs +0 -62
- package/nodes/accessors/Object3DNode.mjs +0 -76
- package/nodes/accessors/PointUVNode.mjs +0 -13
- package/nodes/accessors/PositionNode.mjs +0 -65
- package/nodes/accessors/ReferenceNode.mjs +0 -37
- package/nodes/accessors/ReflectNode.mjs +0 -43
- package/nodes/accessors/SkinningNode.mjs +0 -58
- package/nodes/accessors/TextureNode.mjs +0 -54
- package/nodes/accessors/UVNode.mjs +0 -23
- package/nodes/core/ArrayUniformNode.mjs +0 -14
- package/nodes/core/AttributeNode.mjs +0 -30
- package/nodes/core/BypassNode.mjs +0 -22
- package/nodes/core/CodeNode.mjs +0 -28
- package/nodes/core/ConstNode.mjs +0 -14
- package/nodes/core/ContextNode.mjs +0 -22
- package/nodes/core/ExpressionNode.mjs +0 -19
- package/nodes/core/FunctionCallNode.mjs +0 -37
- package/nodes/core/FunctionNode.mjs +0 -56
- package/nodes/core/InputNode.mjs +0 -38
- package/nodes/core/Node.mjs +0 -139
- package/nodes/core/NodeAttribute.mjs +0 -10
- package/nodes/core/NodeBuilder.mjs +0 -395
- package/nodes/core/NodeCode.mjs +0 -11
- package/nodes/core/NodeFrame.mjs +0 -35
- package/nodes/core/NodeFunctionInput.mjs +0 -13
- package/nodes/core/NodeKeywords.mjs +0 -44
- package/nodes/core/NodeUniform.mjs +0 -18
- package/nodes/core/NodeUtils.mjs +0 -57
- package/nodes/core/NodeVar.mjs +0 -10
- package/nodes/core/NodeVary.mjs +0 -10
- package/nodes/core/PropertyNode.mjs +0 -21
- package/nodes/core/TempNode.mjs +0 -25
- package/nodes/core/UniformNode.mjs +0 -23
- package/nodes/core/VarNode.mjs +0 -31
- package/nodes/core/VaryNode.mjs +0 -30
- package/nodes/core/constants.mjs +0 -24
- package/nodes/display/ColorSpaceNode.mjs +0 -63
- package/nodes/display/NormalMapNode.mjs +0 -54
- package/nodes/fog/FogNode.mjs +0 -15
- package/nodes/fog/FogRangeNode.mjs +0 -17
- package/nodes/functions/BSDFs.mjs +0 -64
- package/nodes/lights/LightContextNode.mjs +0 -35
- package/nodes/lights/LightNode.mjs +0 -58
- package/nodes/lights/LightsNode.mjs +0 -59
- package/nodes/loaders/NodeLoader.mjs +0 -66
- package/nodes/loaders/NodeMaterialLoader.mjs +0 -24
- package/nodes/loaders/NodeObjectLoader.mjs +0 -40
- package/nodes/materials/LineBasicNodeMaterial.mjs +0 -27
- package/nodes/materials/Materials.mjs +0 -28
- package/nodes/materials/MeshBasicNodeMaterial.mjs +0 -28
- package/nodes/materials/MeshStandardNodeMaterial.mjs +0 -41
- package/nodes/materials/NodeMaterial.mjs +0 -64
- package/nodes/materials/PointsNodeMaterial.mjs +0 -30
- package/nodes/math/CondNode.mjs +0 -38
- package/nodes/math/MathNode.mjs +0 -163
- package/nodes/math/OperatorNode.mjs +0 -103
- package/nodes/procedural/CheckerNode.mjs +0 -21
- package/nodes/utils/ArrayElementNode.mjs +0 -19
- package/nodes/utils/ConvertNode.mjs +0 -25
- package/nodes/utils/JoinNode.mjs +0 -26
- package/nodes/utils/MatcapUVNode.mjs +0 -16
- package/nodes/utils/OscNode.mjs +0 -50
- package/nodes/utils/SplitNode.mjs +0 -45
- package/nodes/utils/SpriteSheetUVNode.mjs +0 -40
- package/nodes/utils/TimerNode.mjs +0 -44
- package/objects/GroundProjectedEnv.mjs +0 -130
- package/objects/Lensflare.mjs +0 -262
- package/objects/LightningStorm.mjs +0 -110
- package/objects/MarchingCubes.mjs +0 -457
- package/objects/Reflector.mjs +0 -166
- package/objects/ReflectorForSSRPass.mjs +0 -247
- package/objects/ReflectorRTT.mjs +0 -10
- package/objects/Refractor.mjs +0 -178
- package/objects/ShadowMesh.mjs +0 -41
- package/objects/Sky.mjs +0 -124
- package/objects/Water.mjs +0 -235
- package/objects/Water2.mjs +0 -252
- package/offscreen/jank.mjs +0 -27
- package/offscreen/offscreen.mjs +0 -5
- package/offscreen/scene.mjs +0 -52
- package/physics/AmmoPhysics.mjs +0 -165
- package/postprocessing/AdaptiveToneMappingPass.mjs +0 -221
- package/postprocessing/AfterimagePass.mjs +0 -55
- package/postprocessing/BloomPass.mjs +0 -90
- package/postprocessing/BokehPass.mjs +0 -76
- package/postprocessing/ClearPass.mjs +0 -27
- package/postprocessing/CubeTexturePass.mjs +0 -49
- package/postprocessing/DotScreenPass.mjs +0 -40
- package/postprocessing/EffectComposer.mjs +0 -139
- package/postprocessing/FilmPass.mjs +0 -42
- package/postprocessing/GlitchPass.mjs +0 -75
- package/postprocessing/HalftonePass.mjs +0 -44
- package/postprocessing/LUTPass.mjs +0 -136
- package/postprocessing/MaskPass.mjs +0 -60
- package/postprocessing/OutlinePass.mjs +0 -438
- package/postprocessing/Pass.mjs +0 -37
- package/postprocessing/RenderPass.mjs +0 -48
- package/postprocessing/RenderPixelatedPass.mjs +0 -199
- package/postprocessing/SAOPass.mjs +0 -282
- package/postprocessing/SMAAPass.mjs +0 -112
- package/postprocessing/SSAARenderPass.mjs +0 -170
- package/postprocessing/SSAOPass.mjs +0 -265
- package/postprocessing/SSRPass.mjs +0 -432
- package/postprocessing/SavePass.mjs +0 -37
- package/postprocessing/ShaderPass.mjs +0 -39
- package/postprocessing/TAARenderPass.mjs +0 -88
- package/postprocessing/TexturePass.mjs +0 -39
- package/postprocessing/UnrealBloomPass.mjs +0 -220
- package/renderers/CSS2DRenderer.mjs +0 -112
- package/renderers/CSS3DRenderer.mjs +0 -133
- package/renderers/Projector.mjs +0 -511
- package/renderers/SVGRenderer.mjs +0 -306
- package/renderers/nodes/accessors/CameraNode.mjs +0 -63
- package/renderers/nodes/accessors/ModelNode.mjs +0 -61
- package/renderers/nodes/accessors/ModelViewProjectionNode.mjs +0 -21
- package/renderers/nodes/accessors/NormalNode.mjs +0 -61
- package/renderers/nodes/accessors/PositionNode.mjs +0 -30
- package/renderers/nodes/accessors/UVNode.mjs +0 -13
- package/renderers/nodes/core/AttributeNode.mjs +0 -35
- package/renderers/nodes/core/InputNode.mjs +0 -31
- package/renderers/nodes/core/Node.mjs +0 -34
- package/renderers/nodes/core/NodeAttribute.mjs +0 -10
- package/renderers/nodes/core/NodeBuilder.mjs +0 -243
- package/renderers/nodes/core/NodeFrame.mjs +0 -35
- package/renderers/nodes/core/NodeSlot.mjs +0 -10
- package/renderers/nodes/core/NodeUniform.mjs +0 -18
- package/renderers/nodes/core/NodeVary.mjs +0 -11
- package/renderers/nodes/core/VaryNode.mjs +0 -22
- package/renderers/nodes/core/constants.mjs +0 -22
- package/renderers/nodes/inputs/ColorNode.mjs +0 -11
- package/renderers/nodes/inputs/FloatNode.mjs +0 -11
- package/renderers/nodes/inputs/Matrix3Node.mjs +0 -12
- package/renderers/nodes/inputs/Matrix4Node.mjs +0 -12
- package/renderers/nodes/inputs/TextureNode.mjs +0 -20
- package/renderers/nodes/inputs/Vector2Node.mjs +0 -11
- package/renderers/nodes/inputs/Vector3Node.mjs +0 -12
- package/renderers/nodes/inputs/Vector4Node.mjs +0 -12
- package/renderers/nodes/math/MathNode.mjs +0 -55
- package/renderers/nodes/math/OperatorNode.mjs +0 -42
- package/renderers/nodes/utils/SwitchNode.mjs +0 -20
- package/renderers/nodes/utils/TimerNode.mjs +0 -14
- package/renderers/webgpu/WebGPU.mjs +0 -24
- package/renderers/webgpu/WebGPUAttributes.mjs +0 -69
- package/renderers/webgpu/WebGPUBackground.mjs +0 -61
- package/renderers/webgpu/WebGPUBinding.mjs +0 -14
- package/renderers/webgpu/WebGPUBindings.mjs +0 -155
- package/renderers/webgpu/WebGPUComputePipelines.mjs +0 -44
- package/renderers/webgpu/WebGPUGeometries.mjs +0 -41
- package/renderers/webgpu/WebGPUInfo.mjs +0 -46
- package/renderers/webgpu/WebGPUObjects.mjs +0 -25
- package/renderers/webgpu/WebGPUProperties.mjs +0 -22
- package/renderers/webgpu/WebGPURenderLists.mjs +0 -119
- package/renderers/webgpu/WebGPURenderPipelines.mjs +0 -545
- package/renderers/webgpu/WebGPURenderer.mjs +0 -574
- package/renderers/webgpu/WebGPUSampledTexture.mjs +0 -40
- package/renderers/webgpu/WebGPUSampler.mjs +0 -15
- package/renderers/webgpu/WebGPUStorageBuffer.mjs +0 -15
- package/renderers/webgpu/WebGPUTextureRenderer.mjs +0 -23
- package/renderers/webgpu/WebGPUTextureUtils.mjs +0 -98
- package/renderers/webgpu/WebGPUTextures.mjs +0 -484
- package/renderers/webgpu/WebGPUUniform.mjs +0 -81
- package/renderers/webgpu/WebGPUUniformsGroup.mjs +0 -176
- package/renderers/webgpu/constants.mjs +0 -230
- package/renderers/webgpu/nodes/ShaderLib.mjs +0 -42
- package/renderers/webgpu/nodes/WebGPUNodeBuilder.mjs +0 -165
- package/renderers/webgpu/nodes/WebGPUNodeUniform.mjs +0 -73
- package/renderers/webgpu/nodes/WebGPUNodeUniformsGroup.mjs +0 -15
- package/renderers/webgpu/nodes/WebGPUNodes.mjs +0 -40
- package/shaders/ACESFilmicToneMappingShader.mjs +0 -48
- package/shaders/AfterimageShader.mjs +0 -32
- package/shaders/BasicShader.mjs +0 -12
- package/shaders/BleachBypassShader.mjs +0 -35
- package/shaders/BlendShader.mjs +0 -30
- package/shaders/BokehShader.mjs +0 -106
- package/shaders/BokehShader2.mjs +0 -269
- package/shaders/BrightnessContrastShader.mjs +0 -32
- package/shaders/ColorCorrectionShader.mjs +0 -30
- package/shaders/ColorifyShader.mjs +0 -28
- package/shaders/ConvolutionShader.mjs +0 -55
- package/shaders/CopyShader.mjs +0 -25
- package/shaders/DOFMipMapShader.mjs +0 -32
- package/shaders/DepthLimitedBlurShader.mjs +0 -114
- package/shaders/DigitalGlitch.mjs +0 -78
- package/shaders/DotScreenShader.mjs +0 -39
- package/shaders/FXAAShader.mjs +0 -1098
- package/shaders/FilmShader.mjs +0 -42
- package/shaders/FocusShader.mjs +0 -55
- package/shaders/FreiChenShader.mjs +0 -61
- package/shaders/FresnelShader.mjs +0 -47
- package/shaders/GammaCorrectionShader.mjs +0 -23
- package/shaders/GodRaysShader.mjs +0 -146
- package/shaders/HalftoneShader.mjs +0 -212
- package/shaders/HorizontalBlurShader.mjs +0 -43
- package/shaders/HorizontalTiltShiftShader.mjs +0 -37
- package/shaders/HueSaturationShader.mjs +0 -41
- package/shaders/KaleidoShader.mjs +0 -34
- package/shaders/LuminosityHighPassShader.mjs +0 -37
- package/shaders/LuminosityShader.mjs +0 -25
- package/shaders/MirrorShader.mjs +0 -35
- package/shaders/NormalMapShader.mjs +0 -31
- package/shaders/ParallaxShader.mjs +0 -113
- package/shaders/PixelShader.mjs +0 -28
- package/shaders/RGBShiftShader.mjs +0 -30
- package/shaders/SAOShader.mjs +0 -144
- package/shaders/SMAAShader.mjs +0 -272
- package/shaders/SSAOShader.mjs +0 -172
- package/shaders/SSRShader.mjs +0 -324
- package/shaders/SepiaShader.mjs +0 -29
- package/shaders/SobelOperatorShader.mjs +0 -44
- package/shaders/SubsurfaceScatteringShader.mjs +0 -59
- package/shaders/TechnicolorShader.mjs +0 -24
- package/shaders/ToneMapShader.mjs +0 -48
- package/shaders/ToonShader.mjs +0 -188
- package/shaders/TriangleBlurShader.mjs +0 -36
- package/shaders/UnpackDepthRGBAShader.mjs +0 -26
- package/shaders/VerticalBlurShader.mjs +0 -44
- package/shaders/VerticalTiltShiftShader.mjs +0 -37
- package/shaders/VignetteShader.mjs +0 -28
- package/shaders/VolumeShader.mjs +0 -178
- package/shaders/WaterRefractionShader.mjs +0 -57
- package/textures/FlakesTexture.mjs +0 -30
- package/types/helpers.mjs +0 -4
- package/utils/BufferGeometryUtils.mjs +0 -570
- package/utils/GeometryCompressionUtils.mjs +0 -547
- package/utils/GeometryUtils.mjs +0 -108
- package/utils/RoughnessMipmapper.mjs +0 -213
- package/utils/SceneUtils.mjs +0 -36
- package/utils/ShadowMapViewer.mjs +0 -114
- package/utils/SkeletonUtils.mjs +0 -292
- package/utils/UVsDebug.mjs +0 -85
- package/utils/WorkerPool.mjs +0 -62
- package/webxr/ARButton.mjs +0 -119
- package/webxr/OculusHandModel.mjs +0 -71
- package/webxr/OculusHandPointerModel.mjs +0 -207
- package/webxr/Text2D.mjs +0 -31
- package/webxr/VRButton.mjs +0 -105
- package/webxr/XRControllerModelFactory.mjs +0 -146
- package/webxr/XREstimatedLight.mjs +0 -126
- package/webxr/XRHandMeshModel.mjs +0 -73
- package/webxr/XRHandModelFactory.mjs +0 -61
- package/webxr/XRHandPrimitiveModel.mjs +0 -68
package/loaders/VRMLLoader.js
CHANGED
|
@@ -1,732 +1,884 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class VRMLLoader extends THREE.Loader {
|
|
1
|
+
import { Loader, LoaderUtils, FileLoader, Vector3, Vector2, TextureLoader, Scene, Object3D, Group, SphereGeometry, MeshBasicMaterial, BackSide, Mesh, PointsMaterial, Points, LineBasicMaterial, LineSegments, FrontSide, DoubleSide, MeshPhongMaterial, Color, DataTexture, BufferGeometry, Float32BufferAttribute, BoxGeometry, ConeGeometry, CylinderGeometry, Quaternion, ShapeUtils, BufferAttribute, RepeatWrapping, ClampToEdgeWrapping } from 'three';
|
|
2
|
+
import { createToken, Lexer, CstParser } from 'chevrotain';
|
|
3
|
+
|
|
4
|
+
class VRMLLoader extends Loader {
|
|
6
5
|
constructor(manager) {
|
|
7
6
|
super(manager);
|
|
8
7
|
}
|
|
8
|
+
|
|
9
9
|
load(url, onLoad, onProgress, onError) {
|
|
10
10
|
const scope = this;
|
|
11
|
-
const path = scope.path ===
|
|
12
|
-
const loader = new
|
|
11
|
+
const path = scope.path === '' ? LoaderUtils.extractUrlBase(url) : scope.path;
|
|
12
|
+
const loader = new FileLoader(scope.manager);
|
|
13
13
|
loader.setPath(scope.path);
|
|
14
14
|
loader.setRequestHeader(scope.requestHeader);
|
|
15
15
|
loader.setWithCredentials(scope.withCredentials);
|
|
16
|
-
loader.load(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
} else {
|
|
25
|
-
console.error(e);
|
|
26
|
-
}
|
|
27
|
-
scope.manager.itemError(url);
|
|
16
|
+
loader.load(url, function (text) {
|
|
17
|
+
try {
|
|
18
|
+
onLoad(scope.parse(text, path));
|
|
19
|
+
} catch (e) {
|
|
20
|
+
if (onError) {
|
|
21
|
+
onError(e);
|
|
22
|
+
} else {
|
|
23
|
+
console.error(e);
|
|
28
24
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
);
|
|
25
|
+
|
|
26
|
+
scope.manager.itemError(url);
|
|
27
|
+
}
|
|
28
|
+
}, onProgress, onError);
|
|
33
29
|
}
|
|
30
|
+
|
|
34
31
|
parse(data, path) {
|
|
35
32
|
const nodeMap = {};
|
|
36
|
-
|
|
33
|
+
|
|
34
|
+
function generateVRMLTree(data) {
|
|
35
|
+
// create lexer, parser and visitor
|
|
37
36
|
const tokenData = createTokens();
|
|
38
37
|
const lexer = new VRMLLexer(tokenData.tokens);
|
|
39
38
|
const parser = new VRMLParser(tokenData.tokenVocabulary);
|
|
40
|
-
const visitor = createVisitor(parser.getBaseCstVisitorConstructor());
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
const visitor = createVisitor(parser.getBaseCstVisitorConstructor()); // lexing
|
|
40
|
+
|
|
41
|
+
const lexingResult = lexer.lex(data);
|
|
42
|
+
parser.input = lexingResult.tokens; // parsing
|
|
43
|
+
|
|
43
44
|
const cstOutput = parser.vrml();
|
|
45
|
+
|
|
44
46
|
if (parser.errors.length > 0) {
|
|
45
47
|
console.error(parser.errors);
|
|
46
|
-
throw Error(
|
|
47
|
-
}
|
|
48
|
+
throw Error('THREE.VRMLLoader: Parsing errors detected.');
|
|
49
|
+
} // actions
|
|
50
|
+
|
|
51
|
+
|
|
48
52
|
const ast = visitor.visit(cstOutput);
|
|
49
53
|
return ast;
|
|
50
54
|
}
|
|
55
|
+
|
|
51
56
|
function createTokens() {
|
|
52
|
-
|
|
53
|
-
|
|
57
|
+
// from http://gun.teipir.gr/VRML-amgem/spec/part1/concepts.html#SyntaxBasics
|
|
58
|
+
const RouteIdentifier = createToken({
|
|
59
|
+
name: 'RouteIdentifier',
|
|
54
60
|
pattern: /[^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d][^\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]*[\.][^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d][^\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]*/
|
|
55
61
|
});
|
|
56
|
-
const Identifier =
|
|
57
|
-
name:
|
|
62
|
+
const Identifier = createToken({
|
|
63
|
+
name: 'Identifier',
|
|
58
64
|
pattern: /[^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d][^\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]*/,
|
|
59
65
|
longer_alt: RouteIdentifier
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
"SpotLight",
|
|
77
|
-
"WorldInfo",
|
|
78
|
-
"CylinderSensor",
|
|
79
|
-
"PlaneSensor",
|
|
80
|
-
"ProximitySensor",
|
|
81
|
-
"SphereSensor",
|
|
82
|
-
"TimeSensor",
|
|
83
|
-
"TouchSensor",
|
|
84
|
-
"VisibilitySensor",
|
|
85
|
-
"Box",
|
|
86
|
-
"Cone",
|
|
87
|
-
"Cylinder",
|
|
88
|
-
"ElevationGrid",
|
|
89
|
-
"Extrusion",
|
|
90
|
-
"IndexedFaceSet",
|
|
91
|
-
"IndexedLineSet",
|
|
92
|
-
"PointSet",
|
|
93
|
-
"Sphere",
|
|
94
|
-
"Color",
|
|
95
|
-
"Coordinate",
|
|
96
|
-
"Normal",
|
|
97
|
-
"TextureCoordinate",
|
|
98
|
-
"Appearance",
|
|
99
|
-
"FontStyle",
|
|
100
|
-
"ImageTexture",
|
|
101
|
-
"Material",
|
|
102
|
-
"MovieTexture",
|
|
103
|
-
"PixelTexture",
|
|
104
|
-
"TextureTransform",
|
|
105
|
-
"ColorInterpolator",
|
|
106
|
-
"CoordinateInterpolator",
|
|
107
|
-
"NormalInterpolator",
|
|
108
|
-
"OrientationInterpolator",
|
|
109
|
-
"PositionInterpolator",
|
|
110
|
-
"ScalarInterpolator",
|
|
111
|
-
"Background",
|
|
112
|
-
"Fog",
|
|
113
|
-
"NavigationInfo",
|
|
114
|
-
"Viewpoint",
|
|
115
|
-
"Text"
|
|
116
|
-
];
|
|
117
|
-
const Version = chevrotain.createToken({
|
|
118
|
-
name: "Version",
|
|
66
|
+
}); // from http://gun.teipir.gr/VRML-amgem/spec/part1/nodesRef.html
|
|
67
|
+
|
|
68
|
+
const nodeTypes = ['Anchor', 'Billboard', 'Collision', 'Group', 'Transform', // grouping nodes
|
|
69
|
+
'Inline', 'LOD', 'Switch', // special groups
|
|
70
|
+
'AudioClip', 'DirectionalLight', 'PointLight', 'Script', 'Shape', 'Sound', 'SpotLight', 'WorldInfo', // common nodes
|
|
71
|
+
'CylinderSensor', 'PlaneSensor', 'ProximitySensor', 'SphereSensor', 'TimeSensor', 'TouchSensor', 'VisibilitySensor', // sensors
|
|
72
|
+
'Box', 'Cone', 'Cylinder', 'ElevationGrid', 'Extrusion', 'IndexedFaceSet', 'IndexedLineSet', 'PointSet', 'Sphere', // geometries
|
|
73
|
+
'Color', 'Coordinate', 'Normal', 'TextureCoordinate', // geometric properties
|
|
74
|
+
'Appearance', 'FontStyle', 'ImageTexture', 'Material', 'MovieTexture', 'PixelTexture', 'TextureTransform', // appearance
|
|
75
|
+
'ColorInterpolator', 'CoordinateInterpolator', 'NormalInterpolator', 'OrientationInterpolator', 'PositionInterpolator', 'ScalarInterpolator', // interpolators
|
|
76
|
+
'Background', 'Fog', 'NavigationInfo', 'Viewpoint', // bindable nodes
|
|
77
|
+
'Text' // Text must be placed at the end of the regex so there are no matches for TextureTransform and TextureCoordinate
|
|
78
|
+
]; //
|
|
79
|
+
|
|
80
|
+
const Version = createToken({
|
|
81
|
+
name: 'Version',
|
|
119
82
|
pattern: /#VRML.*/,
|
|
120
83
|
longer_alt: Identifier
|
|
121
84
|
});
|
|
122
|
-
const NodeName =
|
|
123
|
-
name:
|
|
124
|
-
pattern: new RegExp(nodeTypes.join(
|
|
85
|
+
const NodeName = createToken({
|
|
86
|
+
name: 'NodeName',
|
|
87
|
+
pattern: new RegExp(nodeTypes.join('|')),
|
|
125
88
|
longer_alt: Identifier
|
|
126
89
|
});
|
|
127
|
-
const DEF =
|
|
128
|
-
name:
|
|
90
|
+
const DEF = createToken({
|
|
91
|
+
name: 'DEF',
|
|
129
92
|
pattern: /DEF/,
|
|
130
93
|
longer_alt: Identifier
|
|
131
94
|
});
|
|
132
|
-
const USE =
|
|
133
|
-
name:
|
|
95
|
+
const USE = createToken({
|
|
96
|
+
name: 'USE',
|
|
134
97
|
pattern: /USE/,
|
|
135
98
|
longer_alt: Identifier
|
|
136
99
|
});
|
|
137
|
-
const ROUTE =
|
|
138
|
-
name:
|
|
100
|
+
const ROUTE = createToken({
|
|
101
|
+
name: 'ROUTE',
|
|
139
102
|
pattern: /ROUTE/,
|
|
140
103
|
longer_alt: Identifier
|
|
141
104
|
});
|
|
142
|
-
const TO =
|
|
143
|
-
name:
|
|
105
|
+
const TO = createToken({
|
|
106
|
+
name: 'TO',
|
|
144
107
|
pattern: /TO/,
|
|
145
108
|
longer_alt: Identifier
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
|
|
109
|
+
}); //
|
|
110
|
+
|
|
111
|
+
const StringLiteral = createToken({
|
|
112
|
+
name: 'StringLiteral',
|
|
149
113
|
pattern: /"(?:[^\\"\n\r]|\\[bfnrtv"\\/]|\\u[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])*"/
|
|
150
114
|
});
|
|
151
|
-
const HexLiteral =
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
115
|
+
const HexLiteral = createToken({
|
|
116
|
+
name: 'HexLiteral',
|
|
117
|
+
pattern: /0[xX][0-9a-fA-F]+/
|
|
118
|
+
});
|
|
119
|
+
const NumberLiteral = createToken({
|
|
120
|
+
name: 'NumberLiteral',
|
|
121
|
+
pattern: /[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?/
|
|
122
|
+
});
|
|
123
|
+
const TrueLiteral = createToken({
|
|
124
|
+
name: 'TrueLiteral',
|
|
125
|
+
pattern: /TRUE/
|
|
126
|
+
});
|
|
127
|
+
const FalseLiteral = createToken({
|
|
128
|
+
name: 'FalseLiteral',
|
|
129
|
+
pattern: /FALSE/
|
|
130
|
+
});
|
|
131
|
+
const NullLiteral = createToken({
|
|
132
|
+
name: 'NullLiteral',
|
|
133
|
+
pattern: /NULL/
|
|
164
134
|
});
|
|
165
|
-
const
|
|
166
|
-
name:
|
|
135
|
+
const LSquare = createToken({
|
|
136
|
+
name: 'LSquare',
|
|
137
|
+
pattern: /\[/
|
|
138
|
+
});
|
|
139
|
+
const RSquare = createToken({
|
|
140
|
+
name: 'RSquare',
|
|
141
|
+
pattern: /]/
|
|
142
|
+
});
|
|
143
|
+
const LCurly = createToken({
|
|
144
|
+
name: 'LCurly',
|
|
145
|
+
pattern: /{/
|
|
146
|
+
});
|
|
147
|
+
const RCurly = createToken({
|
|
148
|
+
name: 'RCurly',
|
|
149
|
+
pattern: /}/
|
|
150
|
+
});
|
|
151
|
+
const Comment = createToken({
|
|
152
|
+
name: 'Comment',
|
|
153
|
+
pattern: /#.*/,
|
|
154
|
+
group: Lexer.SKIPPED // eslint-disable-line no-undef
|
|
155
|
+
|
|
156
|
+
}); // commas, blanks, tabs, newlines and carriage returns are whitespace characters wherever they appear outside of string fields
|
|
157
|
+
|
|
158
|
+
const WhiteSpace = createToken({
|
|
159
|
+
name: 'WhiteSpace',
|
|
167
160
|
pattern: /[ ,\s]/,
|
|
168
|
-
group:
|
|
161
|
+
group: Lexer.SKIPPED // eslint-disable-line no-undef
|
|
162
|
+
|
|
169
163
|
});
|
|
170
|
-
const tokens = [
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
DEF,
|
|
174
|
-
USE,
|
|
175
|
-
ROUTE,
|
|
176
|
-
TO,
|
|
177
|
-
TrueLiteral,
|
|
178
|
-
FalseLiteral,
|
|
179
|
-
NullLiteral,
|
|
180
|
-
Version,
|
|
181
|
-
Identifier,
|
|
182
|
-
RouteIdentifier,
|
|
183
|
-
StringLiteral,
|
|
184
|
-
HexLiteral,
|
|
185
|
-
NumberLiteral,
|
|
186
|
-
LSquare,
|
|
187
|
-
RSquare,
|
|
188
|
-
LCurly,
|
|
189
|
-
RCurly,
|
|
190
|
-
Comment
|
|
191
|
-
];
|
|
164
|
+
const tokens = [WhiteSpace, // keywords appear before the Identifier
|
|
165
|
+
NodeName, DEF, USE, ROUTE, TO, TrueLiteral, FalseLiteral, NullLiteral, // the Identifier must appear after the keywords because all keywords are valid identifiers
|
|
166
|
+
Version, Identifier, RouteIdentifier, StringLiteral, HexLiteral, NumberLiteral, LSquare, RSquare, LCurly, RCurly, Comment];
|
|
192
167
|
const tokenVocabulary = {};
|
|
168
|
+
|
|
193
169
|
for (let i = 0, l = tokens.length; i < l; i++) {
|
|
194
170
|
const token = tokens[i];
|
|
195
171
|
tokenVocabulary[token.name] = token;
|
|
196
172
|
}
|
|
197
|
-
|
|
173
|
+
|
|
174
|
+
return {
|
|
175
|
+
tokens: tokens,
|
|
176
|
+
tokenVocabulary: tokenVocabulary
|
|
177
|
+
};
|
|
198
178
|
}
|
|
179
|
+
|
|
199
180
|
function createVisitor(BaseVRMLVisitor) {
|
|
181
|
+
// the visitor is created dynmaically based on the given base class
|
|
200
182
|
function VRMLToASTVisitor() {
|
|
201
183
|
BaseVRMLVisitor.call(this);
|
|
202
184
|
this.validateVisitor();
|
|
203
185
|
}
|
|
186
|
+
|
|
204
187
|
VRMLToASTVisitor.prototype = Object.assign(Object.create(BaseVRMLVisitor.prototype), {
|
|
205
188
|
constructor: VRMLToASTVisitor,
|
|
206
|
-
vrml: function(ctx) {
|
|
207
|
-
const
|
|
189
|
+
vrml: function (ctx) {
|
|
190
|
+
const data = {
|
|
208
191
|
version: this.visit(ctx.version),
|
|
209
192
|
nodes: [],
|
|
210
193
|
routes: []
|
|
211
194
|
};
|
|
195
|
+
|
|
212
196
|
for (let i = 0, l = ctx.node.length; i < l; i++) {
|
|
213
197
|
const node = ctx.node[i];
|
|
214
|
-
|
|
198
|
+
data.nodes.push(this.visit(node));
|
|
215
199
|
}
|
|
200
|
+
|
|
216
201
|
if (ctx.route) {
|
|
217
202
|
for (let i = 0, l = ctx.route.length; i < l; i++) {
|
|
218
203
|
const route = ctx.route[i];
|
|
219
|
-
|
|
204
|
+
data.routes.push(this.visit(route));
|
|
220
205
|
}
|
|
221
206
|
}
|
|
222
|
-
|
|
207
|
+
|
|
208
|
+
return data;
|
|
223
209
|
},
|
|
224
|
-
version: function(ctx) {
|
|
210
|
+
version: function (ctx) {
|
|
225
211
|
return ctx.Version[0].image;
|
|
226
212
|
},
|
|
227
|
-
node: function(ctx) {
|
|
228
|
-
const
|
|
213
|
+
node: function (ctx) {
|
|
214
|
+
const data = {
|
|
229
215
|
name: ctx.NodeName[0].image,
|
|
230
216
|
fields: []
|
|
231
217
|
};
|
|
218
|
+
|
|
232
219
|
if (ctx.field) {
|
|
233
220
|
for (let i = 0, l = ctx.field.length; i < l; i++) {
|
|
234
221
|
const field = ctx.field[i];
|
|
235
|
-
|
|
222
|
+
data.fields.push(this.visit(field));
|
|
236
223
|
}
|
|
237
|
-
}
|
|
224
|
+
} // DEF
|
|
225
|
+
|
|
226
|
+
|
|
238
227
|
if (ctx.def) {
|
|
239
|
-
|
|
228
|
+
data.DEF = this.visit(ctx.def[0]);
|
|
240
229
|
}
|
|
241
|
-
|
|
230
|
+
|
|
231
|
+
return data;
|
|
242
232
|
},
|
|
243
|
-
field: function(ctx) {
|
|
244
|
-
const
|
|
233
|
+
field: function (ctx) {
|
|
234
|
+
const data = {
|
|
245
235
|
name: ctx.Identifier[0].image,
|
|
246
236
|
type: null,
|
|
247
237
|
values: null
|
|
248
238
|
};
|
|
249
|
-
let result;
|
|
239
|
+
let result; // SFValue
|
|
240
|
+
|
|
250
241
|
if (ctx.singleFieldValue) {
|
|
251
242
|
result = this.visit(ctx.singleFieldValue[0]);
|
|
252
|
-
}
|
|
243
|
+
} // MFValue
|
|
244
|
+
|
|
245
|
+
|
|
253
246
|
if (ctx.multiFieldValue) {
|
|
254
247
|
result = this.visit(ctx.multiFieldValue[0]);
|
|
255
248
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
249
|
+
|
|
250
|
+
data.type = result.type;
|
|
251
|
+
data.values = result.values;
|
|
252
|
+
return data;
|
|
259
253
|
},
|
|
260
|
-
def: function(ctx) {
|
|
254
|
+
def: function (ctx) {
|
|
261
255
|
return (ctx.Identifier || ctx.NodeName)[0].image;
|
|
262
256
|
},
|
|
263
|
-
use: function(ctx) {
|
|
264
|
-
return {
|
|
257
|
+
use: function (ctx) {
|
|
258
|
+
return {
|
|
259
|
+
USE: (ctx.Identifier || ctx.NodeName)[0].image
|
|
260
|
+
};
|
|
265
261
|
},
|
|
266
|
-
singleFieldValue: function(ctx) {
|
|
262
|
+
singleFieldValue: function (ctx) {
|
|
267
263
|
return processField(this, ctx);
|
|
268
264
|
},
|
|
269
|
-
multiFieldValue: function(ctx) {
|
|
265
|
+
multiFieldValue: function (ctx) {
|
|
270
266
|
return processField(this, ctx);
|
|
271
267
|
},
|
|
272
|
-
route: function(ctx) {
|
|
273
|
-
const
|
|
268
|
+
route: function (ctx) {
|
|
269
|
+
const data = {
|
|
274
270
|
FROM: ctx.RouteIdentifier[0].image,
|
|
275
271
|
TO: ctx.RouteIdentifier[1].image
|
|
276
272
|
};
|
|
277
|
-
return
|
|
273
|
+
return data;
|
|
278
274
|
}
|
|
279
275
|
});
|
|
276
|
+
|
|
280
277
|
function processField(scope, ctx) {
|
|
281
278
|
const field = {
|
|
282
279
|
type: null,
|
|
283
280
|
values: []
|
|
284
281
|
};
|
|
282
|
+
|
|
285
283
|
if (ctx.node) {
|
|
286
|
-
field.type =
|
|
284
|
+
field.type = 'node';
|
|
285
|
+
|
|
287
286
|
for (let i = 0, l = ctx.node.length; i < l; i++) {
|
|
288
287
|
const node = ctx.node[i];
|
|
289
288
|
field.values.push(scope.visit(node));
|
|
290
289
|
}
|
|
291
290
|
}
|
|
291
|
+
|
|
292
292
|
if (ctx.use) {
|
|
293
|
-
field.type =
|
|
293
|
+
field.type = 'use';
|
|
294
|
+
|
|
294
295
|
for (let i = 0, l = ctx.use.length; i < l; i++) {
|
|
295
296
|
const use = ctx.use[i];
|
|
296
297
|
field.values.push(scope.visit(use));
|
|
297
298
|
}
|
|
298
299
|
}
|
|
300
|
+
|
|
299
301
|
if (ctx.StringLiteral) {
|
|
300
|
-
field.type =
|
|
302
|
+
field.type = 'string';
|
|
303
|
+
|
|
301
304
|
for (let i = 0, l = ctx.StringLiteral.length; i < l; i++) {
|
|
302
305
|
const stringLiteral = ctx.StringLiteral[i];
|
|
303
|
-
field.values.push(stringLiteral.image.replace(/'|"/g,
|
|
306
|
+
field.values.push(stringLiteral.image.replace(/'|"/g, ''));
|
|
304
307
|
}
|
|
305
308
|
}
|
|
309
|
+
|
|
306
310
|
if (ctx.NumberLiteral) {
|
|
307
|
-
field.type =
|
|
311
|
+
field.type = 'number';
|
|
312
|
+
|
|
308
313
|
for (let i = 0, l = ctx.NumberLiteral.length; i < l; i++) {
|
|
309
314
|
const numberLiteral = ctx.NumberLiteral[i];
|
|
310
315
|
field.values.push(parseFloat(numberLiteral.image));
|
|
311
316
|
}
|
|
312
317
|
}
|
|
318
|
+
|
|
313
319
|
if (ctx.HexLiteral) {
|
|
314
|
-
field.type =
|
|
320
|
+
field.type = 'hex';
|
|
321
|
+
|
|
315
322
|
for (let i = 0, l = ctx.HexLiteral.length; i < l; i++) {
|
|
316
323
|
const hexLiteral = ctx.HexLiteral[i];
|
|
317
324
|
field.values.push(hexLiteral.image);
|
|
318
325
|
}
|
|
319
326
|
}
|
|
327
|
+
|
|
320
328
|
if (ctx.TrueLiteral) {
|
|
321
|
-
field.type =
|
|
329
|
+
field.type = 'boolean';
|
|
330
|
+
|
|
322
331
|
for (let i = 0, l = ctx.TrueLiteral.length; i < l; i++) {
|
|
323
332
|
const trueLiteral = ctx.TrueLiteral[i];
|
|
324
|
-
if (trueLiteral.image ===
|
|
325
|
-
field.values.push(true);
|
|
333
|
+
if (trueLiteral.image === 'TRUE') field.values.push(true);
|
|
326
334
|
}
|
|
327
335
|
}
|
|
336
|
+
|
|
328
337
|
if (ctx.FalseLiteral) {
|
|
329
|
-
field.type =
|
|
338
|
+
field.type = 'boolean';
|
|
339
|
+
|
|
330
340
|
for (let i = 0, l = ctx.FalseLiteral.length; i < l; i++) {
|
|
331
341
|
const falseLiteral = ctx.FalseLiteral[i];
|
|
332
|
-
if (falseLiteral.image ===
|
|
333
|
-
field.values.push(false);
|
|
342
|
+
if (falseLiteral.image === 'FALSE') field.values.push(false);
|
|
334
343
|
}
|
|
335
344
|
}
|
|
345
|
+
|
|
336
346
|
if (ctx.NullLiteral) {
|
|
337
|
-
field.type =
|
|
338
|
-
ctx.NullLiteral.forEach(function() {
|
|
347
|
+
field.type = 'null';
|
|
348
|
+
ctx.NullLiteral.forEach(function () {
|
|
339
349
|
field.values.push(null);
|
|
340
350
|
});
|
|
341
351
|
}
|
|
352
|
+
|
|
342
353
|
return field;
|
|
343
354
|
}
|
|
355
|
+
|
|
344
356
|
return new VRMLToASTVisitor();
|
|
345
357
|
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
358
|
+
|
|
359
|
+
function parseTree(tree) {
|
|
360
|
+
// console.log( JSON.stringify( tree, null, 2 ) );
|
|
361
|
+
const nodes = tree.nodes;
|
|
362
|
+
const scene = new Scene(); // first iteration: build nodemap based on DEF statements
|
|
363
|
+
|
|
349
364
|
for (let i = 0, l = nodes.length; i < l; i++) {
|
|
350
365
|
const node = nodes[i];
|
|
351
366
|
buildNodeMap(node);
|
|
352
|
-
}
|
|
367
|
+
} // second iteration: build nodes
|
|
368
|
+
|
|
369
|
+
|
|
353
370
|
for (let i = 0, l = nodes.length; i < l; i++) {
|
|
354
371
|
const node = nodes[i];
|
|
355
372
|
const object = getNode(node);
|
|
356
|
-
if (object instanceof
|
|
357
|
-
|
|
358
|
-
if (node.name === "WorldInfo")
|
|
359
|
-
scene2.userData.worldInfo = object;
|
|
373
|
+
if (object instanceof Object3D) scene.add(object);
|
|
374
|
+
if (node.name === 'WorldInfo') scene.userData.worldInfo = object;
|
|
360
375
|
}
|
|
361
|
-
|
|
376
|
+
|
|
377
|
+
return scene;
|
|
362
378
|
}
|
|
379
|
+
|
|
363
380
|
function buildNodeMap(node) {
|
|
364
381
|
if (node.DEF) {
|
|
365
382
|
nodeMap[node.DEF] = node;
|
|
366
383
|
}
|
|
384
|
+
|
|
367
385
|
const fields = node.fields;
|
|
386
|
+
|
|
368
387
|
for (let i = 0, l = fields.length; i < l; i++) {
|
|
369
388
|
const field = fields[i];
|
|
370
|
-
|
|
389
|
+
|
|
390
|
+
if (field.type === 'node') {
|
|
371
391
|
const fieldValues = field.values;
|
|
392
|
+
|
|
372
393
|
for (let j = 0, jl = fieldValues.length; j < jl; j++) {
|
|
373
394
|
buildNodeMap(fieldValues[j]);
|
|
374
395
|
}
|
|
375
396
|
}
|
|
376
397
|
}
|
|
377
398
|
}
|
|
399
|
+
|
|
378
400
|
function getNode(node) {
|
|
401
|
+
// handle case where a node refers to a different one
|
|
379
402
|
if (node.USE) {
|
|
380
403
|
return resolveUSE(node.USE);
|
|
381
404
|
}
|
|
382
|
-
|
|
383
|
-
|
|
405
|
+
|
|
406
|
+
if (node.build !== undefined) return node.build;
|
|
384
407
|
node.build = buildNode(node);
|
|
385
408
|
return node.build;
|
|
386
|
-
}
|
|
409
|
+
} // node builder
|
|
410
|
+
|
|
411
|
+
|
|
387
412
|
function buildNode(node) {
|
|
388
413
|
const nodeName = node.name;
|
|
389
414
|
let build;
|
|
415
|
+
|
|
390
416
|
switch (nodeName) {
|
|
391
|
-
case
|
|
392
|
-
case
|
|
393
|
-
case
|
|
417
|
+
case 'Group':
|
|
418
|
+
case 'Transform':
|
|
419
|
+
case 'Collision':
|
|
394
420
|
build = buildGroupingNode(node);
|
|
395
421
|
break;
|
|
396
|
-
|
|
422
|
+
|
|
423
|
+
case 'Background':
|
|
397
424
|
build = buildBackgroundNode(node);
|
|
398
425
|
break;
|
|
399
|
-
|
|
426
|
+
|
|
427
|
+
case 'Shape':
|
|
400
428
|
build = buildShapeNode(node);
|
|
401
429
|
break;
|
|
402
|
-
|
|
430
|
+
|
|
431
|
+
case 'Appearance':
|
|
403
432
|
build = buildAppearanceNode(node);
|
|
404
433
|
break;
|
|
405
|
-
|
|
434
|
+
|
|
435
|
+
case 'Material':
|
|
406
436
|
build = buildMaterialNode(node);
|
|
407
437
|
break;
|
|
408
|
-
|
|
438
|
+
|
|
439
|
+
case 'ImageTexture':
|
|
409
440
|
build = buildImageTextureNode(node);
|
|
410
441
|
break;
|
|
411
|
-
|
|
442
|
+
|
|
443
|
+
case 'PixelTexture':
|
|
412
444
|
build = buildPixelTextureNode(node);
|
|
413
445
|
break;
|
|
414
|
-
|
|
446
|
+
|
|
447
|
+
case 'TextureTransform':
|
|
415
448
|
build = buildTextureTransformNode(node);
|
|
416
449
|
break;
|
|
417
|
-
|
|
450
|
+
|
|
451
|
+
case 'IndexedFaceSet':
|
|
418
452
|
build = buildIndexedFaceSetNode(node);
|
|
419
453
|
break;
|
|
420
|
-
|
|
454
|
+
|
|
455
|
+
case 'IndexedLineSet':
|
|
421
456
|
build = buildIndexedLineSetNode(node);
|
|
422
457
|
break;
|
|
423
|
-
|
|
458
|
+
|
|
459
|
+
case 'PointSet':
|
|
424
460
|
build = buildPointSetNode(node);
|
|
425
461
|
break;
|
|
426
|
-
|
|
462
|
+
|
|
463
|
+
case 'Box':
|
|
427
464
|
build = buildBoxNode(node);
|
|
428
465
|
break;
|
|
429
|
-
|
|
466
|
+
|
|
467
|
+
case 'Cone':
|
|
430
468
|
build = buildConeNode(node);
|
|
431
469
|
break;
|
|
432
|
-
|
|
470
|
+
|
|
471
|
+
case 'Cylinder':
|
|
433
472
|
build = buildCylinderNode(node);
|
|
434
473
|
break;
|
|
435
|
-
|
|
474
|
+
|
|
475
|
+
case 'Sphere':
|
|
436
476
|
build = buildSphereNode(node);
|
|
437
477
|
break;
|
|
438
|
-
|
|
478
|
+
|
|
479
|
+
case 'ElevationGrid':
|
|
439
480
|
build = buildElevationGridNode(node);
|
|
440
481
|
break;
|
|
441
|
-
|
|
482
|
+
|
|
483
|
+
case 'Extrusion':
|
|
442
484
|
build = buildExtrusionNode(node);
|
|
443
485
|
break;
|
|
444
|
-
|
|
445
|
-
case
|
|
446
|
-
case
|
|
447
|
-
case
|
|
486
|
+
|
|
487
|
+
case 'Color':
|
|
488
|
+
case 'Coordinate':
|
|
489
|
+
case 'Normal':
|
|
490
|
+
case 'TextureCoordinate':
|
|
448
491
|
build = buildGeometricNode(node);
|
|
449
492
|
break;
|
|
450
|
-
|
|
493
|
+
|
|
494
|
+
case 'WorldInfo':
|
|
451
495
|
build = buildWorldInfoNode(node);
|
|
452
496
|
break;
|
|
453
|
-
|
|
454
|
-
case
|
|
455
|
-
case
|
|
456
|
-
case
|
|
457
|
-
case
|
|
458
|
-
case
|
|
459
|
-
case
|
|
460
|
-
case
|
|
461
|
-
case
|
|
462
|
-
case
|
|
463
|
-
case
|
|
464
|
-
case
|
|
465
|
-
case
|
|
466
|
-
case
|
|
467
|
-
case
|
|
468
|
-
case
|
|
469
|
-
case
|
|
470
|
-
case
|
|
471
|
-
case
|
|
472
|
-
case
|
|
473
|
-
case
|
|
474
|
-
case
|
|
475
|
-
case
|
|
476
|
-
case
|
|
477
|
-
case
|
|
478
|
-
case
|
|
479
|
-
case
|
|
480
|
-
case
|
|
481
|
-
case
|
|
482
|
-
case
|
|
497
|
+
|
|
498
|
+
case 'Anchor':
|
|
499
|
+
case 'Billboard':
|
|
500
|
+
case 'Inline':
|
|
501
|
+
case 'LOD':
|
|
502
|
+
case 'Switch':
|
|
503
|
+
case 'AudioClip':
|
|
504
|
+
case 'DirectionalLight':
|
|
505
|
+
case 'PointLight':
|
|
506
|
+
case 'Script':
|
|
507
|
+
case 'Sound':
|
|
508
|
+
case 'SpotLight':
|
|
509
|
+
case 'CylinderSensor':
|
|
510
|
+
case 'PlaneSensor':
|
|
511
|
+
case 'ProximitySensor':
|
|
512
|
+
case 'SphereSensor':
|
|
513
|
+
case 'TimeSensor':
|
|
514
|
+
case 'TouchSensor':
|
|
515
|
+
case 'VisibilitySensor':
|
|
516
|
+
case 'Text':
|
|
517
|
+
case 'FontStyle':
|
|
518
|
+
case 'MovieTexture':
|
|
519
|
+
case 'ColorInterpolator':
|
|
520
|
+
case 'CoordinateInterpolator':
|
|
521
|
+
case 'NormalInterpolator':
|
|
522
|
+
case 'OrientationInterpolator':
|
|
523
|
+
case 'PositionInterpolator':
|
|
524
|
+
case 'ScalarInterpolator':
|
|
525
|
+
case 'Fog':
|
|
526
|
+
case 'NavigationInfo':
|
|
527
|
+
case 'Viewpoint':
|
|
528
|
+
// node not supported yet
|
|
483
529
|
break;
|
|
530
|
+
|
|
484
531
|
default:
|
|
485
|
-
console.warn(
|
|
532
|
+
console.warn('THREE.VRMLLoader: Unknown node:', nodeName);
|
|
486
533
|
break;
|
|
487
534
|
}
|
|
488
|
-
|
|
535
|
+
|
|
536
|
+
if (build !== undefined && node.DEF !== undefined && build.hasOwnProperty('name') === true) {
|
|
489
537
|
build.name = node.DEF;
|
|
490
538
|
}
|
|
539
|
+
|
|
491
540
|
return build;
|
|
492
541
|
}
|
|
542
|
+
|
|
493
543
|
function buildGroupingNode(node) {
|
|
494
|
-
const object = new
|
|
544
|
+
const object = new Group(); //
|
|
545
|
+
|
|
495
546
|
const fields = node.fields;
|
|
547
|
+
|
|
496
548
|
for (let i = 0, l = fields.length; i < l; i++) {
|
|
497
549
|
const field = fields[i];
|
|
498
550
|
const fieldName = field.name;
|
|
499
551
|
const fieldValues = field.values;
|
|
552
|
+
|
|
500
553
|
switch (fieldName) {
|
|
501
|
-
case
|
|
554
|
+
case 'bboxCenter':
|
|
555
|
+
// field not supported
|
|
502
556
|
break;
|
|
503
|
-
|
|
557
|
+
|
|
558
|
+
case 'bboxSize':
|
|
559
|
+
// field not supported
|
|
504
560
|
break;
|
|
505
|
-
|
|
561
|
+
|
|
562
|
+
case 'center':
|
|
563
|
+
// field not supported
|
|
506
564
|
break;
|
|
507
|
-
|
|
565
|
+
|
|
566
|
+
case 'children':
|
|
508
567
|
parseFieldChildren(fieldValues, object);
|
|
509
568
|
break;
|
|
510
|
-
|
|
569
|
+
|
|
570
|
+
case 'collide':
|
|
571
|
+
// field not supported
|
|
511
572
|
break;
|
|
512
|
-
|
|
513
|
-
|
|
573
|
+
|
|
574
|
+
case 'rotation':
|
|
575
|
+
const axis = new Vector3(fieldValues[0], fieldValues[1], fieldValues[2]);
|
|
514
576
|
const angle = fieldValues[3];
|
|
515
577
|
object.quaternion.setFromAxisAngle(axis, angle);
|
|
516
578
|
break;
|
|
517
|
-
|
|
579
|
+
|
|
580
|
+
case 'scale':
|
|
518
581
|
object.scale.set(fieldValues[0], fieldValues[1], fieldValues[2]);
|
|
519
582
|
break;
|
|
520
|
-
|
|
583
|
+
|
|
584
|
+
case 'scaleOrientation':
|
|
585
|
+
// field not supported
|
|
521
586
|
break;
|
|
522
|
-
|
|
587
|
+
|
|
588
|
+
case 'translation':
|
|
523
589
|
object.position.set(fieldValues[0], fieldValues[1], fieldValues[2]);
|
|
524
590
|
break;
|
|
525
|
-
|
|
591
|
+
|
|
592
|
+
case 'proxy':
|
|
593
|
+
// field not supported
|
|
526
594
|
break;
|
|
595
|
+
|
|
527
596
|
default:
|
|
528
|
-
console.warn(
|
|
597
|
+
console.warn('THREE.VRMLLoader: Unknown field:', fieldName);
|
|
529
598
|
break;
|
|
530
599
|
}
|
|
531
600
|
}
|
|
601
|
+
|
|
532
602
|
return object;
|
|
533
603
|
}
|
|
604
|
+
|
|
534
605
|
function buildBackgroundNode(node) {
|
|
535
|
-
const group = new
|
|
606
|
+
const group = new Group();
|
|
536
607
|
let groundAngle, groundColor;
|
|
537
608
|
let skyAngle, skyColor;
|
|
538
609
|
const fields = node.fields;
|
|
610
|
+
|
|
539
611
|
for (let i = 0, l = fields.length; i < l; i++) {
|
|
540
612
|
const field = fields[i];
|
|
541
613
|
const fieldName = field.name;
|
|
542
614
|
const fieldValues = field.values;
|
|
615
|
+
|
|
543
616
|
switch (fieldName) {
|
|
544
|
-
case
|
|
617
|
+
case 'groundAngle':
|
|
545
618
|
groundAngle = fieldValues;
|
|
546
619
|
break;
|
|
547
|
-
|
|
620
|
+
|
|
621
|
+
case 'groundColor':
|
|
548
622
|
groundColor = fieldValues;
|
|
549
623
|
break;
|
|
550
|
-
|
|
624
|
+
|
|
625
|
+
case 'backUrl':
|
|
626
|
+
// field not supported
|
|
551
627
|
break;
|
|
552
|
-
|
|
628
|
+
|
|
629
|
+
case 'bottomUrl':
|
|
630
|
+
// field not supported
|
|
553
631
|
break;
|
|
554
|
-
|
|
632
|
+
|
|
633
|
+
case 'frontUrl':
|
|
634
|
+
// field not supported
|
|
555
635
|
break;
|
|
556
|
-
|
|
636
|
+
|
|
637
|
+
case 'leftUrl':
|
|
638
|
+
// field not supported
|
|
557
639
|
break;
|
|
558
|
-
|
|
640
|
+
|
|
641
|
+
case 'rightUrl':
|
|
642
|
+
// field not supported
|
|
559
643
|
break;
|
|
560
|
-
|
|
644
|
+
|
|
645
|
+
case 'topUrl':
|
|
646
|
+
// field not supported
|
|
561
647
|
break;
|
|
562
|
-
|
|
648
|
+
|
|
649
|
+
case 'skyAngle':
|
|
563
650
|
skyAngle = fieldValues;
|
|
564
651
|
break;
|
|
565
|
-
|
|
652
|
+
|
|
653
|
+
case 'skyColor':
|
|
566
654
|
skyColor = fieldValues;
|
|
567
655
|
break;
|
|
656
|
+
|
|
568
657
|
default:
|
|
569
|
-
console.warn(
|
|
658
|
+
console.warn('THREE.VRMLLoader: Unknown field:', fieldName);
|
|
570
659
|
break;
|
|
571
660
|
}
|
|
572
661
|
}
|
|
573
|
-
|
|
662
|
+
|
|
663
|
+
const radius = 10000; // sky
|
|
664
|
+
|
|
574
665
|
if (skyColor) {
|
|
575
|
-
const skyGeometry = new
|
|
576
|
-
const skyMaterial = new
|
|
666
|
+
const skyGeometry = new SphereGeometry(radius, 32, 16);
|
|
667
|
+
const skyMaterial = new MeshBasicMaterial({
|
|
668
|
+
fog: false,
|
|
669
|
+
side: BackSide,
|
|
670
|
+
depthWrite: false,
|
|
671
|
+
depthTest: false
|
|
672
|
+
});
|
|
673
|
+
|
|
577
674
|
if (skyColor.length > 3) {
|
|
578
675
|
paintFaces(skyGeometry, radius, skyAngle, toColorArray(skyColor), true);
|
|
579
676
|
skyMaterial.vertexColors = true;
|
|
580
677
|
} else {
|
|
581
678
|
skyMaterial.color.setRGB(skyColor[0], skyColor[1], skyColor[2]);
|
|
582
679
|
}
|
|
583
|
-
|
|
680
|
+
|
|
681
|
+
const sky = new Mesh(skyGeometry, skyMaterial);
|
|
584
682
|
group.add(sky);
|
|
585
|
-
}
|
|
683
|
+
} // ground
|
|
684
|
+
|
|
685
|
+
|
|
586
686
|
if (groundColor) {
|
|
587
687
|
if (groundColor.length > 0) {
|
|
588
|
-
const groundGeometry = new
|
|
589
|
-
const groundMaterial = new
|
|
688
|
+
const groundGeometry = new SphereGeometry(radius, 32, 16, 0, 2 * Math.PI, 0.5 * Math.PI, 1.5 * Math.PI);
|
|
689
|
+
const groundMaterial = new MeshBasicMaterial({
|
|
590
690
|
fog: false,
|
|
591
|
-
side:
|
|
691
|
+
side: BackSide,
|
|
592
692
|
vertexColors: true,
|
|
593
693
|
depthWrite: false,
|
|
594
694
|
depthTest: false
|
|
595
695
|
});
|
|
596
696
|
paintFaces(groundGeometry, radius, groundAngle, toColorArray(groundColor), false);
|
|
597
|
-
const ground = new
|
|
697
|
+
const ground = new Mesh(groundGeometry, groundMaterial);
|
|
598
698
|
group.add(ground);
|
|
599
699
|
}
|
|
600
|
-
}
|
|
700
|
+
} // render background group first
|
|
701
|
+
|
|
702
|
+
|
|
601
703
|
group.renderOrder = -Infinity;
|
|
602
704
|
return group;
|
|
603
705
|
}
|
|
706
|
+
|
|
604
707
|
function buildShapeNode(node) {
|
|
605
|
-
const fields = node.fields;
|
|
606
|
-
|
|
708
|
+
const fields = node.fields; // if the appearance field is NULL or unspecified, lighting is off and the unlit object color is (0, 0, 0)
|
|
709
|
+
|
|
710
|
+
let material = new MeshBasicMaterial({
|
|
711
|
+
color: 0x000000
|
|
712
|
+
});
|
|
607
713
|
let geometry;
|
|
714
|
+
|
|
608
715
|
for (let i = 0, l = fields.length; i < l; i++) {
|
|
609
716
|
const field = fields[i];
|
|
610
717
|
const fieldName = field.name;
|
|
611
718
|
const fieldValues = field.values;
|
|
719
|
+
|
|
612
720
|
switch (fieldName) {
|
|
613
|
-
case
|
|
721
|
+
case 'appearance':
|
|
614
722
|
if (fieldValues[0] !== null) {
|
|
615
723
|
material = getNode(fieldValues[0]);
|
|
616
724
|
}
|
|
725
|
+
|
|
617
726
|
break;
|
|
618
|
-
|
|
727
|
+
|
|
728
|
+
case 'geometry':
|
|
619
729
|
if (fieldValues[0] !== null) {
|
|
620
730
|
geometry = getNode(fieldValues[0]);
|
|
621
731
|
}
|
|
732
|
+
|
|
622
733
|
break;
|
|
734
|
+
|
|
623
735
|
default:
|
|
624
|
-
console.warn(
|
|
736
|
+
console.warn('THREE.VRMLLoader: Unknown field:', fieldName);
|
|
625
737
|
break;
|
|
626
738
|
}
|
|
627
|
-
}
|
|
739
|
+
} // build 3D object
|
|
740
|
+
|
|
741
|
+
|
|
628
742
|
let object;
|
|
743
|
+
|
|
629
744
|
if (geometry && geometry.attributes.position) {
|
|
630
745
|
const type = geometry._type;
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
746
|
+
|
|
747
|
+
if (type === 'points') {
|
|
748
|
+
// points
|
|
749
|
+
const pointsMaterial = new PointsMaterial({
|
|
750
|
+
color: 0xffffff
|
|
751
|
+
});
|
|
752
|
+
|
|
753
|
+
if (geometry.attributes.color !== undefined) {
|
|
634
754
|
pointsMaterial.vertexColors = true;
|
|
635
755
|
} else {
|
|
756
|
+
// 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
|
|
636
757
|
if (material.isMeshPhongMaterial) {
|
|
637
758
|
pointsMaterial.color.copy(material.emissive);
|
|
638
759
|
}
|
|
639
760
|
}
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
761
|
+
|
|
762
|
+
object = new Points(geometry, pointsMaterial);
|
|
763
|
+
} else if (type === 'line') {
|
|
764
|
+
// lines
|
|
765
|
+
const lineMaterial = new LineBasicMaterial({
|
|
766
|
+
color: 0xffffff
|
|
767
|
+
});
|
|
768
|
+
|
|
769
|
+
if (geometry.attributes.color !== undefined) {
|
|
644
770
|
lineMaterial.vertexColors = true;
|
|
645
771
|
} else {
|
|
772
|
+
// 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
|
|
646
773
|
if (material.isMeshPhongMaterial) {
|
|
647
774
|
lineMaterial.color.copy(material.emissive);
|
|
648
775
|
}
|
|
649
776
|
}
|
|
650
|
-
|
|
777
|
+
|
|
778
|
+
object = new LineSegments(geometry, lineMaterial);
|
|
651
779
|
} else {
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
780
|
+
// consider meshes
|
|
781
|
+
// check "solid" hint (it's placed in the geometry but affects the material)
|
|
782
|
+
if (geometry._solid !== undefined) {
|
|
783
|
+
material.side = geometry._solid ? FrontSide : DoubleSide;
|
|
784
|
+
} // check for vertex colors
|
|
785
|
+
|
|
786
|
+
|
|
787
|
+
if (geometry.attributes.color !== undefined) {
|
|
656
788
|
material.vertexColors = true;
|
|
657
789
|
}
|
|
658
|
-
|
|
790
|
+
|
|
791
|
+
object = new Mesh(geometry, material);
|
|
659
792
|
}
|
|
660
793
|
} else {
|
|
661
|
-
object = new
|
|
794
|
+
object = new Object3D(); // if the geometry field is NULL or no vertices are defined the object is not drawn
|
|
795
|
+
|
|
662
796
|
object.visible = false;
|
|
663
797
|
}
|
|
798
|
+
|
|
664
799
|
return object;
|
|
665
800
|
}
|
|
801
|
+
|
|
666
802
|
function buildAppearanceNode(node) {
|
|
667
|
-
let material = new
|
|
803
|
+
let material = new MeshPhongMaterial();
|
|
668
804
|
let transformData;
|
|
669
805
|
const fields = node.fields;
|
|
806
|
+
|
|
670
807
|
for (let i = 0, l = fields.length; i < l; i++) {
|
|
671
808
|
const field = fields[i];
|
|
672
809
|
const fieldName = field.name;
|
|
673
810
|
const fieldValues = field.values;
|
|
811
|
+
|
|
674
812
|
switch (fieldName) {
|
|
675
|
-
case
|
|
813
|
+
case 'material':
|
|
676
814
|
if (fieldValues[0] !== null) {
|
|
677
815
|
const materialData = getNode(fieldValues[0]);
|
|
678
|
-
if (materialData.diffuseColor)
|
|
679
|
-
|
|
680
|
-
if (materialData.
|
|
681
|
-
|
|
682
|
-
if (materialData.
|
|
683
|
-
|
|
684
|
-
if (materialData.specularColor)
|
|
685
|
-
material.specular.copy(materialData.specularColor);
|
|
686
|
-
if (materialData.transparency)
|
|
687
|
-
material.opacity = 1 - materialData.transparency;
|
|
688
|
-
if (materialData.transparency > 0)
|
|
689
|
-
material.transparent = true;
|
|
816
|
+
if (materialData.diffuseColor) material.color.copy(materialData.diffuseColor);
|
|
817
|
+
if (materialData.emissiveColor) material.emissive.copy(materialData.emissiveColor);
|
|
818
|
+
if (materialData.shininess) material.shininess = materialData.shininess;
|
|
819
|
+
if (materialData.specularColor) material.specular.copy(materialData.specularColor);
|
|
820
|
+
if (materialData.transparency) material.opacity = 1 - materialData.transparency;
|
|
821
|
+
if (materialData.transparency > 0) material.transparent = true;
|
|
690
822
|
} else {
|
|
691
|
-
material
|
|
823
|
+
// if the material field is NULL or unspecified, lighting is off and the unlit object color is (0, 0, 0)
|
|
824
|
+
material = new MeshBasicMaterial({
|
|
825
|
+
color: 0x000000
|
|
826
|
+
});
|
|
692
827
|
}
|
|
828
|
+
|
|
693
829
|
break;
|
|
694
|
-
|
|
830
|
+
|
|
831
|
+
case 'texture':
|
|
695
832
|
const textureNode = fieldValues[0];
|
|
833
|
+
|
|
696
834
|
if (textureNode !== null) {
|
|
697
|
-
if (textureNode.name ===
|
|
835
|
+
if (textureNode.name === 'ImageTexture' || textureNode.name === 'PixelTexture') {
|
|
698
836
|
material.map = getNode(textureNode);
|
|
699
|
-
} else {
|
|
700
837
|
}
|
|
701
838
|
}
|
|
839
|
+
|
|
702
840
|
break;
|
|
703
|
-
|
|
841
|
+
|
|
842
|
+
case 'textureTransform':
|
|
704
843
|
if (fieldValues[0] !== null) {
|
|
705
844
|
transformData = getNode(fieldValues[0]);
|
|
706
845
|
}
|
|
846
|
+
|
|
707
847
|
break;
|
|
848
|
+
|
|
708
849
|
default:
|
|
709
|
-
console.warn(
|
|
850
|
+
console.warn('THREE.VRMLLoader: Unknown field:', fieldName);
|
|
710
851
|
break;
|
|
711
852
|
}
|
|
712
|
-
}
|
|
853
|
+
} // only apply texture transform data if a texture was defined
|
|
854
|
+
|
|
855
|
+
|
|
713
856
|
if (material.map) {
|
|
857
|
+
// respect VRML lighting model
|
|
714
858
|
if (material.map.__type) {
|
|
715
859
|
switch (material.map.__type) {
|
|
716
860
|
case TEXTURE_TYPE.INTENSITY_ALPHA:
|
|
717
|
-
material.opacity = 1;
|
|
861
|
+
material.opacity = 1; // ignore transparency
|
|
862
|
+
|
|
718
863
|
break;
|
|
864
|
+
|
|
719
865
|
case TEXTURE_TYPE.RGB:
|
|
720
|
-
material.color.set(
|
|
866
|
+
material.color.set(0xffffff); // ignore material color
|
|
867
|
+
|
|
721
868
|
break;
|
|
869
|
+
|
|
722
870
|
case TEXTURE_TYPE.RGBA:
|
|
723
|
-
material.color.set(
|
|
724
|
-
|
|
871
|
+
material.color.set(0xffffff); // ignore material color
|
|
872
|
+
|
|
873
|
+
material.opacity = 1; // ignore transparency
|
|
874
|
+
|
|
725
875
|
break;
|
|
726
|
-
default:
|
|
727
876
|
}
|
|
877
|
+
|
|
728
878
|
delete material.map.__type;
|
|
729
|
-
}
|
|
879
|
+
} // apply texture transform
|
|
880
|
+
|
|
881
|
+
|
|
730
882
|
if (transformData) {
|
|
731
883
|
material.map.center.copy(transformData.center);
|
|
732
884
|
material.map.rotation = transformData.rotation;
|
|
@@ -734,563 +886,734 @@ class VRMLLoader extends THREE.Loader {
|
|
|
734
886
|
material.map.offset.copy(transformData.translation);
|
|
735
887
|
}
|
|
736
888
|
}
|
|
889
|
+
|
|
737
890
|
return material;
|
|
738
891
|
}
|
|
892
|
+
|
|
739
893
|
function buildMaterialNode(node) {
|
|
740
894
|
const materialData = {};
|
|
741
895
|
const fields = node.fields;
|
|
896
|
+
|
|
742
897
|
for (let i = 0, l = fields.length; i < l; i++) {
|
|
743
898
|
const field = fields[i];
|
|
744
899
|
const fieldName = field.name;
|
|
745
900
|
const fieldValues = field.values;
|
|
901
|
+
|
|
746
902
|
switch (fieldName) {
|
|
747
|
-
case
|
|
903
|
+
case 'ambientIntensity':
|
|
904
|
+
// field not supported
|
|
748
905
|
break;
|
|
749
|
-
|
|
750
|
-
|
|
906
|
+
|
|
907
|
+
case 'diffuseColor':
|
|
908
|
+
materialData.diffuseColor = new Color(fieldValues[0], fieldValues[1], fieldValues[2]);
|
|
751
909
|
break;
|
|
752
|
-
|
|
753
|
-
|
|
910
|
+
|
|
911
|
+
case 'emissiveColor':
|
|
912
|
+
materialData.emissiveColor = new Color(fieldValues[0], fieldValues[1], fieldValues[2]);
|
|
754
913
|
break;
|
|
755
|
-
|
|
914
|
+
|
|
915
|
+
case 'shininess':
|
|
756
916
|
materialData.shininess = fieldValues[0];
|
|
757
917
|
break;
|
|
758
|
-
|
|
759
|
-
|
|
918
|
+
|
|
919
|
+
case 'specularColor':
|
|
920
|
+
materialData.emissiveColor = new Color(fieldValues[0], fieldValues[1], fieldValues[2]);
|
|
760
921
|
break;
|
|
761
|
-
|
|
922
|
+
|
|
923
|
+
case 'transparency':
|
|
762
924
|
materialData.transparency = fieldValues[0];
|
|
763
925
|
break;
|
|
926
|
+
|
|
764
927
|
default:
|
|
765
|
-
console.warn(
|
|
928
|
+
console.warn('THREE.VRMLLoader: Unknown field:', fieldName);
|
|
766
929
|
break;
|
|
767
930
|
}
|
|
768
931
|
}
|
|
932
|
+
|
|
769
933
|
return materialData;
|
|
770
934
|
}
|
|
935
|
+
|
|
771
936
|
function parseHexColor(hex, textureType, color) {
|
|
772
937
|
let value;
|
|
938
|
+
|
|
773
939
|
switch (textureType) {
|
|
774
940
|
case TEXTURE_TYPE.INTENSITY:
|
|
941
|
+
// Intensity texture: A one-component image specifies one-byte hexadecimal or integer values representing the intensity of the image
|
|
775
942
|
value = parseInt(hex);
|
|
776
943
|
color.r = value;
|
|
777
944
|
color.g = value;
|
|
778
945
|
color.b = value;
|
|
779
946
|
color.a = 1;
|
|
780
947
|
break;
|
|
948
|
+
|
|
781
949
|
case TEXTURE_TYPE.INTENSITY_ALPHA:
|
|
782
|
-
|
|
950
|
+
// Intensity+Alpha texture: A two-component image specifies the intensity in the first (high) byte and the alpha opacity in the second (low) byte.
|
|
951
|
+
value = parseInt('0x' + hex.substring(2, 4));
|
|
783
952
|
color.r = value;
|
|
784
953
|
color.g = value;
|
|
785
954
|
color.b = value;
|
|
786
|
-
color.a = parseInt(
|
|
955
|
+
color.a = parseInt('0x' + hex.substring(4, 6));
|
|
787
956
|
break;
|
|
957
|
+
|
|
788
958
|
case TEXTURE_TYPE.RGB:
|
|
789
|
-
|
|
790
|
-
color.
|
|
791
|
-
color.
|
|
959
|
+
// RGB texture: Pixels in a three-component image specify the red component in the first (high) byte, followed by the green and blue components
|
|
960
|
+
color.r = parseInt('0x' + hex.substring(2, 4));
|
|
961
|
+
color.g = parseInt('0x' + hex.substring(4, 6));
|
|
962
|
+
color.b = parseInt('0x' + hex.substring(6, 8));
|
|
792
963
|
color.a = 1;
|
|
793
964
|
break;
|
|
965
|
+
|
|
794
966
|
case TEXTURE_TYPE.RGBA:
|
|
795
|
-
|
|
796
|
-
color.
|
|
797
|
-
color.
|
|
798
|
-
color.
|
|
967
|
+
// RGBA texture: Four-component images specify the alpha opacity byte after red/green/blue
|
|
968
|
+
color.r = parseInt('0x' + hex.substring(2, 4));
|
|
969
|
+
color.g = parseInt('0x' + hex.substring(4, 6));
|
|
970
|
+
color.b = parseInt('0x' + hex.substring(6, 8));
|
|
971
|
+
color.a = parseInt('0x' + hex.substring(8, 10));
|
|
799
972
|
break;
|
|
800
|
-
default:
|
|
801
973
|
}
|
|
802
974
|
}
|
|
975
|
+
|
|
803
976
|
function getTextureType(num_components) {
|
|
804
977
|
let type;
|
|
978
|
+
|
|
805
979
|
switch (num_components) {
|
|
806
980
|
case 1:
|
|
807
981
|
type = TEXTURE_TYPE.INTENSITY;
|
|
808
982
|
break;
|
|
983
|
+
|
|
809
984
|
case 2:
|
|
810
985
|
type = TEXTURE_TYPE.INTENSITY_ALPHA;
|
|
811
986
|
break;
|
|
987
|
+
|
|
812
988
|
case 3:
|
|
813
989
|
type = TEXTURE_TYPE.RGB;
|
|
814
990
|
break;
|
|
991
|
+
|
|
815
992
|
case 4:
|
|
816
993
|
type = TEXTURE_TYPE.RGBA;
|
|
817
994
|
break;
|
|
818
|
-
default:
|
|
819
995
|
}
|
|
996
|
+
|
|
820
997
|
return type;
|
|
821
998
|
}
|
|
999
|
+
|
|
822
1000
|
function buildPixelTextureNode(node) {
|
|
823
1001
|
let texture;
|
|
824
|
-
let wrapS =
|
|
825
|
-
let wrapT =
|
|
1002
|
+
let wrapS = RepeatWrapping;
|
|
1003
|
+
let wrapT = RepeatWrapping;
|
|
826
1004
|
const fields = node.fields;
|
|
1005
|
+
|
|
827
1006
|
for (let i = 0, l = fields.length; i < l; i++) {
|
|
828
1007
|
const field = fields[i];
|
|
829
1008
|
const fieldName = field.name;
|
|
830
1009
|
const fieldValues = field.values;
|
|
1010
|
+
|
|
831
1011
|
switch (fieldName) {
|
|
832
|
-
case
|
|
1012
|
+
case 'image':
|
|
833
1013
|
const width = fieldValues[0];
|
|
834
1014
|
const height = fieldValues[1];
|
|
835
1015
|
const num_components = fieldValues[2];
|
|
836
1016
|
const textureType = getTextureType(num_components);
|
|
837
|
-
const
|
|
838
|
-
const color = {
|
|
1017
|
+
const data = new Uint8Array(4 * width * height);
|
|
1018
|
+
const color = {
|
|
1019
|
+
r: 0,
|
|
1020
|
+
g: 0,
|
|
1021
|
+
b: 0,
|
|
1022
|
+
a: 0
|
|
1023
|
+
};
|
|
1024
|
+
|
|
839
1025
|
for (let j = 3, k = 0, jl = fieldValues.length; j < jl; j++, k++) {
|
|
840
1026
|
parseHexColor(fieldValues[j], textureType, color);
|
|
841
1027
|
const stride = k * 4;
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
1028
|
+
data[stride + 0] = color.r;
|
|
1029
|
+
data[stride + 1] = color.g;
|
|
1030
|
+
data[stride + 2] = color.b;
|
|
1031
|
+
data[stride + 3] = color.a;
|
|
846
1032
|
}
|
|
847
|
-
|
|
1033
|
+
|
|
1034
|
+
texture = new DataTexture(data, width, height);
|
|
848
1035
|
texture.needsUpdate = true;
|
|
849
|
-
texture.__type = textureType;
|
|
1036
|
+
texture.__type = textureType; // needed for material modifications
|
|
1037
|
+
|
|
850
1038
|
break;
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
1039
|
+
|
|
1040
|
+
case 'repeatS':
|
|
1041
|
+
if (fieldValues[0] === false) wrapS = ClampToEdgeWrapping;
|
|
854
1042
|
break;
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
1043
|
+
|
|
1044
|
+
case 'repeatT':
|
|
1045
|
+
if (fieldValues[0] === false) wrapT = ClampToEdgeWrapping;
|
|
858
1046
|
break;
|
|
1047
|
+
|
|
859
1048
|
default:
|
|
860
|
-
console.warn(
|
|
1049
|
+
console.warn('THREE.VRMLLoader: Unknown field:', fieldName);
|
|
861
1050
|
break;
|
|
862
1051
|
}
|
|
863
1052
|
}
|
|
1053
|
+
|
|
864
1054
|
if (texture) {
|
|
865
1055
|
texture.wrapS = wrapS;
|
|
866
1056
|
texture.wrapT = wrapT;
|
|
867
1057
|
}
|
|
1058
|
+
|
|
868
1059
|
return texture;
|
|
869
1060
|
}
|
|
1061
|
+
|
|
870
1062
|
function buildImageTextureNode(node) {
|
|
871
1063
|
let texture;
|
|
872
|
-
let wrapS =
|
|
873
|
-
let wrapT =
|
|
1064
|
+
let wrapS = RepeatWrapping;
|
|
1065
|
+
let wrapT = RepeatWrapping;
|
|
874
1066
|
const fields = node.fields;
|
|
1067
|
+
|
|
875
1068
|
for (let i = 0, l = fields.length; i < l; i++) {
|
|
876
1069
|
const field = fields[i];
|
|
877
1070
|
const fieldName = field.name;
|
|
878
1071
|
const fieldValues = field.values;
|
|
1072
|
+
|
|
879
1073
|
switch (fieldName) {
|
|
880
|
-
case
|
|
1074
|
+
case 'url':
|
|
881
1075
|
const url = fieldValues[0];
|
|
882
|
-
if (url)
|
|
883
|
-
texture = textureLoader.load(url);
|
|
1076
|
+
if (url) texture = textureLoader.load(url);
|
|
884
1077
|
break;
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
1078
|
+
|
|
1079
|
+
case 'repeatS':
|
|
1080
|
+
if (fieldValues[0] === false) wrapS = ClampToEdgeWrapping;
|
|
888
1081
|
break;
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
1082
|
+
|
|
1083
|
+
case 'repeatT':
|
|
1084
|
+
if (fieldValues[0] === false) wrapT = ClampToEdgeWrapping;
|
|
892
1085
|
break;
|
|
1086
|
+
|
|
893
1087
|
default:
|
|
894
|
-
console.warn(
|
|
1088
|
+
console.warn('THREE.VRMLLoader: Unknown field:', fieldName);
|
|
895
1089
|
break;
|
|
896
1090
|
}
|
|
897
1091
|
}
|
|
1092
|
+
|
|
898
1093
|
if (texture) {
|
|
899
1094
|
texture.wrapS = wrapS;
|
|
900
1095
|
texture.wrapT = wrapT;
|
|
901
1096
|
}
|
|
1097
|
+
|
|
902
1098
|
return texture;
|
|
903
1099
|
}
|
|
1100
|
+
|
|
904
1101
|
function buildTextureTransformNode(node) {
|
|
905
1102
|
const transformData = {
|
|
906
|
-
center: new
|
|
907
|
-
rotation: new
|
|
908
|
-
scale: new
|
|
909
|
-
translation: new
|
|
1103
|
+
center: new Vector2(),
|
|
1104
|
+
rotation: new Vector2(),
|
|
1105
|
+
scale: new Vector2(),
|
|
1106
|
+
translation: new Vector2()
|
|
910
1107
|
};
|
|
911
1108
|
const fields = node.fields;
|
|
1109
|
+
|
|
912
1110
|
for (let i = 0, l = fields.length; i < l; i++) {
|
|
913
1111
|
const field = fields[i];
|
|
914
1112
|
const fieldName = field.name;
|
|
915
1113
|
const fieldValues = field.values;
|
|
1114
|
+
|
|
916
1115
|
switch (fieldName) {
|
|
917
|
-
case
|
|
1116
|
+
case 'center':
|
|
918
1117
|
transformData.center.set(fieldValues[0], fieldValues[1]);
|
|
919
1118
|
break;
|
|
920
|
-
|
|
1119
|
+
|
|
1120
|
+
case 'rotation':
|
|
921
1121
|
transformData.rotation = fieldValues[0];
|
|
922
1122
|
break;
|
|
923
|
-
|
|
1123
|
+
|
|
1124
|
+
case 'scale':
|
|
924
1125
|
transformData.scale.set(fieldValues[0], fieldValues[1]);
|
|
925
1126
|
break;
|
|
926
|
-
|
|
1127
|
+
|
|
1128
|
+
case 'translation':
|
|
927
1129
|
transformData.translation.set(fieldValues[0], fieldValues[1]);
|
|
928
1130
|
break;
|
|
1131
|
+
|
|
929
1132
|
default:
|
|
930
|
-
console.warn(
|
|
1133
|
+
console.warn('THREE.VRMLLoader: Unknown field:', fieldName);
|
|
931
1134
|
break;
|
|
932
1135
|
}
|
|
933
1136
|
}
|
|
1137
|
+
|
|
934
1138
|
return transformData;
|
|
935
1139
|
}
|
|
1140
|
+
|
|
936
1141
|
function buildGeometricNode(node) {
|
|
937
1142
|
return node.fields[0].values;
|
|
938
1143
|
}
|
|
1144
|
+
|
|
939
1145
|
function buildWorldInfoNode(node) {
|
|
940
1146
|
const worldInfo = {};
|
|
941
1147
|
const fields = node.fields;
|
|
1148
|
+
|
|
942
1149
|
for (let i = 0, l = fields.length; i < l; i++) {
|
|
943
1150
|
const field = fields[i];
|
|
944
1151
|
const fieldName = field.name;
|
|
945
1152
|
const fieldValues = field.values;
|
|
1153
|
+
|
|
946
1154
|
switch (fieldName) {
|
|
947
|
-
case
|
|
1155
|
+
case 'title':
|
|
948
1156
|
worldInfo.title = fieldValues[0];
|
|
949
1157
|
break;
|
|
950
|
-
|
|
1158
|
+
|
|
1159
|
+
case 'info':
|
|
951
1160
|
worldInfo.info = fieldValues;
|
|
952
1161
|
break;
|
|
1162
|
+
|
|
953
1163
|
default:
|
|
954
|
-
console.warn(
|
|
1164
|
+
console.warn('THREE.VRMLLoader: Unknown field:', fieldName);
|
|
955
1165
|
break;
|
|
956
1166
|
}
|
|
957
1167
|
}
|
|
1168
|
+
|
|
958
1169
|
return worldInfo;
|
|
959
1170
|
}
|
|
1171
|
+
|
|
960
1172
|
function buildIndexedFaceSetNode(node) {
|
|
961
1173
|
let color, coord, normal, texCoord;
|
|
962
|
-
let ccw = true,
|
|
1174
|
+
let ccw = true,
|
|
1175
|
+
solid = true,
|
|
1176
|
+
creaseAngle = 0;
|
|
963
1177
|
let colorIndex, coordIndex, normalIndex, texCoordIndex;
|
|
964
|
-
let colorPerVertex = true,
|
|
1178
|
+
let colorPerVertex = true,
|
|
1179
|
+
normalPerVertex = true;
|
|
965
1180
|
const fields = node.fields;
|
|
1181
|
+
|
|
966
1182
|
for (let i = 0, l = fields.length; i < l; i++) {
|
|
967
1183
|
const field = fields[i];
|
|
968
1184
|
const fieldName = field.name;
|
|
969
1185
|
const fieldValues = field.values;
|
|
1186
|
+
|
|
970
1187
|
switch (fieldName) {
|
|
971
|
-
case
|
|
1188
|
+
case 'color':
|
|
972
1189
|
const colorNode = fieldValues[0];
|
|
1190
|
+
|
|
973
1191
|
if (colorNode !== null) {
|
|
974
1192
|
color = getNode(colorNode);
|
|
975
1193
|
}
|
|
1194
|
+
|
|
976
1195
|
break;
|
|
977
|
-
|
|
1196
|
+
|
|
1197
|
+
case 'coord':
|
|
978
1198
|
const coordNode = fieldValues[0];
|
|
1199
|
+
|
|
979
1200
|
if (coordNode !== null) {
|
|
980
1201
|
coord = getNode(coordNode);
|
|
981
1202
|
}
|
|
1203
|
+
|
|
982
1204
|
break;
|
|
983
|
-
|
|
1205
|
+
|
|
1206
|
+
case 'normal':
|
|
984
1207
|
const normalNode = fieldValues[0];
|
|
1208
|
+
|
|
985
1209
|
if (normalNode !== null) {
|
|
986
1210
|
normal = getNode(normalNode);
|
|
987
1211
|
}
|
|
1212
|
+
|
|
988
1213
|
break;
|
|
989
|
-
|
|
1214
|
+
|
|
1215
|
+
case 'texCoord':
|
|
990
1216
|
const texCoordNode = fieldValues[0];
|
|
1217
|
+
|
|
991
1218
|
if (texCoordNode !== null) {
|
|
992
1219
|
texCoord = getNode(texCoordNode);
|
|
993
1220
|
}
|
|
1221
|
+
|
|
994
1222
|
break;
|
|
995
|
-
|
|
1223
|
+
|
|
1224
|
+
case 'ccw':
|
|
996
1225
|
ccw = fieldValues[0];
|
|
997
1226
|
break;
|
|
998
|
-
|
|
1227
|
+
|
|
1228
|
+
case 'colorIndex':
|
|
999
1229
|
colorIndex = fieldValues;
|
|
1000
1230
|
break;
|
|
1001
|
-
|
|
1231
|
+
|
|
1232
|
+
case 'colorPerVertex':
|
|
1002
1233
|
colorPerVertex = fieldValues[0];
|
|
1003
1234
|
break;
|
|
1004
|
-
|
|
1235
|
+
|
|
1236
|
+
case 'convex':
|
|
1237
|
+
// field not supported
|
|
1005
1238
|
break;
|
|
1006
|
-
|
|
1239
|
+
|
|
1240
|
+
case 'coordIndex':
|
|
1007
1241
|
coordIndex = fieldValues;
|
|
1008
1242
|
break;
|
|
1009
|
-
|
|
1243
|
+
|
|
1244
|
+
case 'creaseAngle':
|
|
1010
1245
|
creaseAngle = fieldValues[0];
|
|
1011
1246
|
break;
|
|
1012
|
-
|
|
1247
|
+
|
|
1248
|
+
case 'normalIndex':
|
|
1013
1249
|
normalIndex = fieldValues;
|
|
1014
1250
|
break;
|
|
1015
|
-
|
|
1251
|
+
|
|
1252
|
+
case 'normalPerVertex':
|
|
1016
1253
|
normalPerVertex = fieldValues[0];
|
|
1017
1254
|
break;
|
|
1018
|
-
|
|
1255
|
+
|
|
1256
|
+
case 'solid':
|
|
1019
1257
|
solid = fieldValues[0];
|
|
1020
1258
|
break;
|
|
1021
|
-
|
|
1259
|
+
|
|
1260
|
+
case 'texCoordIndex':
|
|
1022
1261
|
texCoordIndex = fieldValues;
|
|
1023
1262
|
break;
|
|
1263
|
+
|
|
1024
1264
|
default:
|
|
1025
|
-
console.warn(
|
|
1265
|
+
console.warn('THREE.VRMLLoader: Unknown field:', fieldName);
|
|
1026
1266
|
break;
|
|
1027
1267
|
}
|
|
1028
1268
|
}
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1269
|
+
|
|
1270
|
+
if (coordIndex === undefined) {
|
|
1271
|
+
console.warn('THREE.VRMLLoader: Missing coordIndex.');
|
|
1272
|
+
return new BufferGeometry(); // handle VRML files with incomplete geometry definition
|
|
1032
1273
|
}
|
|
1274
|
+
|
|
1033
1275
|
const triangulatedCoordIndex = triangulateFaceIndex(coordIndex, ccw);
|
|
1034
1276
|
let colorAttribute;
|
|
1035
1277
|
let normalAttribute;
|
|
1036
1278
|
let uvAttribute;
|
|
1279
|
+
|
|
1037
1280
|
if (color) {
|
|
1038
1281
|
if (colorPerVertex === true) {
|
|
1039
1282
|
if (colorIndex && colorIndex.length > 0) {
|
|
1283
|
+
// if the colorIndex field is not empty, then it is used to choose colors for each vertex of the IndexedFaceSet.
|
|
1040
1284
|
const triangulatedColorIndex = triangulateFaceIndex(colorIndex, ccw);
|
|
1041
1285
|
colorAttribute = computeAttributeFromIndexedData(triangulatedCoordIndex, triangulatedColorIndex, color, 3);
|
|
1042
1286
|
} else {
|
|
1043
|
-
|
|
1287
|
+
// if the colorIndex field is empty, then the coordIndex field is used to choose colors from the Color node
|
|
1288
|
+
colorAttribute = toNonIndexedAttribute(triangulatedCoordIndex, new Float32BufferAttribute(color, 3));
|
|
1044
1289
|
}
|
|
1045
1290
|
} else {
|
|
1046
1291
|
if (colorIndex && colorIndex.length > 0) {
|
|
1292
|
+
// if the colorIndex field is not empty, then they are used to choose one color for each face of the IndexedFaceSet
|
|
1047
1293
|
const flattenFaceColors = flattenData(color, colorIndex);
|
|
1048
1294
|
const triangulatedFaceColors = triangulateFaceData(flattenFaceColors, coordIndex);
|
|
1049
1295
|
colorAttribute = computeAttributeFromFaceData(triangulatedCoordIndex, triangulatedFaceColors);
|
|
1050
1296
|
} else {
|
|
1297
|
+
// if the colorIndex field is empty, then the color are applied to each face of the IndexedFaceSet in order
|
|
1051
1298
|
const triangulatedFaceColors = triangulateFaceData(color, coordIndex);
|
|
1052
1299
|
colorAttribute = computeAttributeFromFaceData(triangulatedCoordIndex, triangulatedFaceColors);
|
|
1053
1300
|
}
|
|
1054
1301
|
}
|
|
1055
1302
|
}
|
|
1303
|
+
|
|
1056
1304
|
if (normal) {
|
|
1057
1305
|
if (normalPerVertex === true) {
|
|
1306
|
+
// consider vertex normals
|
|
1058
1307
|
if (normalIndex && normalIndex.length > 0) {
|
|
1308
|
+
// if the normalIndex field is not empty, then it is used to choose normals for each vertex of the IndexedFaceSet.
|
|
1059
1309
|
const triangulatedNormalIndex = triangulateFaceIndex(normalIndex, ccw);
|
|
1060
|
-
normalAttribute = computeAttributeFromIndexedData(
|
|
1061
|
-
triangulatedCoordIndex,
|
|
1062
|
-
triangulatedNormalIndex,
|
|
1063
|
-
normal,
|
|
1064
|
-
3
|
|
1065
|
-
);
|
|
1310
|
+
normalAttribute = computeAttributeFromIndexedData(triangulatedCoordIndex, triangulatedNormalIndex, normal, 3);
|
|
1066
1311
|
} else {
|
|
1067
|
-
|
|
1312
|
+
// if the normalIndex field is empty, then the coordIndex field is used to choose normals from the Normal node
|
|
1313
|
+
normalAttribute = toNonIndexedAttribute(triangulatedCoordIndex, new Float32BufferAttribute(normal, 3));
|
|
1068
1314
|
}
|
|
1069
1315
|
} else {
|
|
1316
|
+
// consider face normals
|
|
1070
1317
|
if (normalIndex && normalIndex.length > 0) {
|
|
1318
|
+
// if the normalIndex field is not empty, then they are used to choose one normal for each face of the IndexedFaceSet
|
|
1071
1319
|
const flattenFaceNormals = flattenData(normal, normalIndex);
|
|
1072
1320
|
const triangulatedFaceNormals = triangulateFaceData(flattenFaceNormals, coordIndex);
|
|
1073
1321
|
normalAttribute = computeAttributeFromFaceData(triangulatedCoordIndex, triangulatedFaceNormals);
|
|
1074
1322
|
} else {
|
|
1323
|
+
// if the normalIndex field is empty, then the normals are applied to each face of the IndexedFaceSet in order
|
|
1075
1324
|
const triangulatedFaceNormals = triangulateFaceData(normal, coordIndex);
|
|
1076
1325
|
normalAttribute = computeAttributeFromFaceData(triangulatedCoordIndex, triangulatedFaceNormals);
|
|
1077
1326
|
}
|
|
1078
1327
|
}
|
|
1079
1328
|
} else {
|
|
1329
|
+
// 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
|
|
1080
1330
|
normalAttribute = computeNormalAttribute(triangulatedCoordIndex, coord, creaseAngle);
|
|
1081
1331
|
}
|
|
1332
|
+
|
|
1082
1333
|
if (texCoord) {
|
|
1334
|
+
// texture coordinates are always defined on vertex level
|
|
1083
1335
|
if (texCoordIndex && texCoordIndex.length > 0) {
|
|
1336
|
+
// if the texCoordIndex field is not empty, then it is used to choose texture coordinates for each vertex of the IndexedFaceSet.
|
|
1084
1337
|
const triangulatedTexCoordIndex = triangulateFaceIndex(texCoordIndex, ccw);
|
|
1085
1338
|
uvAttribute = computeAttributeFromIndexedData(triangulatedCoordIndex, triangulatedTexCoordIndex, texCoord, 2);
|
|
1086
1339
|
} else {
|
|
1087
|
-
|
|
1340
|
+
// if the texCoordIndex field is empty, then the coordIndex array is used to choose texture coordinates from the TextureCoordinate node
|
|
1341
|
+
uvAttribute = toNonIndexedAttribute(triangulatedCoordIndex, new Float32BufferAttribute(texCoord, 2));
|
|
1088
1342
|
}
|
|
1089
1343
|
}
|
|
1090
|
-
|
|
1091
|
-
const
|
|
1092
|
-
|
|
1093
|
-
geometry.setAttribute(
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
if (
|
|
1097
|
-
|
|
1344
|
+
|
|
1345
|
+
const geometry = new BufferGeometry();
|
|
1346
|
+
const positionAttribute = toNonIndexedAttribute(triangulatedCoordIndex, new Float32BufferAttribute(coord, 3));
|
|
1347
|
+
geometry.setAttribute('position', positionAttribute);
|
|
1348
|
+
geometry.setAttribute('normal', normalAttribute); // optional attributes
|
|
1349
|
+
|
|
1350
|
+
if (colorAttribute) geometry.setAttribute('color', colorAttribute);
|
|
1351
|
+
if (uvAttribute) geometry.setAttribute('uv', uvAttribute); // "solid" influences the material so let's store it for later use
|
|
1352
|
+
|
|
1098
1353
|
geometry._solid = solid;
|
|
1099
|
-
geometry._type =
|
|
1354
|
+
geometry._type = 'mesh';
|
|
1100
1355
|
return geometry;
|
|
1101
1356
|
}
|
|
1357
|
+
|
|
1102
1358
|
function buildIndexedLineSetNode(node) {
|
|
1103
1359
|
let color, coord;
|
|
1104
1360
|
let colorIndex, coordIndex;
|
|
1105
1361
|
let colorPerVertex = true;
|
|
1106
1362
|
const fields = node.fields;
|
|
1363
|
+
|
|
1107
1364
|
for (let i = 0, l = fields.length; i < l; i++) {
|
|
1108
1365
|
const field = fields[i];
|
|
1109
1366
|
const fieldName = field.name;
|
|
1110
1367
|
const fieldValues = field.values;
|
|
1368
|
+
|
|
1111
1369
|
switch (fieldName) {
|
|
1112
|
-
case
|
|
1370
|
+
case 'color':
|
|
1113
1371
|
const colorNode = fieldValues[0];
|
|
1372
|
+
|
|
1114
1373
|
if (colorNode !== null) {
|
|
1115
1374
|
color = getNode(colorNode);
|
|
1116
1375
|
}
|
|
1376
|
+
|
|
1117
1377
|
break;
|
|
1118
|
-
|
|
1378
|
+
|
|
1379
|
+
case 'coord':
|
|
1119
1380
|
const coordNode = fieldValues[0];
|
|
1381
|
+
|
|
1120
1382
|
if (coordNode !== null) {
|
|
1121
1383
|
coord = getNode(coordNode);
|
|
1122
1384
|
}
|
|
1385
|
+
|
|
1123
1386
|
break;
|
|
1124
|
-
|
|
1387
|
+
|
|
1388
|
+
case 'colorIndex':
|
|
1125
1389
|
colorIndex = fieldValues;
|
|
1126
1390
|
break;
|
|
1127
|
-
|
|
1391
|
+
|
|
1392
|
+
case 'colorPerVertex':
|
|
1128
1393
|
colorPerVertex = fieldValues[0];
|
|
1129
1394
|
break;
|
|
1130
|
-
|
|
1395
|
+
|
|
1396
|
+
case 'coordIndex':
|
|
1131
1397
|
coordIndex = fieldValues;
|
|
1132
1398
|
break;
|
|
1399
|
+
|
|
1133
1400
|
default:
|
|
1134
|
-
console.warn(
|
|
1401
|
+
console.warn('THREE.VRMLLoader: Unknown field:', fieldName);
|
|
1135
1402
|
break;
|
|
1136
1403
|
}
|
|
1137
|
-
}
|
|
1404
|
+
} // build lines
|
|
1405
|
+
|
|
1406
|
+
|
|
1138
1407
|
let colorAttribute;
|
|
1139
|
-
const expandedLineIndex = expandLineIndex(coordIndex);
|
|
1408
|
+
const expandedLineIndex = expandLineIndex(coordIndex); // create an index for three.js's linesegment primitive
|
|
1409
|
+
|
|
1140
1410
|
if (color) {
|
|
1141
1411
|
if (colorPerVertex === true) {
|
|
1142
1412
|
if (colorIndex.length > 0) {
|
|
1143
|
-
|
|
1144
|
-
|
|
1413
|
+
// if the colorIndex field is not empty, then one color is used for each polyline of the IndexedLineSet.
|
|
1414
|
+
const expandedColorIndex = expandLineIndex(colorIndex); // compute colors for each line segment (rendering primitve)
|
|
1415
|
+
|
|
1416
|
+
colorAttribute = computeAttributeFromIndexedData(expandedLineIndex, expandedColorIndex, color, 3); // compute data on vertex level
|
|
1145
1417
|
} else {
|
|
1146
|
-
|
|
1418
|
+
// if the colorIndex field is empty, then the colors are applied to each polyline of the IndexedLineSet in order.
|
|
1419
|
+
colorAttribute = toNonIndexedAttribute(expandedLineIndex, new Float32BufferAttribute(color, 3));
|
|
1147
1420
|
}
|
|
1148
1421
|
} else {
|
|
1149
1422
|
if (colorIndex.length > 0) {
|
|
1150
|
-
|
|
1151
|
-
const
|
|
1152
|
-
|
|
1423
|
+
// if the colorIndex field is not empty, then colors are applied to each vertex of the IndexedLineSet
|
|
1424
|
+
const flattenLineColors = flattenData(color, colorIndex); // compute colors for each VRML primitve
|
|
1425
|
+
|
|
1426
|
+
const expandedLineColors = expandLineData(flattenLineColors, coordIndex); // compute colors for each line segment (rendering primitve)
|
|
1427
|
+
|
|
1428
|
+
colorAttribute = computeAttributeFromLineData(expandedLineIndex, expandedLineColors); // compute data on vertex level
|
|
1153
1429
|
} else {
|
|
1154
|
-
|
|
1155
|
-
|
|
1430
|
+
// if the colorIndex field is empty, then the coordIndex field is used to choose colors from the Color node
|
|
1431
|
+
const expandedLineColors = expandLineData(color, coordIndex); // compute colors for each line segment (rendering primitve)
|
|
1432
|
+
|
|
1433
|
+
colorAttribute = computeAttributeFromLineData(expandedLineIndex, expandedLineColors); // compute data on vertex level
|
|
1156
1434
|
}
|
|
1157
1435
|
}
|
|
1158
|
-
}
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
geometry
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
geometry.
|
|
1436
|
+
} //
|
|
1437
|
+
|
|
1438
|
+
|
|
1439
|
+
const geometry = new BufferGeometry();
|
|
1440
|
+
const positionAttribute = toNonIndexedAttribute(expandedLineIndex, new Float32BufferAttribute(coord, 3));
|
|
1441
|
+
geometry.setAttribute('position', positionAttribute);
|
|
1442
|
+
if (colorAttribute) geometry.setAttribute('color', colorAttribute);
|
|
1443
|
+
geometry._type = 'line';
|
|
1165
1444
|
return geometry;
|
|
1166
1445
|
}
|
|
1446
|
+
|
|
1167
1447
|
function buildPointSetNode(node) {
|
|
1168
1448
|
let color, coord;
|
|
1169
1449
|
const fields = node.fields;
|
|
1450
|
+
|
|
1170
1451
|
for (let i = 0, l = fields.length; i < l; i++) {
|
|
1171
1452
|
const field = fields[i];
|
|
1172
1453
|
const fieldName = field.name;
|
|
1173
1454
|
const fieldValues = field.values;
|
|
1455
|
+
|
|
1174
1456
|
switch (fieldName) {
|
|
1175
|
-
case
|
|
1457
|
+
case 'color':
|
|
1176
1458
|
const colorNode = fieldValues[0];
|
|
1459
|
+
|
|
1177
1460
|
if (colorNode !== null) {
|
|
1178
1461
|
color = getNode(colorNode);
|
|
1179
1462
|
}
|
|
1463
|
+
|
|
1180
1464
|
break;
|
|
1181
|
-
|
|
1465
|
+
|
|
1466
|
+
case 'coord':
|
|
1182
1467
|
const coordNode = fieldValues[0];
|
|
1468
|
+
|
|
1183
1469
|
if (coordNode !== null) {
|
|
1184
1470
|
coord = getNode(coordNode);
|
|
1185
1471
|
}
|
|
1472
|
+
|
|
1186
1473
|
break;
|
|
1474
|
+
|
|
1187
1475
|
default:
|
|
1188
|
-
console.warn(
|
|
1476
|
+
console.warn('THREE.VRMLLoader: Unknown field:', fieldName);
|
|
1189
1477
|
break;
|
|
1190
1478
|
}
|
|
1191
1479
|
}
|
|
1192
|
-
|
|
1193
|
-
geometry
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
geometry._type =
|
|
1480
|
+
|
|
1481
|
+
const geometry = new BufferGeometry();
|
|
1482
|
+
geometry.setAttribute('position', new Float32BufferAttribute(coord, 3));
|
|
1483
|
+
if (color) geometry.setAttribute('color', new Float32BufferAttribute(color, 3));
|
|
1484
|
+
geometry._type = 'points';
|
|
1197
1485
|
return geometry;
|
|
1198
1486
|
}
|
|
1487
|
+
|
|
1199
1488
|
function buildBoxNode(node) {
|
|
1200
|
-
const size = new
|
|
1489
|
+
const size = new Vector3(2, 2, 2);
|
|
1201
1490
|
const fields = node.fields;
|
|
1491
|
+
|
|
1202
1492
|
for (let i = 0, l = fields.length; i < l; i++) {
|
|
1203
1493
|
const field = fields[i];
|
|
1204
1494
|
const fieldName = field.name;
|
|
1205
1495
|
const fieldValues = field.values;
|
|
1496
|
+
|
|
1206
1497
|
switch (fieldName) {
|
|
1207
|
-
case
|
|
1498
|
+
case 'size':
|
|
1208
1499
|
size.x = fieldValues[0];
|
|
1209
1500
|
size.y = fieldValues[1];
|
|
1210
1501
|
size.z = fieldValues[2];
|
|
1211
1502
|
break;
|
|
1503
|
+
|
|
1212
1504
|
default:
|
|
1213
|
-
console.warn(
|
|
1505
|
+
console.warn('THREE.VRMLLoader: Unknown field:', fieldName);
|
|
1214
1506
|
break;
|
|
1215
1507
|
}
|
|
1216
1508
|
}
|
|
1217
|
-
|
|
1509
|
+
|
|
1510
|
+
const geometry = new BoxGeometry(size.x, size.y, size.z);
|
|
1218
1511
|
return geometry;
|
|
1219
1512
|
}
|
|
1513
|
+
|
|
1220
1514
|
function buildConeNode(node) {
|
|
1221
|
-
let radius = 1,
|
|
1515
|
+
let radius = 1,
|
|
1516
|
+
height = 2,
|
|
1517
|
+
openEnded = false;
|
|
1222
1518
|
const fields = node.fields;
|
|
1519
|
+
|
|
1223
1520
|
for (let i = 0, l = fields.length; i < l; i++) {
|
|
1224
1521
|
const field = fields[i];
|
|
1225
1522
|
const fieldName = field.name;
|
|
1226
1523
|
const fieldValues = field.values;
|
|
1524
|
+
|
|
1227
1525
|
switch (fieldName) {
|
|
1228
|
-
case
|
|
1526
|
+
case 'bottom':
|
|
1229
1527
|
openEnded = !fieldValues[0];
|
|
1230
1528
|
break;
|
|
1231
|
-
|
|
1529
|
+
|
|
1530
|
+
case 'bottomRadius':
|
|
1232
1531
|
radius = fieldValues[0];
|
|
1233
1532
|
break;
|
|
1234
|
-
|
|
1533
|
+
|
|
1534
|
+
case 'height':
|
|
1235
1535
|
height = fieldValues[0];
|
|
1236
1536
|
break;
|
|
1237
|
-
|
|
1537
|
+
|
|
1538
|
+
case 'side':
|
|
1539
|
+
// field not supported
|
|
1238
1540
|
break;
|
|
1541
|
+
|
|
1239
1542
|
default:
|
|
1240
|
-
console.warn(
|
|
1543
|
+
console.warn('THREE.VRMLLoader: Unknown field:', fieldName);
|
|
1241
1544
|
break;
|
|
1242
1545
|
}
|
|
1243
1546
|
}
|
|
1244
|
-
|
|
1547
|
+
|
|
1548
|
+
const geometry = new ConeGeometry(radius, height, 16, 1, openEnded);
|
|
1245
1549
|
return geometry;
|
|
1246
1550
|
}
|
|
1551
|
+
|
|
1247
1552
|
function buildCylinderNode(node) {
|
|
1248
|
-
let radius = 1,
|
|
1553
|
+
let radius = 1,
|
|
1554
|
+
height = 2;
|
|
1249
1555
|
const fields = node.fields;
|
|
1556
|
+
|
|
1250
1557
|
for (let i = 0, l = fields.length; i < l; i++) {
|
|
1251
1558
|
const field = fields[i];
|
|
1252
1559
|
const fieldName = field.name;
|
|
1253
1560
|
const fieldValues = field.values;
|
|
1561
|
+
|
|
1254
1562
|
switch (fieldName) {
|
|
1255
|
-
case
|
|
1563
|
+
case 'bottom':
|
|
1564
|
+
// field not supported
|
|
1256
1565
|
break;
|
|
1257
|
-
|
|
1566
|
+
|
|
1567
|
+
case 'radius':
|
|
1258
1568
|
radius = fieldValues[0];
|
|
1259
1569
|
break;
|
|
1260
|
-
|
|
1570
|
+
|
|
1571
|
+
case 'height':
|
|
1261
1572
|
height = fieldValues[0];
|
|
1262
1573
|
break;
|
|
1263
|
-
|
|
1574
|
+
|
|
1575
|
+
case 'side':
|
|
1576
|
+
// field not supported
|
|
1264
1577
|
break;
|
|
1265
|
-
|
|
1578
|
+
|
|
1579
|
+
case 'top':
|
|
1580
|
+
// field not supported
|
|
1266
1581
|
break;
|
|
1582
|
+
|
|
1267
1583
|
default:
|
|
1268
|
-
console.warn(
|
|
1584
|
+
console.warn('THREE.VRMLLoader: Unknown field:', fieldName);
|
|
1269
1585
|
break;
|
|
1270
1586
|
}
|
|
1271
1587
|
}
|
|
1272
|
-
|
|
1588
|
+
|
|
1589
|
+
const geometry = new CylinderGeometry(radius, radius, height, 16, 1);
|
|
1273
1590
|
return geometry;
|
|
1274
1591
|
}
|
|
1592
|
+
|
|
1275
1593
|
function buildSphereNode(node) {
|
|
1276
1594
|
let radius = 1;
|
|
1277
1595
|
const fields = node.fields;
|
|
1596
|
+
|
|
1278
1597
|
for (let i = 0, l = fields.length; i < l; i++) {
|
|
1279
1598
|
const field = fields[i];
|
|
1280
1599
|
const fieldName = field.name;
|
|
1281
1600
|
const fieldValues = field.values;
|
|
1601
|
+
|
|
1282
1602
|
switch (fieldName) {
|
|
1283
|
-
case
|
|
1603
|
+
case 'radius':
|
|
1284
1604
|
radius = fieldValues[0];
|
|
1285
1605
|
break;
|
|
1606
|
+
|
|
1286
1607
|
default:
|
|
1287
|
-
console.warn(
|
|
1608
|
+
console.warn('THREE.VRMLLoader: Unknown field:', fieldName);
|
|
1288
1609
|
break;
|
|
1289
1610
|
}
|
|
1290
1611
|
}
|
|
1291
|
-
|
|
1612
|
+
|
|
1613
|
+
const geometry = new SphereGeometry(radius, 16, 16);
|
|
1292
1614
|
return geometry;
|
|
1293
1615
|
}
|
|
1616
|
+
|
|
1294
1617
|
function buildElevationGridNode(node) {
|
|
1295
1618
|
let color;
|
|
1296
1619
|
let normal;
|
|
@@ -1306,87 +1629,118 @@ class VRMLLoader extends THREE.Loader {
|
|
|
1306
1629
|
let xSpacing = 1;
|
|
1307
1630
|
let zSpacing = 1;
|
|
1308
1631
|
const fields = node.fields;
|
|
1632
|
+
|
|
1309
1633
|
for (let i = 0, l = fields.length; i < l; i++) {
|
|
1310
1634
|
const field = fields[i];
|
|
1311
1635
|
const fieldName = field.name;
|
|
1312
1636
|
const fieldValues = field.values;
|
|
1637
|
+
|
|
1313
1638
|
switch (fieldName) {
|
|
1314
|
-
case
|
|
1639
|
+
case 'color':
|
|
1315
1640
|
const colorNode = fieldValues[0];
|
|
1641
|
+
|
|
1316
1642
|
if (colorNode !== null) {
|
|
1317
1643
|
color = getNode(colorNode);
|
|
1318
1644
|
}
|
|
1645
|
+
|
|
1319
1646
|
break;
|
|
1320
|
-
|
|
1647
|
+
|
|
1648
|
+
case 'normal':
|
|
1321
1649
|
const normalNode = fieldValues[0];
|
|
1650
|
+
|
|
1322
1651
|
if (normalNode !== null) {
|
|
1323
1652
|
normal = getNode(normalNode);
|
|
1324
1653
|
}
|
|
1654
|
+
|
|
1325
1655
|
break;
|
|
1326
|
-
|
|
1656
|
+
|
|
1657
|
+
case 'texCoord':
|
|
1327
1658
|
const texCoordNode = fieldValues[0];
|
|
1659
|
+
|
|
1328
1660
|
if (texCoordNode !== null) {
|
|
1329
1661
|
texCoord = getNode(texCoordNode);
|
|
1330
1662
|
}
|
|
1663
|
+
|
|
1331
1664
|
break;
|
|
1332
|
-
|
|
1665
|
+
|
|
1666
|
+
case 'height':
|
|
1333
1667
|
height = fieldValues;
|
|
1334
1668
|
break;
|
|
1335
|
-
|
|
1669
|
+
|
|
1670
|
+
case 'ccw':
|
|
1336
1671
|
ccw = fieldValues[0];
|
|
1337
1672
|
break;
|
|
1338
|
-
|
|
1673
|
+
|
|
1674
|
+
case 'colorPerVertex':
|
|
1339
1675
|
colorPerVertex = fieldValues[0];
|
|
1340
1676
|
break;
|
|
1341
|
-
|
|
1677
|
+
|
|
1678
|
+
case 'creaseAngle':
|
|
1342
1679
|
creaseAngle = fieldValues[0];
|
|
1343
1680
|
break;
|
|
1344
|
-
|
|
1681
|
+
|
|
1682
|
+
case 'normalPerVertex':
|
|
1345
1683
|
normalPerVertex = fieldValues[0];
|
|
1346
1684
|
break;
|
|
1347
|
-
|
|
1685
|
+
|
|
1686
|
+
case 'solid':
|
|
1348
1687
|
solid = fieldValues[0];
|
|
1349
1688
|
break;
|
|
1350
|
-
|
|
1689
|
+
|
|
1690
|
+
case 'xDimension':
|
|
1351
1691
|
xDimension = fieldValues[0];
|
|
1352
1692
|
break;
|
|
1353
|
-
|
|
1693
|
+
|
|
1694
|
+
case 'xSpacing':
|
|
1354
1695
|
xSpacing = fieldValues[0];
|
|
1355
1696
|
break;
|
|
1356
|
-
|
|
1697
|
+
|
|
1698
|
+
case 'zDimension':
|
|
1357
1699
|
zDimension = fieldValues[0];
|
|
1358
1700
|
break;
|
|
1359
|
-
|
|
1701
|
+
|
|
1702
|
+
case 'zSpacing':
|
|
1360
1703
|
zSpacing = fieldValues[0];
|
|
1361
1704
|
break;
|
|
1705
|
+
|
|
1362
1706
|
default:
|
|
1363
|
-
console.warn(
|
|
1707
|
+
console.warn('THREE.VRMLLoader: Unknown field:', fieldName);
|
|
1364
1708
|
break;
|
|
1365
1709
|
}
|
|
1366
|
-
}
|
|
1710
|
+
} // vertex data
|
|
1711
|
+
|
|
1712
|
+
|
|
1367
1713
|
const vertices = [];
|
|
1368
1714
|
const normals = [];
|
|
1369
1715
|
const colors = [];
|
|
1370
1716
|
const uvs = [];
|
|
1717
|
+
|
|
1371
1718
|
for (let i = 0; i < zDimension; i++) {
|
|
1372
1719
|
for (let j = 0; j < xDimension; j++) {
|
|
1373
|
-
|
|
1720
|
+
// compute a row major index
|
|
1721
|
+
const index = i * xDimension + j; // vertices
|
|
1722
|
+
|
|
1374
1723
|
const x = xSpacing * i;
|
|
1375
1724
|
const y = height[index];
|
|
1376
1725
|
const z = zSpacing * j;
|
|
1377
|
-
vertices.push(x, y, z);
|
|
1726
|
+
vertices.push(x, y, z); // colors
|
|
1727
|
+
|
|
1378
1728
|
if (color && colorPerVertex === true) {
|
|
1379
1729
|
const r = color[index * 3 + 0];
|
|
1380
1730
|
const g = color[index * 3 + 1];
|
|
1381
1731
|
const b = color[index * 3 + 2];
|
|
1382
1732
|
colors.push(r, g, b);
|
|
1383
|
-
}
|
|
1733
|
+
} // normals
|
|
1734
|
+
|
|
1735
|
+
|
|
1384
1736
|
if (normal && normalPerVertex === true) {
|
|
1385
1737
|
const xn = normal[index * 3 + 0];
|
|
1386
1738
|
const yn = normal[index * 3 + 1];
|
|
1387
1739
|
const zn = normal[index * 3 + 2];
|
|
1388
1740
|
normals.push(xn, yn, zn);
|
|
1389
|
-
}
|
|
1741
|
+
} // uvs
|
|
1742
|
+
|
|
1743
|
+
|
|
1390
1744
|
if (texCoord) {
|
|
1391
1745
|
const s = texCoord[index * 2 + 0];
|
|
1392
1746
|
const t = texCoord[index * 2 + 1];
|
|
@@ -1395,14 +1749,19 @@ class VRMLLoader extends THREE.Loader {
|
|
|
1395
1749
|
uvs.push(i / (xDimension - 1), j / (zDimension - 1));
|
|
1396
1750
|
}
|
|
1397
1751
|
}
|
|
1398
|
-
}
|
|
1752
|
+
} // indices
|
|
1753
|
+
|
|
1754
|
+
|
|
1399
1755
|
const indices = [];
|
|
1756
|
+
|
|
1400
1757
|
for (let i = 0; i < xDimension - 1; i++) {
|
|
1401
1758
|
for (let j = 0; j < zDimension - 1; j++) {
|
|
1759
|
+
// from https://tecfa.unige.ch/guides/vrml/vrml97/spec/part1/nodesRef.html#ElevationGrid
|
|
1402
1760
|
const a = i + j * xDimension;
|
|
1403
1761
|
const b = i + (j + 1) * xDimension;
|
|
1404
1762
|
const c = i + 1 + (j + 1) * xDimension;
|
|
1405
|
-
const d = i + 1 + j * xDimension;
|
|
1763
|
+
const d = i + 1 + j * xDimension; // faces
|
|
1764
|
+
|
|
1406
1765
|
if (ccw === true) {
|
|
1407
1766
|
indices.push(a, c, b);
|
|
1408
1767
|
indices.push(c, a, d);
|
|
@@ -1411,11 +1770,14 @@ class VRMLLoader extends THREE.Loader {
|
|
|
1411
1770
|
indices.push(c, d, a);
|
|
1412
1771
|
}
|
|
1413
1772
|
}
|
|
1414
|
-
}
|
|
1415
|
-
|
|
1416
|
-
|
|
1773
|
+
} //
|
|
1774
|
+
|
|
1775
|
+
|
|
1776
|
+
const positionAttribute = toNonIndexedAttribute(indices, new Float32BufferAttribute(vertices, 3));
|
|
1777
|
+
const uvAttribute = toNonIndexedAttribute(indices, new Float32BufferAttribute(uvs, 2));
|
|
1417
1778
|
let colorAttribute;
|
|
1418
|
-
let normalAttribute;
|
|
1779
|
+
let normalAttribute; // color attribute
|
|
1780
|
+
|
|
1419
1781
|
if (color) {
|
|
1420
1782
|
if (colorPerVertex === false) {
|
|
1421
1783
|
for (let i = 0; i < xDimension - 1; i++) {
|
|
@@ -1423,7 +1785,8 @@ class VRMLLoader extends THREE.Loader {
|
|
|
1423
1785
|
const index = i + j * (xDimension - 1);
|
|
1424
1786
|
const r = color[index * 3 + 0];
|
|
1425
1787
|
const g = color[index * 3 + 1];
|
|
1426
|
-
const b = color[index * 3 + 2];
|
|
1788
|
+
const b = color[index * 3 + 2]; // one color per quad
|
|
1789
|
+
|
|
1427
1790
|
colors.push(r, g, b);
|
|
1428
1791
|
colors.push(r, g, b);
|
|
1429
1792
|
colors.push(r, g, b);
|
|
@@ -1432,11 +1795,14 @@ class VRMLLoader extends THREE.Loader {
|
|
|
1432
1795
|
colors.push(r, g, b);
|
|
1433
1796
|
}
|
|
1434
1797
|
}
|
|
1435
|
-
|
|
1798
|
+
|
|
1799
|
+
colorAttribute = new Float32BufferAttribute(colors, 3);
|
|
1436
1800
|
} else {
|
|
1437
|
-
colorAttribute = toNonIndexedAttribute(indices, new
|
|
1801
|
+
colorAttribute = toNonIndexedAttribute(indices, new Float32BufferAttribute(colors, 3));
|
|
1438
1802
|
}
|
|
1439
|
-
}
|
|
1803
|
+
} // normal attribute
|
|
1804
|
+
|
|
1805
|
+
|
|
1440
1806
|
if (normal) {
|
|
1441
1807
|
if (normalPerVertex === false) {
|
|
1442
1808
|
for (let i = 0; i < xDimension - 1; i++) {
|
|
@@ -1444,7 +1810,8 @@ class VRMLLoader extends THREE.Loader {
|
|
|
1444
1810
|
const index = i + j * (xDimension - 1);
|
|
1445
1811
|
const xn = normal[index * 3 + 0];
|
|
1446
1812
|
const yn = normal[index * 3 + 1];
|
|
1447
|
-
const zn = normal[index * 3 + 2];
|
|
1813
|
+
const zn = normal[index * 3 + 2]; // one normal per quad
|
|
1814
|
+
|
|
1448
1815
|
normals.push(xn, yn, zn);
|
|
1449
1816
|
normals.push(xn, yn, zn);
|
|
1450
1817
|
normals.push(xn, yn, zn);
|
|
@@ -1453,23 +1820,27 @@ class VRMLLoader extends THREE.Loader {
|
|
|
1453
1820
|
normals.push(xn, yn, zn);
|
|
1454
1821
|
}
|
|
1455
1822
|
}
|
|
1456
|
-
|
|
1823
|
+
|
|
1824
|
+
normalAttribute = new Float32BufferAttribute(normals, 3);
|
|
1457
1825
|
} else {
|
|
1458
|
-
normalAttribute = toNonIndexedAttribute(indices, new
|
|
1826
|
+
normalAttribute = toNonIndexedAttribute(indices, new Float32BufferAttribute(normals, 3));
|
|
1459
1827
|
}
|
|
1460
1828
|
} else {
|
|
1461
1829
|
normalAttribute = computeNormalAttribute(indices, vertices, creaseAngle);
|
|
1462
|
-
}
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
geometry
|
|
1466
|
-
geometry.setAttribute(
|
|
1467
|
-
|
|
1468
|
-
|
|
1830
|
+
} // build geometry
|
|
1831
|
+
|
|
1832
|
+
|
|
1833
|
+
const geometry = new BufferGeometry();
|
|
1834
|
+
geometry.setAttribute('position', positionAttribute);
|
|
1835
|
+
geometry.setAttribute('normal', normalAttribute);
|
|
1836
|
+
geometry.setAttribute('uv', uvAttribute);
|
|
1837
|
+
if (colorAttribute) geometry.setAttribute('color', colorAttribute); // "solid" influences the material so let's store it for later use
|
|
1838
|
+
|
|
1469
1839
|
geometry._solid = solid;
|
|
1470
|
-
geometry._type =
|
|
1840
|
+
geometry._type = 'mesh';
|
|
1471
1841
|
return geometry;
|
|
1472
1842
|
}
|
|
1843
|
+
|
|
1473
1844
|
function buildExtrusionNode(node) {
|
|
1474
1845
|
let crossSection = [1, 1, 1, -1, -1, -1, -1, 1, 1, 1];
|
|
1475
1846
|
let spine = [0, 0, 0, 0, 1, 0];
|
|
@@ -1481,52 +1852,69 @@ class VRMLLoader extends THREE.Loader {
|
|
|
1481
1852
|
let endCap = true;
|
|
1482
1853
|
let solid = true;
|
|
1483
1854
|
const fields = node.fields;
|
|
1855
|
+
|
|
1484
1856
|
for (let i = 0, l = fields.length; i < l; i++) {
|
|
1485
1857
|
const field = fields[i];
|
|
1486
1858
|
const fieldName = field.name;
|
|
1487
1859
|
const fieldValues = field.values;
|
|
1860
|
+
|
|
1488
1861
|
switch (fieldName) {
|
|
1489
|
-
case
|
|
1862
|
+
case 'beginCap':
|
|
1490
1863
|
beginCap = fieldValues[0];
|
|
1491
1864
|
break;
|
|
1492
|
-
|
|
1865
|
+
|
|
1866
|
+
case 'ccw':
|
|
1493
1867
|
ccw = fieldValues[0];
|
|
1494
1868
|
break;
|
|
1495
|
-
|
|
1869
|
+
|
|
1870
|
+
case 'convex':
|
|
1871
|
+
// field not supported
|
|
1496
1872
|
break;
|
|
1497
|
-
|
|
1873
|
+
|
|
1874
|
+
case 'creaseAngle':
|
|
1498
1875
|
creaseAngle = fieldValues[0];
|
|
1499
1876
|
break;
|
|
1500
|
-
|
|
1877
|
+
|
|
1878
|
+
case 'crossSection':
|
|
1501
1879
|
crossSection = fieldValues;
|
|
1502
1880
|
break;
|
|
1503
|
-
|
|
1881
|
+
|
|
1882
|
+
case 'endCap':
|
|
1504
1883
|
endCap = fieldValues[0];
|
|
1505
1884
|
break;
|
|
1506
|
-
|
|
1885
|
+
|
|
1886
|
+
case 'orientation':
|
|
1507
1887
|
orientation = fieldValues;
|
|
1508
1888
|
break;
|
|
1509
|
-
|
|
1889
|
+
|
|
1890
|
+
case 'scale':
|
|
1510
1891
|
scale = fieldValues;
|
|
1511
1892
|
break;
|
|
1512
|
-
|
|
1893
|
+
|
|
1894
|
+
case 'solid':
|
|
1513
1895
|
solid = fieldValues[0];
|
|
1514
1896
|
break;
|
|
1515
|
-
|
|
1516
|
-
|
|
1897
|
+
|
|
1898
|
+
case 'spine':
|
|
1899
|
+
spine = fieldValues; // only extrusion along the Y-axis are supported so far
|
|
1900
|
+
|
|
1517
1901
|
break;
|
|
1902
|
+
|
|
1518
1903
|
default:
|
|
1519
|
-
console.warn(
|
|
1904
|
+
console.warn('THREE.VRMLLoader: Unknown field:', fieldName);
|
|
1520
1905
|
break;
|
|
1521
1906
|
}
|
|
1522
1907
|
}
|
|
1523
|
-
|
|
1908
|
+
|
|
1909
|
+
const crossSectionClosed = crossSection[0] === crossSection[crossSection.length - 2] && crossSection[1] === crossSection[crossSection.length - 1]; // vertices
|
|
1910
|
+
|
|
1524
1911
|
const vertices = [];
|
|
1525
|
-
const spineVector = new
|
|
1526
|
-
const scaling = new
|
|
1527
|
-
const axis = new
|
|
1528
|
-
const vertex = new
|
|
1529
|
-
const quaternion = new
|
|
1912
|
+
const spineVector = new Vector3();
|
|
1913
|
+
const scaling = new Vector3();
|
|
1914
|
+
const axis = new Vector3();
|
|
1915
|
+
const vertex = new Vector3();
|
|
1916
|
+
const quaternion = new Quaternion();
|
|
1917
|
+
|
|
1530
1918
|
for (let i = 0, j = 0, o = 0, il = spine.length; i < il; i += 3, j += 2, o += 4) {
|
|
1531
1919
|
spineVector.fromArray(spine, i);
|
|
1532
1920
|
scaling.x = scale ? scale[j + 0] : 1;
|
|
@@ -1536,30 +1924,39 @@ class VRMLLoader extends THREE.Loader {
|
|
|
1536
1924
|
axis.y = orientation ? orientation[o + 1] : 0;
|
|
1537
1925
|
axis.z = orientation ? orientation[o + 2] : 1;
|
|
1538
1926
|
const angle = orientation ? orientation[o + 3] : 0;
|
|
1927
|
+
|
|
1539
1928
|
for (let k = 0, kl = crossSection.length; k < kl; k += 2) {
|
|
1540
1929
|
vertex.x = crossSection[k + 0];
|
|
1541
1930
|
vertex.y = 0;
|
|
1542
|
-
vertex.z = crossSection[k + 1];
|
|
1543
|
-
|
|
1931
|
+
vertex.z = crossSection[k + 1]; // scale
|
|
1932
|
+
|
|
1933
|
+
vertex.multiply(scaling); // rotate
|
|
1934
|
+
|
|
1544
1935
|
quaternion.setFromAxisAngle(axis, angle);
|
|
1545
|
-
vertex.applyQuaternion(quaternion);
|
|
1936
|
+
vertex.applyQuaternion(quaternion); // translate
|
|
1937
|
+
|
|
1546
1938
|
vertex.add(spineVector);
|
|
1547
1939
|
vertices.push(vertex.x, vertex.y, vertex.z);
|
|
1548
1940
|
}
|
|
1549
|
-
}
|
|
1941
|
+
} // indices
|
|
1942
|
+
|
|
1943
|
+
|
|
1550
1944
|
const indices = [];
|
|
1551
1945
|
const spineCount = spine.length / 3;
|
|
1552
1946
|
const crossSectionCount = crossSection.length / 2;
|
|
1947
|
+
|
|
1553
1948
|
for (let i = 0; i < spineCount - 1; i++) {
|
|
1554
1949
|
for (let j = 0; j < crossSectionCount - 1; j++) {
|
|
1555
1950
|
const a = j + i * crossSectionCount;
|
|
1556
1951
|
let b = j + 1 + i * crossSectionCount;
|
|
1557
1952
|
const c = j + (i + 1) * crossSectionCount;
|
|
1558
1953
|
let d = j + 1 + (i + 1) * crossSectionCount;
|
|
1954
|
+
|
|
1559
1955
|
if (j === crossSectionCount - 2 && crossSectionClosed === true) {
|
|
1560
1956
|
b = i * crossSectionCount;
|
|
1561
1957
|
d = (i + 1) * crossSectionCount;
|
|
1562
1958
|
}
|
|
1959
|
+
|
|
1563
1960
|
if (ccw === true) {
|
|
1564
1961
|
indices.push(a, b, c);
|
|
1565
1962
|
indices.push(c, b, d);
|
|
@@ -1568,18 +1965,25 @@ class VRMLLoader extends THREE.Loader {
|
|
|
1568
1965
|
indices.push(c, d, b);
|
|
1569
1966
|
}
|
|
1570
1967
|
}
|
|
1571
|
-
}
|
|
1968
|
+
} // triangulate cap
|
|
1969
|
+
|
|
1970
|
+
|
|
1572
1971
|
if (beginCap === true || endCap === true) {
|
|
1573
1972
|
const contour = [];
|
|
1973
|
+
|
|
1574
1974
|
for (let i = 0, l = crossSection.length; i < l; i += 2) {
|
|
1575
|
-
contour.push(new
|
|
1975
|
+
contour.push(new Vector2(crossSection[i], crossSection[i + 1]));
|
|
1576
1976
|
}
|
|
1577
|
-
|
|
1977
|
+
|
|
1978
|
+
const faces = ShapeUtils.triangulateShape(contour, []);
|
|
1578
1979
|
const capIndices = [];
|
|
1980
|
+
|
|
1579
1981
|
for (let i = 0, l = faces.length; i < l; i++) {
|
|
1580
1982
|
const face = faces[i];
|
|
1581
1983
|
capIndices.push(face[0], face[1], face[2]);
|
|
1582
|
-
}
|
|
1984
|
+
} // begin cap
|
|
1985
|
+
|
|
1986
|
+
|
|
1583
1987
|
if (beginCap === true) {
|
|
1584
1988
|
for (let i = 0, l = capIndices.length; i < l; i += 3) {
|
|
1585
1989
|
if (ccw === true) {
|
|
@@ -1588,185 +1992,228 @@ class VRMLLoader extends THREE.Loader {
|
|
|
1588
1992
|
indices.push(capIndices[i + 0], capIndices[i + 2], capIndices[i + 1]);
|
|
1589
1993
|
}
|
|
1590
1994
|
}
|
|
1591
|
-
}
|
|
1995
|
+
} // end cap
|
|
1996
|
+
|
|
1997
|
+
|
|
1592
1998
|
if (endCap === true) {
|
|
1593
|
-
const indexOffset = crossSectionCount * (spineCount - 1);
|
|
1999
|
+
const indexOffset = crossSectionCount * (spineCount - 1); // references to the first vertex of the last cross section
|
|
2000
|
+
|
|
1594
2001
|
for (let i = 0, l = capIndices.length; i < l; i += 3) {
|
|
1595
2002
|
if (ccw === true) {
|
|
1596
|
-
indices.push(
|
|
1597
|
-
indexOffset + capIndices[i + 0],
|
|
1598
|
-
indexOffset + capIndices[i + 2],
|
|
1599
|
-
indexOffset + capIndices[i + 1]
|
|
1600
|
-
);
|
|
2003
|
+
indices.push(indexOffset + capIndices[i + 0], indexOffset + capIndices[i + 2], indexOffset + capIndices[i + 1]);
|
|
1601
2004
|
} else {
|
|
1602
|
-
indices.push(
|
|
1603
|
-
indexOffset + capIndices[i + 0],
|
|
1604
|
-
indexOffset + capIndices[i + 1],
|
|
1605
|
-
indexOffset + capIndices[i + 2]
|
|
1606
|
-
);
|
|
2005
|
+
indices.push(indexOffset + capIndices[i + 0], indexOffset + capIndices[i + 1], indexOffset + capIndices[i + 2]);
|
|
1607
2006
|
}
|
|
1608
2007
|
}
|
|
1609
2008
|
}
|
|
1610
2009
|
}
|
|
1611
|
-
|
|
2010
|
+
|
|
2011
|
+
const positionAttribute = toNonIndexedAttribute(indices, new Float32BufferAttribute(vertices, 3));
|
|
1612
2012
|
const normalAttribute = computeNormalAttribute(indices, vertices, creaseAngle);
|
|
1613
|
-
const geometry = new
|
|
1614
|
-
geometry.setAttribute(
|
|
1615
|
-
geometry.setAttribute(
|
|
2013
|
+
const geometry = new BufferGeometry();
|
|
2014
|
+
geometry.setAttribute('position', positionAttribute);
|
|
2015
|
+
geometry.setAttribute('normal', normalAttribute); // no uvs yet
|
|
2016
|
+
// "solid" influences the material so let's store it for later use
|
|
2017
|
+
|
|
1616
2018
|
geometry._solid = solid;
|
|
1617
|
-
geometry._type =
|
|
2019
|
+
geometry._type = 'mesh';
|
|
1618
2020
|
return geometry;
|
|
1619
|
-
}
|
|
2021
|
+
} // helper functions
|
|
2022
|
+
|
|
2023
|
+
|
|
1620
2024
|
function resolveUSE(identifier) {
|
|
1621
2025
|
const node = nodeMap[identifier];
|
|
1622
|
-
const build = getNode(node);
|
|
2026
|
+
const build = getNode(node); // because the same 3D objects can have different transformations, it's necessary to clone them.
|
|
2027
|
+
// materials can be influenced by the geometry (e.g. vertex normals). cloning is necessary to avoid
|
|
2028
|
+
// any side effects
|
|
2029
|
+
|
|
1623
2030
|
return build.isObject3D || build.isMaterial ? build.clone() : build;
|
|
1624
2031
|
}
|
|
2032
|
+
|
|
1625
2033
|
function parseFieldChildren(children, owner) {
|
|
1626
2034
|
for (let i = 0, l = children.length; i < l; i++) {
|
|
1627
2035
|
const object = getNode(children[i]);
|
|
1628
|
-
if (object instanceof
|
|
1629
|
-
owner.add(object);
|
|
2036
|
+
if (object instanceof Object3D) owner.add(object);
|
|
1630
2037
|
}
|
|
1631
2038
|
}
|
|
2039
|
+
|
|
1632
2040
|
function triangulateFaceIndex(index, ccw) {
|
|
1633
|
-
const indices = [];
|
|
2041
|
+
const indices = []; // since face defintions can have more than three vertices, it's necessary to
|
|
2042
|
+
// perform a simple triangulation
|
|
2043
|
+
|
|
1634
2044
|
let start = 0;
|
|
2045
|
+
|
|
1635
2046
|
for (let i = 0, l = index.length; i < l; i++) {
|
|
1636
2047
|
const i1 = index[start];
|
|
1637
2048
|
const i2 = index[i + (ccw ? 1 : 2)];
|
|
1638
2049
|
const i3 = index[i + (ccw ? 2 : 1)];
|
|
1639
|
-
indices.push(i1, i2, i3);
|
|
2050
|
+
indices.push(i1, i2, i3); // an index of -1 indicates that the current face has ended and the next one begins
|
|
2051
|
+
|
|
1640
2052
|
if (index[i + 3] === -1 || i + 3 >= l) {
|
|
1641
2053
|
i += 3;
|
|
1642
2054
|
start = i + 1;
|
|
1643
2055
|
}
|
|
1644
2056
|
}
|
|
2057
|
+
|
|
1645
2058
|
return indices;
|
|
1646
2059
|
}
|
|
1647
|
-
|
|
2060
|
+
|
|
2061
|
+
function triangulateFaceData(data, index) {
|
|
1648
2062
|
const triangulatedData = [];
|
|
1649
2063
|
let start = 0;
|
|
2064
|
+
|
|
1650
2065
|
for (let i = 0, l = index.length; i < l; i++) {
|
|
1651
2066
|
const stride = start * 3;
|
|
1652
|
-
const x =
|
|
1653
|
-
const y =
|
|
1654
|
-
const z =
|
|
1655
|
-
triangulatedData.push(x, y, z);
|
|
2067
|
+
const x = data[stride];
|
|
2068
|
+
const y = data[stride + 1];
|
|
2069
|
+
const z = data[stride + 2];
|
|
2070
|
+
triangulatedData.push(x, y, z); // an index of -1 indicates that the current face has ended and the next one begins
|
|
2071
|
+
|
|
1656
2072
|
if (index[i + 3] === -1 || i + 3 >= l) {
|
|
1657
2073
|
i += 3;
|
|
1658
2074
|
start++;
|
|
1659
2075
|
}
|
|
1660
2076
|
}
|
|
2077
|
+
|
|
1661
2078
|
return triangulatedData;
|
|
1662
2079
|
}
|
|
1663
|
-
|
|
1664
|
-
|
|
2080
|
+
|
|
2081
|
+
function flattenData(data, index) {
|
|
2082
|
+
const flattenData = [];
|
|
2083
|
+
|
|
1665
2084
|
for (let i = 0, l = index.length; i < l; i++) {
|
|
1666
2085
|
const i1 = index[i];
|
|
1667
2086
|
const stride = i1 * 3;
|
|
1668
|
-
const x =
|
|
1669
|
-
const y =
|
|
1670
|
-
const z =
|
|
1671
|
-
|
|
2087
|
+
const x = data[stride];
|
|
2088
|
+
const y = data[stride + 1];
|
|
2089
|
+
const z = data[stride + 2];
|
|
2090
|
+
flattenData.push(x, y, z);
|
|
1672
2091
|
}
|
|
1673
|
-
|
|
2092
|
+
|
|
2093
|
+
return flattenData;
|
|
1674
2094
|
}
|
|
2095
|
+
|
|
1675
2096
|
function expandLineIndex(index) {
|
|
1676
2097
|
const indices = [];
|
|
2098
|
+
|
|
1677
2099
|
for (let i = 0, l = index.length; i < l; i++) {
|
|
1678
2100
|
const i1 = index[i];
|
|
1679
2101
|
const i2 = index[i + 1];
|
|
1680
|
-
indices.push(i1, i2);
|
|
2102
|
+
indices.push(i1, i2); // an index of -1 indicates that the current line has ended and the next one begins
|
|
2103
|
+
|
|
1681
2104
|
if (index[i + 2] === -1 || i + 2 >= l) {
|
|
1682
2105
|
i += 2;
|
|
1683
2106
|
}
|
|
1684
2107
|
}
|
|
2108
|
+
|
|
1685
2109
|
return indices;
|
|
1686
2110
|
}
|
|
1687
|
-
|
|
2111
|
+
|
|
2112
|
+
function expandLineData(data, index) {
|
|
1688
2113
|
const triangulatedData = [];
|
|
1689
2114
|
let start = 0;
|
|
2115
|
+
|
|
1690
2116
|
for (let i = 0, l = index.length; i < l; i++) {
|
|
1691
2117
|
const stride = start * 3;
|
|
1692
|
-
const x =
|
|
1693
|
-
const y =
|
|
1694
|
-
const z =
|
|
1695
|
-
triangulatedData.push(x, y, z);
|
|
2118
|
+
const x = data[stride];
|
|
2119
|
+
const y = data[stride + 1];
|
|
2120
|
+
const z = data[stride + 2];
|
|
2121
|
+
triangulatedData.push(x, y, z); // an index of -1 indicates that the current line has ended and the next one begins
|
|
2122
|
+
|
|
1696
2123
|
if (index[i + 2] === -1 || i + 2 >= l) {
|
|
1697
2124
|
i += 2;
|
|
1698
2125
|
start++;
|
|
1699
2126
|
}
|
|
1700
2127
|
}
|
|
2128
|
+
|
|
1701
2129
|
return triangulatedData;
|
|
1702
2130
|
}
|
|
1703
|
-
|
|
1704
|
-
const
|
|
1705
|
-
const
|
|
1706
|
-
const
|
|
1707
|
-
const
|
|
1708
|
-
const
|
|
1709
|
-
|
|
1710
|
-
|
|
2131
|
+
|
|
2132
|
+
const vA = new Vector3();
|
|
2133
|
+
const vB = new Vector3();
|
|
2134
|
+
const vC = new Vector3();
|
|
2135
|
+
const uvA = new Vector2();
|
|
2136
|
+
const uvB = new Vector2();
|
|
2137
|
+
const uvC = new Vector2();
|
|
2138
|
+
|
|
2139
|
+
function computeAttributeFromIndexedData(coordIndex, index, data, itemSize) {
|
|
2140
|
+
const array = []; // we use the coordIndex.length as delimiter since normalIndex must contain at least as many indices
|
|
2141
|
+
|
|
1711
2142
|
for (let i = 0, l = coordIndex.length; i < l; i += 3) {
|
|
1712
2143
|
const a = index[i];
|
|
1713
2144
|
const b = index[i + 1];
|
|
1714
2145
|
const c = index[i + 2];
|
|
2146
|
+
|
|
1715
2147
|
if (itemSize === 2) {
|
|
1716
|
-
uvA.fromArray(
|
|
1717
|
-
uvB.fromArray(
|
|
1718
|
-
uvC.fromArray(
|
|
2148
|
+
uvA.fromArray(data, a * itemSize);
|
|
2149
|
+
uvB.fromArray(data, b * itemSize);
|
|
2150
|
+
uvC.fromArray(data, c * itemSize);
|
|
1719
2151
|
array.push(uvA.x, uvA.y);
|
|
1720
2152
|
array.push(uvB.x, uvB.y);
|
|
1721
2153
|
array.push(uvC.x, uvC.y);
|
|
1722
2154
|
} else {
|
|
1723
|
-
vA.fromArray(
|
|
1724
|
-
vB.fromArray(
|
|
1725
|
-
vC.fromArray(
|
|
2155
|
+
vA.fromArray(data, a * itemSize);
|
|
2156
|
+
vB.fromArray(data, b * itemSize);
|
|
2157
|
+
vC.fromArray(data, c * itemSize);
|
|
1726
2158
|
array.push(vA.x, vA.y, vA.z);
|
|
1727
2159
|
array.push(vB.x, vB.y, vB.z);
|
|
1728
2160
|
array.push(vC.x, vC.y, vC.z);
|
|
1729
2161
|
}
|
|
1730
2162
|
}
|
|
1731
|
-
|
|
2163
|
+
|
|
2164
|
+
return new Float32BufferAttribute(array, itemSize);
|
|
1732
2165
|
}
|
|
2166
|
+
|
|
1733
2167
|
function computeAttributeFromFaceData(index, faceData) {
|
|
1734
2168
|
const array = [];
|
|
2169
|
+
|
|
1735
2170
|
for (let i = 0, j = 0, l = index.length; i < l; i += 3, j++) {
|
|
1736
2171
|
vA.fromArray(faceData, j * 3);
|
|
1737
2172
|
array.push(vA.x, vA.y, vA.z);
|
|
1738
2173
|
array.push(vA.x, vA.y, vA.z);
|
|
1739
2174
|
array.push(vA.x, vA.y, vA.z);
|
|
1740
2175
|
}
|
|
1741
|
-
|
|
2176
|
+
|
|
2177
|
+
return new Float32BufferAttribute(array, 3);
|
|
1742
2178
|
}
|
|
2179
|
+
|
|
1743
2180
|
function computeAttributeFromLineData(index, lineData) {
|
|
1744
2181
|
const array = [];
|
|
2182
|
+
|
|
1745
2183
|
for (let i = 0, j = 0, l = index.length; i < l; i += 2, j++) {
|
|
1746
2184
|
vA.fromArray(lineData, j * 3);
|
|
1747
2185
|
array.push(vA.x, vA.y, vA.z);
|
|
1748
2186
|
array.push(vA.x, vA.y, vA.z);
|
|
1749
2187
|
}
|
|
1750
|
-
|
|
2188
|
+
|
|
2189
|
+
return new Float32BufferAttribute(array, 3);
|
|
1751
2190
|
}
|
|
2191
|
+
|
|
1752
2192
|
function toNonIndexedAttribute(indices, attribute) {
|
|
1753
2193
|
const array = attribute.array;
|
|
1754
2194
|
const itemSize = attribute.itemSize;
|
|
1755
2195
|
const array2 = new array.constructor(indices.length * itemSize);
|
|
1756
|
-
let index = 0,
|
|
2196
|
+
let index = 0,
|
|
2197
|
+
index2 = 0;
|
|
2198
|
+
|
|
1757
2199
|
for (let i = 0, l = indices.length; i < l; i++) {
|
|
1758
2200
|
index = indices[i] * itemSize;
|
|
2201
|
+
|
|
1759
2202
|
for (let j = 0; j < itemSize; j++) {
|
|
1760
2203
|
array2[index2++] = array[index++];
|
|
1761
2204
|
}
|
|
1762
2205
|
}
|
|
1763
|
-
|
|
2206
|
+
|
|
2207
|
+
return new Float32BufferAttribute(array2, itemSize);
|
|
1764
2208
|
}
|
|
1765
|
-
|
|
1766
|
-
const
|
|
2209
|
+
|
|
2210
|
+
const ab = new Vector3();
|
|
2211
|
+
const cb = new Vector3();
|
|
2212
|
+
|
|
1767
2213
|
function computeNormalAttribute(index, coord, creaseAngle) {
|
|
1768
2214
|
const faces = [];
|
|
1769
|
-
const vertexNormals = {};
|
|
2215
|
+
const vertexNormals = {}; // prepare face and raw vertex normals
|
|
2216
|
+
|
|
1770
2217
|
for (let i = 0, l = index.length; i < l; i += 3) {
|
|
1771
2218
|
const a = index[i];
|
|
1772
2219
|
const b = index[i + 1];
|
|
@@ -1780,18 +2227,18 @@ class VRMLLoader extends THREE.Loader {
|
|
|
1780
2227
|
cb.cross(ab);
|
|
1781
2228
|
cb.normalize();
|
|
1782
2229
|
face.normal.copy(cb);
|
|
1783
|
-
if (vertexNormals[a] ===
|
|
1784
|
-
|
|
1785
|
-
if (vertexNormals[
|
|
1786
|
-
vertexNormals[b] = [];
|
|
1787
|
-
if (vertexNormals[c] === void 0)
|
|
1788
|
-
vertexNormals[c] = [];
|
|
2230
|
+
if (vertexNormals[a] === undefined) vertexNormals[a] = [];
|
|
2231
|
+
if (vertexNormals[b] === undefined) vertexNormals[b] = [];
|
|
2232
|
+
if (vertexNormals[c] === undefined) vertexNormals[c] = [];
|
|
1789
2233
|
vertexNormals[a].push(face.normal);
|
|
1790
2234
|
vertexNormals[b].push(face.normal);
|
|
1791
2235
|
vertexNormals[c].push(face.normal);
|
|
1792
2236
|
faces.push(face);
|
|
1793
|
-
}
|
|
2237
|
+
} // compute vertex normals and build final geometry
|
|
2238
|
+
|
|
2239
|
+
|
|
1794
2240
|
const normals = [];
|
|
2241
|
+
|
|
1795
2242
|
for (let i = 0, l = faces.length; i < l; i++) {
|
|
1796
2243
|
const face = faces[i];
|
|
1797
2244
|
const nA = weightedNormal(vertexNormals[face.a], face.normal, creaseAngle);
|
|
@@ -1804,10 +2251,13 @@ class VRMLLoader extends THREE.Loader {
|
|
|
1804
2251
|
normals.push(nB.x, nB.y, nB.z);
|
|
1805
2252
|
normals.push(nC.x, nC.y, nC.z);
|
|
1806
2253
|
}
|
|
1807
|
-
|
|
2254
|
+
|
|
2255
|
+
return new Float32BufferAttribute(normals, 3);
|
|
1808
2256
|
}
|
|
2257
|
+
|
|
1809
2258
|
function weightedNormal(normals, vector, creaseAngle) {
|
|
1810
|
-
const normal = new
|
|
2259
|
+
const normal = new Vector3();
|
|
2260
|
+
|
|
1811
2261
|
if (creaseAngle === 0) {
|
|
1812
2262
|
normal.copy(vector);
|
|
1813
2263
|
} else {
|
|
@@ -1817,257 +2267,284 @@ class VRMLLoader extends THREE.Loader {
|
|
|
1817
2267
|
}
|
|
1818
2268
|
}
|
|
1819
2269
|
}
|
|
2270
|
+
|
|
1820
2271
|
return normal.normalize();
|
|
1821
2272
|
}
|
|
2273
|
+
|
|
1822
2274
|
function toColorArray(colors) {
|
|
1823
2275
|
const array = [];
|
|
2276
|
+
|
|
1824
2277
|
for (let i = 0, l = colors.length; i < l; i += 3) {
|
|
1825
|
-
array.push(new
|
|
2278
|
+
array.push(new Color(colors[i], colors[i + 1], colors[i + 2]));
|
|
1826
2279
|
}
|
|
2280
|
+
|
|
1827
2281
|
return array;
|
|
1828
2282
|
}
|
|
2283
|
+
/**
|
|
2284
|
+
* Vertically paints the faces interpolating between the
|
|
2285
|
+
* specified colors at the specified angels. This is used for the Background
|
|
2286
|
+
* node, but could be applied to other nodes with multiple faces as well.
|
|
2287
|
+
*
|
|
2288
|
+
* When used with the Background node, default is directionIsDown is true if
|
|
2289
|
+
* interpolating the skyColor down from the Zenith. When interpolationg up from
|
|
2290
|
+
* the Nadir i.e. interpolating the groundColor, the directionIsDown is false.
|
|
2291
|
+
*
|
|
2292
|
+
* The first angle is never specified, it is the Zenith (0 rad). Angles are specified
|
|
2293
|
+
* in radians. The geometry is thought a sphere, but could be anything. The color interpolation
|
|
2294
|
+
* is linear along the Y axis in any case.
|
|
2295
|
+
*
|
|
2296
|
+
* You must specify one more color than you have angles at the beginning of the colors array.
|
|
2297
|
+
* This is the color of the Zenith (the top of the shape).
|
|
2298
|
+
*
|
|
2299
|
+
* @param {BufferGeometry} geometry
|
|
2300
|
+
* @param {number} radius
|
|
2301
|
+
* @param {array} angles
|
|
2302
|
+
* @param {array} colors
|
|
2303
|
+
* @param {boolean} topDown - Whether to work top down or bottom up.
|
|
2304
|
+
*/
|
|
2305
|
+
|
|
2306
|
+
|
|
1829
2307
|
function paintFaces(geometry, radius, angles, colors, topDown) {
|
|
2308
|
+
// compute threshold values
|
|
1830
2309
|
const thresholds = [];
|
|
1831
2310
|
const startAngle = topDown === true ? 0 : Math.PI;
|
|
2311
|
+
|
|
1832
2312
|
for (let i = 0, l = colors.length; i < l; i++) {
|
|
1833
2313
|
let angle = i === 0 ? 0 : angles[i - 1];
|
|
1834
2314
|
angle = topDown === true ? angle : startAngle - angle;
|
|
1835
|
-
const point = new
|
|
2315
|
+
const point = new Vector3();
|
|
1836
2316
|
point.setFromSphericalCoords(radius, angle, 0);
|
|
1837
2317
|
thresholds.push(point);
|
|
1838
|
-
}
|
|
2318
|
+
} // generate vertex colors
|
|
2319
|
+
|
|
2320
|
+
|
|
1839
2321
|
const indices = geometry.index;
|
|
1840
2322
|
const positionAttribute = geometry.attributes.position;
|
|
1841
|
-
const colorAttribute = new
|
|
1842
|
-
const position = new
|
|
1843
|
-
const color = new
|
|
2323
|
+
const colorAttribute = new BufferAttribute(new Float32Array(geometry.attributes.position.count * 3), 3);
|
|
2324
|
+
const position = new Vector3();
|
|
2325
|
+
const color = new Color();
|
|
2326
|
+
|
|
1844
2327
|
for (let i = 0; i < indices.count; i++) {
|
|
1845
2328
|
const index = indices.getX(i);
|
|
1846
2329
|
position.fromBufferAttribute(positionAttribute, index);
|
|
1847
2330
|
let thresholdIndexA, thresholdIndexB;
|
|
1848
2331
|
let t = 1;
|
|
2332
|
+
|
|
1849
2333
|
for (let j = 1; j < thresholds.length; j++) {
|
|
1850
2334
|
thresholdIndexA = j - 1;
|
|
1851
2335
|
thresholdIndexB = j;
|
|
1852
2336
|
const thresholdA = thresholds[thresholdIndexA];
|
|
1853
2337
|
const thresholdB = thresholds[thresholdIndexB];
|
|
2338
|
+
|
|
1854
2339
|
if (topDown === true) {
|
|
2340
|
+
// interpolation for sky color
|
|
1855
2341
|
if (position.y <= thresholdA.y && position.y > thresholdB.y) {
|
|
1856
2342
|
t = Math.abs(thresholdA.y - position.y) / Math.abs(thresholdA.y - thresholdB.y);
|
|
1857
2343
|
break;
|
|
1858
2344
|
}
|
|
1859
2345
|
} else {
|
|
2346
|
+
// interpolation for ground color
|
|
1860
2347
|
if (position.y >= thresholdA.y && position.y < thresholdB.y) {
|
|
1861
2348
|
t = Math.abs(thresholdA.y - position.y) / Math.abs(thresholdA.y - thresholdB.y);
|
|
1862
2349
|
break;
|
|
1863
2350
|
}
|
|
1864
2351
|
}
|
|
1865
2352
|
}
|
|
2353
|
+
|
|
1866
2354
|
const colorA = colors[thresholdIndexA];
|
|
1867
2355
|
const colorB = colors[thresholdIndexB];
|
|
1868
2356
|
color.copy(colorA).lerp(colorB, t);
|
|
1869
2357
|
colorAttribute.setXYZ(index, color.r, color.g, color.b);
|
|
1870
2358
|
}
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
2359
|
+
|
|
2360
|
+
geometry.setAttribute('color', colorAttribute);
|
|
2361
|
+
} //
|
|
2362
|
+
|
|
2363
|
+
|
|
2364
|
+
const textureLoader = new TextureLoader(this.manager);
|
|
2365
|
+
textureLoader.setPath(this.resourcePath || path).setCrossOrigin(this.crossOrigin); // check version (only 2.0 is supported)
|
|
2366
|
+
|
|
2367
|
+
if (data.indexOf('#VRML V2.0') === -1) {
|
|
2368
|
+
throw Error('THREE.VRMLLexer: Version of VRML asset not supported.');
|
|
2369
|
+
} // create JSON representing the tree structure of the VRML asset
|
|
2370
|
+
|
|
2371
|
+
|
|
2372
|
+
const tree = generateVRMLTree(data); // parse the tree structure to a three.js scene
|
|
2373
|
+
|
|
1879
2374
|
const scene = parseTree(tree);
|
|
1880
2375
|
return scene;
|
|
1881
2376
|
}
|
|
2377
|
+
|
|
1882
2378
|
}
|
|
2379
|
+
|
|
1883
2380
|
class VRMLLexer {
|
|
1884
2381
|
constructor(tokens) {
|
|
1885
|
-
this.lexer = new
|
|
2382
|
+
this.lexer = new Lexer(tokens); // eslint-disable-line no-undef
|
|
1886
2383
|
}
|
|
2384
|
+
|
|
1887
2385
|
lex(inputText) {
|
|
1888
2386
|
const lexingResult = this.lexer.tokenize(inputText);
|
|
2387
|
+
|
|
1889
2388
|
if (lexingResult.errors.length > 0) {
|
|
1890
2389
|
console.error(lexingResult.errors);
|
|
1891
|
-
throw Error(
|
|
2390
|
+
throw Error('THREE.VRMLLexer: Lexing errors detected.');
|
|
1892
2391
|
}
|
|
2392
|
+
|
|
1893
2393
|
return lexingResult;
|
|
1894
2394
|
}
|
|
2395
|
+
|
|
1895
2396
|
}
|
|
1896
|
-
|
|
2397
|
+
|
|
2398
|
+
class VRMLParser extends CstParser {
|
|
1897
2399
|
constructor(tokenVocabulary) {
|
|
1898
2400
|
super(tokenVocabulary);
|
|
1899
2401
|
const $ = this;
|
|
1900
|
-
const Version = tokenVocabulary[
|
|
1901
|
-
const LCurly = tokenVocabulary[
|
|
1902
|
-
const RCurly = tokenVocabulary[
|
|
1903
|
-
const LSquare = tokenVocabulary[
|
|
1904
|
-
const RSquare = tokenVocabulary[
|
|
1905
|
-
const Identifier = tokenVocabulary[
|
|
1906
|
-
const RouteIdentifier = tokenVocabulary[
|
|
1907
|
-
const StringLiteral = tokenVocabulary[
|
|
1908
|
-
const HexLiteral = tokenVocabulary[
|
|
1909
|
-
const NumberLiteral = tokenVocabulary[
|
|
1910
|
-
const TrueLiteral = tokenVocabulary[
|
|
1911
|
-
const FalseLiteral = tokenVocabulary[
|
|
1912
|
-
const NullLiteral = tokenVocabulary[
|
|
1913
|
-
const DEF = tokenVocabulary[
|
|
1914
|
-
const USE = tokenVocabulary[
|
|
1915
|
-
const ROUTE = tokenVocabulary[
|
|
1916
|
-
const TO = tokenVocabulary[
|
|
1917
|
-
const NodeName = tokenVocabulary[
|
|
1918
|
-
$.RULE(
|
|
2402
|
+
const Version = tokenVocabulary['Version'];
|
|
2403
|
+
const LCurly = tokenVocabulary['LCurly'];
|
|
2404
|
+
const RCurly = tokenVocabulary['RCurly'];
|
|
2405
|
+
const LSquare = tokenVocabulary['LSquare'];
|
|
2406
|
+
const RSquare = tokenVocabulary['RSquare'];
|
|
2407
|
+
const Identifier = tokenVocabulary['Identifier'];
|
|
2408
|
+
const RouteIdentifier = tokenVocabulary['RouteIdentifier'];
|
|
2409
|
+
const StringLiteral = tokenVocabulary['StringLiteral'];
|
|
2410
|
+
const HexLiteral = tokenVocabulary['HexLiteral'];
|
|
2411
|
+
const NumberLiteral = tokenVocabulary['NumberLiteral'];
|
|
2412
|
+
const TrueLiteral = tokenVocabulary['TrueLiteral'];
|
|
2413
|
+
const FalseLiteral = tokenVocabulary['FalseLiteral'];
|
|
2414
|
+
const NullLiteral = tokenVocabulary['NullLiteral'];
|
|
2415
|
+
const DEF = tokenVocabulary['DEF'];
|
|
2416
|
+
const USE = tokenVocabulary['USE'];
|
|
2417
|
+
const ROUTE = tokenVocabulary['ROUTE'];
|
|
2418
|
+
const TO = tokenVocabulary['TO'];
|
|
2419
|
+
const NodeName = tokenVocabulary['NodeName'];
|
|
2420
|
+
$.RULE('vrml', function () {
|
|
1919
2421
|
$.SUBRULE($.version);
|
|
1920
|
-
$.AT_LEAST_ONE(function() {
|
|
2422
|
+
$.AT_LEAST_ONE(function () {
|
|
1921
2423
|
$.SUBRULE($.node);
|
|
1922
2424
|
});
|
|
1923
|
-
$.MANY(function() {
|
|
2425
|
+
$.MANY(function () {
|
|
1924
2426
|
$.SUBRULE($.route);
|
|
1925
2427
|
});
|
|
1926
2428
|
});
|
|
1927
|
-
$.RULE(
|
|
2429
|
+
$.RULE('version', function () {
|
|
1928
2430
|
$.CONSUME(Version);
|
|
1929
2431
|
});
|
|
1930
|
-
$.RULE(
|
|
1931
|
-
$.OPTION(function() {
|
|
2432
|
+
$.RULE('node', function () {
|
|
2433
|
+
$.OPTION(function () {
|
|
1932
2434
|
$.SUBRULE($.def);
|
|
1933
2435
|
});
|
|
1934
2436
|
$.CONSUME(NodeName);
|
|
1935
2437
|
$.CONSUME(LCurly);
|
|
1936
|
-
$.MANY(function() {
|
|
2438
|
+
$.MANY(function () {
|
|
1937
2439
|
$.SUBRULE($.field);
|
|
1938
2440
|
});
|
|
1939
2441
|
$.CONSUME(RCurly);
|
|
1940
2442
|
});
|
|
1941
|
-
$.RULE(
|
|
2443
|
+
$.RULE('field', function () {
|
|
1942
2444
|
$.CONSUME(Identifier);
|
|
1943
|
-
$.OR2([
|
|
1944
|
-
{
|
|
1945
|
-
|
|
1946
|
-
$.SUBRULE($.singleFieldValue);
|
|
1947
|
-
}
|
|
1948
|
-
},
|
|
1949
|
-
{
|
|
1950
|
-
ALT: function() {
|
|
1951
|
-
$.SUBRULE($.multiFieldValue);
|
|
1952
|
-
}
|
|
2445
|
+
$.OR2([{
|
|
2446
|
+
ALT: function () {
|
|
2447
|
+
$.SUBRULE($.singleFieldValue);
|
|
1953
2448
|
}
|
|
1954
|
-
|
|
2449
|
+
}, {
|
|
2450
|
+
ALT: function () {
|
|
2451
|
+
$.SUBRULE($.multiFieldValue);
|
|
2452
|
+
}
|
|
2453
|
+
}]);
|
|
1955
2454
|
});
|
|
1956
|
-
$.RULE(
|
|
2455
|
+
$.RULE('def', function () {
|
|
1957
2456
|
$.CONSUME(DEF);
|
|
1958
|
-
$.OR([
|
|
1959
|
-
{
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
ALT: function() {
|
|
1966
|
-
$.CONSUME(NodeName);
|
|
1967
|
-
}
|
|
2457
|
+
$.OR([{
|
|
2458
|
+
ALT: function () {
|
|
2459
|
+
$.CONSUME(Identifier);
|
|
2460
|
+
}
|
|
2461
|
+
}, {
|
|
2462
|
+
ALT: function () {
|
|
2463
|
+
$.CONSUME(NodeName);
|
|
1968
2464
|
}
|
|
1969
|
-
]);
|
|
2465
|
+
}]);
|
|
1970
2466
|
});
|
|
1971
|
-
$.RULE(
|
|
2467
|
+
$.RULE('use', function () {
|
|
1972
2468
|
$.CONSUME(USE);
|
|
1973
|
-
$.OR([
|
|
1974
|
-
{
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
ALT: function() {
|
|
1981
|
-
$.CONSUME(NodeName);
|
|
1982
|
-
}
|
|
2469
|
+
$.OR([{
|
|
2470
|
+
ALT: function () {
|
|
2471
|
+
$.CONSUME(Identifier);
|
|
2472
|
+
}
|
|
2473
|
+
}, {
|
|
2474
|
+
ALT: function () {
|
|
2475
|
+
$.CONSUME(NodeName);
|
|
1983
2476
|
}
|
|
1984
|
-
]);
|
|
2477
|
+
}]);
|
|
1985
2478
|
});
|
|
1986
|
-
$.RULE(
|
|
1987
|
-
$.AT_LEAST_ONE(function() {
|
|
1988
|
-
$.OR([
|
|
1989
|
-
{
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
}
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
{
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
{
|
|
2020
|
-
ALT: function() {
|
|
2021
|
-
$.CONSUME(FalseLiteral);
|
|
2022
|
-
}
|
|
2023
|
-
},
|
|
2024
|
-
{
|
|
2025
|
-
ALT: function() {
|
|
2026
|
-
$.CONSUME(NullLiteral);
|
|
2027
|
-
}
|
|
2479
|
+
$.RULE('singleFieldValue', function () {
|
|
2480
|
+
$.AT_LEAST_ONE(function () {
|
|
2481
|
+
$.OR([{
|
|
2482
|
+
ALT: function () {
|
|
2483
|
+
$.SUBRULE($.node);
|
|
2484
|
+
}
|
|
2485
|
+
}, {
|
|
2486
|
+
ALT: function () {
|
|
2487
|
+
$.SUBRULE($.use);
|
|
2488
|
+
}
|
|
2489
|
+
}, {
|
|
2490
|
+
ALT: function () {
|
|
2491
|
+
$.CONSUME(StringLiteral);
|
|
2492
|
+
}
|
|
2493
|
+
}, {
|
|
2494
|
+
ALT: function () {
|
|
2495
|
+
$.CONSUME(HexLiteral);
|
|
2496
|
+
}
|
|
2497
|
+
}, {
|
|
2498
|
+
ALT: function () {
|
|
2499
|
+
$.CONSUME(NumberLiteral);
|
|
2500
|
+
}
|
|
2501
|
+
}, {
|
|
2502
|
+
ALT: function () {
|
|
2503
|
+
$.CONSUME(TrueLiteral);
|
|
2504
|
+
}
|
|
2505
|
+
}, {
|
|
2506
|
+
ALT: function () {
|
|
2507
|
+
$.CONSUME(FalseLiteral);
|
|
2508
|
+
}
|
|
2509
|
+
}, {
|
|
2510
|
+
ALT: function () {
|
|
2511
|
+
$.CONSUME(NullLiteral);
|
|
2028
2512
|
}
|
|
2029
|
-
]);
|
|
2513
|
+
}]);
|
|
2030
2514
|
});
|
|
2031
2515
|
});
|
|
2032
|
-
$.RULE(
|
|
2516
|
+
$.RULE('multiFieldValue', function () {
|
|
2033
2517
|
$.CONSUME(LSquare);
|
|
2034
|
-
$.MANY(function() {
|
|
2035
|
-
$.OR([
|
|
2036
|
-
{
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
}
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
{
|
|
2057
|
-
|
|
2058
|
-
$.CONSUME(NumberLiteral);
|
|
2059
|
-
}
|
|
2060
|
-
},
|
|
2061
|
-
{
|
|
2062
|
-
ALT: function() {
|
|
2063
|
-
$.CONSUME(NullLiteral);
|
|
2064
|
-
}
|
|
2518
|
+
$.MANY(function () {
|
|
2519
|
+
$.OR([{
|
|
2520
|
+
ALT: function () {
|
|
2521
|
+
$.SUBRULE($.node);
|
|
2522
|
+
}
|
|
2523
|
+
}, {
|
|
2524
|
+
ALT: function () {
|
|
2525
|
+
$.SUBRULE($.use);
|
|
2526
|
+
}
|
|
2527
|
+
}, {
|
|
2528
|
+
ALT: function () {
|
|
2529
|
+
$.CONSUME(StringLiteral);
|
|
2530
|
+
}
|
|
2531
|
+
}, {
|
|
2532
|
+
ALT: function () {
|
|
2533
|
+
$.CONSUME(HexLiteral);
|
|
2534
|
+
}
|
|
2535
|
+
}, {
|
|
2536
|
+
ALT: function () {
|
|
2537
|
+
$.CONSUME(NumberLiteral);
|
|
2538
|
+
}
|
|
2539
|
+
}, {
|
|
2540
|
+
ALT: function () {
|
|
2541
|
+
$.CONSUME(NullLiteral);
|
|
2065
2542
|
}
|
|
2066
|
-
]);
|
|
2543
|
+
}]);
|
|
2067
2544
|
});
|
|
2068
2545
|
$.CONSUME(RSquare);
|
|
2069
2546
|
});
|
|
2070
|
-
$.RULE(
|
|
2547
|
+
$.RULE('route', function () {
|
|
2071
2548
|
$.CONSUME(ROUTE);
|
|
2072
2549
|
$.CONSUME(RouteIdentifier);
|
|
2073
2550
|
$.CONSUME(TO);
|
|
@@ -2075,19 +2552,24 @@ class VRMLParser extends chevrotain.CstParser {
|
|
|
2075
2552
|
});
|
|
2076
2553
|
this.performSelfAnalysis();
|
|
2077
2554
|
}
|
|
2555
|
+
|
|
2078
2556
|
}
|
|
2557
|
+
|
|
2079
2558
|
class Face {
|
|
2080
2559
|
constructor(a, b, c) {
|
|
2081
2560
|
this.a = a;
|
|
2082
2561
|
this.b = b;
|
|
2083
2562
|
this.c = c;
|
|
2084
|
-
this.normal = new
|
|
2563
|
+
this.normal = new Vector3();
|
|
2085
2564
|
}
|
|
2565
|
+
|
|
2086
2566
|
}
|
|
2567
|
+
|
|
2087
2568
|
const TEXTURE_TYPE = {
|
|
2088
2569
|
INTENSITY: 1,
|
|
2089
2570
|
INTENSITY_ALPHA: 2,
|
|
2090
2571
|
RGB: 3,
|
|
2091
2572
|
RGBA: 4
|
|
2092
2573
|
};
|
|
2093
|
-
|
|
2574
|
+
|
|
2575
|
+
export { VRMLLoader };
|