three-stdlib 2.22.4 → 2.22.6
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +1 -1
- package/README.md +0 -2
- package/package.json +34 -14
- package/BufferGeometryUtils-903f7ecb.js +0 -1
- package/BufferGeometryUtils-f2288d1c.js +0 -740
- package/Nodes-2106b101.js +0 -352
- package/Nodes-8947ba9a.js +0 -1
- package/_polyfill/CompressedArrayTexture.cjs.js +0 -1
- package/_polyfill/CompressedArrayTexture.js +0 -13
- package/_polyfill/Data3DTexture.cjs.js +0 -1
- package/_polyfill/Data3DTexture.js +0 -23
- package/animation/AnimationClipCreator.cjs.js +0 -1
- package/animation/AnimationClipCreator.d.ts +0 -12
- package/animation/AnimationClipCreator.js +0 -77
- package/animation/CCDIKSolver.cjs.js +0 -1
- package/animation/CCDIKSolver.d.ts +0 -25
- package/animation/CCDIKSolver.js +0 -304
- package/animation/MMDAnimationHelper.cjs.js +0 -1
- package/animation/MMDAnimationHelper.d.ts +0 -103
- package/animation/MMDAnimationHelper.js +0 -705
- package/animation/MMDPhysics.cjs.js +0 -1
- package/animation/MMDPhysics.d.ts +0 -119
- package/animation/MMDPhysics.js +0 -976
- package/cameras/CinematicCamera.cjs.js +0 -1
- package/cameras/CinematicCamera.d.ts +0 -41
- package/cameras/CinematicCamera.js +0 -139
- package/controls/ArcballControls.cjs.js +0 -1
- package/controls/ArcballControls.d.ts +0 -161
- package/controls/ArcballControls.js +0 -2642
- package/controls/DeviceOrientationControls.cjs.js +0 -1
- package/controls/DeviceOrientationControls.d.ts +0 -24
- package/controls/DeviceOrientationControls.js +0 -119
- package/controls/DragControls.cjs.js +0 -1
- package/controls/DragControls.d.ts +0 -34
- package/controls/DragControls.js +0 -274
- package/controls/FirstPersonControls.cjs.js +0 -1
- package/controls/FirstPersonControls.d.ts +0 -48
- package/controls/FirstPersonControls.js +0 -290
- package/controls/FlyControls.cjs.js +0 -1
- package/controls/FlyControls.d.ts +0 -32
- package/controls/FlyControls.js +0 -309
- package/controls/OrbitControls.cjs.js +0 -1
- package/controls/OrbitControls.d.ts +0 -63
- package/controls/OrbitControls.js +0 -980
- package/controls/PointerLockControls.cjs.js +0 -1
- package/controls/PointerLockControls.d.ts +0 -24
- package/controls/PointerLockControls.js +0 -135
- package/controls/TrackballControls.cjs.js +0 -1
- package/controls/TrackballControls.d.ts +0 -95
- package/controls/TrackballControls.js +0 -653
- package/controls/TransformControls.cjs.js +0 -1
- package/controls/TransformControls.d.ts +0 -151
- package/controls/TransformControls.js +0 -1275
- package/controls/experimental/CameraControls.cjs.js +0 -1
- package/controls/experimental/CameraControls.d.ts +0 -170
- package/controls/experimental/CameraControls.js +0 -953
- package/csm/CSM.cjs.js +0 -1
- package/csm/CSM.d.ts +0 -61
- package/csm/CSM.js +0 -305
- package/csm/CSMFrustum.cjs.js +0 -1
- package/csm/CSMFrustum.d.ts +0 -19
- package/csm/CSMFrustum.js +0 -90
- package/csm/CSMHelper.cjs.js +0 -1
- package/csm/CSMHelper.d.ts +0 -26
- package/csm/CSMHelper.js +0 -128
- package/csm/CSMShader.cjs.js +0 -1
- package/csm/CSMShader.d.ts +0 -4
- package/csm/CSMShader.js +0 -255
- package/curves/CurveExtras.cjs.js +0 -1
- package/curves/CurveExtras.d.ts +0 -68
- package/curves/CurveExtras.js +0 -266
- package/curves/NURBSCurve.cjs.js +0 -1
- package/curves/NURBSCurve.d.ts +0 -11
- package/curves/NURBSCurve.js +0 -63
- package/curves/NURBSSurface.cjs.js +0 -1
- package/curves/NURBSSurface.d.ts +0 -13
- package/curves/NURBSSurface.js +0 -44
- package/curves/NURBSUtils.cjs.js +0 -1
- package/curves/NURBSUtils.d.ts +0 -22
- package/curves/NURBSUtils.js +0 -375
- package/custom.d.cjs.js +0 -1
- package/custom.d.js +0 -1
- package/deprecated/Geometry.cjs.js +0 -1
- package/deprecated/Geometry.d.ts +0 -342
- package/deprecated/Geometry.js +0 -1261
- package/effects/AnaglyphEffect.cjs.js +0 -1
- package/effects/AnaglyphEffect.d.ts +0 -11
- package/effects/AnaglyphEffect.js +0 -85
- package/effects/AsciiEffect.cjs.js +0 -1
- package/effects/AsciiEffect.d.ts +0 -18
- package/effects/AsciiEffect.js +0 -203
- package/effects/OutlineEffect.cjs.js +0 -1
- package/effects/OutlineEffect.d.ts +0 -28
- package/effects/OutlineEffect.js +0 -378
- package/effects/ParallaxBarrierEffect.cjs.js +0 -1
- package/effects/ParallaxBarrierEffect.d.ts +0 -8
- package/effects/ParallaxBarrierEffect.js +0 -63
- package/effects/PeppersGhostEffect.cjs.js +0 -1
- package/effects/PeppersGhostEffect.d.ts +0 -10
- package/effects/PeppersGhostEffect.js +0 -134
- package/effects/StereoEffect.cjs.js +0 -1
- package/effects/StereoEffect.d.ts +0 -9
- package/effects/StereoEffect.js +0 -36
- package/environments/RoomEnvironment.cjs.js +0 -1
- package/environments/RoomEnvironment.d.ts +0 -5
- package/environments/RoomEnvironment.js +0 -92
- package/exporters/ColladaExporter.cjs.js +0 -1
- package/exporters/ColladaExporter.d.ts +0 -39
- package/exporters/ColladaExporter.js +0 -425
- package/exporters/DRACOExporter.cjs.js +0 -1
- package/exporters/DRACOExporter.d.ts +0 -23
- package/exporters/DRACOExporter.js +0 -186
- package/exporters/GLTFExporter.cjs.js +0 -1
- package/exporters/GLTFExporter.d.ts +0 -270
- package/exporters/GLTFExporter.js +0 -1932
- package/exporters/MMDExporter.cjs.js +0 -1
- package/exporters/MMDExporter.d.ts +0 -8
- package/exporters/MMDExporter.js +0 -160
- package/exporters/OBJExporter.cjs.js +0 -1
- package/exporters/OBJExporter.d.ts +0 -18
- package/exporters/OBJExporter.js +0 -228
- package/exporters/PLYExporter.cjs.js +0 -1
- package/exporters/PLYExporter.d.ts +0 -11
- package/exporters/PLYExporter.js +0 -339
- package/exporters/STLExporter.cjs.js +0 -1
- package/exporters/STLExporter.d.ts +0 -23
- package/exporters/STLExporter.js +0 -180
- package/exporters/USDZExporter.cjs.js +0 -1
- package/exporters/USDZExporter.d.ts +0 -27
- package/exporters/USDZExporter.js +0 -388
- package/geometries/BoxLineGeometry.cjs.js +0 -1
- package/geometries/BoxLineGeometry.d.ts +0 -12
- package/geometries/BoxLineGeometry.js +0 -52
- package/geometries/ConvexGeometry.cjs.js +0 -1
- package/geometries/ConvexGeometry.d.ts +0 -5
- package/geometries/ConvexGeometry.js +0 -38
- package/geometries/DecalGeometry.cjs.js +0 -1
- package/geometries/DecalGeometry.d.ts +0 -10
- package/geometries/DecalGeometry.js +0 -238
- package/geometries/LightningStrike.cjs.js +0 -1
- package/geometries/LightningStrike.d.ts +0 -108
- package/geometries/LightningStrike.js +0 -740
- package/geometries/ParametricGeometries.cjs.js +0 -1
- package/geometries/ParametricGeometries.d.ts +0 -32
- package/geometries/ParametricGeometries.js +0 -179
- package/geometries/ParametricGeometry.cjs.js +0 -1
- package/geometries/ParametricGeometry.d.ts +0 -18
- package/geometries/ParametricGeometry.js +0 -87
- package/geometries/RoundedBoxGeometry.cjs.js +0 -1
- package/geometries/RoundedBoxGeometry.d.ts +0 -5
- package/geometries/RoundedBoxGeometry.js +0 -122
- package/geometries/TeapotGeometry.cjs.js +0 -1
- package/geometries/TeapotGeometry.d.ts +0 -13
- package/geometries/TeapotGeometry.js +0 -297
- package/geometries/TextGeometry.cjs.js +0 -1
- package/geometries/TextGeometry.d.ts +0 -18
- package/geometries/TextGeometry.js +0 -37
- package/helpers/LightProbeHelper.cjs.js +0 -1
- package/helpers/LightProbeHelper.d.ts +0 -10
- package/helpers/LightProbeHelper.js +0 -40
- package/helpers/PositionalAudioHelper.cjs.js +0 -1
- package/helpers/PositionalAudioHelper.d.ts +0 -13
- package/helpers/PositionalAudioHelper.js +0 -75
- package/helpers/RectAreaLightHelper.cjs.js +0 -1
- package/helpers/RectAreaLightHelper.d.ts +0 -10
- package/helpers/RectAreaLightHelper.js +0 -60
- package/helpers/VertexNormalsHelper.cjs.js +0 -1
- package/helpers/VertexNormalsHelper.d.ts +0 -10
- package/helpers/VertexNormalsHelper.js +0 -75
- package/helpers/VertexTangentsHelper.cjs.js +0 -1
- package/helpers/VertexTangentsHelper.d.ts +0 -10
- package/helpers/VertexTangentsHelper.js +0 -63
- package/index.cjs.js +0 -1
- package/index.d.ts +0 -254
- package/index.js +0 -337
- package/interactive/HTMLMesh.cjs.js +0 -1
- package/interactive/HTMLMesh.d.ts +0 -6
- package/interactive/HTMLMesh.js +0 -406
- package/interactive/InteractiveGroup.cjs.js +0 -1
- package/interactive/InteractiveGroup.d.ts +0 -5
- package/interactive/InteractiveGroup.js +0 -87
- package/interactive/SelectionBox.cjs.js +0 -1
- package/interactive/SelectionBox.d.ts +0 -15
- package/interactive/SelectionBox.js +0 -152
- package/interactive/SelectionHelper.cjs.js +0 -1
- package/interactive/SelectionHelper.d.ts +0 -17
- package/interactive/SelectionHelper.js +0 -59
- package/libs/MeshoptDecoder.cjs.js +0 -1
- package/libs/MeshoptDecoder.d.ts +0 -12
- package/libs/MeshoptDecoder.js +0 -124
- package/libs/MotionControllers.cjs.js +0 -1
- package/libs/MotionControllers.d.ts +0 -132
- package/libs/MotionControllers.js +0 -455
- package/lights/LightProbeGenerator.cjs.js +0 -1
- package/lights/LightProbeGenerator.d.ts +0 -6
- package/lights/LightProbeGenerator.js +0 -200
- package/lights/RectAreaLightUniformsLib.cjs.js +0 -1
- package/lights/RectAreaLightUniformsLib.d.ts +0 -3
- package/lights/RectAreaLightUniformsLib.js +0 -9
- package/lines/Line2.cjs.js +0 -1
- package/lines/Line2.d.ts +0 -11
- package/lines/Line2.js +0 -16
- package/lines/LineGeometry.cjs.js +0 -1
- package/lines/LineGeometry.d.ts +0 -10
- package/lines/LineGeometry.js +0 -56
- package/lines/LineMaterial.cjs.js +0 -1
- package/lines/LineMaterial.d.ts +0 -31
- package/lines/LineMaterial.js +0 -577
- package/lines/LineSegments2.cjs.js +0 -1
- package/lines/LineSegments2.d.ts +0 -14
- package/lines/LineSegments2.js +0 -311
- package/lines/LineSegmentsGeometry.cjs.js +0 -1
- package/lines/LineSegmentsGeometry.d.ts +0 -23
- package/lines/LineSegmentsGeometry.js +0 -166
- package/lines/Wireframe.cjs.js +0 -1
- package/lines/Wireframe.d.ts +0 -11
- package/lines/Wireframe.js +0 -45
- package/lines/WireframeGeometry2.cjs.js +0 -1
- package/lines/WireframeGeometry2.d.ts +0 -8
- package/lines/WireframeGeometry2.js +0 -14
- package/loaders/3DMLoader.cjs.js +0 -1
- package/loaders/3DMLoader.d.ts +0 -17
- package/loaders/3DMLoader.js +0 -1037
- package/loaders/3MFLoader.cjs.js +0 -1
- package/loaders/3MFLoader.d.ts +0 -16
- package/loaders/3MFLoader.js +0 -1053
- package/loaders/AMFLoader.cjs.js +0 -1
- package/loaders/AMFLoader.d.ts +0 -14
- package/loaders/AMFLoader.js +0 -389
- package/loaders/AssimpLoader.cjs.js +0 -1
- package/loaders/AssimpLoader.js +0 -1793
- package/loaders/BVHLoader.cjs.js +0 -1
- package/loaders/BVHLoader.d.ts +0 -21
- package/loaders/BVHLoader.js +0 -313
- package/loaders/BasisTextureLoader.cjs.js +0 -1
- package/loaders/BasisTextureLoader.d.ts +0 -32
- package/loaders/BasisTextureLoader.js +0 -602
- package/loaders/ColladaLoader.cjs.js +0 -1
- package/loaders/ColladaLoader.d.ts +0 -20
- package/loaders/ColladaLoader.js +0 -2993
- package/loaders/DDSLoader.cjs.js +0 -1
- package/loaders/DDSLoader.d.ts +0 -16
- package/loaders/DDSLoader.js +0 -214
- package/loaders/DRACOLoader.cjs.js +0 -1
- package/loaders/DRACOLoader.d.ts +0 -18
- package/loaders/DRACOLoader.js +0 -447
- package/loaders/EXRLoader.cjs.js +0 -1
- package/loaders/EXRLoader.d.ts +0 -18
- package/loaders/EXRLoader.js +0 -1699
- package/loaders/FBXLoader.cjs.js +0 -1
- package/loaders/FBXLoader.d.ts +0 -14
- package/loaders/FBXLoader.js +0 -2917
- package/loaders/FontLoader.cjs.js +0 -1
- package/loaders/FontLoader.d.ts +0 -36
- package/loaders/FontLoader.js +0 -144
- package/loaders/GCodeLoader.cjs.js +0 -1
- package/loaders/GCodeLoader.d.ts +0 -15
- package/loaders/GCodeLoader.js +0 -189
- package/loaders/GLTFLoader.cjs.js +0 -1
- package/loaders/GLTFLoader.d.ts +0 -151
- package/loaders/GLTFLoader.js +0 -3136
- package/loaders/HDRCubeTextureLoader.cjs.js +0 -1
- package/loaders/HDRCubeTextureLoader.d.ts +0 -18
- package/loaders/HDRCubeTextureLoader.js +0 -77
- package/loaders/KMZLoader.cjs.js +0 -1
- package/loaders/KMZLoader.d.ts +0 -16
- package/loaders/KMZLoader.js +0 -88
- package/loaders/KTX2Loader.cjs.js +0 -1
- package/loaders/KTX2Loader.d.ts +0 -16
- package/loaders/KTX2Loader.js +0 -596
- package/loaders/KTXLoader.cjs.js +0 -1
- package/loaders/KTXLoader.d.ts +0 -16
- package/loaders/KTXLoader.js +0 -149
- package/loaders/LDrawLoader.cjs.js +0 -1
- package/loaders/LDrawLoader.d.ts +0 -26
- package/loaders/LDrawLoader.js +0 -1842
- package/loaders/LUT3dlLoader.cjs.js +0 -1
- package/loaders/LUT3dlLoader.d.ts +0 -20
- package/loaders/LUT3dlLoader.js +0 -115
- package/loaders/LUTCubeLoader.cjs.js +0 -1
- package/loaders/LUTCubeLoader.d.ts +0 -23
- package/loaders/LUTCubeLoader.js +0 -118
- package/loaders/LWOLoader.cjs.js +0 -1
- package/loaders/LWOLoader.d.ts +0 -26
- package/loaders/LWOLoader.js +0 -737
- package/loaders/LottieLoader.cjs.js +0 -1
- package/loaders/LottieLoader.d.ts +0 -15
- package/loaders/LottieLoader.js +0 -49
- package/loaders/MD2Loader.cjs.js +0 -1
- package/loaders/MD2Loader.d.ts +0 -14
- package/loaders/MD2Loader.js +0 -202
- package/loaders/MDDLoader.cjs.js +0 -1
- package/loaders/MDDLoader.d.ts +0 -19
- package/loaders/MDDLoader.js +0 -78
- package/loaders/MMDLoader.cjs.js +0 -1
- package/loaders/MMDLoader.d.ts +0 -63
- package/loaders/MMDLoader.js +0 -1434
- package/loaders/MTLLoader.cjs.js +0 -1
- package/loaders/MTLLoader.d.ts +0 -112
- package/loaders/MTLLoader.js +0 -390
- package/loaders/NRRDLoader.cjs.js +0 -1
- package/loaders/NRRDLoader.d.ts +0 -21
- package/loaders/NRRDLoader.js +0 -482
- package/loaders/NodeMaterialLoader.cjs.js +0 -1
- package/loaders/NodeMaterialLoader.js +0 -39
- package/loaders/OBJLoader.cjs.js +0 -1
- package/loaders/OBJLoader.d.ts +0 -17
- package/loaders/OBJLoader.js +0 -609
- package/loaders/PCDLoader.cjs.js +0 -1
- package/loaders/PCDLoader.d.ts +0 -15
- package/loaders/PCDLoader.js +0 -267
- package/loaders/PDBLoader.cjs.js +0 -1
- package/loaders/PDBLoader.d.ts +0 -22
- package/loaders/PDBLoader.js +0 -264
- package/loaders/PLYLoader.cjs.js +0 -1
- package/loaders/PLYLoader.d.ts +0 -16
- package/loaders/PLYLoader.js +0 -414
- package/loaders/PRWMLoader.cjs.js +0 -1
- package/loaders/PRWMLoader.d.ts +0 -16
- package/loaders/PRWMLoader.js +0 -197
- package/loaders/PVRLoader.cjs.js +0 -1
- package/loaders/PVRLoader.d.ts +0 -16
- package/loaders/PVRLoader.js +0 -192
- package/loaders/RGBELoader.cjs.js +0 -1
- package/loaders/RGBELoader.d.ts +0 -20
- package/loaders/RGBELoader.js +0 -382
- package/loaders/RGBMLoader.cjs.js +0 -1
- package/loaders/RGBMLoader.d.ts +0 -32
- package/loaders/RGBMLoader.js +0 -1168
- package/loaders/STLLoader.cjs.js +0 -1
- package/loaders/STLLoader.d.ts +0 -14
- package/loaders/STLLoader.js +0 -296
- package/loaders/SVGLoader.cjs.js +0 -1
- package/loaders/SVGLoader.d.ts +0 -63
- package/loaders/SVGLoader.js +0 -2083
- package/loaders/TDSLoader.cjs.js +0 -1
- package/loaders/TDSLoader.d.ts +0 -42
- package/loaders/TDSLoader.js +0 -870
- package/loaders/TGALoader.cjs.js +0 -1
- package/loaders/TGALoader.d.ts +0 -14
- package/loaders/TGALoader.js +0 -396
- package/loaders/TTFLoader.cjs.js +0 -1
- package/loaders/TTFLoader.d.ts +0 -15
- package/loaders/TTFLoader.js +0 -152
- package/loaders/TiltLoader.cjs.js +0 -1
- package/loaders/TiltLoader.d.ts +0 -14
- package/loaders/TiltLoader.js +0 -411
- package/loaders/VOXLoader.cjs.js +0 -1
- package/loaders/VOXLoader.d.ts +0 -28
- package/loaders/VOXLoader.js +0 -196
- package/loaders/VRMLLoader.cjs.js +0 -1
- package/loaders/VRMLLoader.d.ts +0 -14
- package/loaders/VRMLLoader.js +0 -2575
- package/loaders/VRMLoader.cjs.js +0 -1
- package/loaders/VRMLoader.js +0 -46
- package/loaders/VTKLoader.cjs.js +0 -1
- package/loaders/VTKLoader.d.ts +0 -14
- package/loaders/VTKLoader.js +0 -834
- package/loaders/XLoader.cjs.js +0 -1
- package/loaders/XLoader.js +0 -1434
- package/loaders/XYZLoader.cjs.js +0 -1
- package/loaders/XYZLoader.d.ts +0 -14
- package/loaders/XYZLoader.js +0 -66
- package/loaders/lwo/IFFParser.cjs.js +0 -1
- package/loaders/lwo/IFFParser.js +0 -951
- package/loaders/lwo/LWO2Parser.cjs.js +0 -1
- package/loaders/lwo/LWO2Parser.js +0 -430
- package/loaders/lwo/LWO3Parser.cjs.js +0 -1
- package/loaders/lwo/LWO3Parser.js +0 -385
- package/math/Capsule.cjs.js +0 -1
- package/math/Capsule.d.ts +0 -27
- package/math/Capsule.js +0 -87
- package/math/ColorConverter.cjs.js +0 -1
- package/math/ColorConverter.d.ts +0 -21
- package/math/ColorConverter.js +0 -65
- package/math/ConvexHull.cjs.js +0 -1
- package/math/ConvexHull.d.ts +0 -89
- package/math/ConvexHull.js +0 -834
- package/math/ImprovedNoise.cjs.js +0 -1
- package/math/ImprovedNoise.d.ts +0 -4
- package/math/ImprovedNoise.js +0 -52
- package/math/Lut.cjs.js +0 -1
- package/math/Lut.d.ts +0 -27
- package/math/Lut.js +0 -119
- package/math/MeshSurfaceSampler.cjs.js +0 -1
- package/math/MeshSurfaceSampler.d.ts +0 -15
- package/math/MeshSurfaceSampler.js +0 -150
- package/math/OBB.cjs.js +0 -1
- package/math/OBB.d.ts +0 -24
- package/math/OBB.js +0 -296
- package/math/Octree.cjs.js +0 -1
- package/math/Octree.d.ts +0 -24
- package/math/Octree.js +0 -341
- package/math/SimplexNoise.cjs.js +0 -1
- package/math/SimplexNoise.d.ts +0 -17
- package/math/SimplexNoise.js +0 -446
- package/misc/ConvexObjectBreaker.cjs.js +0 -1
- package/misc/ConvexObjectBreaker.d.ts +0 -25
- package/misc/ConvexObjectBreaker.js +0 -398
- package/misc/GPUComputationRenderer.cjs.js +0 -1
- package/misc/GPUComputationRenderer.d.ts +0 -52
- package/misc/GPUComputationRenderer.js +0 -296
- package/misc/Gyroscope.cjs.js +0 -1
- package/misc/Gyroscope.d.ts +0 -5
- package/misc/Gyroscope.js +0 -41
- package/misc/MD2Character.cjs.js +0 -1
- package/misc/MD2Character.d.ts +0 -33
- package/misc/MD2Character.js +0 -184
- package/misc/MD2CharacterComplex.cjs.js +0 -1
- package/misc/MD2CharacterComplex.d.ts +0 -47
- package/misc/MD2CharacterComplex.js +0 -379
- package/misc/MorphAnimMesh.cjs.js +0 -1
- package/misc/MorphAnimMesh.d.ts +0 -13
- package/misc/MorphAnimMesh.js +0 -48
- package/misc/MorphBlendMesh.cjs.js +0 -1
- package/misc/MorphBlendMesh.d.ts +0 -21
- package/misc/MorphBlendMesh.js +0 -203
- package/misc/ProgressiveLightmap.cjs.js +0 -1
- package/misc/ProgressiveLightmap.js +0 -285
- package/misc/RollerCoaster.cjs.js +0 -1
- package/misc/RollerCoaster.d.ts +0 -21
- package/misc/RollerCoaster.js +0 -375
- package/misc/Timer.cjs.js +0 -1
- package/misc/Timer.d.ts +0 -27
- package/misc/Timer.js +0 -125
- package/misc/TubePainter.cjs.js +0 -1
- package/misc/TubePainter.d.ts +0 -10
- package/misc/TubePainter.js +0 -141
- package/misc/Volume.cjs.js +0 -1
- package/misc/Volume.d.ts +0 -37
- package/misc/Volume.js +0 -406
- package/misc/VolumeSlice.cjs.js +0 -1
- package/misc/VolumeSlice.d.ts +0 -28
- package/misc/VolumeSlice.js +0 -194
- package/misc/WebGL.cjs.js +0 -1
- package/misc/WebGL.d.ts +0 -5
- package/misc/WebGL.js +0 -71
- package/modifiers/CurveModifier.cjs.js +0 -1
- package/modifiers/CurveModifier.d.ts +0 -39
- package/modifiers/CurveModifier.js +0 -288
- package/modifiers/EdgeSplitModifier.cjs.js +0 -1
- package/modifiers/EdgeSplitModifier.d.ts +0 -19
- package/modifiers/EdgeSplitModifier.js +0 -205
- package/modifiers/SimplifyModifier.cjs.js +0 -1
- package/modifiers/SimplifyModifier.d.ts +0 -12
- package/modifiers/SimplifyModifier.js +0 -407
- package/modifiers/TessellateModifier.cjs.js +0 -1
- package/modifiers/TessellateModifier.d.ts +0 -8
- package/modifiers/TessellateModifier.js +0 -231
- package/nodes/Nodes.cjs.js +0 -1
- package/nodes/Nodes.js +0 -204
- package/nodes/ShaderNode.cjs.js +0 -1
- package/nodes/ShaderNode.js +0 -308
- package/nodes/accessors/BufferNode.cjs.js +0 -1
- package/nodes/accessors/BufferNode.js +0 -18
- package/nodes/accessors/CameraNode.cjs.js +0 -1
- package/nodes/accessors/CameraNode.js +0 -48
- package/nodes/accessors/CubeTextureNode.cjs.js +0 -1
- package/nodes/accessors/CubeTextureNode.js +0 -53
- package/nodes/accessors/MaterialNode.cjs.js +0 -1
- package/nodes/accessors/MaterialNode.js +0 -80
- package/nodes/accessors/MaterialReferenceNode.cjs.js +0 -1
- package/nodes/accessors/MaterialReferenceNode.js +0 -16
- package/nodes/accessors/ModelNode.cjs.js +0 -1
- package/nodes/accessors/ModelNode.js +0 -10
- package/nodes/accessors/ModelViewProjectionNode.cjs.js +0 -1
- package/nodes/accessors/ModelViewProjectionNode.js +0 -22
- package/nodes/accessors/NormalNode.cjs.js +0 -1
- package/nodes/accessors/NormalNode.js +0 -60
- package/nodes/accessors/Object3DNode.cjs.js +0 -1
- package/nodes/accessors/Object3DNode.js +0 -85
- package/nodes/accessors/PointUVNode.cjs.js +0 -1
- package/nodes/accessors/PointUVNode.js +0 -16
- package/nodes/accessors/PositionNode.cjs.js +0 -1
- package/nodes/accessors/PositionNode.js +0 -63
- package/nodes/accessors/ReferenceNode.cjs.js +0 -1
- package/nodes/accessors/ReferenceNode.js +0 -43
- package/nodes/accessors/ReflectNode.cjs.js +0 -1
- package/nodes/accessors/ReflectNode.js +0 -45
- package/nodes/accessors/SkinningNode.cjs.js +0 -1
- package/nodes/accessors/SkinningNode.js +0 -59
- package/nodes/accessors/TextureNode.cjs.js +0 -1
- package/nodes/accessors/TextureNode.js +0 -68
- package/nodes/accessors/UVNode.cjs.js +0 -1
- package/nodes/accessors/UVNode.js +0 -28
- package/nodes/core/ArrayUniformNode.cjs.js +0 -1
- package/nodes/core/ArrayUniformNode.js +0 -17
- package/nodes/core/AttributeNode.cjs.js +0 -1
- package/nodes/core/AttributeNode.js +0 -36
- package/nodes/core/BypassNode.cjs.js +0 -1
- package/nodes/core/BypassNode.js +0 -28
- package/nodes/core/CodeNode.cjs.js +0 -1
- package/nodes/core/CodeNode.js +0 -35
- package/nodes/core/ConstNode.cjs.js +0 -1
- package/nodes/core/ConstNode.js +0 -17
- package/nodes/core/ContextNode.cjs.js +0 -1
- package/nodes/core/ContextNode.js +0 -26
- package/nodes/core/ExpressionNode.cjs.js +0 -1
- package/nodes/core/ExpressionNode.js +0 -22
- package/nodes/core/FunctionCallNode.cjs.js +0 -1
- package/nodes/core/FunctionCallNode.js +0 -45
- package/nodes/core/FunctionNode.cjs.js +0 -1
- package/nodes/core/FunctionNode.js +0 -70
- package/nodes/core/InputNode.cjs.js +0 -1
- package/nodes/core/InputNode.js +0 -48
- package/nodes/core/Node.cjs.js +0 -1
- package/nodes/core/Node.js +0 -178
- package/nodes/core/NodeAttribute.cjs.js +0 -1
- package/nodes/core/NodeAttribute.js +0 -11
- package/nodes/core/NodeBuilder.cjs.js +0 -1
- package/nodes/core/NodeBuilder.js +0 -509
- package/nodes/core/NodeCode.cjs.js +0 -1
- package/nodes/core/NodeCode.js +0 -13
- package/nodes/core/NodeFrame.cjs.js +0 -1
- package/nodes/core/NodeFrame.js +0 -37
- package/nodes/core/NodeFunction.cjs.js +0 -1
- package/nodes/core/NodeFunction.js +0 -17
- package/nodes/core/NodeFunctionInput.cjs.js +0 -1
- package/nodes/core/NodeFunctionInput.js +0 -14
- package/nodes/core/NodeKeywords.cjs.js +0 -1
- package/nodes/core/NodeKeywords.js +0 -54
- package/nodes/core/NodeParser.cjs.js +0 -1
- package/nodes/core/NodeParser.js +0 -8
- package/nodes/core/NodeUniform.cjs.js +0 -1
- package/nodes/core/NodeUniform.js +0 -21
- package/nodes/core/NodeUtils.cjs.js +0 -1
- package/nodes/core/NodeUtils.js +0 -61
- package/nodes/core/NodeVar.cjs.js +0 -1
- package/nodes/core/NodeVar.js +0 -11
- package/nodes/core/NodeVary.cjs.js +0 -1
- package/nodes/core/NodeVary.js +0 -11
- package/nodes/core/PropertyNode.cjs.js +0 -1
- package/nodes/core/PropertyNode.js +0 -26
- package/nodes/core/TempNode.cjs.js +0 -1
- package/nodes/core/TempNode.js +0 -30
- package/nodes/core/UniformNode.cjs.js +0 -1
- package/nodes/core/UniformNode.js +0 -28
- package/nodes/core/VarNode.cjs.js +0 -1
- package/nodes/core/VarNode.js +0 -38
- package/nodes/core/VaryNode.cjs.js +0 -1
- package/nodes/core/VaryNode.js +0 -38
- package/nodes/core/constants.cjs.js +0 -1
- package/nodes/core/constants.js +0 -11
- package/nodes/display/ColorSpaceNode.cjs.js +0 -1
- package/nodes/display/ColorSpaceNode.js +0 -66
- package/nodes/display/NormalMapNode.cjs.js +0 -1
- package/nodes/display/NormalMapNode.js +0 -71
- package/nodes/fog/FogNode.cjs.js +0 -1
- package/nodes/fog/FogNode.js +0 -18
- package/nodes/fog/FogRangeNode.cjs.js +0 -1
- package/nodes/fog/FogRangeNode.js +0 -20
- package/nodes/functions/BSDFs.cjs.js +0 -1
- package/nodes/functions/BSDFs.js +0 -121
- package/nodes/functions/PhysicalMaterialFunctions.cjs.js +0 -1
- package/nodes/functions/PhysicalMaterialFunctions.js +0 -57
- package/nodes/lights/LightContextNode.cjs.js +0 -1
- package/nodes/lights/LightContextNode.js +0 -43
- package/nodes/lights/LightNode.cjs.js +0 -1
- package/nodes/lights/LightNode.js +0 -61
- package/nodes/lights/LightsNode.cjs.js +0 -1
- package/nodes/lights/LightsNode.js +0 -77
- package/nodes/loaders/NodeLoader.cjs.js +0 -1
- package/nodes/loaders/NodeLoader.js +0 -212
- package/nodes/loaders/NodeMaterialLoader.cjs.js +0 -1
- package/nodes/loaders/NodeMaterialLoader.js +0 -29
- package/nodes/loaders/NodeObjectLoader.cjs.js +0 -1
- package/nodes/loaders/NodeObjectLoader.js +0 -49
- package/nodes/materials/LineBasicNodeMaterial.cjs.js +0 -1
- package/nodes/materials/LineBasicNodeMaterial.js +0 -31
- package/nodes/materials/Materials.cjs.js +0 -1
- package/nodes/materials/Materials.js +0 -27
- package/nodes/materials/MeshBasicNodeMaterial.cjs.js +0 -1
- package/nodes/materials/MeshBasicNodeMaterial.js +0 -32
- package/nodes/materials/MeshStandardNodeMaterial.cjs.js +0 -1
- package/nodes/materials/MeshStandardNodeMaterial.js +0 -43
- package/nodes/materials/NodeMaterial.cjs.js +0 -1
- package/nodes/materials/NodeMaterial.js +0 -79
- package/nodes/materials/PointsNodeMaterial.cjs.js +0 -1
- package/nodes/materials/PointsNodeMaterial.js +0 -34
- package/nodes/math/CondNode.cjs.js +0 -1
- package/nodes/math/CondNode.js +0 -49
- package/nodes/math/MathNode.cjs.js +0 -1
- package/nodes/math/MathNode.js +0 -206
- package/nodes/math/OperatorNode.cjs.js +0 -1
- package/nodes/math/OperatorNode.js +0 -124
- package/nodes/parsers/GLSLNodeFunction.cjs.js +0 -1
- package/nodes/parsers/GLSLNodeFunction.js +0 -101
- package/nodes/parsers/GLSLNodeParser.cjs.js +0 -1
- package/nodes/parsers/GLSLNodeParser.js +0 -13
- package/nodes/parsers/WGSLNodeFunction.cjs.js +0 -1
- package/nodes/parsers/WGSLNodeFunction.js +0 -71
- package/nodes/parsers/WGSLNodeParser.cjs.js +0 -1
- package/nodes/parsers/WGSLNodeParser.js +0 -13
- package/nodes/procedural/CheckerNode.cjs.js +0 -1
- package/nodes/procedural/CheckerNode.js +0 -26
- package/nodes/utils/ArrayElementNode.cjs.js +0 -1
- package/nodes/utils/ArrayElementNode.js +0 -22
- package/nodes/utils/ConvertNode.cjs.js +0 -1
- package/nodes/utils/ConvertNode.js +0 -29
- package/nodes/utils/JoinNode.cjs.js +0 -1
- package/nodes/utils/JoinNode.js +0 -29
- package/nodes/utils/MatcapUVNode.cjs.js +0 -1
- package/nodes/utils/MatcapUVNode.js +0 -18
- package/nodes/utils/OscNode.cjs.js +0 -1
- package/nodes/utils/OscNode.js +0 -55
- package/nodes/utils/SplitNode.cjs.js +0 -1
- package/nodes/utils/SplitNode.js +0 -58
- package/nodes/utils/SpriteSheetUVNode.cjs.js +0 -1
- package/nodes/utils/SpriteSheetUVNode.js +0 -39
- package/nodes/utils/TimerNode.cjs.js +0 -1
- package/nodes/utils/TimerNode.js +0 -47
- package/objects/GroundProjectedEnv.cjs.js +0 -1
- package/objects/GroundProjectedEnv.d.ts +0 -12
- package/objects/GroundProjectedEnv.js +0 -145
- package/objects/Lensflare.cjs.js +0 -1
- package/objects/Lensflare.d.ts +0 -17
- package/objects/Lensflare.js +0 -332
- package/objects/LightningStorm.cjs.js +0 -1
- package/objects/LightningStorm.d.ts +0 -32
- package/objects/LightningStorm.js +0 -174
- package/objects/MarchingCubes.cjs.js +0 -1
- package/objects/MarchingCubes.d.ts +0 -75
- package/objects/MarchingCubes.js +0 -610
- package/objects/Reflector.cjs.js +0 -1
- package/objects/Reflector.d.ts +0 -19
- package/objects/Reflector.js +0 -188
- package/objects/ReflectorForSSRPass.cjs.js +0 -1
- package/objects/ReflectorForSSRPass.d.ts +0 -57
- package/objects/ReflectorForSSRPass.js +0 -298
- package/objects/ReflectorRTT.cjs.js +0 -1
- package/objects/ReflectorRTT.js +0 -11
- package/objects/Refractor.cjs.js +0 -1
- package/objects/Refractor.d.ts +0 -19
- package/objects/Refractor.js +0 -220
- package/objects/ShadowMesh.cjs.js +0 -1
- package/objects/ShadowMesh.d.ts +0 -7
- package/objects/ShadowMesh.js +0 -50
- package/objects/Sky.cjs.js +0 -1
- package/objects/Sky.d.ts +0 -30
- package/objects/Sky.js +0 -85
- package/objects/Water.cjs.js +0 -1
- package/objects/Water.d.ts +0 -22
- package/objects/Water.js +0 -279
- package/objects/Water2.cjs.js +0 -1
- package/objects/Water2.d.ts +0 -30
- package/objects/Water2.js +0 -288
- package/offscreen/jank.cjs.js +0 -1
- package/offscreen/jank.js +0 -30
- package/offscreen/offscreen.cjs.js +0 -1
- package/offscreen/offscreen.js +0 -7
- package/offscreen/scene.cjs.js +0 -1
- package/offscreen/scene.js +0 -73
- package/physics/AmmoPhysics.cjs.js +0 -1
- package/physics/AmmoPhysics.d.ts +0 -7
- package/physics/AmmoPhysics.js +0 -206
- package/postprocessing/AdaptiveToneMappingPass.cjs.js +0 -1
- package/postprocessing/AdaptiveToneMappingPass.d.ts +0 -29
- package/postprocessing/AdaptiveToneMappingPass.js +0 -247
- package/postprocessing/AfterimagePass.cjs.js +0 -1
- package/postprocessing/AfterimagePass.d.ts +0 -15
- package/postprocessing/AfterimagePass.js +0 -76
- package/postprocessing/BloomPass.cjs.js +0 -1
- package/postprocessing/BloomPass.d.ts +0 -16
- package/postprocessing/BloomPass.js +0 -116
- package/postprocessing/BokehPass.cjs.js +0 -1
- package/postprocessing/BokehPass.d.ts +0 -23
- package/postprocessing/BokehPass.js +0 -106
- package/postprocessing/ClearPass.cjs.js +0 -1
- package/postprocessing/ClearPass.d.ts +0 -10
- package/postprocessing/ClearPass.js +0 -42
- package/postprocessing/CubeTexturePass.cjs.js +0 -1
- package/postprocessing/CubeTexturePass.d.ts +0 -14
- package/postprocessing/CubeTexturePass.js +0 -48
- package/postprocessing/DotScreenPass.cjs.js +0 -1
- package/postprocessing/DotScreenPass.d.ts +0 -10
- package/postprocessing/DotScreenPass.js +0 -48
- package/postprocessing/EffectComposer.cjs.js +0 -1
- package/postprocessing/EffectComposer.d.ts +0 -27
- package/postprocessing/EffectComposer.js +0 -186
- package/postprocessing/FilmPass.cjs.js +0 -1
- package/postprocessing/FilmPass.d.ts +0 -10
- package/postprocessing/FilmPass.js +0 -47
- package/postprocessing/GlitchPass.cjs.js +0 -1
- package/postprocessing/GlitchPass.d.ts +0 -15
- package/postprocessing/GlitchPass.js +0 -96
- package/postprocessing/HalftonePass.cjs.js +0 -1
- package/postprocessing/HalftonePass.d.ts +0 -23
- package/postprocessing/HalftonePass.js +0 -64
- package/postprocessing/LUTPass.cjs.js +0 -1
- package/postprocessing/LUTPass.d.ts +0 -13
- package/postprocessing/LUTPass.js +0 -161
- package/postprocessing/MaskPass.cjs.js +0 -1
- package/postprocessing/MaskPass.d.ts +0 -14
- package/postprocessing/MaskPass.js +0 -79
- package/postprocessing/OutlinePass.cjs.js +0 -1
- package/postprocessing/OutlinePass.d.ts +0 -53
- package/postprocessing/OutlinePass.js +0 -580
- package/postprocessing/Pass.cjs.js +0 -1
- package/postprocessing/Pass.d.ts +0 -20
- package/postprocessing/Pass.js +0 -61
- package/postprocessing/RenderPass.cjs.js +0 -1
- package/postprocessing/RenderPass.d.ts +0 -14
- package/postprocessing/RenderPass.js +0 -71
- package/postprocessing/RenderPixelatedPass.cjs.js +0 -1
- package/postprocessing/RenderPixelatedPass.js +0 -213
- package/postprocessing/SAOPass.cjs.js +0 -1
- package/postprocessing/SAOPass.d.ts +0 -79
- package/postprocessing/SAOPass.js +0 -317
- package/postprocessing/SMAAPass.cjs.js +0 -1
- package/postprocessing/SMAAPass.d.ts +0 -21
- package/postprocessing/SMAAPass.js +0 -132
- package/postprocessing/SSAARenderPass.cjs.js +0 -1
- package/postprocessing/SSAARenderPass.d.ts +0 -17
- package/postprocessing/SSAARenderPass.js +0 -118
- package/postprocessing/SSAOPass.cjs.js +0 -1
- package/postprocessing/SSAOPass.d.ts +0 -71
- package/postprocessing/SSAOPass.js +0 -314
- package/postprocessing/SSRPass.cjs.js +0 -1
- package/postprocessing/SSRPass.d.ts +0 -124
- package/postprocessing/SSRPass.js +0 -508
- package/postprocessing/SavePass.cjs.js +0 -1
- package/postprocessing/SavePass.d.ts +0 -12
- package/postprocessing/SavePass.js +0 -42
- package/postprocessing/ShaderPass.cjs.js +0 -1
- package/postprocessing/ShaderPass.d.ts +0 -13
- package/postprocessing/ShaderPass.js +0 -55
- package/postprocessing/TAARenderPass.cjs.js +0 -1
- package/postprocessing/TAARenderPass.d.ts +0 -8
- package/postprocessing/TAARenderPass.js +0 -107
- package/postprocessing/TexturePass.cjs.js +0 -1
- package/postprocessing/TexturePass.d.ts +0 -12
- package/postprocessing/TexturePass.js +0 -40
- package/postprocessing/UnrealBloomPass.cjs.js +0 -1
- package/postprocessing/UnrealBloomPass.d.ts +0 -31
- package/postprocessing/UnrealBloomPass.js +0 -273
- package/postprocessing/WaterPass.cjs.js +0 -1
- package/postprocessing/WaterPass.d.ts +0 -12
- package/postprocessing/WaterPass.js +0 -102
- package/renderers/CSS2DRenderer.cjs.js +0 -1
- package/renderers/CSS2DRenderer.d.ts +0 -22
- package/renderers/CSS2DRenderer.js +0 -152
- package/renderers/CSS3DRenderer.cjs.js +0 -1
- package/renderers/CSS3DRenderer.d.ts +0 -26
- package/renderers/CSS3DRenderer.js +0 -166
- package/renderers/Projector.cjs.js +0 -1
- package/renderers/Projector.d.ts +0 -60
- package/renderers/Projector.js +0 -678
- package/renderers/SVGRenderer.cjs.js +0 -1
- package/renderers/SVGRenderer.d.ts +0 -25
- package/renderers/SVGRenderer.js +0 -416
- package/renderers/nodes/accessors/CameraNode.cjs.js +0 -1
- package/renderers/nodes/accessors/CameraNode.js +0 -73
- package/renderers/nodes/accessors/ModelNode.cjs.js +0 -1
- package/renderers/nodes/accessors/ModelNode.js +0 -69
- package/renderers/nodes/accessors/ModelViewProjectionNode.cjs.js +0 -1
- package/renderers/nodes/accessors/ModelViewProjectionNode.js +0 -33
- package/renderers/nodes/accessors/NormalNode.cjs.js +0 -1
- package/renderers/nodes/accessors/NormalNode.js +0 -70
- package/renderers/nodes/accessors/PositionNode.cjs.js +0 -1
- package/renderers/nodes/accessors/PositionNode.js +0 -30
- package/renderers/nodes/accessors/UVNode.cjs.js +0 -1
- package/renderers/nodes/accessors/UVNode.js +0 -17
- package/renderers/nodes/core/AttributeNode.cjs.js +0 -1
- package/renderers/nodes/core/AttributeNode.js +0 -43
- package/renderers/nodes/core/InputNode.cjs.js +0 -1
- package/renderers/nodes/core/InputNode.js +0 -40
- package/renderers/nodes/core/Node.cjs.js +0 -1
- package/renderers/nodes/core/Node.js +0 -43
- package/renderers/nodes/core/NodeAttribute.cjs.js +0 -1
- package/renderers/nodes/core/NodeAttribute.js +0 -12
- package/renderers/nodes/core/NodeBuilder.cjs.js +0 -1
- package/renderers/nodes/core/NodeBuilder.js +0 -309
- package/renderers/nodes/core/NodeFrame.cjs.js +0 -1
- package/renderers/nodes/core/NodeFrame.js +0 -37
- package/renderers/nodes/core/NodeSlot.cjs.js +0 -1
- package/renderers/nodes/core/NodeSlot.js +0 -10
- package/renderers/nodes/core/NodeUniform.cjs.js +0 -1
- package/renderers/nodes/core/NodeUniform.js +0 -22
- package/renderers/nodes/core/NodeVary.cjs.js +0 -1
- package/renderers/nodes/core/NodeVary.js +0 -13
- package/renderers/nodes/core/VaryNode.cjs.js +0 -1
- package/renderers/nodes/core/VaryNode.js +0 -27
- package/renderers/nodes/core/constants.cjs.js +0 -1
- package/renderers/nodes/core/constants.js +0 -19
- package/renderers/nodes/inputs/ColorNode.cjs.js +0 -1
- package/renderers/nodes/inputs/ColorNode.js +0 -16
- package/renderers/nodes/inputs/FloatNode.cjs.js +0 -1
- package/renderers/nodes/inputs/FloatNode.js +0 -16
- package/renderers/nodes/inputs/Matrix3Node.cjs.js +0 -1
- package/renderers/nodes/inputs/Matrix3Node.js +0 -17
- package/renderers/nodes/inputs/Matrix4Node.cjs.js +0 -1
- package/renderers/nodes/inputs/Matrix4Node.js +0 -17
- package/renderers/nodes/inputs/TextureNode.cjs.js +0 -1
- package/renderers/nodes/inputs/TextureNode.js +0 -27
- package/renderers/nodes/inputs/Vector2Node.cjs.js +0 -1
- package/renderers/nodes/inputs/Vector2Node.js +0 -16
- package/renderers/nodes/inputs/Vector3Node.cjs.js +0 -1
- package/renderers/nodes/inputs/Vector3Node.js +0 -17
- package/renderers/nodes/inputs/Vector4Node.cjs.js +0 -1
- package/renderers/nodes/inputs/Vector4Node.js +0 -17
- package/renderers/nodes/math/MathNode.cjs.js +0 -1
- package/renderers/nodes/math/MathNode.js +0 -64
- package/renderers/nodes/math/OperatorNode.cjs.js +0 -1
- package/renderers/nodes/math/OperatorNode.js +0 -57
- package/renderers/nodes/utils/SwitchNode.cjs.js +0 -1
- package/renderers/nodes/utils/SwitchNode.js +0 -24
- package/renderers/nodes/utils/TimerNode.cjs.js +0 -1
- package/renderers/nodes/utils/TimerNode.js +0 -18
- package/renderers/webgpu/WebGPU.cjs.js +0 -1
- package/renderers/webgpu/WebGPU.js +0 -25
- package/renderers/webgpu/WebGPUAttributes.cjs.js +0 -1
- package/renderers/webgpu/WebGPUAttributes.js +0 -75
- package/renderers/webgpu/WebGPUBackground.cjs.js +0 -1
- package/renderers/webgpu/WebGPUBackground.js +0 -77
- package/renderers/webgpu/WebGPUBinding.cjs.js +0 -1
- package/renderers/webgpu/WebGPUBinding.js +0 -16
- package/renderers/webgpu/WebGPUBindings.cjs.js +0 -1
- package/renderers/webgpu/WebGPUBindings.js +0 -190
- package/renderers/webgpu/WebGPUComputePipelines.cjs.js +0 -1
- package/renderers/webgpu/WebGPUComputePipelines.js +0 -54
- package/renderers/webgpu/WebGPUGeometries.cjs.js +0 -1
- package/renderers/webgpu/WebGPUGeometries.js +0 -50
- package/renderers/webgpu/WebGPUInfo.cjs.js +0 -1
- package/renderers/webgpu/WebGPUInfo.js +0 -50
- package/renderers/webgpu/WebGPUObjects.cjs.js +0 -1
- package/renderers/webgpu/WebGPUObjects.js +0 -29
- package/renderers/webgpu/WebGPUProperties.cjs.js +0 -1
- package/renderers/webgpu/WebGPUProperties.js +0 -27
- package/renderers/webgpu/WebGPURenderLists.cjs.js +0 -1
- package/renderers/webgpu/WebGPURenderLists.js +0 -134
- package/renderers/webgpu/WebGPURenderPipelines.cjs.js +0 -1
- package/renderers/webgpu/WebGPURenderPipelines.js +0 -671
- package/renderers/webgpu/WebGPURenderer.cjs.js +0 -1
- package/renderers/webgpu/WebGPURenderer.js +0 -713
- package/renderers/webgpu/WebGPUSampledTexture.cjs.js +0 -1
- package/renderers/webgpu/WebGPUSampledTexture.js +0 -53
- package/renderers/webgpu/WebGPUSampler.cjs.js +0 -1
- package/renderers/webgpu/WebGPUSampler.js +0 -19
- package/renderers/webgpu/WebGPUStorageBuffer.cjs.js +0 -1
- package/renderers/webgpu/WebGPUStorageBuffer.js +0 -19
- package/renderers/webgpu/WebGPUTextureRenderer.cjs.js +0 -1
- package/renderers/webgpu/WebGPUTextureRenderer.js +0 -28
- package/renderers/webgpu/WebGPUTextureUtils.cjs.js +0 -1
- package/renderers/webgpu/WebGPUTextureUtils.js +0 -108
- package/renderers/webgpu/WebGPUTextures.cjs.js +0 -1
- package/renderers/webgpu/WebGPUTextures.js +0 -630
- package/renderers/webgpu/WebGPUUniform.cjs.js +0 -1
- package/renderers/webgpu/WebGPUUniform.js +0 -107
- package/renderers/webgpu/WebGPUUniformsGroup.cjs.js +0 -1
- package/renderers/webgpu/WebGPUUniformsGroup.js +0 -215
- package/renderers/webgpu/constants.cjs.js +0 -1
- package/renderers/webgpu/constants.js +0 -221
- package/renderers/webgpu/nodes/ShaderLib.cjs.js +0 -1
- package/renderers/webgpu/nodes/ShaderLib.js +0 -41
- package/renderers/webgpu/nodes/WebGPUNodeBuilder.cjs.js +0 -1
- package/renderers/webgpu/nodes/WebGPUNodeBuilder.js +0 -235
- package/renderers/webgpu/nodes/WebGPUNodeUniform.cjs.js +0 -1
- package/renderers/webgpu/nodes/WebGPUNodeUniform.js +0 -87
- package/renderers/webgpu/nodes/WebGPUNodeUniformsGroup.cjs.js +0 -1
- package/renderers/webgpu/nodes/WebGPUNodeUniformsGroup.js +0 -15
- package/renderers/webgpu/nodes/WebGPUNodes.cjs.js +0 -1
- package/renderers/webgpu/nodes/WebGPUNodes.js +0 -77
- package/shaders/ACESFilmicToneMappingShader.cjs.js +0 -1
- package/shaders/ACESFilmicToneMappingShader.d.ts +0 -9
- package/shaders/ACESFilmicToneMappingShader.js +0 -28
- package/shaders/AfterimageShader.cjs.js +0 -1
- package/shaders/AfterimageShader.d.ts +0 -10
- package/shaders/AfterimageShader.js +0 -22
- package/shaders/BasicShader.cjs.js +0 -1
- package/shaders/BasicShader.d.ts +0 -5
- package/shaders/BasicShader.js +0 -10
- package/shaders/BleachBypassShader.cjs.js +0 -1
- package/shaders/BleachBypassShader.d.ts +0 -9
- package/shaders/BleachBypassShader.js +0 -19
- package/shaders/BlendShader.cjs.js +0 -1
- package/shaders/BlendShader.d.ts +0 -18
- package/shaders/BlendShader.js +0 -23
- package/shaders/BokehShader.cjs.js +0 -1
- package/shaders/BokehShader.d.ts +0 -19
- package/shaders/BokehShader.js +0 -44
- package/shaders/BokehShader2.cjs.js +0 -1
- package/shaders/BokehShader2.d.ts +0 -43
- package/shaders/BokehShader2.js +0 -98
- package/shaders/BrightnessContrastShader.cjs.js +0 -1
- package/shaders/BrightnessContrastShader.d.ts +0 -15
- package/shaders/BrightnessContrastShader.js +0 -23
- package/shaders/ColorCorrectionShader.cjs.js +0 -1
- package/shaders/ColorCorrectionShader.d.ts +0 -19
- package/shaders/ColorCorrectionShader.js +0 -26
- package/shaders/ColorifyShader.cjs.js +0 -1
- package/shaders/ColorifyShader.d.ts +0 -13
- package/shaders/ColorifyShader.js +0 -20
- package/shaders/ConvolutionShader.cjs.js +0 -1
- package/shaders/ConvolutionShader.d.ts +0 -16
- package/shaders/ConvolutionShader.js +0 -51
- package/shaders/CopyShader.cjs.js +0 -1
- package/shaders/CopyShader.d.ts +0 -9
- package/shaders/CopyShader.js +0 -17
- package/shaders/DOFMipMapShader.cjs.js +0 -1
- package/shaders/DOFMipMapShader.d.ts +0 -18
- package/shaders/DOFMipMapShader.js +0 -25
- package/shaders/DepthLimitedBlurShader.cjs.js +0 -1
- package/shaders/DepthLimitedBlurShader.d.ts +0 -28
- package/shaders/DepthLimitedBlurShader.js +0 -69
- package/shaders/DigitalGlitch.cjs.js +0 -1
- package/shaders/DigitalGlitch.d.ts +0 -39
- package/shaders/DigitalGlitch.js +0 -106
- package/shaders/DotScreenShader.cjs.js +0 -1
- package/shaders/DotScreenShader.d.ts +0 -22
- package/shaders/DotScreenShader.js +0 -31
- package/shaders/FXAAShader.cjs.js +0 -1
- package/shaders/FXAAShader.d.ts +0 -13
- package/shaders/FXAAShader.js +0 -23
- package/shaders/FilmShader.cjs.js +0 -1
- package/shaders/FilmShader.d.ts +0 -24
- package/shaders/FilmShader.js +0 -56
- package/shaders/FocusShader.cjs.js +0 -1
- package/shaders/FocusShader.d.ts +0 -21
- package/shaders/FocusShader.js +0 -28
- package/shaders/FreiChenShader.cjs.js +0 -1
- package/shaders/FreiChenShader.d.ts +0 -13
- package/shaders/FreiChenShader.js +0 -28
- package/shaders/FresnelShader.cjs.js +0 -1
- package/shaders/FresnelShader.d.ts +0 -21
- package/shaders/FresnelShader.js +0 -26
- package/shaders/GammaCorrectionShader.cjs.js +0 -1
- package/shaders/GammaCorrectionShader.d.ts +0 -8
- package/shaders/GammaCorrectionShader.js +0 -15
- package/shaders/GodRaysShader.cjs.js +0 -1
- package/shaders/GodRaysShader.d.ts +0 -58
- package/shaders/GodRaysShader.js +0 -137
- package/shaders/HalftoneShader.cjs.js +0 -1
- package/shaders/HalftoneShader.d.ts +0 -45
- package/shaders/HalftoneShader.js +0 -69
- package/shaders/HorizontalBlurShader.cjs.js +0 -1
- package/shaders/HorizontalBlurShader.d.ts +0 -9
- package/shaders/HorizontalBlurShader.js +0 -59
- package/shaders/HorizontalTiltShiftShader.cjs.js +0 -1
- package/shaders/HorizontalTiltShiftShader.d.ts +0 -15
- package/shaders/HorizontalTiltShiftShader.js +0 -25
- package/shaders/HueSaturationShader.cjs.js +0 -1
- package/shaders/HueSaturationShader.d.ts +0 -15
- package/shaders/HueSaturationShader.js +0 -25
- package/shaders/KaleidoShader.cjs.js +0 -1
- package/shaders/KaleidoShader.d.ts +0 -15
- package/shaders/KaleidoShader.js +0 -26
- package/shaders/LuminosityHighPassShader.cjs.js +0 -1
- package/shaders/LuminosityHighPassShader.d.ts +0 -23
- package/shaders/LuminosityHighPassShader.js +0 -31
- package/shaders/LuminosityShader.cjs.js +0 -1
- package/shaders/LuminosityShader.d.ts +0 -9
- package/shaders/LuminosityShader.js +0 -15
- package/shaders/MirrorShader.cjs.js +0 -1
- package/shaders/MirrorShader.d.ts +0 -12
- package/shaders/MirrorShader.js +0 -20
- package/shaders/NormalMapShader.cjs.js +0 -1
- package/shaders/NormalMapShader.d.ts +0 -19
- package/shaders/NormalMapShader.js +0 -27
- package/shaders/ParallaxShader.cjs.js +0 -1
- package/shaders/ParallaxShader.d.ts +0 -28
- package/shaders/ParallaxShader.js +0 -54
- package/shaders/PixelShader.cjs.js +0 -1
- package/shaders/PixelShader.d.ts +0 -15
- package/shaders/PixelShader.js +0 -20
- package/shaders/RGBShiftShader.cjs.js +0 -1
- package/shaders/RGBShiftShader.d.ts +0 -15
- package/shaders/RGBShiftShader.js +0 -26
- package/shaders/SAOShader.cjs.js +0 -1
- package/shaders/SAOShader.d.ts +0 -25
- package/shaders/SAOShader.js +0 -60
- package/shaders/SMAAShader.cjs.js +0 -1
- package/shaders/SMAAShader.d.ts +0 -55
- package/shaders/SMAAShader.js +0 -151
- package/shaders/SSAOShader.cjs.js +0 -1
- package/shaders/SSAOShader.d.ts +0 -80
- package/shaders/SSAOShader.js +0 -100
- package/shaders/SSRShader.cjs.js +0 -1
- package/shaders/SSRShader.d.ts +0 -90
- package/shaders/SSRShader.js +0 -379
- package/shaders/SepiaShader.cjs.js +0 -1
- package/shaders/SepiaShader.d.ts +0 -12
- package/shaders/SepiaShader.js +0 -19
- package/shaders/SobelOperatorShader.cjs.js +0 -1
- package/shaders/SobelOperatorShader.d.ts +0 -13
- package/shaders/SobelOperatorShader.js +0 -33
- package/shaders/SubsurfaceScatteringShader.cjs.js +0 -1
- package/shaders/SubsurfaceScatteringShader.d.ts +0 -5
- package/shaders/SubsurfaceScatteringShader.js +0 -45
- package/shaders/TechnicolorShader.cjs.js +0 -1
- package/shaders/TechnicolorShader.d.ts +0 -9
- package/shaders/TechnicolorShader.js +0 -17
- package/shaders/ToneMapShader.cjs.js +0 -1
- package/shaders/ToneMapShader.d.ts +0 -24
- package/shaders/ToneMapShader.js +0 -32
- package/shaders/ToonShader.cjs.js +0 -1
- package/shaders/ToonShader.d.ts +0 -100
- package/shaders/ToonShader.js +0 -112
- package/shaders/TriangleBlurShader.cjs.js +0 -1
- package/shaders/TriangleBlurShader.d.ts +0 -13
- package/shaders/TriangleBlurShader.js +0 -27
- package/shaders/UnpackDepthRGBAShader.cjs.js +0 -1
- package/shaders/UnpackDepthRGBAShader.d.ts +0 -12
- package/shaders/UnpackDepthRGBAShader.js +0 -18
- package/shaders/VerticalBlurShader.cjs.js +0 -1
- package/shaders/VerticalBlurShader.d.ts +0 -9
- package/shaders/VerticalBlurShader.js +0 -60
- package/shaders/VerticalTiltShiftShader.cjs.js +0 -1
- package/shaders/VerticalTiltShiftShader.d.ts +0 -15
- package/shaders/VerticalTiltShiftShader.js +0 -25
- package/shaders/VignetteShader.cjs.js +0 -1
- package/shaders/VignetteShader.d.ts +0 -15
- package/shaders/VignetteShader.js +0 -32
- package/shaders/VolumeShader.cjs.js +0 -1
- package/shaders/VolumeShader.d.ts +0 -25
- package/shaders/VolumeShader.js +0 -81
- package/shaders/WaterRefractionShader.cjs.js +0 -1
- package/shaders/WaterRefractionShader.d.ts +0 -21
- package/shaders/WaterRefractionShader.js +0 -25
- package/shaders/types.cjs.js +0 -1
- package/shaders/types.d.ts +0 -14
- package/shaders/types.js +0 -1
- package/textures/FlakesTexture.cjs.js +0 -1
- package/textures/FlakesTexture.d.ts +0 -4
- package/textures/FlakesTexture.js +0 -32
- package/types/helpers.cjs.js +0 -1
- package/types/helpers.d.ts +0 -1
- package/types/helpers.js +0 -3
- package/types/shared.cjs.js +0 -1
- package/types/shared.d.ts +0 -2
- package/types/shared.js +0 -1
- package/types/utils.cjs.js +0 -1
- package/types/utils.d.ts +0 -3
- package/types/utils.js +0 -1
- package/utils/BufferGeometryUtils.cjs.js +0 -1
- package/utils/BufferGeometryUtils.d.ts +0 -15
- package/utils/BufferGeometryUtils.js +0 -728
- package/utils/GeometryCompressionUtils.cjs.js +0 -1
- package/utils/GeometryCompressionUtils.d.ts +0 -7
- package/utils/GeometryCompressionUtils.js +0 -545
- package/utils/GeometryUtils.cjs.js +0 -1
- package/utils/GeometryUtils.d.ts +0 -6
- package/utils/GeometryUtils.js +0 -161
- package/utils/LDrawUtils.cjs.js +0 -1
- package/utils/LDrawUtils.d.ts +0 -5
- package/utils/LDrawUtils.js +0 -144
- package/utils/RoughnessMipmapper.cjs.js +0 -1
- package/utils/RoughnessMipmapper.js +0 -257
- package/utils/SceneUtils.cjs.js +0 -1
- package/utils/SceneUtils.d.ts +0 -9
- package/utils/SceneUtils.js +0 -41
- package/utils/ShadowMapViewer.cjs.js +0 -1
- package/utils/ShadowMapViewer.d.ts +0 -24
- package/utils/ShadowMapViewer.js +0 -160
- package/utils/SkeletonUtils.cjs.js +0 -1
- package/utils/SkeletonUtils.d.ts +0 -30
- package/utils/SkeletonUtils.js +0 -383
- package/utils/UVsDebug.cjs.js +0 -1
- package/utils/UVsDebug.d.ts +0 -3
- package/utils/UVsDebug.js +0 -115
- package/utils/WorkerPool.cjs.js +0 -1
- package/utils/WorkerPool.js +0 -82
- package/webxr/ARButton.cjs.js +0 -1
- package/webxr/ARButton.d.ts +0 -5
- package/webxr/ARButton.js +0 -145
- package/webxr/OculusHandModel.cjs.js +0 -1
- package/webxr/OculusHandModel.d.ts +0 -22
- package/webxr/OculusHandModel.js +0 -90
- package/webxr/OculusHandPointerModel.cjs.js +0 -1
- package/webxr/OculusHandPointerModel.d.ts +0 -63
- package/webxr/OculusHandPointerModel.js +0 -248
- package/webxr/Text2D.cjs.js +0 -1
- package/webxr/Text2D.d.ts +0 -3
- package/webxr/Text2D.js +0 -32
- package/webxr/VRButton.cjs.js +0 -1
- package/webxr/VRButton.d.ts +0 -7
- package/webxr/VRButton.js +0 -136
- package/webxr/XRControllerModelFactory.cjs.js +0 -1
- package/webxr/XRControllerModelFactory.d.ts +0 -19
- package/webxr/XRControllerModelFactory.js +0 -237
- package/webxr/XREstimatedLight.cjs.js +0 -1
- package/webxr/XREstimatedLight.d.ts +0 -32
- package/webxr/XREstimatedLight.js +0 -153
- package/webxr/XRHandMeshModel.cjs.js +0 -1
- package/webxr/XRHandMeshModel.d.ts +0 -9
- package/webxr/XRHandMeshModel.js +0 -62
- package/webxr/XRHandModelFactory.cjs.js +0 -1
- package/webxr/XRHandModelFactory.d.ts +0 -25
- package/webxr/XRHandModelFactory.js +0 -64
- package/webxr/XRHandPrimitiveModel.cjs.js +0 -1
- package/webxr/XRHandPrimitiveModel.d.ts +0 -24
- package/webxr/XRHandPrimitiveModel.js +0 -54
package/loaders/LDrawLoader.js
DELETED
@@ -1,1842 +0,0 @@
|
|
1
|
-
import { Vector3, Ray, Loader, FileLoader, MeshStandardMaterial, LineBasicMaterial, ShaderMaterial, UniformsUtils, UniformsLib, Color, BufferGeometry, BufferAttribute, LineSegments, Mesh, Matrix4, Group } from 'three';
|
2
|
-
|
3
|
-
// Note: "MATERIAL" tag (e.g. GLITTER, SPECKLE) is not implemented
|
4
|
-
|
5
|
-
const FINISH_TYPE_DEFAULT = 0;
|
6
|
-
const FINISH_TYPE_CHROME = 1;
|
7
|
-
const FINISH_TYPE_PEARLESCENT = 2;
|
8
|
-
const FINISH_TYPE_RUBBER = 3;
|
9
|
-
const FINISH_TYPE_MATTE_METALLIC = 4;
|
10
|
-
const FINISH_TYPE_METAL = 5; // State machine to search a subobject path.
|
11
|
-
// The LDraw standard establishes these various possible subfolders.
|
12
|
-
|
13
|
-
const FILE_LOCATION_AS_IS = 0;
|
14
|
-
const FILE_LOCATION_TRY_PARTS = 1;
|
15
|
-
const FILE_LOCATION_TRY_P = 2;
|
16
|
-
const FILE_LOCATION_TRY_MODELS = 3;
|
17
|
-
const FILE_LOCATION_TRY_RELATIVE = 4;
|
18
|
-
const FILE_LOCATION_TRY_ABSOLUTE = 5;
|
19
|
-
const FILE_LOCATION_NOT_FOUND = 6;
|
20
|
-
const MAIN_COLOUR_CODE = '16';
|
21
|
-
const MAIN_EDGE_COLOUR_CODE = '24';
|
22
|
-
|
23
|
-
const _tempVec0 = new Vector3();
|
24
|
-
|
25
|
-
const _tempVec1 = new Vector3();
|
26
|
-
|
27
|
-
class LDrawConditionalLineMaterial extends ShaderMaterial {
|
28
|
-
constructor(parameters) {
|
29
|
-
super({
|
30
|
-
uniforms: UniformsUtils.merge([UniformsLib.fog, {
|
31
|
-
diffuse: {
|
32
|
-
value: new Color()
|
33
|
-
},
|
34
|
-
opacity: {
|
35
|
-
value: 1.0
|
36
|
-
}
|
37
|
-
}]),
|
38
|
-
vertexShader:
|
39
|
-
/* glsl */
|
40
|
-
`
|
41
|
-
attribute vec3 control0;
|
42
|
-
attribute vec3 control1;
|
43
|
-
attribute vec3 direction;
|
44
|
-
varying float discardFlag;
|
45
|
-
|
46
|
-
#include <common>
|
47
|
-
#include <color_pars_vertex>
|
48
|
-
#include <fog_pars_vertex>
|
49
|
-
#include <logdepthbuf_pars_vertex>
|
50
|
-
#include <clipping_planes_pars_vertex>
|
51
|
-
|
52
|
-
void main() {
|
53
|
-
#include <color_vertex>
|
54
|
-
|
55
|
-
vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);
|
56
|
-
gl_Position = projectionMatrix * mvPosition;
|
57
|
-
|
58
|
-
// Transform the line segment ends and control points into camera clip space
|
59
|
-
vec4 c0 = projectionMatrix * modelViewMatrix * vec4(control0, 1.0);
|
60
|
-
vec4 c1 = projectionMatrix * modelViewMatrix * vec4(control1, 1.0);
|
61
|
-
vec4 p0 = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
62
|
-
vec4 p1 = projectionMatrix * modelViewMatrix * vec4(position + direction, 1.0);
|
63
|
-
|
64
|
-
c0.xy /= c0.w;
|
65
|
-
c1.xy /= c1.w;
|
66
|
-
p0.xy /= p0.w;
|
67
|
-
p1.xy /= p1.w;
|
68
|
-
|
69
|
-
// Get the direction of the segment and an orthogonal vector
|
70
|
-
vec2 dir = p1.xy - p0.xy;
|
71
|
-
vec2 norm = vec2(-dir.y, dir.x);
|
72
|
-
|
73
|
-
// Get control point directions from the line
|
74
|
-
vec2 c0dir = c0.xy - p1.xy;
|
75
|
-
vec2 c1dir = c1.xy - p1.xy;
|
76
|
-
|
77
|
-
// If the vectors to the controls points are pointed in different directions away
|
78
|
-
// from the line segment then the line should not be drawn.
|
79
|
-
float d0 = dot(normalize(norm), normalize(c0dir));
|
80
|
-
float d1 = dot(normalize(norm), normalize(c1dir));
|
81
|
-
discardFlag = float(sign(d0) != sign(d1));
|
82
|
-
|
83
|
-
#include <logdepthbuf_vertex>
|
84
|
-
#include <clipping_planes_vertex>
|
85
|
-
#include <fog_vertex>
|
86
|
-
}
|
87
|
-
`,
|
88
|
-
fragmentShader:
|
89
|
-
/* glsl */
|
90
|
-
`
|
91
|
-
uniform vec3 diffuse;
|
92
|
-
uniform float opacity;
|
93
|
-
varying float discardFlag;
|
94
|
-
|
95
|
-
#include <common>
|
96
|
-
#include <color_pars_fragment>
|
97
|
-
#include <fog_pars_fragment>
|
98
|
-
#include <logdepthbuf_pars_fragment>
|
99
|
-
#include <clipping_planes_pars_fragment>
|
100
|
-
|
101
|
-
void main() {
|
102
|
-
if (discardFlag > 0.5) discard;
|
103
|
-
|
104
|
-
#include <clipping_planes_fragment>
|
105
|
-
vec3 outgoingLight = vec3(0.0);
|
106
|
-
vec4 diffuseColor = vec4(diffuse, opacity);
|
107
|
-
#include <logdepthbuf_fragment>
|
108
|
-
#include <color_fragment>
|
109
|
-
outgoingLight = diffuseColor.rgb; // simple shader
|
110
|
-
gl_FragColor = vec4(outgoingLight, diffuseColor.a);
|
111
|
-
#include <tonemapping_fragment>
|
112
|
-
#include <encodings_fragment>
|
113
|
-
#include <fog_fragment>
|
114
|
-
#include <premultiplied_alpha_fragment>
|
115
|
-
}
|
116
|
-
`
|
117
|
-
});
|
118
|
-
Object.defineProperties(this, {
|
119
|
-
opacity: {
|
120
|
-
get: function () {
|
121
|
-
return this.uniforms.opacity.value;
|
122
|
-
},
|
123
|
-
set: function (value) {
|
124
|
-
this.uniforms.opacity.value = value;
|
125
|
-
}
|
126
|
-
},
|
127
|
-
color: {
|
128
|
-
get: function () {
|
129
|
-
return this.uniforms.diffuse.value;
|
130
|
-
}
|
131
|
-
}
|
132
|
-
});
|
133
|
-
this.setValues(parameters);
|
134
|
-
this.isLDrawConditionalLineMaterial = true;
|
135
|
-
}
|
136
|
-
|
137
|
-
}
|
138
|
-
|
139
|
-
class ConditionalLineSegments extends LineSegments {
|
140
|
-
constructor(geometry, material) {
|
141
|
-
super(geometry, material);
|
142
|
-
this.isConditionalLine = true;
|
143
|
-
}
|
144
|
-
|
145
|
-
}
|
146
|
-
|
147
|
-
function generateFaceNormals(faces) {
|
148
|
-
for (let i = 0, l = faces.length; i < l; i++) {
|
149
|
-
const face = faces[i];
|
150
|
-
const vertices = face.vertices;
|
151
|
-
const v0 = vertices[0];
|
152
|
-
const v1 = vertices[1];
|
153
|
-
const v2 = vertices[2];
|
154
|
-
|
155
|
-
_tempVec0.subVectors(v1, v0);
|
156
|
-
|
157
|
-
_tempVec1.subVectors(v2, v1);
|
158
|
-
|
159
|
-
face.faceNormal = new Vector3().crossVectors(_tempVec0, _tempVec1).normalize();
|
160
|
-
}
|
161
|
-
}
|
162
|
-
|
163
|
-
const _ray = new Ray();
|
164
|
-
|
165
|
-
function smoothNormals(faces, lineSegments, checkSubSegments = false) {
|
166
|
-
// NOTE: 1e2 is pretty coarse but was chosen to quantize the resulting value because
|
167
|
-
// it allows edges to be smoothed as expected (see minifig arms).
|
168
|
-
// --
|
169
|
-
// And the vector values are initialize multiplied by 1 + 1e-10 to account for floating
|
170
|
-
// point errors on vertices along quantization boundaries. Ie after matrix multiplication
|
171
|
-
// vertices that should be merged might be set to "1.7" and "1.6999..." meaning they won't
|
172
|
-
// get merged. This added epsilon attempts to push these error values to the same quantized
|
173
|
-
// value for the sake of hashing. See "AT-ST mini" dishes. See mrdoob/three#23169.
|
174
|
-
const hashMultiplier = (1 + 1e-10) * 1e2;
|
175
|
-
|
176
|
-
function hashVertex(v) {
|
177
|
-
const x = ~~(v.x * hashMultiplier);
|
178
|
-
const y = ~~(v.y * hashMultiplier);
|
179
|
-
const z = ~~(v.z * hashMultiplier);
|
180
|
-
return `${x},${y},${z}`;
|
181
|
-
}
|
182
|
-
|
183
|
-
function hashEdge(v0, v1) {
|
184
|
-
return `${hashVertex(v0)}_${hashVertex(v1)}`;
|
185
|
-
} // converts the two vertices to a ray with a normalized direction and origin of 0, 0, 0 projected
|
186
|
-
// onto the original line.
|
187
|
-
|
188
|
-
|
189
|
-
function toNormalizedRay(v0, v1, targetRay) {
|
190
|
-
targetRay.direction.subVectors(v1, v0).normalize();
|
191
|
-
const scalar = v0.dot(targetRay.direction);
|
192
|
-
targetRay.origin.copy(v0).addScaledVector(targetRay.direction, -scalar);
|
193
|
-
return targetRay;
|
194
|
-
}
|
195
|
-
|
196
|
-
function hashRay(ray) {
|
197
|
-
return hashEdge(ray.origin, ray.direction);
|
198
|
-
}
|
199
|
-
|
200
|
-
const hardEdges = new Set();
|
201
|
-
const hardEdgeRays = new Map();
|
202
|
-
const halfEdgeList = {};
|
203
|
-
const normals = []; // Save the list of hard edges by hash
|
204
|
-
|
205
|
-
for (let i = 0, l = lineSegments.length; i < l; i++) {
|
206
|
-
const ls = lineSegments[i];
|
207
|
-
const vertices = ls.vertices;
|
208
|
-
const v0 = vertices[0];
|
209
|
-
const v1 = vertices[1];
|
210
|
-
hardEdges.add(hashEdge(v0, v1));
|
211
|
-
hardEdges.add(hashEdge(v1, v0)); // only generate the hard edge ray map if we're checking subsegments because it's more expensive to check
|
212
|
-
// and requires more memory.
|
213
|
-
|
214
|
-
if (checkSubSegments) {
|
215
|
-
// add both ray directions to the map
|
216
|
-
const ray = toNormalizedRay(v0, v1, new Ray());
|
217
|
-
const rh1 = hashRay(ray);
|
218
|
-
|
219
|
-
if (!hardEdgeRays.has(rh1)) {
|
220
|
-
toNormalizedRay(v1, v0, ray);
|
221
|
-
const rh2 = hashRay(ray);
|
222
|
-
const info = {
|
223
|
-
ray,
|
224
|
-
distances: []
|
225
|
-
};
|
226
|
-
hardEdgeRays.set(rh1, info);
|
227
|
-
hardEdgeRays.set(rh2, info);
|
228
|
-
} // store both segments ends in min, max order in the distances array to check if a face edge is a
|
229
|
-
// subsegment later.
|
230
|
-
|
231
|
-
|
232
|
-
const info = hardEdgeRays.get(rh1);
|
233
|
-
let d0 = info.ray.direction.dot(v0);
|
234
|
-
let d1 = info.ray.direction.dot(v1);
|
235
|
-
|
236
|
-
if (d0 > d1) {
|
237
|
-
[d0, d1] = [d1, d0];
|
238
|
-
}
|
239
|
-
|
240
|
-
info.distances.push(d0, d1);
|
241
|
-
}
|
242
|
-
} // track the half edges associated with each triangle
|
243
|
-
|
244
|
-
|
245
|
-
for (let i = 0, l = faces.length; i < l; i++) {
|
246
|
-
const tri = faces[i];
|
247
|
-
const vertices = tri.vertices;
|
248
|
-
const vertCount = vertices.length;
|
249
|
-
|
250
|
-
for (let i2 = 0; i2 < vertCount; i2++) {
|
251
|
-
const index = i2;
|
252
|
-
const next = (i2 + 1) % vertCount;
|
253
|
-
const v0 = vertices[index];
|
254
|
-
const v1 = vertices[next];
|
255
|
-
const hash = hashEdge(v0, v1); // don't add the triangle if the edge is supposed to be hard
|
256
|
-
|
257
|
-
if (hardEdges.has(hash)) {
|
258
|
-
continue;
|
259
|
-
} // if checking subsegments then check to see if this edge lies on a hard edge ray and whether its within any ray bounds
|
260
|
-
|
261
|
-
|
262
|
-
if (checkSubSegments) {
|
263
|
-
toNormalizedRay(v0, v1, _ray);
|
264
|
-
const rayHash = hashRay(_ray);
|
265
|
-
|
266
|
-
if (hardEdgeRays.has(rayHash)) {
|
267
|
-
const info = hardEdgeRays.get(rayHash);
|
268
|
-
const {
|
269
|
-
ray,
|
270
|
-
distances
|
271
|
-
} = info;
|
272
|
-
let d0 = ray.direction.dot(v0);
|
273
|
-
let d1 = ray.direction.dot(v1);
|
274
|
-
|
275
|
-
if (d0 > d1) {
|
276
|
-
[d0, d1] = [d1, d0];
|
277
|
-
} // return early if the face edge is found to be a subsegment of a line edge meaning the edge will have "hard" normals
|
278
|
-
|
279
|
-
|
280
|
-
let found = false;
|
281
|
-
|
282
|
-
for (let i = 0, l = distances.length; i < l; i += 2) {
|
283
|
-
if (d0 >= distances[i] && d1 <= distances[i + 1]) {
|
284
|
-
found = true;
|
285
|
-
break;
|
286
|
-
}
|
287
|
-
}
|
288
|
-
|
289
|
-
if (found) {
|
290
|
-
continue;
|
291
|
-
}
|
292
|
-
}
|
293
|
-
}
|
294
|
-
|
295
|
-
const info = {
|
296
|
-
index: index,
|
297
|
-
tri: tri
|
298
|
-
};
|
299
|
-
halfEdgeList[hash] = info;
|
300
|
-
}
|
301
|
-
} // Iterate until we've tried to connect all faces to share normals
|
302
|
-
|
303
|
-
|
304
|
-
while (true) {
|
305
|
-
// Stop if there are no more faces left
|
306
|
-
let halfEdge = null;
|
307
|
-
|
308
|
-
for (const key in halfEdgeList) {
|
309
|
-
halfEdge = halfEdgeList[key];
|
310
|
-
break;
|
311
|
-
}
|
312
|
-
|
313
|
-
if (halfEdge === null) {
|
314
|
-
break;
|
315
|
-
} // Exhaustively find all connected faces
|
316
|
-
|
317
|
-
|
318
|
-
const queue = [halfEdge];
|
319
|
-
|
320
|
-
while (queue.length > 0) {
|
321
|
-
// initialize all vertex normals in this triangle
|
322
|
-
const tri = queue.pop().tri;
|
323
|
-
const vertices = tri.vertices;
|
324
|
-
const vertNormals = tri.normals;
|
325
|
-
const faceNormal = tri.faceNormal; // Check if any edge is connected to another triangle edge
|
326
|
-
|
327
|
-
const vertCount = vertices.length;
|
328
|
-
|
329
|
-
for (let i2 = 0; i2 < vertCount; i2++) {
|
330
|
-
const index = i2;
|
331
|
-
const next = (i2 + 1) % vertCount;
|
332
|
-
const v0 = vertices[index];
|
333
|
-
const v1 = vertices[next]; // delete this triangle from the list so it won't be found again
|
334
|
-
|
335
|
-
const hash = hashEdge(v0, v1);
|
336
|
-
delete halfEdgeList[hash];
|
337
|
-
const reverseHash = hashEdge(v1, v0);
|
338
|
-
const otherInfo = halfEdgeList[reverseHash];
|
339
|
-
|
340
|
-
if (otherInfo) {
|
341
|
-
const otherTri = otherInfo.tri;
|
342
|
-
const otherIndex = otherInfo.index;
|
343
|
-
const otherNormals = otherTri.normals;
|
344
|
-
const otherVertCount = otherNormals.length;
|
345
|
-
const otherFaceNormal = otherTri.faceNormal; // NOTE: If the angle between faces is > 67.5 degrees then assume it's
|
346
|
-
// hard edge. There are some cases where the line segments do not line up exactly
|
347
|
-
// with or span multiple triangle edges (see Lunar Vehicle wheels).
|
348
|
-
|
349
|
-
if (Math.abs(otherTri.faceNormal.dot(tri.faceNormal)) < 0.25) {
|
350
|
-
continue;
|
351
|
-
} // if this triangle has already been traversed then it won't be in
|
352
|
-
// the halfEdgeList. If it has not then add it to the queue and delete
|
353
|
-
// it so it won't be found again.
|
354
|
-
|
355
|
-
|
356
|
-
if (reverseHash in halfEdgeList) {
|
357
|
-
queue.push(otherInfo);
|
358
|
-
delete halfEdgeList[reverseHash];
|
359
|
-
} // share the first normal
|
360
|
-
|
361
|
-
|
362
|
-
const otherNext = (otherIndex + 1) % otherVertCount;
|
363
|
-
|
364
|
-
if (vertNormals[index] && otherNormals[otherNext] && vertNormals[index] !== otherNormals[otherNext]) {
|
365
|
-
otherNormals[otherNext].norm.add(vertNormals[index].norm);
|
366
|
-
vertNormals[index].norm = otherNormals[otherNext].norm;
|
367
|
-
}
|
368
|
-
|
369
|
-
let sharedNormal1 = vertNormals[index] || otherNormals[otherNext];
|
370
|
-
|
371
|
-
if (sharedNormal1 === null) {
|
372
|
-
// it's possible to encounter an edge of a triangle that has already been traversed meaning
|
373
|
-
// both edges already have different normals defined and shared. To work around this we create
|
374
|
-
// a wrapper object so when those edges are merged the normals can be updated everywhere.
|
375
|
-
sharedNormal1 = {
|
376
|
-
norm: new Vector3()
|
377
|
-
};
|
378
|
-
normals.push(sharedNormal1.norm);
|
379
|
-
}
|
380
|
-
|
381
|
-
if (vertNormals[index] === null) {
|
382
|
-
vertNormals[index] = sharedNormal1;
|
383
|
-
sharedNormal1.norm.add(faceNormal);
|
384
|
-
}
|
385
|
-
|
386
|
-
if (otherNormals[otherNext] === null) {
|
387
|
-
otherNormals[otherNext] = sharedNormal1;
|
388
|
-
sharedNormal1.norm.add(otherFaceNormal);
|
389
|
-
} // share the second normal
|
390
|
-
|
391
|
-
|
392
|
-
if (vertNormals[next] && otherNormals[otherIndex] && vertNormals[next] !== otherNormals[otherIndex]) {
|
393
|
-
otherNormals[otherIndex].norm.add(vertNormals[next].norm);
|
394
|
-
vertNormals[next].norm = otherNormals[otherIndex].norm;
|
395
|
-
}
|
396
|
-
|
397
|
-
let sharedNormal2 = vertNormals[next] || otherNormals[otherIndex];
|
398
|
-
|
399
|
-
if (sharedNormal2 === null) {
|
400
|
-
sharedNormal2 = {
|
401
|
-
norm: new Vector3()
|
402
|
-
};
|
403
|
-
normals.push(sharedNormal2.norm);
|
404
|
-
}
|
405
|
-
|
406
|
-
if (vertNormals[next] === null) {
|
407
|
-
vertNormals[next] = sharedNormal2;
|
408
|
-
sharedNormal2.norm.add(faceNormal);
|
409
|
-
}
|
410
|
-
|
411
|
-
if (otherNormals[otherIndex] === null) {
|
412
|
-
otherNormals[otherIndex] = sharedNormal2;
|
413
|
-
sharedNormal2.norm.add(otherFaceNormal);
|
414
|
-
}
|
415
|
-
}
|
416
|
-
}
|
417
|
-
}
|
418
|
-
} // The normals of each face have been added up so now we average them by normalizing the vector.
|
419
|
-
|
420
|
-
|
421
|
-
for (let i = 0, l = normals.length; i < l; i++) {
|
422
|
-
normals[i].normalize();
|
423
|
-
}
|
424
|
-
}
|
425
|
-
|
426
|
-
function isPartType(type) {
|
427
|
-
return type === 'Part' || type === 'Unofficial_Part';
|
428
|
-
}
|
429
|
-
|
430
|
-
function isPrimitiveType(type) {
|
431
|
-
return /primitive/i.test(type) || type === 'Subpart';
|
432
|
-
}
|
433
|
-
|
434
|
-
class LineParser {
|
435
|
-
constructor(line, lineNumber) {
|
436
|
-
this.line = line;
|
437
|
-
this.lineLength = line.length;
|
438
|
-
this.currentCharIndex = 0;
|
439
|
-
this.currentChar = ' ';
|
440
|
-
this.lineNumber = lineNumber;
|
441
|
-
}
|
442
|
-
|
443
|
-
seekNonSpace() {
|
444
|
-
while (this.currentCharIndex < this.lineLength) {
|
445
|
-
this.currentChar = this.line.charAt(this.currentCharIndex);
|
446
|
-
|
447
|
-
if (this.currentChar !== ' ' && this.currentChar !== '\t') {
|
448
|
-
return;
|
449
|
-
}
|
450
|
-
|
451
|
-
this.currentCharIndex++;
|
452
|
-
}
|
453
|
-
}
|
454
|
-
|
455
|
-
getToken() {
|
456
|
-
const pos0 = this.currentCharIndex++; // Seek space
|
457
|
-
|
458
|
-
while (this.currentCharIndex < this.lineLength) {
|
459
|
-
this.currentChar = this.line.charAt(this.currentCharIndex);
|
460
|
-
|
461
|
-
if (this.currentChar === ' ' || this.currentChar === '\t') {
|
462
|
-
break;
|
463
|
-
}
|
464
|
-
|
465
|
-
this.currentCharIndex++;
|
466
|
-
}
|
467
|
-
|
468
|
-
const pos1 = this.currentCharIndex;
|
469
|
-
this.seekNonSpace();
|
470
|
-
return this.line.substring(pos0, pos1);
|
471
|
-
}
|
472
|
-
|
473
|
-
getVector() {
|
474
|
-
return new Vector3(parseFloat(this.getToken()), parseFloat(this.getToken()), parseFloat(this.getToken()));
|
475
|
-
}
|
476
|
-
|
477
|
-
getRemainingString() {
|
478
|
-
return this.line.substring(this.currentCharIndex, this.lineLength);
|
479
|
-
}
|
480
|
-
|
481
|
-
isAtTheEnd() {
|
482
|
-
return this.currentCharIndex >= this.lineLength;
|
483
|
-
}
|
484
|
-
|
485
|
-
setToEnd() {
|
486
|
-
this.currentCharIndex = this.lineLength;
|
487
|
-
}
|
488
|
-
|
489
|
-
getLineNumberString() {
|
490
|
-
return this.lineNumber >= 0 ? ' at line ' + this.lineNumber : '';
|
491
|
-
}
|
492
|
-
|
493
|
-
} // Fetches and parses an intermediate representation of LDraw parts files.
|
494
|
-
|
495
|
-
|
496
|
-
class LDrawParsedCache {
|
497
|
-
constructor(loader) {
|
498
|
-
this.loader = loader;
|
499
|
-
this._cache = {};
|
500
|
-
}
|
501
|
-
|
502
|
-
cloneResult(original) {
|
503
|
-
const result = {}; // vertices are transformed and normals computed before being converted to geometry
|
504
|
-
// so these pieces must be cloned.
|
505
|
-
|
506
|
-
result.faces = original.faces.map(face => {
|
507
|
-
return {
|
508
|
-
colorCode: face.colorCode,
|
509
|
-
material: face.material,
|
510
|
-
vertices: face.vertices.map(v => v.clone()),
|
511
|
-
normals: face.normals.map(() => null),
|
512
|
-
faceNormal: null
|
513
|
-
};
|
514
|
-
});
|
515
|
-
result.conditionalSegments = original.conditionalSegments.map(face => {
|
516
|
-
return {
|
517
|
-
colorCode: face.colorCode,
|
518
|
-
material: face.material,
|
519
|
-
vertices: face.vertices.map(v => v.clone()),
|
520
|
-
controlPoints: face.controlPoints.map(v => v.clone())
|
521
|
-
};
|
522
|
-
});
|
523
|
-
result.lineSegments = original.lineSegments.map(face => {
|
524
|
-
return {
|
525
|
-
colorCode: face.colorCode,
|
526
|
-
material: face.material,
|
527
|
-
vertices: face.vertices.map(v => v.clone())
|
528
|
-
};
|
529
|
-
}); // none if this is subsequently modified
|
530
|
-
|
531
|
-
result.type = original.type;
|
532
|
-
result.category = original.category;
|
533
|
-
result.keywords = original.keywords;
|
534
|
-
result.subobjects = original.subobjects;
|
535
|
-
result.totalFaces = original.totalFaces;
|
536
|
-
result.startingConstructionStep = original.startingConstructionStep;
|
537
|
-
result.materials = original.materials;
|
538
|
-
result.group = null;
|
539
|
-
return result;
|
540
|
-
}
|
541
|
-
|
542
|
-
async fetchData(fileName) {
|
543
|
-
let triedLowerCase = false;
|
544
|
-
let locationState = FILE_LOCATION_AS_IS;
|
545
|
-
|
546
|
-
while (locationState !== FILE_LOCATION_NOT_FOUND) {
|
547
|
-
let subobjectURL = fileName;
|
548
|
-
|
549
|
-
switch (locationState) {
|
550
|
-
case FILE_LOCATION_AS_IS:
|
551
|
-
locationState = locationState + 1;
|
552
|
-
break;
|
553
|
-
|
554
|
-
case FILE_LOCATION_TRY_PARTS:
|
555
|
-
subobjectURL = 'parts/' + subobjectURL;
|
556
|
-
locationState = locationState + 1;
|
557
|
-
break;
|
558
|
-
|
559
|
-
case FILE_LOCATION_TRY_P:
|
560
|
-
subobjectURL = 'p/' + subobjectURL;
|
561
|
-
locationState = locationState + 1;
|
562
|
-
break;
|
563
|
-
|
564
|
-
case FILE_LOCATION_TRY_MODELS:
|
565
|
-
subobjectURL = 'models/' + subobjectURL;
|
566
|
-
locationState = locationState + 1;
|
567
|
-
break;
|
568
|
-
|
569
|
-
case FILE_LOCATION_TRY_RELATIVE:
|
570
|
-
subobjectURL = fileName.substring(0, fileName.lastIndexOf('/') + 1) + subobjectURL;
|
571
|
-
locationState = locationState + 1;
|
572
|
-
break;
|
573
|
-
|
574
|
-
case FILE_LOCATION_TRY_ABSOLUTE:
|
575
|
-
if (triedLowerCase) {
|
576
|
-
// Try absolute path
|
577
|
-
locationState = FILE_LOCATION_NOT_FOUND;
|
578
|
-
} else {
|
579
|
-
// Next attempt is lower case
|
580
|
-
fileName = fileName.toLowerCase();
|
581
|
-
subobjectURL = fileName;
|
582
|
-
triedLowerCase = true;
|
583
|
-
locationState = FILE_LOCATION_AS_IS;
|
584
|
-
}
|
585
|
-
|
586
|
-
break;
|
587
|
-
}
|
588
|
-
|
589
|
-
const loader = this.loader;
|
590
|
-
const fileLoader = new FileLoader(loader.manager);
|
591
|
-
fileLoader.setPath(loader.partsLibraryPath);
|
592
|
-
fileLoader.setRequestHeader(loader.requestHeader);
|
593
|
-
fileLoader.setWithCredentials(loader.withCredentials);
|
594
|
-
|
595
|
-
try {
|
596
|
-
const text = await fileLoader.loadAsync(subobjectURL);
|
597
|
-
return text;
|
598
|
-
} catch {
|
599
|
-
continue;
|
600
|
-
}
|
601
|
-
}
|
602
|
-
|
603
|
-
throw new Error('LDrawLoader: Subobject "' + fileName + '" could not be loaded.');
|
604
|
-
}
|
605
|
-
|
606
|
-
parse(text, fileName = null) {
|
607
|
-
const loader = this.loader; // final results
|
608
|
-
|
609
|
-
const faces = [];
|
610
|
-
const lineSegments = [];
|
611
|
-
const conditionalSegments = [];
|
612
|
-
const subobjects = [];
|
613
|
-
const materials = {};
|
614
|
-
|
615
|
-
const getLocalMaterial = colorCode => {
|
616
|
-
return materials[colorCode] || null;
|
617
|
-
};
|
618
|
-
|
619
|
-
let type = 'Model';
|
620
|
-
let category = null;
|
621
|
-
let keywords = null;
|
622
|
-
let totalFaces = 0; // split into lines
|
623
|
-
|
624
|
-
if (text.indexOf('\r\n') !== -1) {
|
625
|
-
// This is faster than String.split with regex that splits on both
|
626
|
-
text = text.replace(/\r\n/g, '\n');
|
627
|
-
}
|
628
|
-
|
629
|
-
const lines = text.split('\n');
|
630
|
-
const numLines = lines.length;
|
631
|
-
let parsingEmbeddedFiles = false;
|
632
|
-
let currentEmbeddedFileName = null;
|
633
|
-
let currentEmbeddedText = null;
|
634
|
-
let bfcCertified = false;
|
635
|
-
let bfcCCW = true;
|
636
|
-
let bfcInverted = false;
|
637
|
-
let bfcCull = true;
|
638
|
-
let startingConstructionStep = false; // Parse all line commands
|
639
|
-
|
640
|
-
for (let lineIndex = 0; lineIndex < numLines; lineIndex++) {
|
641
|
-
const line = lines[lineIndex];
|
642
|
-
if (line.length === 0) continue;
|
643
|
-
|
644
|
-
if (parsingEmbeddedFiles) {
|
645
|
-
if (line.startsWith('0 FILE ')) {
|
646
|
-
// Save previous embedded file in the cache
|
647
|
-
this.setData(currentEmbeddedFileName, currentEmbeddedText); // New embedded text file
|
648
|
-
|
649
|
-
currentEmbeddedFileName = line.substring(7);
|
650
|
-
currentEmbeddedText = '';
|
651
|
-
} else {
|
652
|
-
currentEmbeddedText += line + '\n';
|
653
|
-
}
|
654
|
-
|
655
|
-
continue;
|
656
|
-
}
|
657
|
-
|
658
|
-
const lp = new LineParser(line, lineIndex + 1);
|
659
|
-
lp.seekNonSpace();
|
660
|
-
|
661
|
-
if (lp.isAtTheEnd()) {
|
662
|
-
// Empty line
|
663
|
-
continue;
|
664
|
-
} // Parse the line type
|
665
|
-
|
666
|
-
|
667
|
-
const lineType = lp.getToken();
|
668
|
-
let material;
|
669
|
-
let colorCode;
|
670
|
-
let segment;
|
671
|
-
let ccw;
|
672
|
-
let doubleSided;
|
673
|
-
let v0, v1, v2, v3, c0, c1;
|
674
|
-
|
675
|
-
switch (lineType) {
|
676
|
-
// Line type 0: Comment or META
|
677
|
-
case '0':
|
678
|
-
// Parse meta directive
|
679
|
-
const meta = lp.getToken();
|
680
|
-
|
681
|
-
if (meta) {
|
682
|
-
switch (meta) {
|
683
|
-
case '!LDRAW_ORG':
|
684
|
-
type = lp.getToken();
|
685
|
-
break;
|
686
|
-
|
687
|
-
case '!COLOUR':
|
688
|
-
material = loader.parseColorMetaDirective(lp);
|
689
|
-
|
690
|
-
if (material) {
|
691
|
-
materials[material.userData.code] = material;
|
692
|
-
} else {
|
693
|
-
console.warn('LDrawLoader: Error parsing material' + lp.getLineNumberString());
|
694
|
-
}
|
695
|
-
|
696
|
-
break;
|
697
|
-
|
698
|
-
case '!CATEGORY':
|
699
|
-
category = lp.getToken();
|
700
|
-
break;
|
701
|
-
|
702
|
-
case '!KEYWORDS':
|
703
|
-
const newKeywords = lp.getRemainingString().split(',');
|
704
|
-
|
705
|
-
if (newKeywords.length > 0) {
|
706
|
-
if (!keywords) {
|
707
|
-
keywords = [];
|
708
|
-
}
|
709
|
-
|
710
|
-
newKeywords.forEach(function (keyword) {
|
711
|
-
keywords.push(keyword.trim());
|
712
|
-
});
|
713
|
-
}
|
714
|
-
|
715
|
-
break;
|
716
|
-
|
717
|
-
case 'FILE':
|
718
|
-
if (lineIndex > 0) {
|
719
|
-
// Start embedded text files parsing
|
720
|
-
parsingEmbeddedFiles = true;
|
721
|
-
currentEmbeddedFileName = lp.getRemainingString();
|
722
|
-
currentEmbeddedText = '';
|
723
|
-
bfcCertified = false;
|
724
|
-
bfcCCW = true;
|
725
|
-
}
|
726
|
-
|
727
|
-
break;
|
728
|
-
|
729
|
-
case 'BFC':
|
730
|
-
// Changes to the backface culling state
|
731
|
-
while (!lp.isAtTheEnd()) {
|
732
|
-
const token = lp.getToken();
|
733
|
-
|
734
|
-
switch (token) {
|
735
|
-
case 'CERTIFY':
|
736
|
-
case 'NOCERTIFY':
|
737
|
-
bfcCertified = token === 'CERTIFY';
|
738
|
-
bfcCCW = true;
|
739
|
-
break;
|
740
|
-
|
741
|
-
case 'CW':
|
742
|
-
case 'CCW':
|
743
|
-
bfcCCW = token === 'CCW';
|
744
|
-
break;
|
745
|
-
|
746
|
-
case 'INVERTNEXT':
|
747
|
-
bfcInverted = true;
|
748
|
-
break;
|
749
|
-
|
750
|
-
case 'CLIP':
|
751
|
-
case 'NOCLIP':
|
752
|
-
bfcCull = token === 'CLIP';
|
753
|
-
break;
|
754
|
-
|
755
|
-
default:
|
756
|
-
console.warn('THREE.LDrawLoader: BFC directive "' + token + '" is unknown.');
|
757
|
-
break;
|
758
|
-
}
|
759
|
-
}
|
760
|
-
|
761
|
-
break;
|
762
|
-
|
763
|
-
case 'STEP':
|
764
|
-
startingConstructionStep = true;
|
765
|
-
break;
|
766
|
-
}
|
767
|
-
}
|
768
|
-
|
769
|
-
break;
|
770
|
-
// Line type 1: Sub-object file
|
771
|
-
|
772
|
-
case '1':
|
773
|
-
colorCode = lp.getToken();
|
774
|
-
material = getLocalMaterial(colorCode);
|
775
|
-
const posX = parseFloat(lp.getToken());
|
776
|
-
const posY = parseFloat(lp.getToken());
|
777
|
-
const posZ = parseFloat(lp.getToken());
|
778
|
-
const m0 = parseFloat(lp.getToken());
|
779
|
-
const m1 = parseFloat(lp.getToken());
|
780
|
-
const m2 = parseFloat(lp.getToken());
|
781
|
-
const m3 = parseFloat(lp.getToken());
|
782
|
-
const m4 = parseFloat(lp.getToken());
|
783
|
-
const m5 = parseFloat(lp.getToken());
|
784
|
-
const m6 = parseFloat(lp.getToken());
|
785
|
-
const m7 = parseFloat(lp.getToken());
|
786
|
-
const m8 = parseFloat(lp.getToken());
|
787
|
-
const matrix = new Matrix4().set(m0, m1, m2, posX, m3, m4, m5, posY, m6, m7, m8, posZ, 0, 0, 0, 1);
|
788
|
-
let fileName = lp.getRemainingString().trim().replace(/\\/g, '/');
|
789
|
-
|
790
|
-
if (loader.fileMap[fileName]) {
|
791
|
-
// Found the subobject path in the preloaded file path map
|
792
|
-
fileName = loader.fileMap[fileName];
|
793
|
-
} else {
|
794
|
-
// Standardized subfolders
|
795
|
-
if (fileName.startsWith('s/')) {
|
796
|
-
fileName = 'parts/' + fileName;
|
797
|
-
} else if (fileName.startsWith('48/')) {
|
798
|
-
fileName = 'p/' + fileName;
|
799
|
-
}
|
800
|
-
}
|
801
|
-
|
802
|
-
subobjects.push({
|
803
|
-
material: material,
|
804
|
-
colorCode: colorCode,
|
805
|
-
matrix: matrix,
|
806
|
-
fileName: fileName,
|
807
|
-
inverted: bfcInverted,
|
808
|
-
startingConstructionStep: startingConstructionStep
|
809
|
-
});
|
810
|
-
bfcInverted = false;
|
811
|
-
break;
|
812
|
-
// Line type 2: Line segment
|
813
|
-
|
814
|
-
case '2':
|
815
|
-
colorCode = lp.getToken();
|
816
|
-
material = getLocalMaterial(colorCode);
|
817
|
-
v0 = lp.getVector();
|
818
|
-
v1 = lp.getVector();
|
819
|
-
segment = {
|
820
|
-
material: material,
|
821
|
-
colorCode: colorCode,
|
822
|
-
vertices: [v0, v1]
|
823
|
-
};
|
824
|
-
lineSegments.push(segment);
|
825
|
-
break;
|
826
|
-
// Line type 5: Conditional Line segment
|
827
|
-
|
828
|
-
case '5':
|
829
|
-
colorCode = lp.getToken();
|
830
|
-
material = getLocalMaterial(colorCode);
|
831
|
-
v0 = lp.getVector();
|
832
|
-
v1 = lp.getVector();
|
833
|
-
c0 = lp.getVector();
|
834
|
-
c1 = lp.getVector();
|
835
|
-
segment = {
|
836
|
-
material: material,
|
837
|
-
colorCode: colorCode,
|
838
|
-
vertices: [v0, v1],
|
839
|
-
controlPoints: [c0, c1]
|
840
|
-
};
|
841
|
-
conditionalSegments.push(segment);
|
842
|
-
break;
|
843
|
-
// Line type 3: Triangle
|
844
|
-
|
845
|
-
case '3':
|
846
|
-
colorCode = lp.getToken();
|
847
|
-
material = getLocalMaterial(colorCode);
|
848
|
-
ccw = bfcCCW;
|
849
|
-
doubleSided = !bfcCertified || !bfcCull;
|
850
|
-
|
851
|
-
if (ccw === true) {
|
852
|
-
v0 = lp.getVector();
|
853
|
-
v1 = lp.getVector();
|
854
|
-
v2 = lp.getVector();
|
855
|
-
} else {
|
856
|
-
v2 = lp.getVector();
|
857
|
-
v1 = lp.getVector();
|
858
|
-
v0 = lp.getVector();
|
859
|
-
}
|
860
|
-
|
861
|
-
faces.push({
|
862
|
-
material: material,
|
863
|
-
colorCode: colorCode,
|
864
|
-
faceNormal: null,
|
865
|
-
vertices: [v0, v1, v2],
|
866
|
-
normals: [null, null, null]
|
867
|
-
});
|
868
|
-
totalFaces++;
|
869
|
-
|
870
|
-
if (doubleSided === true) {
|
871
|
-
faces.push({
|
872
|
-
material: material,
|
873
|
-
colorCode: colorCode,
|
874
|
-
faceNormal: null,
|
875
|
-
vertices: [v2, v1, v0],
|
876
|
-
normals: [null, null, null]
|
877
|
-
});
|
878
|
-
totalFaces++;
|
879
|
-
}
|
880
|
-
|
881
|
-
break;
|
882
|
-
// Line type 4: Quadrilateral
|
883
|
-
|
884
|
-
case '4':
|
885
|
-
colorCode = lp.getToken();
|
886
|
-
material = getLocalMaterial(colorCode);
|
887
|
-
ccw = bfcCCW;
|
888
|
-
doubleSided = !bfcCertified || !bfcCull;
|
889
|
-
|
890
|
-
if (ccw === true) {
|
891
|
-
v0 = lp.getVector();
|
892
|
-
v1 = lp.getVector();
|
893
|
-
v2 = lp.getVector();
|
894
|
-
v3 = lp.getVector();
|
895
|
-
} else {
|
896
|
-
v3 = lp.getVector();
|
897
|
-
v2 = lp.getVector();
|
898
|
-
v1 = lp.getVector();
|
899
|
-
v0 = lp.getVector();
|
900
|
-
} // specifically place the triangle diagonal in the v0 and v1 slots so we can
|
901
|
-
// account for the doubling of vertices later when smoothing normals.
|
902
|
-
|
903
|
-
|
904
|
-
faces.push({
|
905
|
-
material: material,
|
906
|
-
colorCode: colorCode,
|
907
|
-
faceNormal: null,
|
908
|
-
vertices: [v0, v1, v2, v3],
|
909
|
-
normals: [null, null, null, null]
|
910
|
-
});
|
911
|
-
totalFaces += 2;
|
912
|
-
|
913
|
-
if (doubleSided === true) {
|
914
|
-
faces.push({
|
915
|
-
material: material,
|
916
|
-
colorCode: colorCode,
|
917
|
-
faceNormal: null,
|
918
|
-
vertices: [v3, v2, v1, v0],
|
919
|
-
normals: [null, null, null, null]
|
920
|
-
});
|
921
|
-
totalFaces += 2;
|
922
|
-
}
|
923
|
-
|
924
|
-
break;
|
925
|
-
|
926
|
-
default:
|
927
|
-
throw new Error('LDrawLoader: Unknown line type "' + lineType + '"' + lp.getLineNumberString() + '.');
|
928
|
-
}
|
929
|
-
}
|
930
|
-
|
931
|
-
if (parsingEmbeddedFiles) {
|
932
|
-
this.setData(currentEmbeddedFileName, currentEmbeddedText);
|
933
|
-
}
|
934
|
-
|
935
|
-
return {
|
936
|
-
faces,
|
937
|
-
conditionalSegments,
|
938
|
-
lineSegments,
|
939
|
-
type,
|
940
|
-
category,
|
941
|
-
keywords,
|
942
|
-
subobjects,
|
943
|
-
totalFaces,
|
944
|
-
startingConstructionStep,
|
945
|
-
materials,
|
946
|
-
fileName,
|
947
|
-
group: null
|
948
|
-
};
|
949
|
-
} // returns an (optionally cloned) instance of the data
|
950
|
-
|
951
|
-
|
952
|
-
getData(fileName, clone = true) {
|
953
|
-
const key = fileName.toLowerCase();
|
954
|
-
const result = this._cache[key];
|
955
|
-
|
956
|
-
if (result === null || result instanceof Promise) {
|
957
|
-
return null;
|
958
|
-
}
|
959
|
-
|
960
|
-
if (clone) {
|
961
|
-
return this.cloneResult(result);
|
962
|
-
} else {
|
963
|
-
return result;
|
964
|
-
}
|
965
|
-
} // kicks off a fetch and parse of the requested data if it hasn't already been loaded. Returns when
|
966
|
-
// the data is ready to use and can be retrieved synchronously with "getData".
|
967
|
-
|
968
|
-
|
969
|
-
async ensureDataLoaded(fileName) {
|
970
|
-
const key = fileName.toLowerCase();
|
971
|
-
|
972
|
-
if (!(key in this._cache)) {
|
973
|
-
// replace the promise with a copy of the parsed data for immediate processing
|
974
|
-
this._cache[key] = this.fetchData(fileName).then(text => {
|
975
|
-
const info = this.parse(text, fileName);
|
976
|
-
this._cache[key] = info;
|
977
|
-
return info;
|
978
|
-
});
|
979
|
-
}
|
980
|
-
|
981
|
-
await this._cache[key];
|
982
|
-
} // sets the data in the cache from parsed data
|
983
|
-
|
984
|
-
|
985
|
-
setData(fileName, text) {
|
986
|
-
const key = fileName.toLowerCase();
|
987
|
-
this._cache[key] = this.parse(text, fileName);
|
988
|
-
}
|
989
|
-
|
990
|
-
} // returns the material for an associated color code. If the color code is 16 for a face or 24 for
|
991
|
-
// an edge then the passthroughColorCode is used.
|
992
|
-
|
993
|
-
|
994
|
-
function getMaterialFromCode(colorCode, parentColorCode, materialHierarchy, forEdge) {
|
995
|
-
const isPassthrough = !forEdge && colorCode === MAIN_COLOUR_CODE || forEdge && colorCode === MAIN_EDGE_COLOUR_CODE;
|
996
|
-
|
997
|
-
if (isPassthrough) {
|
998
|
-
colorCode = parentColorCode;
|
999
|
-
}
|
1000
|
-
|
1001
|
-
return materialHierarchy[colorCode] || null;
|
1002
|
-
} // Class used to parse and build LDraw parts as three.js objects and cache them if they're a "Part" type.
|
1003
|
-
|
1004
|
-
|
1005
|
-
class LDrawPartsGeometryCache {
|
1006
|
-
constructor(loader) {
|
1007
|
-
this.loader = loader;
|
1008
|
-
this.parseCache = new LDrawParsedCache(loader);
|
1009
|
-
this._cache = {};
|
1010
|
-
} // Convert the given file information into a mesh by processing subobjects.
|
1011
|
-
|
1012
|
-
|
1013
|
-
async processIntoMesh(info) {
|
1014
|
-
const loader = this.loader;
|
1015
|
-
const parseCache = this.parseCache;
|
1016
|
-
const faceMaterials = new Set(); // Processes the part subobject information to load child parts and merge geometry onto part
|
1017
|
-
// piece object.
|
1018
|
-
|
1019
|
-
const processInfoSubobjects = async (info, subobject = null) => {
|
1020
|
-
const subobjects = info.subobjects;
|
1021
|
-
const promises = []; // Trigger load of all subobjects. If a subobject isn't a primitive then load it as a separate
|
1022
|
-
// group which lets instruction steps apply correctly.
|
1023
|
-
|
1024
|
-
for (let i = 0, l = subobjects.length; i < l; i++) {
|
1025
|
-
const subobject = subobjects[i];
|
1026
|
-
const promise = parseCache.ensureDataLoaded(subobject.fileName).then(() => {
|
1027
|
-
const subobjectInfo = parseCache.getData(subobject.fileName, false);
|
1028
|
-
|
1029
|
-
if (!isPrimitiveType(subobjectInfo.type)) {
|
1030
|
-
return this.loadModel(subobject.fileName).catch(error => {
|
1031
|
-
console.warn(error);
|
1032
|
-
return null;
|
1033
|
-
});
|
1034
|
-
}
|
1035
|
-
|
1036
|
-
return processInfoSubobjects(parseCache.getData(subobject.fileName), subobject);
|
1037
|
-
});
|
1038
|
-
promises.push(promise);
|
1039
|
-
}
|
1040
|
-
|
1041
|
-
const group = new Group();
|
1042
|
-
group.userData.category = info.category;
|
1043
|
-
group.userData.keywords = info.keywords;
|
1044
|
-
info.group = group;
|
1045
|
-
const subobjectInfos = await Promise.all(promises);
|
1046
|
-
|
1047
|
-
for (let i = 0, l = subobjectInfos.length; i < l; i++) {
|
1048
|
-
const subobject = info.subobjects[i];
|
1049
|
-
const subobjectInfo = subobjectInfos[i];
|
1050
|
-
|
1051
|
-
if (subobjectInfo === null) {
|
1052
|
-
// the subobject failed to load
|
1053
|
-
continue;
|
1054
|
-
} // if the subobject was loaded as a separate group then apply the parent scopes materials
|
1055
|
-
|
1056
|
-
|
1057
|
-
if (subobjectInfo.isGroup) {
|
1058
|
-
const subobjectGroup = subobjectInfo;
|
1059
|
-
subobject.matrix.decompose(subobjectGroup.position, subobjectGroup.quaternion, subobjectGroup.scale);
|
1060
|
-
subobjectGroup.userData.startingConstructionStep = subobject.startingConstructionStep;
|
1061
|
-
subobjectGroup.name = subobject.fileName;
|
1062
|
-
loader.applyMaterialsToMesh(subobjectGroup, subobject.colorCode, info.materials);
|
1063
|
-
group.add(subobjectGroup);
|
1064
|
-
continue;
|
1065
|
-
} // add the subobject group if it has children in case it has both children and primitives
|
1066
|
-
|
1067
|
-
|
1068
|
-
if (subobjectInfo.group.children.length) {
|
1069
|
-
group.add(subobjectInfo.group);
|
1070
|
-
} // transform the primitives into the local space of the parent piece and append them to
|
1071
|
-
// to the parent primitives list.
|
1072
|
-
|
1073
|
-
|
1074
|
-
const parentLineSegments = info.lineSegments;
|
1075
|
-
const parentConditionalSegments = info.conditionalSegments;
|
1076
|
-
const parentFaces = info.faces;
|
1077
|
-
const lineSegments = subobjectInfo.lineSegments;
|
1078
|
-
const conditionalSegments = subobjectInfo.conditionalSegments;
|
1079
|
-
const faces = subobjectInfo.faces;
|
1080
|
-
const matrix = subobject.matrix;
|
1081
|
-
const inverted = subobject.inverted;
|
1082
|
-
const matrixScaleInverted = matrix.determinant() < 0;
|
1083
|
-
const colorCode = subobject.colorCode;
|
1084
|
-
const lineColorCode = colorCode === MAIN_COLOUR_CODE ? MAIN_EDGE_COLOUR_CODE : colorCode;
|
1085
|
-
|
1086
|
-
for (let i = 0, l = lineSegments.length; i < l; i++) {
|
1087
|
-
const ls = lineSegments[i];
|
1088
|
-
const vertices = ls.vertices;
|
1089
|
-
vertices[0].applyMatrix4(matrix);
|
1090
|
-
vertices[1].applyMatrix4(matrix);
|
1091
|
-
ls.colorCode = ls.colorCode === MAIN_EDGE_COLOUR_CODE ? lineColorCode : ls.colorCode;
|
1092
|
-
ls.material = ls.material || getMaterialFromCode(ls.colorCode, ls.colorCode, info.materials, true);
|
1093
|
-
parentLineSegments.push(ls);
|
1094
|
-
}
|
1095
|
-
|
1096
|
-
for (let i = 0, l = conditionalSegments.length; i < l; i++) {
|
1097
|
-
const os = conditionalSegments[i];
|
1098
|
-
const vertices = os.vertices;
|
1099
|
-
const controlPoints = os.controlPoints;
|
1100
|
-
vertices[0].applyMatrix4(matrix);
|
1101
|
-
vertices[1].applyMatrix4(matrix);
|
1102
|
-
controlPoints[0].applyMatrix4(matrix);
|
1103
|
-
controlPoints[1].applyMatrix4(matrix);
|
1104
|
-
os.colorCode = os.colorCode === MAIN_EDGE_COLOUR_CODE ? lineColorCode : os.colorCode;
|
1105
|
-
os.material = os.material || getMaterialFromCode(os.colorCode, os.colorCode, info.materials, true);
|
1106
|
-
parentConditionalSegments.push(os);
|
1107
|
-
}
|
1108
|
-
|
1109
|
-
for (let i = 0, l = faces.length; i < l; i++) {
|
1110
|
-
const tri = faces[i];
|
1111
|
-
const vertices = tri.vertices;
|
1112
|
-
|
1113
|
-
for (let i = 0, l = vertices.length; i < l; i++) {
|
1114
|
-
vertices[i].applyMatrix4(matrix);
|
1115
|
-
}
|
1116
|
-
|
1117
|
-
tri.colorCode = tri.colorCode === MAIN_COLOUR_CODE ? colorCode : tri.colorCode;
|
1118
|
-
tri.material = tri.material || getMaterialFromCode(tri.colorCode, colorCode, info.materials, false);
|
1119
|
-
faceMaterials.add(tri.colorCode); // If the scale of the object is negated then the triangle winding order
|
1120
|
-
// needs to be flipped.
|
1121
|
-
|
1122
|
-
if (matrixScaleInverted !== inverted) {
|
1123
|
-
vertices.reverse();
|
1124
|
-
}
|
1125
|
-
|
1126
|
-
parentFaces.push(tri);
|
1127
|
-
}
|
1128
|
-
|
1129
|
-
info.totalFaces += subobjectInfo.totalFaces;
|
1130
|
-
} // Apply the parent subobjects pass through material code to this object. This is done several times due
|
1131
|
-
// to material scoping.
|
1132
|
-
|
1133
|
-
|
1134
|
-
if (subobject) {
|
1135
|
-
loader.applyMaterialsToMesh(group, subobject.colorCode, info.materials);
|
1136
|
-
}
|
1137
|
-
|
1138
|
-
return info;
|
1139
|
-
}; // Track material use to see if we need to use the normal smooth slow path for hard edges.
|
1140
|
-
|
1141
|
-
|
1142
|
-
for (let i = 0, l = info.faces; i < l; i++) {
|
1143
|
-
faceMaterials.add(info.faces[i].colorCode);
|
1144
|
-
}
|
1145
|
-
|
1146
|
-
await processInfoSubobjects(info);
|
1147
|
-
|
1148
|
-
if (loader.smoothNormals) {
|
1149
|
-
const checkSubSegments = faceMaterials.size > 1;
|
1150
|
-
generateFaceNormals(info.faces);
|
1151
|
-
smoothNormals(info.faces, info.lineSegments, checkSubSegments);
|
1152
|
-
} // Add the primitive objects and metadata.
|
1153
|
-
|
1154
|
-
|
1155
|
-
const group = info.group;
|
1156
|
-
|
1157
|
-
if (info.faces.length > 0) {
|
1158
|
-
group.add(createObject(info.faces, 3, false, info.totalFaces));
|
1159
|
-
}
|
1160
|
-
|
1161
|
-
if (info.lineSegments.length > 0) {
|
1162
|
-
group.add(createObject(info.lineSegments, 2));
|
1163
|
-
}
|
1164
|
-
|
1165
|
-
if (info.conditionalSegments.length > 0) {
|
1166
|
-
group.add(createObject(info.conditionalSegments, 2, true));
|
1167
|
-
}
|
1168
|
-
|
1169
|
-
return group;
|
1170
|
-
}
|
1171
|
-
|
1172
|
-
hasCachedModel(fileName) {
|
1173
|
-
return fileName !== null && fileName.toLowerCase() in this._cache;
|
1174
|
-
}
|
1175
|
-
|
1176
|
-
async getCachedModel(fileName) {
|
1177
|
-
if (fileName !== null && this.hasCachedModel(fileName)) {
|
1178
|
-
const key = fileName.toLowerCase();
|
1179
|
-
const group = await this._cache[key];
|
1180
|
-
return group.clone();
|
1181
|
-
} else {
|
1182
|
-
return null;
|
1183
|
-
}
|
1184
|
-
} // Loads and parses the model with the given file name. Returns a cached copy if available.
|
1185
|
-
|
1186
|
-
|
1187
|
-
async loadModel(fileName) {
|
1188
|
-
const parseCache = this.parseCache;
|
1189
|
-
const key = fileName.toLowerCase();
|
1190
|
-
|
1191
|
-
if (this.hasCachedModel(fileName)) {
|
1192
|
-
// Return cached model if available.
|
1193
|
-
return this.getCachedModel(fileName);
|
1194
|
-
} else {
|
1195
|
-
// Otherwise parse a new model.
|
1196
|
-
// Ensure the file data is loaded and pre parsed.
|
1197
|
-
await parseCache.ensureDataLoaded(fileName);
|
1198
|
-
const info = parseCache.getData(fileName);
|
1199
|
-
const promise = this.processIntoMesh(info); // Now that the file has loaded it's possible that another part parse has been waiting in parallel
|
1200
|
-
// so check the cache again to see if it's been added since the last async operation so we don't
|
1201
|
-
// do unnecessary work.
|
1202
|
-
|
1203
|
-
if (this.hasCachedModel(fileName)) {
|
1204
|
-
return this.getCachedModel(fileName);
|
1205
|
-
} // Cache object if it's a part so it can be reused later.
|
1206
|
-
|
1207
|
-
|
1208
|
-
if (isPartType(info.type)) {
|
1209
|
-
this._cache[key] = promise;
|
1210
|
-
} // return a copy
|
1211
|
-
|
1212
|
-
|
1213
|
-
const group = await promise;
|
1214
|
-
return group.clone();
|
1215
|
-
}
|
1216
|
-
} // parses the given model text into a renderable object. Returns cached copy if available.
|
1217
|
-
|
1218
|
-
|
1219
|
-
async parseModel(text) {
|
1220
|
-
const parseCache = this.parseCache;
|
1221
|
-
const info = parseCache.parse(text);
|
1222
|
-
|
1223
|
-
if (isPartType(info.type) && this.hasCachedModel(info.fileName)) {
|
1224
|
-
return this.getCachedModel(info.fileName);
|
1225
|
-
}
|
1226
|
-
|
1227
|
-
return this.processIntoMesh(info);
|
1228
|
-
}
|
1229
|
-
|
1230
|
-
}
|
1231
|
-
|
1232
|
-
function sortByMaterial(a, b) {
|
1233
|
-
if (a.colorCode === b.colorCode) {
|
1234
|
-
return 0;
|
1235
|
-
}
|
1236
|
-
|
1237
|
-
if (a.colorCode < b.colorCode) {
|
1238
|
-
return -1;
|
1239
|
-
}
|
1240
|
-
|
1241
|
-
return 1;
|
1242
|
-
}
|
1243
|
-
|
1244
|
-
function createObject(elements, elementSize, isConditionalSegments = false, totalElements = null) {
|
1245
|
-
// Creates a LineSegments (elementSize = 2) or a Mesh (elementSize = 3 )
|
1246
|
-
// With per face / segment material, implemented with mesh groups and materials array
|
1247
|
-
// Sort the faces or line segments by color code to make later the mesh groups
|
1248
|
-
elements.sort(sortByMaterial);
|
1249
|
-
|
1250
|
-
if (totalElements === null) {
|
1251
|
-
totalElements = elements.length;
|
1252
|
-
}
|
1253
|
-
|
1254
|
-
const positions = new Float32Array(elementSize * totalElements * 3);
|
1255
|
-
const normals = elementSize === 3 ? new Float32Array(elementSize * totalElements * 3) : null;
|
1256
|
-
const materials = [];
|
1257
|
-
const quadArray = new Array(6);
|
1258
|
-
const bufferGeometry = new BufferGeometry();
|
1259
|
-
let prevMaterial = null;
|
1260
|
-
let index0 = 0;
|
1261
|
-
let numGroupVerts = 0;
|
1262
|
-
let offset = 0;
|
1263
|
-
|
1264
|
-
for (let iElem = 0, nElem = elements.length; iElem < nElem; iElem++) {
|
1265
|
-
const elem = elements[iElem];
|
1266
|
-
let vertices = elem.vertices;
|
1267
|
-
|
1268
|
-
if (vertices.length === 4) {
|
1269
|
-
quadArray[0] = vertices[0];
|
1270
|
-
quadArray[1] = vertices[1];
|
1271
|
-
quadArray[2] = vertices[2];
|
1272
|
-
quadArray[3] = vertices[0];
|
1273
|
-
quadArray[4] = vertices[2];
|
1274
|
-
quadArray[5] = vertices[3];
|
1275
|
-
vertices = quadArray;
|
1276
|
-
}
|
1277
|
-
|
1278
|
-
for (let j = 0, l = vertices.length; j < l; j++) {
|
1279
|
-
const v = vertices[j];
|
1280
|
-
const index = offset + j * 3;
|
1281
|
-
positions[index + 0] = v.x;
|
1282
|
-
positions[index + 1] = v.y;
|
1283
|
-
positions[index + 2] = v.z;
|
1284
|
-
} // create the normals array if this is a set of faces
|
1285
|
-
|
1286
|
-
|
1287
|
-
if (elementSize === 3) {
|
1288
|
-
if (!elem.faceNormal) {
|
1289
|
-
const v0 = vertices[0];
|
1290
|
-
const v1 = vertices[1];
|
1291
|
-
const v2 = vertices[2];
|
1292
|
-
|
1293
|
-
_tempVec0.subVectors(v1, v0);
|
1294
|
-
|
1295
|
-
_tempVec1.subVectors(v2, v1);
|
1296
|
-
|
1297
|
-
elem.faceNormal = new Vector3().crossVectors(_tempVec0, _tempVec1).normalize();
|
1298
|
-
}
|
1299
|
-
|
1300
|
-
let elemNormals = elem.normals;
|
1301
|
-
|
1302
|
-
if (elemNormals.length === 4) {
|
1303
|
-
quadArray[0] = elemNormals[0];
|
1304
|
-
quadArray[1] = elemNormals[1];
|
1305
|
-
quadArray[2] = elemNormals[2];
|
1306
|
-
quadArray[3] = elemNormals[0];
|
1307
|
-
quadArray[4] = elemNormals[2];
|
1308
|
-
quadArray[5] = elemNormals[3];
|
1309
|
-
elemNormals = quadArray;
|
1310
|
-
}
|
1311
|
-
|
1312
|
-
for (let j = 0, l = elemNormals.length; j < l; j++) {
|
1313
|
-
// use face normal if a vertex normal is not provided
|
1314
|
-
let n = elem.faceNormal;
|
1315
|
-
|
1316
|
-
if (elemNormals[j]) {
|
1317
|
-
n = elemNormals[j].norm;
|
1318
|
-
}
|
1319
|
-
|
1320
|
-
const index = offset + j * 3;
|
1321
|
-
normals[index + 0] = n.x;
|
1322
|
-
normals[index + 1] = n.y;
|
1323
|
-
normals[index + 2] = n.z;
|
1324
|
-
}
|
1325
|
-
}
|
1326
|
-
|
1327
|
-
if (prevMaterial !== elem.colorCode) {
|
1328
|
-
if (prevMaterial !== null) {
|
1329
|
-
bufferGeometry.addGroup(index0, numGroupVerts, materials.length - 1);
|
1330
|
-
}
|
1331
|
-
|
1332
|
-
const material = elem.material;
|
1333
|
-
|
1334
|
-
if (material !== null) {
|
1335
|
-
if (elementSize === 3) {
|
1336
|
-
materials.push(material);
|
1337
|
-
} else if (elementSize === 2) {
|
1338
|
-
if (material !== null) {
|
1339
|
-
if (isConditionalSegments) {
|
1340
|
-
materials.push(material.userData.edgeMaterial.userData.conditionalEdgeMaterial);
|
1341
|
-
} else {
|
1342
|
-
materials.push(material.userData.edgeMaterial);
|
1343
|
-
}
|
1344
|
-
} else {
|
1345
|
-
materials.push(null);
|
1346
|
-
}
|
1347
|
-
}
|
1348
|
-
} else {
|
1349
|
-
// If a material has not been made available yet then keep the color code string in the material array
|
1350
|
-
// to save the spot for the material once a parent scopes materials are being applied to the object.
|
1351
|
-
materials.push(elem.colorCode);
|
1352
|
-
}
|
1353
|
-
|
1354
|
-
prevMaterial = elem.colorCode;
|
1355
|
-
index0 = offset / 3;
|
1356
|
-
numGroupVerts = vertices.length;
|
1357
|
-
} else {
|
1358
|
-
numGroupVerts += vertices.length;
|
1359
|
-
}
|
1360
|
-
|
1361
|
-
offset += 3 * vertices.length;
|
1362
|
-
}
|
1363
|
-
|
1364
|
-
if (numGroupVerts > 0) {
|
1365
|
-
bufferGeometry.addGroup(index0, Infinity, materials.length - 1);
|
1366
|
-
}
|
1367
|
-
|
1368
|
-
bufferGeometry.setAttribute('position', new BufferAttribute(positions, 3));
|
1369
|
-
|
1370
|
-
if (normals !== null) {
|
1371
|
-
bufferGeometry.setAttribute('normal', new BufferAttribute(normals, 3));
|
1372
|
-
}
|
1373
|
-
|
1374
|
-
let object3d = null;
|
1375
|
-
|
1376
|
-
if (elementSize === 2) {
|
1377
|
-
if (isConditionalSegments) {
|
1378
|
-
object3d = new ConditionalLineSegments(bufferGeometry, materials.length === 1 ? materials[0] : materials);
|
1379
|
-
} else {
|
1380
|
-
object3d = new LineSegments(bufferGeometry, materials.length === 1 ? materials[0] : materials);
|
1381
|
-
}
|
1382
|
-
} else if (elementSize === 3) {
|
1383
|
-
object3d = new Mesh(bufferGeometry, materials.length === 1 ? materials[0] : materials);
|
1384
|
-
}
|
1385
|
-
|
1386
|
-
if (isConditionalSegments) {
|
1387
|
-
object3d.isConditionalLine = true;
|
1388
|
-
const controlArray0 = new Float32Array(elements.length * 3 * 2);
|
1389
|
-
const controlArray1 = new Float32Array(elements.length * 3 * 2);
|
1390
|
-
const directionArray = new Float32Array(elements.length * 3 * 2);
|
1391
|
-
|
1392
|
-
for (let i = 0, l = elements.length; i < l; i++) {
|
1393
|
-
const os = elements[i];
|
1394
|
-
const vertices = os.vertices;
|
1395
|
-
const controlPoints = os.controlPoints;
|
1396
|
-
const c0 = controlPoints[0];
|
1397
|
-
const c1 = controlPoints[1];
|
1398
|
-
const v0 = vertices[0];
|
1399
|
-
const v1 = vertices[1];
|
1400
|
-
const index = i * 3 * 2;
|
1401
|
-
controlArray0[index + 0] = c0.x;
|
1402
|
-
controlArray0[index + 1] = c0.y;
|
1403
|
-
controlArray0[index + 2] = c0.z;
|
1404
|
-
controlArray0[index + 3] = c0.x;
|
1405
|
-
controlArray0[index + 4] = c0.y;
|
1406
|
-
controlArray0[index + 5] = c0.z;
|
1407
|
-
controlArray1[index + 0] = c1.x;
|
1408
|
-
controlArray1[index + 1] = c1.y;
|
1409
|
-
controlArray1[index + 2] = c1.z;
|
1410
|
-
controlArray1[index + 3] = c1.x;
|
1411
|
-
controlArray1[index + 4] = c1.y;
|
1412
|
-
controlArray1[index + 5] = c1.z;
|
1413
|
-
directionArray[index + 0] = v1.x - v0.x;
|
1414
|
-
directionArray[index + 1] = v1.y - v0.y;
|
1415
|
-
directionArray[index + 2] = v1.z - v0.z;
|
1416
|
-
directionArray[index + 3] = v1.x - v0.x;
|
1417
|
-
directionArray[index + 4] = v1.y - v0.y;
|
1418
|
-
directionArray[index + 5] = v1.z - v0.z;
|
1419
|
-
}
|
1420
|
-
|
1421
|
-
bufferGeometry.setAttribute('control0', new BufferAttribute(controlArray0, 3, false));
|
1422
|
-
bufferGeometry.setAttribute('control1', new BufferAttribute(controlArray1, 3, false));
|
1423
|
-
bufferGeometry.setAttribute('direction', new BufferAttribute(directionArray, 3, false));
|
1424
|
-
}
|
1425
|
-
|
1426
|
-
return object3d;
|
1427
|
-
} //
|
1428
|
-
|
1429
|
-
|
1430
|
-
class LDrawLoader extends Loader {
|
1431
|
-
constructor(manager) {
|
1432
|
-
super(manager); // Array of THREE.Material
|
1433
|
-
|
1434
|
-
this.materials = [];
|
1435
|
-
this.materialLibrary = {}; // This also allows to handle the embedded text files ("0 FILE" lines)
|
1436
|
-
|
1437
|
-
this.partsCache = new LDrawPartsGeometryCache(this); // This object is a map from file names to paths. It agilizes the paths search. If it is not set then files will be searched by trial and error.
|
1438
|
-
|
1439
|
-
this.fileMap = {}; // Initializes the materials library with default materials
|
1440
|
-
|
1441
|
-
this.setMaterials([]); // If this flag is set to true the vertex normals will be smoothed.
|
1442
|
-
|
1443
|
-
this.smoothNormals = true; // The path to load parts from the LDraw parts library from.
|
1444
|
-
|
1445
|
-
this.partsLibraryPath = '';
|
1446
|
-
}
|
1447
|
-
|
1448
|
-
setPartsLibraryPath(path) {
|
1449
|
-
this.partsLibraryPath = path;
|
1450
|
-
return this;
|
1451
|
-
}
|
1452
|
-
|
1453
|
-
async preloadMaterials(url) {
|
1454
|
-
const fileLoader = new FileLoader(this.manager);
|
1455
|
-
fileLoader.setPath(this.path);
|
1456
|
-
fileLoader.setRequestHeader(this.requestHeader);
|
1457
|
-
fileLoader.setWithCredentials(this.withCredentials);
|
1458
|
-
const text = await fileLoader.loadAsync(url);
|
1459
|
-
const colorLineRegex = /^0 !COLOUR/;
|
1460
|
-
const lines = text.split(/[\n\r]/g);
|
1461
|
-
const materials = [];
|
1462
|
-
|
1463
|
-
for (let i = 0, l = lines.length; i < l; i++) {
|
1464
|
-
const line = lines[i];
|
1465
|
-
|
1466
|
-
if (colorLineRegex.test(line)) {
|
1467
|
-
const directive = line.replace(colorLineRegex, '');
|
1468
|
-
const material = this.parseColorMetaDirective(new LineParser(directive));
|
1469
|
-
materials.push(material);
|
1470
|
-
}
|
1471
|
-
}
|
1472
|
-
|
1473
|
-
this.setMaterials(materials);
|
1474
|
-
}
|
1475
|
-
|
1476
|
-
load(url, onLoad, onProgress, onError) {
|
1477
|
-
const fileLoader = new FileLoader(this.manager);
|
1478
|
-
fileLoader.setPath(this.path);
|
1479
|
-
fileLoader.setRequestHeader(this.requestHeader);
|
1480
|
-
fileLoader.setWithCredentials(this.withCredentials);
|
1481
|
-
fileLoader.load(url, text => {
|
1482
|
-
this.partsCache.parseModel(text, this.materialLibrary).then(group => {
|
1483
|
-
this.applyMaterialsToMesh(group, MAIN_COLOUR_CODE, this.materialLibrary, true);
|
1484
|
-
this.computeConstructionSteps(group);
|
1485
|
-
onLoad(group);
|
1486
|
-
}).catch(onError);
|
1487
|
-
}, onProgress, onError);
|
1488
|
-
}
|
1489
|
-
|
1490
|
-
parse(text, onLoad) {
|
1491
|
-
this.partsCache.parseModel(text, this.materialLibrary).then(group => {
|
1492
|
-
this.computeConstructionSteps(group);
|
1493
|
-
onLoad(group);
|
1494
|
-
});
|
1495
|
-
}
|
1496
|
-
|
1497
|
-
setMaterials(materials) {
|
1498
|
-
this.materialLibrary = {};
|
1499
|
-
this.materials = [];
|
1500
|
-
|
1501
|
-
for (let i = 0, l = materials.length; i < l; i++) {
|
1502
|
-
this.addMaterial(materials[i]);
|
1503
|
-
} // Add default main triangle and line edge materials (used in pieces that can be colored with a main color)
|
1504
|
-
|
1505
|
-
|
1506
|
-
this.addMaterial(this.parseColorMetaDirective(new LineParser('Main_Colour CODE 16 VALUE #FF8080 EDGE #333333')));
|
1507
|
-
this.addMaterial(this.parseColorMetaDirective(new LineParser('Edge_Colour CODE 24 VALUE #A0A0A0 EDGE #333333')));
|
1508
|
-
return this;
|
1509
|
-
}
|
1510
|
-
|
1511
|
-
setFileMap(fileMap) {
|
1512
|
-
this.fileMap = fileMap;
|
1513
|
-
return this;
|
1514
|
-
}
|
1515
|
-
|
1516
|
-
addMaterial(material) {
|
1517
|
-
// Adds a material to the material library which is on top of the parse scopes stack. And also to the materials array
|
1518
|
-
const matLib = this.materialLibrary;
|
1519
|
-
|
1520
|
-
if (!matLib[material.userData.code]) {
|
1521
|
-
this.materials.push(material);
|
1522
|
-
matLib[material.userData.code] = material;
|
1523
|
-
}
|
1524
|
-
|
1525
|
-
return this;
|
1526
|
-
}
|
1527
|
-
|
1528
|
-
getMaterial(colorCode) {
|
1529
|
-
if (colorCode.startsWith('0x2')) {
|
1530
|
-
// Special 'direct' material value (RGB color)
|
1531
|
-
const color = colorCode.substring(3);
|
1532
|
-
return this.parseColorMetaDirective(new LineParser('Direct_Color_' + color + ' CODE -1 VALUE #' + color + ' EDGE #' + color + ''));
|
1533
|
-
}
|
1534
|
-
|
1535
|
-
return this.materialLibrary[colorCode] || null;
|
1536
|
-
} // Applies the appropriate materials to a prebuilt hierarchy of geometry. Assumes that color codes are present
|
1537
|
-
// in the material array if they need to be filled in.
|
1538
|
-
|
1539
|
-
|
1540
|
-
applyMaterialsToMesh(group, parentColorCode, materialHierarchy, finalMaterialPass = false) {
|
1541
|
-
// find any missing materials as indicated by a color code string and replace it with a material from the current material lib
|
1542
|
-
const loader = this;
|
1543
|
-
const parentIsPassthrough = parentColorCode === MAIN_COLOUR_CODE;
|
1544
|
-
group.traverse(c => {
|
1545
|
-
if (c.isMesh || c.isLineSegments) {
|
1546
|
-
if (Array.isArray(c.material)) {
|
1547
|
-
for (let i = 0, l = c.material.length; i < l; i++) {
|
1548
|
-
if (!c.material[i].isMaterial) {
|
1549
|
-
c.material[i] = getMaterial(c, c.material[i]);
|
1550
|
-
}
|
1551
|
-
}
|
1552
|
-
} else if (!c.material.isMaterial) {
|
1553
|
-
c.material = getMaterial(c, c.material);
|
1554
|
-
}
|
1555
|
-
}
|
1556
|
-
}); // Returns the appropriate material for the object (line or face) given color code. If the code is "pass through"
|
1557
|
-
// (24 for lines, 16 for edges) then the pass through color code is used. If that is also pass through then it's
|
1558
|
-
// simply returned for the subsequent material application.
|
1559
|
-
|
1560
|
-
function getMaterial(c, colorCode) {
|
1561
|
-
// if our parent is a passthrough color code and we don't have the current material color available then
|
1562
|
-
// return early.
|
1563
|
-
if (parentIsPassthrough && !(colorCode in materialHierarchy) && !finalMaterialPass) {
|
1564
|
-
return colorCode;
|
1565
|
-
}
|
1566
|
-
|
1567
|
-
const forEdge = c.isLineSegments || c.isConditionalLine;
|
1568
|
-
const isPassthrough = !forEdge && colorCode === MAIN_COLOUR_CODE || forEdge && colorCode === MAIN_EDGE_COLOUR_CODE;
|
1569
|
-
|
1570
|
-
if (isPassthrough) {
|
1571
|
-
colorCode = parentColorCode;
|
1572
|
-
}
|
1573
|
-
|
1574
|
-
let material = null;
|
1575
|
-
|
1576
|
-
if (colorCode in materialHierarchy) {
|
1577
|
-
material = materialHierarchy[colorCode];
|
1578
|
-
} else if (finalMaterialPass) {
|
1579
|
-
// see if we can get the final material from from the "getMaterial" function which will attempt to
|
1580
|
-
// parse the "direct" colors
|
1581
|
-
material = loader.getMaterial(colorCode);
|
1582
|
-
|
1583
|
-
if (material === null) {
|
1584
|
-
// otherwise throw an error if this is final opportunity to set the material
|
1585
|
-
throw new Error(`LDrawLoader: Material properties for code ${colorCode} not available.`);
|
1586
|
-
}
|
1587
|
-
} else {
|
1588
|
-
return colorCode;
|
1589
|
-
}
|
1590
|
-
|
1591
|
-
if (c.isLineSegments) {
|
1592
|
-
material = material.userData.edgeMaterial;
|
1593
|
-
|
1594
|
-
if (c.isConditionalLine) {
|
1595
|
-
material = material.userData.conditionalEdgeMaterial;
|
1596
|
-
}
|
1597
|
-
}
|
1598
|
-
|
1599
|
-
return material;
|
1600
|
-
}
|
1601
|
-
}
|
1602
|
-
|
1603
|
-
getMainMaterial() {
|
1604
|
-
return this.getMaterial(MAIN_COLOUR_CODE);
|
1605
|
-
}
|
1606
|
-
|
1607
|
-
getMainEdgeMaterial() {
|
1608
|
-
return this.getMaterial(MAIN_EDGE_COLOUR_CODE);
|
1609
|
-
}
|
1610
|
-
|
1611
|
-
parseColorMetaDirective(lineParser) {
|
1612
|
-
// Parses a color definition and returns a THREE.Material
|
1613
|
-
let code = null; // Triangle and line colors
|
1614
|
-
|
1615
|
-
let color = 0xff00ff;
|
1616
|
-
let edgeColor = 0xff00ff; // Transparency
|
1617
|
-
|
1618
|
-
let alpha = 1;
|
1619
|
-
let isTransparent = false; // Self-illumination:
|
1620
|
-
|
1621
|
-
let luminance = 0;
|
1622
|
-
let finishType = FINISH_TYPE_DEFAULT;
|
1623
|
-
let edgeMaterial = null;
|
1624
|
-
const name = lineParser.getToken();
|
1625
|
-
|
1626
|
-
if (!name) {
|
1627
|
-
throw new Error('LDrawLoader: Material name was expected after "!COLOUR tag' + lineParser.getLineNumberString() + '.');
|
1628
|
-
} // Parse tag tokens and their parameters
|
1629
|
-
|
1630
|
-
|
1631
|
-
let token = null;
|
1632
|
-
|
1633
|
-
while (true) {
|
1634
|
-
token = lineParser.getToken();
|
1635
|
-
|
1636
|
-
if (!token) {
|
1637
|
-
break;
|
1638
|
-
}
|
1639
|
-
|
1640
|
-
switch (token.toUpperCase()) {
|
1641
|
-
case 'CODE':
|
1642
|
-
code = lineParser.getToken();
|
1643
|
-
break;
|
1644
|
-
|
1645
|
-
case 'VALUE':
|
1646
|
-
color = lineParser.getToken();
|
1647
|
-
|
1648
|
-
if (color.startsWith('0x')) {
|
1649
|
-
color = '#' + color.substring(2);
|
1650
|
-
} else if (!color.startsWith('#')) {
|
1651
|
-
throw new Error('LDrawLoader: Invalid color while parsing material' + lineParser.getLineNumberString() + '.');
|
1652
|
-
}
|
1653
|
-
|
1654
|
-
break;
|
1655
|
-
|
1656
|
-
case 'EDGE':
|
1657
|
-
edgeColor = lineParser.getToken();
|
1658
|
-
|
1659
|
-
if (edgeColor.startsWith('0x')) {
|
1660
|
-
edgeColor = '#' + edgeColor.substring(2);
|
1661
|
-
} else if (!edgeColor.startsWith('#')) {
|
1662
|
-
// Try to see if edge color is a color code
|
1663
|
-
edgeMaterial = this.getMaterial(edgeColor);
|
1664
|
-
|
1665
|
-
if (!edgeMaterial) {
|
1666
|
-
throw new Error('LDrawLoader: Invalid edge color while parsing material' + lineParser.getLineNumberString() + '.');
|
1667
|
-
} // Get the edge material for this triangle material
|
1668
|
-
|
1669
|
-
|
1670
|
-
edgeMaterial = edgeMaterial.userData.edgeMaterial;
|
1671
|
-
}
|
1672
|
-
|
1673
|
-
break;
|
1674
|
-
|
1675
|
-
case 'ALPHA':
|
1676
|
-
alpha = parseInt(lineParser.getToken());
|
1677
|
-
|
1678
|
-
if (isNaN(alpha)) {
|
1679
|
-
throw new Error('LDrawLoader: Invalid alpha value in material definition' + lineParser.getLineNumberString() + '.');
|
1680
|
-
}
|
1681
|
-
|
1682
|
-
alpha = Math.max(0, Math.min(1, alpha / 255));
|
1683
|
-
|
1684
|
-
if (alpha < 1) {
|
1685
|
-
isTransparent = true;
|
1686
|
-
}
|
1687
|
-
|
1688
|
-
break;
|
1689
|
-
|
1690
|
-
case 'LUMINANCE':
|
1691
|
-
luminance = parseInt(lineParser.getToken());
|
1692
|
-
|
1693
|
-
if (isNaN(luminance)) {
|
1694
|
-
throw new Error('LDrawLoader: Invalid luminance value in material definition' + LineParser.getLineNumberString() + '.');
|
1695
|
-
}
|
1696
|
-
|
1697
|
-
luminance = Math.max(0, Math.min(1, luminance / 255));
|
1698
|
-
break;
|
1699
|
-
|
1700
|
-
case 'CHROME':
|
1701
|
-
finishType = FINISH_TYPE_CHROME;
|
1702
|
-
break;
|
1703
|
-
|
1704
|
-
case 'PEARLESCENT':
|
1705
|
-
finishType = FINISH_TYPE_PEARLESCENT;
|
1706
|
-
break;
|
1707
|
-
|
1708
|
-
case 'RUBBER':
|
1709
|
-
finishType = FINISH_TYPE_RUBBER;
|
1710
|
-
break;
|
1711
|
-
|
1712
|
-
case 'MATTE_METALLIC':
|
1713
|
-
finishType = FINISH_TYPE_MATTE_METALLIC;
|
1714
|
-
break;
|
1715
|
-
|
1716
|
-
case 'METAL':
|
1717
|
-
finishType = FINISH_TYPE_METAL;
|
1718
|
-
break;
|
1719
|
-
|
1720
|
-
case 'MATERIAL':
|
1721
|
-
// Not implemented
|
1722
|
-
lineParser.setToEnd();
|
1723
|
-
break;
|
1724
|
-
|
1725
|
-
default:
|
1726
|
-
throw new Error('LDrawLoader: Unknown token "' + token + '" while parsing material' + lineParser.getLineNumberString() + '.');
|
1727
|
-
}
|
1728
|
-
}
|
1729
|
-
|
1730
|
-
let material = null;
|
1731
|
-
|
1732
|
-
switch (finishType) {
|
1733
|
-
case FINISH_TYPE_DEFAULT:
|
1734
|
-
material = new MeshStandardMaterial({
|
1735
|
-
color: color,
|
1736
|
-
roughness: 0.3,
|
1737
|
-
metalness: 0
|
1738
|
-
});
|
1739
|
-
break;
|
1740
|
-
|
1741
|
-
case FINISH_TYPE_PEARLESCENT:
|
1742
|
-
// Try to imitate pearlescency by making the surface glossy
|
1743
|
-
material = new MeshStandardMaterial({
|
1744
|
-
color: color,
|
1745
|
-
roughness: 0.3,
|
1746
|
-
metalness: 0.25
|
1747
|
-
});
|
1748
|
-
break;
|
1749
|
-
|
1750
|
-
case FINISH_TYPE_CHROME:
|
1751
|
-
// Mirror finish surface
|
1752
|
-
material = new MeshStandardMaterial({
|
1753
|
-
color: color,
|
1754
|
-
roughness: 0,
|
1755
|
-
metalness: 1
|
1756
|
-
});
|
1757
|
-
break;
|
1758
|
-
|
1759
|
-
case FINISH_TYPE_RUBBER:
|
1760
|
-
// Rubber finish
|
1761
|
-
material = new MeshStandardMaterial({
|
1762
|
-
color: color,
|
1763
|
-
roughness: 0.9,
|
1764
|
-
metalness: 0
|
1765
|
-
});
|
1766
|
-
break;
|
1767
|
-
|
1768
|
-
case FINISH_TYPE_MATTE_METALLIC:
|
1769
|
-
// Brushed metal finish
|
1770
|
-
material = new MeshStandardMaterial({
|
1771
|
-
color: color,
|
1772
|
-
roughness: 0.8,
|
1773
|
-
metalness: 0.4
|
1774
|
-
});
|
1775
|
-
break;
|
1776
|
-
|
1777
|
-
case FINISH_TYPE_METAL:
|
1778
|
-
// Average metal finish
|
1779
|
-
material = new MeshStandardMaterial({
|
1780
|
-
color: color,
|
1781
|
-
roughness: 0.2,
|
1782
|
-
metalness: 0.85
|
1783
|
-
});
|
1784
|
-
break;
|
1785
|
-
}
|
1786
|
-
|
1787
|
-
material.transparent = isTransparent;
|
1788
|
-
material.premultipliedAlpha = true;
|
1789
|
-
material.opacity = alpha;
|
1790
|
-
material.depthWrite = !isTransparent;
|
1791
|
-
material.polygonOffset = true;
|
1792
|
-
material.polygonOffsetFactor = 1;
|
1793
|
-
|
1794
|
-
if (luminance !== 0) {
|
1795
|
-
material.emissive.set(material.color).multiplyScalar(luminance);
|
1796
|
-
}
|
1797
|
-
|
1798
|
-
if (!edgeMaterial) {
|
1799
|
-
// This is the material used for edges
|
1800
|
-
edgeMaterial = new LineBasicMaterial({
|
1801
|
-
color: edgeColor,
|
1802
|
-
transparent: isTransparent,
|
1803
|
-
opacity: alpha,
|
1804
|
-
depthWrite: !isTransparent
|
1805
|
-
});
|
1806
|
-
edgeMaterial.userData.code = code;
|
1807
|
-
edgeMaterial.name = name + ' - Edge'; // This is the material used for conditional edges
|
1808
|
-
|
1809
|
-
edgeMaterial.userData.conditionalEdgeMaterial = new LDrawConditionalLineMaterial({
|
1810
|
-
fog: true,
|
1811
|
-
transparent: isTransparent,
|
1812
|
-
depthWrite: !isTransparent,
|
1813
|
-
color: edgeColor,
|
1814
|
-
opacity: alpha
|
1815
|
-
});
|
1816
|
-
}
|
1817
|
-
|
1818
|
-
material.userData.code = code;
|
1819
|
-
material.name = name;
|
1820
|
-
material.userData.edgeMaterial = edgeMaterial;
|
1821
|
-
this.addMaterial(material);
|
1822
|
-
return material;
|
1823
|
-
}
|
1824
|
-
|
1825
|
-
computeConstructionSteps(model) {
|
1826
|
-
// Sets userdata.constructionStep number in Group objects and userData.numConstructionSteps number in the root Group object.
|
1827
|
-
let stepNumber = 0;
|
1828
|
-
model.traverse(c => {
|
1829
|
-
if (c.isGroup) {
|
1830
|
-
if (c.userData.startingConstructionStep) {
|
1831
|
-
stepNumber++;
|
1832
|
-
}
|
1833
|
-
|
1834
|
-
c.userData.constructionStep = stepNumber;
|
1835
|
-
}
|
1836
|
-
});
|
1837
|
-
model.userData.numConstructionSteps = stepNumber + 1;
|
1838
|
-
}
|
1839
|
-
|
1840
|
-
}
|
1841
|
-
|
1842
|
-
export { LDrawLoader };
|