super-three 0.136.1 → 0.144.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -33
- package/build/three.cjs +36413 -0
- package/build/three.js +5108 -5809
- package/build/three.min.js +2 -2
- package/build/three.module.js +7877 -8586
- package/examples/js/animation/CCDIKSolver.js +3 -2
- package/examples/js/animation/MMDAnimationHelper.js +3 -1
- package/examples/js/animation/MMDPhysics.js +3 -18
- package/examples/js/controls/ArcballControls.js +19 -4
- package/examples/js/controls/FirstPersonControls.js +0 -7
- package/examples/js/controls/FlyControls.js +0 -8
- package/examples/js/controls/OrbitControls.js +0 -4
- package/examples/js/controls/PointerLockControls.js +3 -10
- package/examples/js/controls/TrackballControls.js +1 -6
- package/examples/js/controls/TransformControls.js +25 -22
- package/examples/js/csm/CSMFrustum.js +1 -1
- package/examples/js/csm/CSMShader.js +51 -35
- package/examples/js/curves/CurveExtras.js +14 -18
- package/examples/js/effects/AnaglyphEffect.js +9 -6
- package/examples/js/effects/AsciiEffect.js +10 -29
- package/examples/js/effects/OutlineEffect.js +4 -24
- package/examples/js/effects/ParallaxBarrierEffect.js +2 -2
- package/examples/js/effects/PeppersGhostEffect.js +2 -2
- package/examples/js/effects/StereoEffect.js +2 -2
- package/examples/js/environments/RoomEnvironment.js +22 -0
- package/examples/js/exporters/ColladaExporter.js +33 -20
- package/examples/js/exporters/DRACOExporter.js +0 -12
- package/examples/js/exporters/EXRExporter.js +458 -0
- package/examples/js/exporters/GLTFExporter.js +246 -119
- package/examples/js/exporters/OBJExporter.js +14 -41
- package/examples/js/exporters/PLYExporter.js +27 -44
- package/examples/js/exporters/STLExporter.js +0 -7
- package/examples/js/exporters/USDZExporter.js +19 -0
- package/examples/js/geometries/ConvexGeometry.js +1 -1
- package/examples/js/geometries/DecalGeometry.js +0 -7
- package/examples/js/geometries/LightningStrike.js +2 -2
- package/examples/js/geometries/ParametricGeometries.js +3 -3
- package/examples/js/geometries/ParametricGeometry.js +1 -8
- package/examples/js/geometries/TextGeometry.js +12 -10
- package/examples/js/helpers/OctreeHelper.js +74 -0
- package/examples/js/helpers/VertexNormalsHelper.js +4 -23
- package/examples/js/helpers/VertexTangentsHelper.js +3 -13
- package/examples/js/helpers/ViewHelper.js +266 -0
- package/examples/js/interactive/HTMLMesh.js +249 -42
- package/examples/js/interactive/SelectionHelper.js +3 -1
- package/examples/js/libs/ktx-parse.umd.js +1 -0
- package/examples/js/libs/meshopt_decoder.js +98 -32
- package/examples/js/libs/opentype.min.js +1 -118
- package/examples/js/lines/Line2.js +1 -2
- package/examples/js/lines/LineGeometry.js +10 -21
- package/examples/js/lines/LineMaterial.js +2 -3
- package/examples/js/lines/LineSegments2.js +214 -140
- package/examples/js/lines/LineSegmentsGeometry.js +3 -14
- package/examples/js/lines/Wireframe.js +2 -3
- package/examples/js/lines/WireframeGeometry2.js +1 -2
- package/examples/js/loaders/3MFLoader.js +21 -17
- package/examples/js/loaders/AMFLoader.js +1 -1
- package/examples/js/loaders/ColladaLoader.js +34 -12
- package/examples/js/loaders/DDSLoader.js +23 -30
- package/examples/js/loaders/DRACOLoader.js +2 -25
- package/examples/js/loaders/EXRLoader.js +279 -276
- package/examples/js/loaders/FBXLoader.js +21 -3
- package/examples/js/loaders/FontLoader.js +4 -18
- package/examples/js/loaders/GCodeLoader.js +0 -1
- package/examples/js/loaders/GLTFLoader.js +300 -95
- package/examples/js/loaders/HDRCubeTextureLoader.js +0 -11
- package/examples/js/loaders/KMZLoader.js +1 -1
- package/examples/js/loaders/LDrawLoader.js +653 -480
- package/examples/js/loaders/LUT3dlLoader.js +1 -1
- package/examples/js/loaders/LUTCubeLoader.js +1 -1
- package/examples/js/loaders/LWOLoader.js +4 -2
- package/examples/js/loaders/LogLuvLoader.js +1 -2
- package/examples/js/loaders/MD2Loader.js +5 -5
- package/examples/js/loaders/MMDLoader.js +18 -4
- package/examples/js/loaders/MTLLoader.js +10 -3
- package/examples/js/loaders/NRRDLoader.js +1 -1
- package/examples/js/loaders/OBJLoader.js +16 -18
- package/examples/js/loaders/PCDLoader.js +81 -27
- package/examples/js/loaders/PDBLoader.js +11 -11
- package/examples/js/loaders/PLYLoader.js +8 -4
- package/examples/js/loaders/RGBELoader.js +3 -11
- package/examples/js/loaders/RGBMLoader.js +12 -15
- package/examples/js/loaders/STLLoader.js +1 -1
- package/examples/js/loaders/SVGLoader.js +23 -14
- package/examples/js/loaders/TIFFLoader.js +31 -0
- package/examples/js/loaders/VOXLoader.js +3 -4
- package/examples/js/loaders/VRMLLoader.js +33 -24
- package/examples/js/loaders/VTKLoader.js +261 -296
- package/examples/js/loaders/lwo/LWO2Parser.js +12 -11
- package/examples/js/loaders/lwo/LWO3Parser.js +12 -11
- package/examples/js/materials/MeshGouraudMaterial.js +385 -0
- package/examples/js/math/ColorConverter.js +0 -50
- package/examples/js/math/ConvexHull.js +6 -15
- package/examples/js/math/Lut.js +27 -26
- package/examples/js/misc/GPUComputationRenderer.js +23 -0
- package/examples/js/misc/MorphAnimMesh.js +2 -2
- package/examples/js/misc/ProgressiveLightMap.js +1 -1
- package/examples/js/misc/Volume.js +233 -234
- package/examples/js/misc/VolumeSlice.js +108 -106
- package/examples/js/modifiers/EdgeSplitModifier.js +0 -13
- package/examples/js/modifiers/SimplifyModifier.js +2 -19
- package/examples/js/modifiers/TessellateModifier.js +0 -7
- package/examples/js/objects/GroundProjectedEnv.js +193 -0
- package/examples/js/objects/Lensflare.js +4 -4
- package/examples/js/objects/LightningStorm.js +4 -5
- package/examples/js/objects/MarchingCubes.js +6 -11
- package/examples/js/objects/Reflector.js +18 -5
- package/examples/js/objects/ReflectorForSSRPass.js +4 -5
- package/examples/js/objects/Refractor.js +19 -7
- package/examples/js/objects/ShadowMesh.js +6 -3
- package/examples/js/objects/Sky.js +1 -1
- package/examples/js/objects/Water.js +1 -2
- package/examples/js/objects/Water2.js +1 -1
- package/examples/js/postprocessing/AdaptiveToneMappingPass.js +6 -10
- package/examples/js/postprocessing/AfterimagePass.js +2 -6
- package/examples/js/postprocessing/BloomPass.js +50 -19
- package/examples/js/postprocessing/DotScreenPass.js +1 -1
- package/examples/js/postprocessing/EffectComposer.js +1 -6
- package/examples/js/postprocessing/LUTPass.js +2 -2
- package/examples/js/postprocessing/OutlinePass.js +13 -20
- package/examples/js/postprocessing/SAOPass.js +2 -7
- package/examples/js/postprocessing/SSAARenderPass.js +1 -6
- package/examples/js/postprocessing/SSRPass.js +3 -8
- package/examples/js/postprocessing/TAARenderPass.js +4 -4
- package/examples/js/postprocessing/UnrealBloomPass.js +3 -12
- package/examples/js/renderers/CSS2DRenderer.js +22 -21
- package/examples/js/renderers/CSS3DRenderer.js +42 -38
- package/examples/js/renderers/Projector.js +99 -147
- package/examples/js/renderers/SVGRenderer.js +3 -4
- package/examples/js/shaders/BlendShader.js +2 -1
- package/examples/js/shaders/CopyShader.js +4 -3
- package/examples/js/shaders/FXAAShader.js +239 -1069
- package/examples/js/shaders/FreiChenShader.js +1 -1
- package/examples/js/shaders/HorizontalBlurShader.js +1 -1
- package/examples/js/shaders/HorizontalTiltShiftShader.js +1 -1
- package/examples/js/shaders/LuminosityShader.js +1 -1
- package/examples/js/shaders/MMDToonShader.js +6 -2
- package/examples/js/shaders/SSRShader.js +3 -3
- package/examples/js/shaders/ToneMapShader.js +2 -2
- package/examples/js/utils/BufferGeometryUtils.js +282 -22
- package/examples/js/utils/GPUStatsPanel.js +1 -1
- package/examples/js/utils/GeometryUtils.js +2 -18
- package/examples/js/utils/LDrawUtils.js +182 -0
- package/examples/js/utils/PackedPhongMaterial.js +1 -1
- package/examples/js/utils/SceneUtils.js +57 -14
- package/examples/js/utils/SkeletonUtils.js +1 -1
- package/examples/js/utils/UVsDebug.js +23 -33
- package/examples/jsm/animation/CCDIKSolver.js +3 -9
- package/examples/jsm/animation/MMDPhysics.js +4 -23
- package/examples/jsm/capabilities/WebGPU.js +6 -0
- package/examples/jsm/controls/ArcballControls.js +19 -2
- package/examples/jsm/controls/FirstPersonControls.js +0 -7
- package/examples/jsm/controls/FlyControls.js +0 -7
- package/examples/jsm/controls/OrbitControls.js +0 -5
- package/examples/jsm/controls/PointerLockControls.js +4 -9
- package/examples/jsm/controls/TrackballControls.js +1 -7
- package/examples/jsm/controls/TransformControls.js +24 -22
- package/examples/jsm/csm/CSMFrustum.js +1 -1
- package/examples/jsm/csm/CSMShader.js +51 -35
- package/examples/jsm/curves/CurveExtras.js +15 -17
- package/examples/jsm/effects/AnaglyphEffect.js +6 -6
- package/examples/jsm/effects/AsciiEffect.js +9 -22
- package/examples/jsm/effects/OutlineEffect.js +4 -25
- package/examples/jsm/effects/ParallaxBarrierEffect.js +2 -2
- package/examples/jsm/effects/PeppersGhostEffect.js +2 -2
- package/examples/jsm/effects/StereoEffect.js +2 -2
- package/examples/jsm/environments/RoomEnvironment.js +23 -0
- package/examples/jsm/exporters/ColladaExporter.js +35 -19
- package/examples/jsm/exporters/DRACOExporter.js +0 -13
- package/examples/jsm/exporters/EXRExporter.js +507 -0
- package/examples/jsm/exporters/GLTFExporter.js +276 -104
- package/examples/jsm/exporters/KTX2Exporter.js +281 -0
- package/examples/jsm/exporters/OBJExporter.js +11 -36
- package/examples/jsm/exporters/PLYExporter.js +37 -43
- package/examples/jsm/exporters/STLExporter.js +1 -9
- package/examples/jsm/exporters/USDZExporter.js +26 -3
- package/examples/jsm/geometries/ConvexGeometry.js +1 -1
- package/examples/jsm/geometries/DecalGeometry.js +0 -7
- package/examples/jsm/geometries/LightningStrike.js +2 -2
- package/examples/jsm/geometries/ParametricGeometries.js +3 -3
- package/examples/jsm/geometries/ParametricGeometry.js +0 -6
- package/examples/jsm/geometries/TextGeometry.js +13 -13
- package/examples/jsm/helpers/OctreeHelper.js +58 -0
- package/examples/jsm/helpers/VertexNormalsHelper.js +4 -25
- package/examples/jsm/helpers/VertexTangentsHelper.js +3 -15
- package/examples/jsm/helpers/ViewHelper.js +295 -0
- package/examples/jsm/interactive/HTMLMesh.js +268 -36
- package/examples/jsm/interactive/SelectionHelper.js +6 -4
- package/examples/jsm/libs/flow.module.js +947 -183
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/libs/meshopt_decoder.module.js +97 -32
- package/examples/jsm/libs/mikktspace.module.js +128 -0
- package/examples/jsm/libs/opentype.module.js +14568 -0
- package/examples/jsm/libs/utif.module.js +1579 -0
- package/examples/jsm/libs/zstddec.module.js +1 -0
- package/examples/jsm/lines/Line2.js +2 -2
- package/examples/jsm/lines/LineGeometry.js +11 -19
- package/examples/jsm/lines/LineMaterial.js +3 -3
- package/examples/jsm/lines/LineSegments2.js +210 -145
- package/examples/jsm/lines/LineSegmentsGeometry.js +3 -12
- package/examples/jsm/lines/Wireframe.js +3 -3
- package/examples/jsm/lines/WireframeGeometry2.js +2 -2
- package/examples/jsm/loaders/3DMLoader.js +3 -2
- package/examples/jsm/loaders/3MFLoader.js +21 -17
- package/examples/jsm/loaders/AMFLoader.js +1 -1
- package/examples/jsm/loaders/ColladaLoader.js +41 -12
- package/examples/jsm/loaders/DDSLoader.js +21 -28
- package/examples/jsm/loaders/DRACOLoader.js +2 -28
- package/examples/jsm/loaders/EXRLoader.js +278 -275
- package/examples/jsm/loaders/FBXLoader.js +21 -3
- package/examples/jsm/loaders/FontLoader.js +5 -18
- package/examples/jsm/loaders/GCodeLoader.js +0 -1
- package/examples/jsm/loaders/GLTFLoader.js +314 -101
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +0 -13
- package/examples/jsm/loaders/KMZLoader.js +1 -1
- package/examples/jsm/loaders/KTX2Loader.js +193 -40
- package/examples/jsm/loaders/LDrawLoader.js +641 -495
- package/examples/jsm/loaders/LUT3dlLoader.js +2 -2
- package/examples/jsm/loaders/LUTCubeLoader.js +2 -2
- package/examples/jsm/loaders/LWOLoader.js +5 -3
- package/examples/jsm/loaders/LogLuvLoader.js +2 -2
- package/examples/jsm/loaders/MD2Loader.js +5 -5
- package/examples/jsm/loaders/MMDLoader.js +21 -3
- package/examples/jsm/loaders/MTLLoader.js +11 -4
- package/examples/jsm/loaders/NRRDLoader.js +1 -2
- package/examples/jsm/loaders/OBJLoader.js +17 -21
- package/examples/jsm/loaders/PCDLoader.js +82 -28
- package/examples/jsm/loaders/PDBLoader.js +11 -11
- package/examples/jsm/loaders/PLYLoader.js +13 -5
- package/examples/jsm/loaders/RGBELoader.js +4 -12
- package/examples/jsm/loaders/RGBMLoader.js +14 -11
- package/examples/jsm/loaders/STLLoader.js +1 -1
- package/examples/jsm/loaders/SVGLoader.js +24 -13
- package/examples/jsm/loaders/TIFFLoader.js +36 -0
- package/examples/jsm/loaders/TTFLoader.js +1 -1
- package/examples/jsm/loaders/USDZLoader.js +393 -0
- package/examples/jsm/loaders/VOXLoader.js +5 -5
- package/examples/jsm/loaders/VRMLLoader.js +23 -26
- package/examples/jsm/loaders/VTKLoader.js +257 -285
- package/examples/jsm/loaders/ifc/web-ifc-api.js +9 -8
- package/examples/jsm/loaders/lwo/LWO2Parser.js +10 -12
- package/examples/jsm/loaders/lwo/LWO3Parser.js +10 -12
- package/examples/jsm/materials/MeshGouraudMaterial.js +423 -0
- package/examples/jsm/math/ColorConverter.js +1 -49
- package/examples/jsm/math/ConvexHull.js +6 -15
- package/examples/jsm/math/Lut.js +35 -25
- package/examples/jsm/misc/GPUComputationRenderer.js +43 -0
- package/examples/jsm/misc/MorphAnimMesh.js +2 -2
- package/examples/jsm/misc/ProgressiveLightMap.js +1 -1
- package/examples/jsm/misc/Volume.js +204 -213
- package/examples/jsm/misc/VolumeSlice.js +96 -98
- package/examples/jsm/modifiers/EdgeSplitModifier.js +0 -13
- package/examples/jsm/modifiers/SimplifyModifier.js +2 -19
- package/examples/jsm/modifiers/TessellateModifier.js +0 -7
- package/examples/jsm/node-editor/NodeEditor.js +505 -182
- package/examples/jsm/node-editor/accessors/MatcapUVEditor.js +14 -0
- package/examples/jsm/node-editor/accessors/NormalEditor.js +9 -9
- package/examples/jsm/node-editor/accessors/PositionEditor.js +9 -9
- package/examples/jsm/node-editor/accessors/UVEditor.js +7 -8
- package/examples/jsm/node-editor/core/BaseNode.js +89 -0
- package/examples/jsm/node-editor/core/DataFile.js +59 -0
- package/examples/jsm/node-editor/core/FileEditor.js +20 -0
- package/examples/jsm/node-editor/core/FileURLEditor.js +29 -0
- package/examples/jsm/node-editor/display/BlendEditor.js +10 -9
- package/examples/jsm/node-editor/display/NormalMapEditor.js +49 -0
- package/examples/jsm/node-editor/examples/animate-uv.json +1 -1
- package/examples/jsm/node-editor/examples/fake-top-light.json +1 -1
- package/examples/jsm/node-editor/examples/matcap.json +1 -0
- package/examples/jsm/node-editor/examples/oscillator-color.json +1 -1
- package/examples/jsm/node-editor/examples/rim.json +1 -1
- package/examples/jsm/node-editor/inputs/ColorEditor.js +18 -13
- package/examples/jsm/node-editor/inputs/FloatEditor.js +8 -9
- package/examples/jsm/node-editor/inputs/SliderEditor.js +6 -7
- package/examples/jsm/node-editor/inputs/TextureEditor.js +155 -0
- package/examples/jsm/node-editor/inputs/Vector2Editor.js +9 -9
- package/examples/jsm/node-editor/inputs/Vector3Editor.js +11 -11
- package/examples/jsm/node-editor/inputs/Vector4Editor.js +12 -12
- package/examples/jsm/node-editor/materials/BasicMaterialEditor.js +87 -0
- package/examples/jsm/node-editor/materials/PointsMaterialEditor.js +102 -0
- package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +31 -18
- package/examples/jsm/node-editor/math/AngleEditor.js +40 -0
- package/examples/jsm/node-editor/math/DotEditor.js +8 -9
- package/examples/jsm/node-editor/math/InvertEditor.js +8 -7
- package/examples/jsm/node-editor/math/LimiterEditor.js +28 -14
- package/examples/jsm/node-editor/math/NormalizeEditor.js +9 -7
- package/examples/jsm/node-editor/math/OperatorEditor.js +29 -16
- package/examples/jsm/node-editor/math/PowerEditor.js +20 -10
- package/examples/jsm/node-editor/math/TrigonometryEditor.js +15 -9
- package/examples/jsm/node-editor/procedural/CheckerEditor.js +7 -6
- package/examples/jsm/node-editor/scene/MeshEditor.js +99 -0
- package/examples/jsm/node-editor/scene/Object3DEditor.js +160 -0
- package/examples/jsm/node-editor/scene/PointsEditor.js +99 -0
- package/examples/jsm/node-editor/utils/JoinEditor.js +58 -0
- package/examples/jsm/node-editor/utils/OscillatorEditor.js +9 -8
- package/examples/jsm/node-editor/utils/PreviewEditor.js +166 -0
- package/examples/jsm/node-editor/utils/SplitEditor.js +39 -0
- package/examples/jsm/node-editor/utils/TimerEditor.js +7 -6
- package/examples/jsm/nodes/Nodes.js +313 -94
- package/examples/jsm/nodes/accessors/BufferNode.js +24 -0
- package/examples/jsm/nodes/accessors/CameraNode.js +27 -196
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +107 -0
- package/examples/jsm/nodes/accessors/InstanceNode.js +58 -0
- package/examples/jsm/{renderers/nodes → nodes}/accessors/MaterialNode.js +49 -11
- package/examples/jsm/{renderers/nodes → nodes}/accessors/MaterialReferenceNode.js +0 -0
- package/examples/jsm/{renderers/nodes → nodes}/accessors/ModelNode.js +8 -0
- package/examples/jsm/{renderers/nodes → nodes}/accessors/ModelViewProjectionNode.js +0 -0
- package/examples/jsm/nodes/accessors/NormalNode.js +39 -99
- package/examples/jsm/{renderers/nodes → nodes}/accessors/Object3DNode.js +34 -17
- package/examples/jsm/{renderers/nodes → nodes}/accessors/PointUVNode.js +2 -2
- package/examples/jsm/nodes/accessors/PositionNode.js +41 -110
- package/examples/jsm/nodes/accessors/ReferenceNode.js +65 -0
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +31 -0
- package/examples/jsm/nodes/accessors/SkinningNode.js +102 -0
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +21 -0
- package/examples/jsm/nodes/accessors/TextureNode.js +100 -0
- package/examples/jsm/nodes/accessors/UVNode.js +17 -43
- package/examples/jsm/nodes/accessors/UserDataNode.js +23 -0
- package/examples/jsm/nodes/core/ArrayUniformNode.js +23 -0
- package/examples/jsm/nodes/core/AttributeNode.js +33 -30
- package/examples/jsm/{renderers/nodes → nodes}/core/BypassNode.js +2 -2
- package/examples/jsm/nodes/core/CodeNode.js +50 -0
- package/examples/jsm/nodes/core/ConstNode.js +10 -106
- package/examples/jsm/{renderers/nodes → nodes}/core/ContextNode.js +17 -3
- package/examples/jsm/nodes/core/ExpressionNode.js +24 -7
- package/examples/jsm/nodes/core/FunctionCallNode.js +33 -59
- package/examples/jsm/nodes/core/FunctionNode.js +43 -216
- package/examples/jsm/nodes/core/InputNode.js +28 -60
- package/examples/jsm/nodes/core/InstanceIndexNode.js +21 -0
- package/examples/jsm/nodes/core/Node.js +230 -94
- package/examples/jsm/{renderers/nodes → nodes}/core/NodeAttribute.js +2 -2
- package/examples/jsm/nodes/core/NodeBuilder.js +388 -560
- package/examples/jsm/{renderers/nodes → nodes}/core/NodeCode.js +0 -0
- package/examples/jsm/nodes/core/NodeFrame.js +30 -23
- package/examples/jsm/{renderers/nodes → nodes}/core/NodeFunction.js +0 -0
- package/examples/jsm/{renderers/nodes → nodes}/core/NodeFunctionInput.js +0 -0
- package/examples/jsm/{renderers/nodes → nodes}/core/NodeKeywords.js +0 -0
- package/examples/jsm/{renderers/nodes → nodes}/core/NodeParser.js +0 -0
- package/examples/jsm/nodes/core/NodeUniform.js +8 -6
- package/examples/jsm/nodes/core/NodeUtils.js +90 -36
- package/examples/jsm/{renderers/nodes → nodes}/core/NodeVar.js +2 -2
- package/examples/jsm/{renderers/nodes/core/NodeVary.js → nodes/core/NodeVarying.js} +4 -4
- package/examples/jsm/{renderers/nodes → nodes}/core/PropertyNode.js +0 -0
- package/examples/jsm/nodes/core/TempNode.js +20 -112
- package/examples/jsm/nodes/core/UniformNode.js +46 -0
- package/examples/jsm/nodes/core/VarNode.js +58 -27
- package/examples/jsm/{renderers/nodes/core/VaryNode.js → nodes/core/VaryingNode.js} +7 -7
- package/examples/jsm/{renderers/nodes → nodes}/core/constants.js +0 -0
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +94 -0
- package/examples/jsm/{renderers/nodes → nodes}/display/ColorSpaceNode.js +10 -11
- package/examples/jsm/nodes/display/FrontFacingNode.js +21 -0
- package/examples/jsm/nodes/display/NormalMapNode.js +86 -0
- package/examples/jsm/nodes/display/ToneMappingNode.js +51 -0
- package/examples/jsm/nodes/fog/FogNode.js +31 -0
- package/examples/jsm/nodes/fog/FogRangeNode.js +27 -0
- package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +33 -0
- package/examples/jsm/nodes/functions/BSDF/BRDF_Lambert.js +9 -0
- package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +27 -0
- package/examples/jsm/nodes/functions/BSDF/D_GGX.js +18 -0
- package/examples/jsm/nodes/functions/BSDF/F_Schlick.js +18 -0
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +18 -0
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +94 -0
- package/examples/jsm/nodes/functions/light/getDistanceAttenuation.js +22 -0
- package/examples/jsm/nodes/functions/material/getGeometryRoughness.js +12 -0
- package/examples/jsm/nodes/functions/material/getRoughness.js +18 -0
- package/examples/jsm/nodes/geometry/RangeNode.js +109 -0
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +65 -0
- package/examples/jsm/nodes/lighting/AONode.js +25 -0
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +37 -0
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +66 -0
- package/examples/jsm/nodes/lighting/HemisphereLightNode.js +50 -0
- package/examples/jsm/nodes/lighting/LightingContextNode.js +75 -0
- package/examples/jsm/nodes/lighting/LightingNode.js +19 -0
- package/examples/jsm/nodes/lighting/LightsNode.js +120 -0
- package/examples/jsm/nodes/lighting/PunctualLightNode.js +68 -0
- package/examples/jsm/nodes/loaders/NodeLoader.js +107 -0
- package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +73 -0
- package/examples/jsm/nodes/loaders/NodeObjectLoader.js +70 -0
- package/examples/jsm/{renderers/nodes → nodes}/materials/LineBasicNodeMaterial.js +11 -4
- package/examples/jsm/nodes/materials/Materials.js +53 -0
- package/examples/jsm/{renderers/nodes → nodes}/materials/MeshBasicNodeMaterial.js +13 -4
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +70 -0
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +159 -22
- package/examples/jsm/nodes/materials/NodeMaterial.js +128 -113
- package/examples/jsm/{renderers/nodes → nodes}/materials/PointsNodeMaterial.js +13 -4
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +95 -16
- package/examples/jsm/nodes/materialx/Disclaimer.md +199 -0
- package/examples/jsm/nodes/materialx/functions/lib/mx_hsv.js +56 -0
- package/examples/jsm/nodes/materialx/functions/lib/mx_noise.js +607 -0
- package/examples/jsm/nodes/math/CondNode.js +26 -95
- package/examples/jsm/nodes/math/MathNode.js +156 -189
- package/examples/jsm/nodes/math/OperatorNode.js +161 -41
- package/examples/jsm/{renderers/nodes → nodes}/parsers/GLSLNodeFunction.js +23 -8
- package/examples/jsm/{renderers/nodes → nodes}/parsers/GLSLNodeParser.js +0 -0
- package/examples/jsm/{renderers/nodes → nodes}/parsers/WGSLNodeFunction.js +20 -5
- package/examples/jsm/{renderers/nodes → nodes}/parsers/WGSLNodeParser.js +0 -0
- package/examples/jsm/nodes/procedural/CheckerNode.js +16 -57
- package/examples/jsm/nodes/shadernode/ShaderNode.js +262 -0
- package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +277 -0
- package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +120 -0
- package/examples/jsm/{renderers/nodes → nodes}/utils/ArrayElementNode.js +3 -3
- package/examples/jsm/nodes/utils/ConvertNode.js +46 -0
- package/examples/jsm/nodes/utils/JoinNode.js +15 -87
- package/examples/jsm/nodes/utils/MatcapUVNode.js +25 -0
- package/examples/jsm/nodes/utils/MaxMipLevelNode.js +33 -0
- package/examples/jsm/{renderers/nodes → nodes}/utils/OscNode.js +18 -2
- package/examples/jsm/nodes/utils/RotateUVNode.js +32 -0
- package/examples/jsm/nodes/utils/SplitNode.js +102 -0
- package/examples/jsm/{renderers/nodes → nodes}/utils/SpriteSheetUVNode.js +3 -3
- package/examples/jsm/nodes/utils/TimerNode.js +30 -65
- package/examples/jsm/objects/GroundProjectedEnv.js +186 -0
- package/examples/jsm/objects/Lensflare.js +2 -2
- package/examples/jsm/objects/LightningStorm.js +4 -4
- package/examples/jsm/objects/MarchingCubes.js +5 -9
- package/examples/jsm/objects/Reflector.js +19 -8
- package/examples/jsm/objects/ReflectorForSSRPass.js +5 -7
- package/examples/jsm/objects/Refractor.js +19 -9
- package/examples/jsm/objects/ShadowMesh.js +10 -4
- package/examples/jsm/objects/Sky.js +2 -2
- package/examples/jsm/objects/Water.js +2 -2
- package/examples/jsm/objects/Water2.js +2 -2
- package/examples/jsm/offscreen/jank.js +5 -5
- package/examples/jsm/offscreen/offscreen.js +1 -1
- package/examples/jsm/offscreen/scene.js +11 -11
- package/examples/jsm/postprocessing/AdaptiveToneMappingPass.js +5 -7
- package/examples/jsm/postprocessing/AfterimagePass.js +0 -10
- package/examples/jsm/postprocessing/BloomPass.js +48 -20
- package/examples/jsm/postprocessing/DotScreenPass.js +1 -1
- package/examples/jsm/postprocessing/EffectComposer.js +1 -9
- package/examples/jsm/postprocessing/LUTPass.js +2 -2
- package/examples/jsm/postprocessing/OutlinePass.js +13 -18
- package/examples/jsm/postprocessing/SAOPass.js +2 -9
- package/examples/jsm/postprocessing/SSAARenderPass.js +1 -4
- package/examples/jsm/postprocessing/SSRPass.js +3 -9
- package/examples/jsm/postprocessing/TAARenderPass.js +4 -4
- package/examples/jsm/postprocessing/UnrealBloomPass.js +3 -8
- package/examples/jsm/renderers/CSS2DRenderer.js +23 -21
- package/examples/jsm/renderers/CSS3DRenderer.js +41 -36
- package/examples/jsm/renderers/Projector.js +103 -152
- package/examples/jsm/renderers/SVGRenderer.js +4 -4
- package/examples/jsm/renderers/webgl/nodes/SlotNode.js +9 -5
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +398 -183
- package/examples/jsm/renderers/webgl/nodes/WebGLNodes.js +19 -4
- package/examples/jsm/renderers/webgpu/WebGPUAttributes.js +4 -4
- package/examples/jsm/renderers/webgpu/WebGPUBackground.js +55 -13
- package/examples/jsm/renderers/webgpu/WebGPUBindings.js +8 -7
- package/examples/jsm/renderers/webgpu/WebGPUBuffer.js +43 -0
- package/examples/jsm/renderers/webgpu/WebGPUComputePipelines.js +20 -7
- package/examples/jsm/renderers/webgpu/WebGPUGeometries.js +6 -0
- package/examples/jsm/renderers/webgpu/WebGPUInfo.js +1 -1
- package/examples/jsm/renderers/webgpu/WebGPUObjects.js +1 -7
- package/examples/jsm/renderers/webgpu/WebGPURenderPipeline.js +37 -39
- package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +18 -15
- package/examples/jsm/renderers/webgpu/WebGPURenderStates.js +66 -0
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +103 -95
- package/examples/jsm/renderers/webgpu/WebGPUSampledTexture.js +14 -14
- package/examples/jsm/renderers/webgpu/WebGPUSampler.js +2 -2
- package/examples/jsm/renderers/webgpu/WebGPUStorageBuffer.js +5 -8
- package/examples/jsm/renderers/webgpu/WebGPUTextureUtils.js +25 -20
- package/examples/jsm/renderers/webgpu/WebGPUTextures.js +37 -18
- package/examples/jsm/renderers/webgpu/WebGPUUniform.js +14 -14
- package/examples/jsm/renderers/webgpu/WebGPUUniformBuffer.js +5 -32
- package/examples/jsm/renderers/webgpu/WebGPUUniformsGroup.js +2 -2
- package/examples/jsm/renderers/webgpu/WebGPUUtils.js +81 -0
- package/examples/jsm/renderers/webgpu/constants.js +3 -2
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +287 -300
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeSampledTexture.js +20 -2
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodes.js +24 -14
- package/examples/jsm/shaders/BlendShader.js +2 -1
- package/examples/jsm/shaders/CopyShader.js +4 -3
- package/examples/jsm/shaders/FXAAShader.js +219 -1051
- package/examples/jsm/shaders/FreiChenShader.js +1 -1
- package/examples/jsm/shaders/HorizontalBlurShader.js +1 -1
- package/examples/jsm/shaders/HorizontalTiltShiftShader.js +1 -1
- package/examples/jsm/shaders/LuminosityShader.js +1 -1
- package/examples/jsm/shaders/MMDToonShader.js +2 -2
- package/examples/jsm/shaders/SSRShader.js +3 -3
- package/examples/jsm/shaders/ToneMapShader.js +2 -2
- package/examples/jsm/utils/BufferGeometryUtils.js +293 -22
- package/examples/jsm/utils/GPUStatsPanel.js +1 -1
- package/examples/jsm/utils/GeometryUtils.js +17 -25
- package/examples/jsm/utils/LDrawUtils.js +24 -17
- package/examples/jsm/utils/PackedPhongMaterial.js +0 -1
- package/examples/jsm/utils/SceneUtils.js +73 -19
- package/examples/jsm/utils/SkeletonUtils.js +1 -1
- package/examples/jsm/utils/UVsDebug.js +23 -32
- package/examples/jsm/webxr/ARButton.js +14 -4
- package/examples/jsm/webxr/OculusHandPointerModel.js +9 -4
- package/examples/jsm/webxr/Text2D.js +1 -1
- package/examples/jsm/webxr/VRButton.js +16 -8
- package/examples/jsm/webxr/XRHandMeshModel.js +3 -7
- package/examples/jsm/webxr/XRHandModelFactory.js +3 -0
- package/package.json +57 -28
- package/src/Three.Legacy.js +164 -1809
- package/src/Three.js +9 -5
- package/src/animation/AnimationAction.js +6 -5
- package/src/animation/AnimationClip.js +2 -2
- package/src/animation/AnimationMixer.js +5 -3
- package/src/animation/AnimationObjectGroup.js +2 -2
- package/src/animation/AnimationUtils.js +204 -199
- package/src/animation/KeyframeTrack.js +1 -1
- package/src/animation/PropertyBinding.js +32 -23
- package/src/audio/PositionalAudio.js +8 -0
- package/src/cameras/ArrayCamera.js +2 -3
- package/src/cameras/Camera.js +2 -2
- package/src/cameras/CubeCamera.js +6 -8
- package/src/cameras/OrthographicCamera.js +2 -2
- package/src/cameras/PerspectiveCamera.js +2 -2
- package/src/constants.js +7 -6
- package/src/core/BufferAttribute.js +88 -123
- package/src/core/BufferGeometry.js +9 -47
- package/src/core/GLBufferAttribute.js +2 -2
- package/src/core/InstancedBufferAttribute.js +2 -12
- package/src/core/InstancedBufferGeometry.js +2 -2
- package/src/core/InstancedInterleavedBuffer.js +2 -2
- package/src/core/InterleavedBuffer.js +3 -3
- package/src/core/InterleavedBufferAttribute.js +61 -18
- package/src/core/Object3D.js +28 -8
- package/src/core/Raycaster.js +2 -2
- package/src/core/Uniform.js +0 -7
- package/src/core/UniformsGroup.js +92 -0
- package/src/extras/DataUtils.js +144 -41
- package/src/extras/Earcut.js +2 -2
- package/src/extras/PMREMGenerator.js +132 -104
- package/src/extras/core/CurvePath.js +3 -3
- package/src/extras/core/Path.js +1 -0
- package/src/extras/core/ShapePath.js +6 -10
- package/src/extras/curves/ArcCurve.js +2 -2
- package/src/extras/curves/CatmullRomCurve3.js +6 -4
- package/src/extras/curves/CubicBezierCurve.js +2 -2
- package/src/extras/curves/CubicBezierCurve3.js +2 -2
- package/src/extras/curves/EllipseCurve.js +2 -2
- package/src/extras/curves/LineCurve.js +2 -2
- package/src/extras/curves/LineCurve3.js +2 -1
- package/src/extras/curves/QuadraticBezierCurve.js +2 -2
- package/src/extras/curves/QuadraticBezierCurve3.js +2 -2
- package/src/extras/curves/SplineCurve.js +2 -2
- package/src/geometries/BoxGeometry.js +1 -1
- package/src/geometries/CapsuleGeometry.js +33 -0
- package/src/geometries/CircleGeometry.js +1 -1
- package/src/geometries/ConeGeometry.js +1 -1
- package/src/geometries/CylinderGeometry.js +2 -1
- package/src/geometries/DodecahedronGeometry.js +1 -1
- package/src/geometries/EdgesGeometry.js +5 -4
- package/src/geometries/ExtrudeGeometry.js +4 -11
- package/src/geometries/Geometries.js +1 -0
- package/src/geometries/IcosahedronGeometry.js +1 -1
- package/src/geometries/LatheGeometry.js +3 -3
- package/src/geometries/OctahedronGeometry.js +1 -1
- package/src/geometries/PlaneGeometry.js +2 -1
- package/src/geometries/PolyhedronGeometry.js +1 -1
- package/src/geometries/RingGeometry.js +1 -1
- package/src/geometries/ShapeGeometry.js +2 -1
- package/src/geometries/SphereGeometry.js +2 -1
- package/src/geometries/TetrahedronGeometry.js +1 -1
- package/src/geometries/TorusGeometry.js +2 -1
- package/src/geometries/TorusKnotGeometry.js +4 -3
- package/src/geometries/TubeGeometry.js +2 -1
- package/src/geometries/WireframeGeometry.js +4 -2
- package/src/helpers/BoxHelper.js +2 -2
- package/src/helpers/CameraHelper.js +97 -38
- package/src/helpers/DirectionalLightHelper.js +1 -0
- package/src/helpers/HemisphereLightHelper.js +1 -0
- package/src/helpers/PlaneHelper.js +6 -9
- package/src/helpers/PointLightHelper.js +1 -1
- package/src/helpers/PolarGridHelper.js +18 -14
- package/src/helpers/SkeletonHelper.js +3 -2
- package/src/helpers/SpotLightHelper.js +1 -0
- package/src/lights/AmbientLight.js +2 -2
- package/src/lights/AmbientLightProbe.js +2 -2
- package/src/lights/DirectionalLight.js +2 -2
- package/src/lights/DirectionalLightShadow.js +2 -2
- package/src/lights/HemisphereLight.js +4 -4
- package/src/lights/HemisphereLightProbe.js +2 -2
- package/src/lights/Light.js +4 -4
- package/src/lights/LightProbe.js +2 -2
- package/src/lights/PointLight.js +4 -4
- package/src/lights/PointLightShadow.js +2 -2
- package/src/lights/RectAreaLight.js +2 -2
- package/src/lights/SpotLight.js +6 -4
- package/src/lights/SpotLightShadow.js +2 -2
- package/src/loaders/FileLoader.js +35 -5
- package/src/loaders/ImageBitmapLoader.js +2 -2
- package/src/loaders/ImageLoader.js +1 -1
- package/src/loaders/LoaderUtils.js +1 -1
- package/src/loaders/LoadingManager.js +1 -1
- package/src/loaders/MaterialLoader.js +55 -8
- package/src/loaders/ObjectLoader.js +27 -66
- package/src/materials/LineBasicMaterial.js +6 -13
- package/src/materials/LineDashedMaterial.js +2 -15
- package/src/materials/Material.js +26 -24
- package/src/materials/Materials.js +39 -18
- package/src/materials/MeshBasicMaterial.js +6 -31
- package/src/materials/MeshDepthMaterial.js +2 -22
- package/src/materials/MeshDistanceMaterial.js +2 -22
- package/src/materials/MeshLambertMaterial.js +34 -35
- package/src/materials/MeshMatcapMaterial.js +6 -28
- package/src/materials/MeshNormalMaterial.js +2 -26
- package/src/materials/MeshPhongMaterial.js +6 -48
- package/src/materials/MeshPhysicalMaterial.js +32 -35
- package/src/materials/MeshStandardMaterial.js +6 -54
- package/src/materials/MeshToonMaterial.js +6 -38
- package/src/materials/PointsMaterial.js +6 -15
- package/src/materials/RawShaderMaterial.js +2 -2
- package/src/materials/ShaderMaterial.js +6 -24
- package/src/materials/ShadowMaterial.js +6 -8
- package/src/materials/SpriteMaterial.js +6 -12
- package/src/math/Box2.js +2 -2
- package/src/math/Box3.js +29 -15
- package/src/math/Color.js +87 -48
- package/src/math/ColorManagement.js +74 -0
- package/src/math/Euler.js +16 -14
- package/src/math/Interpolant.js +4 -9
- package/src/math/MathUtils.js +77 -14
- package/src/math/Matrix3.js +2 -8
- package/src/math/Matrix4.js +3 -28
- package/src/math/Plane.js +2 -2
- package/src/math/Quaternion.js +12 -23
- package/src/math/Spherical.js +1 -1
- package/src/math/SphericalHarmonics3.js +2 -2
- package/src/math/Vector2.js +5 -25
- package/src/math/Vector3.js +17 -47
- package/src/math/Vector4.js +5 -25
- package/src/math/interpolants/DiscreteInterpolant.js +1 -1
- package/src/objects/Bone.js +2 -2
- package/src/objects/Group.js +2 -2
- package/src/objects/InstancedMesh.js +4 -4
- package/src/objects/Line.js +76 -107
- package/src/objects/LineLoop.js +2 -2
- package/src/objects/LineSegments.js +15 -23
- package/src/objects/Mesh.js +82 -104
- package/src/objects/Points.js +32 -54
- package/src/objects/SkinnedMesh.js +5 -8
- package/src/objects/Sprite.js +4 -4
- package/src/renderers/WebGL3DRenderTarget.js +22 -0
- package/src/renderers/WebGLArrayRenderTarget.js +22 -0
- package/src/renderers/WebGLCubeRenderTarget.js +7 -14
- package/src/renderers/WebGLMultipleRenderTargets.js +8 -5
- package/src/renderers/WebGLRenderTarget.js +19 -18
- package/src/renderers/WebGLRenderer.js +195 -74
- package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +46 -0
- package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +3 -5
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +7 -5
- package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +35 -36
- package/src/renderers/shaders/ShaderChunk/dithering_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +3 -19
- package/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js +2 -1
- package/src/renderers/shaders/ShaderChunk/iridescence_fragment.glsl.js +121 -0
- package/src/renderers/shaders/ShaderChunk/iridescence_pars_fragment.glsl.js +14 -0
- package/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +0 -6
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +48 -1
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +0 -6
- package/src/renderers/shaders/ShaderChunk/lights_lambert_fragment.glsl.js +5 -0
- package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +30 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +26 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +56 -6
- package/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js +24 -0
- package/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +7 -7
- package/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js +1 -9
- package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +2 -4
- package/src/renderers/shaders/ShaderChunk/output_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +18 -7
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +8 -3
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +9 -6
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl.js +16 -31
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +14 -10
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk.js +10 -2
- package/src/renderers/shaders/ShaderLib/background.glsl.js +8 -0
- package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +3 -3
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +23 -50
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +6 -0
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +10 -0
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/points.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib.js +37 -31
- package/src/renderers/shaders/UniformsLib.js +14 -13
- package/src/renderers/shaders/UniformsUtils.js +14 -0
- package/src/renderers/webgl/WebGLAttributes.js +6 -6
- package/src/renderers/webgl/WebGLBackground.js +7 -4
- package/src/renderers/webgl/WebGLBindingStates.js +57 -29
- package/src/renderers/webgl/WebGLGeometries.js +2 -2
- package/src/renderers/webgl/WebGLLights.js +37 -14
- package/src/renderers/webgl/WebGLMaterials.js +72 -187
- package/src/renderers/webgl/WebGLMorphtargets.js +43 -39
- package/src/renderers/webgl/WebGLProgram.js +63 -30
- package/src/renderers/webgl/WebGLPrograms.js +97 -104
- package/src/renderers/webgl/WebGLRenderLists.js +5 -4
- package/src/renderers/webgl/WebGLRenderStates.js +5 -4
- package/src/renderers/webgl/WebGLShaderCache.js +12 -8
- package/src/renderers/webgl/WebGLShadowMap.js +13 -20
- package/src/renderers/webgl/WebGLState.js +49 -2
- package/src/renderers/webgl/WebGLTextures.js +576 -386
- package/src/renderers/webgl/WebGLUniforms.js +81 -82
- package/src/renderers/webgl/WebGLUniformsGroups.js +372 -0
- package/src/renderers/webgl/WebGLUtils.js +14 -3
- package/src/renderers/webvr/WebVRManager.js +42 -9
- package/src/renderers/webvr/WebVRUtils.js +1 -1
- package/src/renderers/webxr/WebXRController.js +45 -37
- package/src/renderers/webxr/WebXRManager.js +110 -68
- package/src/scenes/Fog.js +2 -2
- package/src/scenes/FogExp2.js +2 -2
- package/src/scenes/Scene.js +18 -5
- package/src/textures/CanvasTexture.js +2 -2
- package/src/textures/CompressedTexture.js +2 -2
- package/src/textures/CubeTexture.js +2 -2
- package/src/textures/{DataTexture3D.js → Data3DTexture.js} +4 -4
- package/src/textures/{DataTexture2DArray.js → DataArrayTexture.js} +4 -4
- package/src/textures/DataTexture.js +2 -5
- package/src/textures/DepthTexture.js +5 -5
- package/src/textures/FramebufferTexture.js +2 -2
- package/src/textures/Source.js +123 -0
- package/src/textures/Texture.js +27 -97
- package/src/textures/VideoTexture.js +2 -2
- package/src/utils.js +15 -1
- package/examples/js/controls/experimental/CameraControls.js +0 -1044
- package/examples/js/csm/Frustum.js +0 -133
- package/examples/js/deprecated/Geometry.js +0 -1656
- package/examples/js/loaders/KTX2Loader.js +0 -566
- package/examples/js/loaders/VRMLoader.js +0 -72
- package/examples/js/objects/ReflectorRTT.js +0 -16
- package/examples/js/postprocessing/SSRrPass.js +0 -494
- package/examples/js/shaders/SSRrShader.js +0 -336
- package/examples/jsm/controls/experimental/CameraControls.js +0 -1248
- package/examples/jsm/deprecated/Geometry.js +0 -1869
- package/examples/jsm/libs/opentype.module.min.js +0 -119
- package/examples/jsm/loaders/NodeMaterialLoader.js +0 -263
- package/examples/jsm/loaders/VRMLoader.js +0 -78
- package/examples/jsm/nodes/accessors/ColorsNode.js +0 -56
- package/examples/jsm/nodes/accessors/LightNode.js +0 -60
- package/examples/jsm/nodes/accessors/ReflectNode.js +0 -157
- package/examples/jsm/nodes/accessors/ResolutionNode.js +0 -64
- package/examples/jsm/nodes/accessors/ScreenUVNode.js +0 -64
- package/examples/jsm/nodes/core/NodeLib.js +0 -64
- package/examples/jsm/nodes/core/StructNode.js +0 -106
- package/examples/jsm/nodes/effects/BlurNode.js +0 -171
- package/examples/jsm/nodes/effects/ColorAdjustmentNode.js +0 -140
- package/examples/jsm/nodes/effects/LuminanceNode.js +0 -75
- package/examples/jsm/nodes/inputs/BoolNode.js +0 -51
- package/examples/jsm/nodes/inputs/ColorNode.js +0 -58
- package/examples/jsm/nodes/inputs/CubeTextureNode.js +0 -108
- package/examples/jsm/nodes/inputs/FloatNode.js +0 -51
- package/examples/jsm/nodes/inputs/IntNode.js +0 -51
- package/examples/jsm/nodes/inputs/Matrix3Node.js +0 -63
- package/examples/jsm/nodes/inputs/Matrix4Node.js +0 -63
- package/examples/jsm/nodes/inputs/PropertyNode.js +0 -47
- package/examples/jsm/nodes/inputs/RTTNode.js +0 -157
- package/examples/jsm/nodes/inputs/ReflectorNode.js +0 -90
- package/examples/jsm/nodes/inputs/ScreenNode.js +0 -28
- package/examples/jsm/nodes/inputs/TextureNode.js +0 -116
- package/examples/jsm/nodes/inputs/Vector2Node.js +0 -57
- package/examples/jsm/nodes/inputs/Vector3Node.js +0 -58
- package/examples/jsm/nodes/inputs/Vector4Node.js +0 -59
- package/examples/jsm/nodes/materials/BasicNodeMaterial.js +0 -26
- package/examples/jsm/nodes/materials/PhongNodeMaterial.js +0 -36
- package/examples/jsm/nodes/materials/StandardNodeMaterial.js +0 -40
- package/examples/jsm/nodes/materials/nodes/BasicNode.js +0 -154
- package/examples/jsm/nodes/materials/nodes/MeshStandardNode.js +0 -116
- package/examples/jsm/nodes/materials/nodes/PhongNode.js +0 -409
- package/examples/jsm/nodes/materials/nodes/RawNode.js +0 -62
- package/examples/jsm/nodes/materials/nodes/SpriteNode.js +0 -236
- package/examples/jsm/nodes/materials/nodes/StandardNode.js +0 -609
- package/examples/jsm/nodes/misc/BumpMapNode.js +0 -163
- package/examples/jsm/nodes/misc/NormalMapNode.js +0 -138
- package/examples/jsm/nodes/misc/TextureCubeNode.js +0 -86
- package/examples/jsm/nodes/misc/TextureCubeUVNode.js +0 -280
- package/examples/jsm/nodes/postprocessing/NodePass.js +0 -93
- package/examples/jsm/nodes/postprocessing/NodePostProcessing.js +0 -148
- package/examples/jsm/nodes/procedural/Fractal3DNode.js +0 -104
- package/examples/jsm/nodes/procedural/Noise2DNode.js +0 -149
- package/examples/jsm/nodes/procedural/Noise3DNode.js +0 -141
- package/examples/jsm/nodes/utils/BypassNode.js +0 -85
- package/examples/jsm/nodes/utils/ColorSpaceNode.js +0 -145
- package/examples/jsm/nodes/utils/MaxMIPLevelNode.js +0 -56
- package/examples/jsm/nodes/utils/RemapNode.js +0 -155
- package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +0 -101
- package/examples/jsm/nodes/utils/SubSlotNode.js +0 -77
- package/examples/jsm/nodes/utils/SwitchNode.js +0 -103
- package/examples/jsm/nodes/utils/UVTransformNode.js +0 -66
- package/examples/jsm/nodes/utils/VelocityNode.js +0 -170
- package/examples/jsm/objects/ReflectorRTT.js +0 -15
- package/examples/jsm/package.json +0 -3
- package/examples/jsm/postprocessing/SSRrPass.js +0 -579
- package/examples/jsm/renderers/nodes/Nodes.js +0 -166
- package/examples/jsm/renderers/nodes/ShaderNode.js +0 -373
- package/examples/jsm/renderers/nodes/accessors/CameraNode.js +0 -68
- package/examples/jsm/renderers/nodes/accessors/NormalNode.js +0 -63
- package/examples/jsm/renderers/nodes/accessors/PositionNode.js +0 -67
- package/examples/jsm/renderers/nodes/accessors/ReferenceNode.js +0 -91
- package/examples/jsm/renderers/nodes/accessors/SkinningNode.js +0 -107
- package/examples/jsm/renderers/nodes/accessors/UVNode.js +0 -25
- package/examples/jsm/renderers/nodes/core/ArrayInputNode.js +0 -23
- package/examples/jsm/renderers/nodes/core/AttributeNode.js +0 -54
- package/examples/jsm/renderers/nodes/core/CodeNode.js +0 -78
- package/examples/jsm/renderers/nodes/core/ExpressionNode.js +0 -32
- package/examples/jsm/renderers/nodes/core/FunctionCallNode.js +0 -67
- package/examples/jsm/renderers/nodes/core/FunctionNode.js +0 -87
- package/examples/jsm/renderers/nodes/core/InputNode.js +0 -66
- package/examples/jsm/renderers/nodes/core/Node.js +0 -104
- package/examples/jsm/renderers/nodes/core/NodeBuilder.js +0 -633
- package/examples/jsm/renderers/nodes/core/NodeFrame.js +0 -59
- package/examples/jsm/renderers/nodes/core/NodeUniform.js +0 -28
- package/examples/jsm/renderers/nodes/core/TempNode.js +0 -43
- package/examples/jsm/renderers/nodes/core/VarNode.js +0 -51
- package/examples/jsm/renderers/nodes/display/NormalMapNode.js +0 -87
- package/examples/jsm/renderers/nodes/functions/BSDFs.js +0 -122
- package/examples/jsm/renderers/nodes/functions/PhysicalMaterialFunctions.js +0 -27
- package/examples/jsm/renderers/nodes/inputs/BufferNode.js +0 -25
- package/examples/jsm/renderers/nodes/inputs/ColorNode.js +0 -18
- package/examples/jsm/renderers/nodes/inputs/FloatNode.js +0 -17
- package/examples/jsm/renderers/nodes/inputs/IntNode.js +0 -17
- package/examples/jsm/renderers/nodes/inputs/Matrix3Node.js +0 -18
- package/examples/jsm/renderers/nodes/inputs/Matrix4Node.js +0 -18
- package/examples/jsm/renderers/nodes/inputs/TextureNode.js +0 -74
- package/examples/jsm/renderers/nodes/inputs/Vector2Node.js +0 -18
- package/examples/jsm/renderers/nodes/inputs/Vector3Node.js +0 -18
- package/examples/jsm/renderers/nodes/inputs/Vector4Node.js +0 -18
- package/examples/jsm/renderers/nodes/lights/LightContextNode.js +0 -59
- package/examples/jsm/renderers/nodes/lights/LightNode.js +0 -79
- package/examples/jsm/renderers/nodes/lights/LightsNode.js +0 -44
- package/examples/jsm/renderers/nodes/materials/Materials.js +0 -11
- package/examples/jsm/renderers/nodes/materials/MeshStandardNodeMaterial.js +0 -63
- package/examples/jsm/renderers/nodes/math/CondNode.js +0 -60
- package/examples/jsm/renderers/nodes/math/MathNode.js +0 -242
- package/examples/jsm/renderers/nodes/math/OperatorNode.js +0 -174
- package/examples/jsm/renderers/nodes/procedural/CheckerNode.js +0 -36
- package/examples/jsm/renderers/nodes/utils/ConvertNode.js +0 -33
- package/examples/jsm/renderers/nodes/utils/JoinNode.js +0 -42
- package/examples/jsm/renderers/nodes/utils/SplitNode.js +0 -55
- package/examples/jsm/renderers/nodes/utils/TimerNode.js +0 -47
- package/examples/jsm/renderers/webgl/nodes/WebGLPhysicalContextNode.js +0 -45
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeUniformsGroup.js +0 -20
- package/examples/jsm/shaders/SSRrShader.js +0 -307
- package/src/renderers/WebGLMultisampleRenderTarget.js +0 -33
- package/src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl.js +0 -122
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
LineBasicMaterial,
|
|
8
8
|
LineSegments,
|
|
9
9
|
Loader,
|
|
10
|
-
Matrix3,
|
|
11
10
|
Matrix4,
|
|
12
11
|
Mesh,
|
|
13
12
|
MeshStandardMaterial,
|
|
@@ -29,14 +28,17 @@ const FINISH_TYPE_METAL = 5;
|
|
|
29
28
|
|
|
30
29
|
// State machine to search a subobject path.
|
|
31
30
|
// The LDraw standard establishes these various possible subfolders.
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
31
|
+
const FILE_LOCATION_TRY_PARTS = 0;
|
|
32
|
+
const FILE_LOCATION_TRY_P = 1;
|
|
33
|
+
const FILE_LOCATION_TRY_MODELS = 2;
|
|
34
|
+
const FILE_LOCATION_AS_IS = 3;
|
|
36
35
|
const FILE_LOCATION_TRY_RELATIVE = 4;
|
|
37
36
|
const FILE_LOCATION_TRY_ABSOLUTE = 5;
|
|
38
37
|
const FILE_LOCATION_NOT_FOUND = 6;
|
|
39
38
|
|
|
39
|
+
const MAIN_COLOUR_CODE = '16';
|
|
40
|
+
const MAIN_EDGE_COLOUR_CODE = '24';
|
|
41
|
+
|
|
40
42
|
const _tempVec0 = new Vector3();
|
|
41
43
|
const _tempVec1 = new Vector3();
|
|
42
44
|
|
|
@@ -169,6 +171,17 @@ class LDrawConditionalLineMaterial extends ShaderMaterial {
|
|
|
169
171
|
|
|
170
172
|
}
|
|
171
173
|
|
|
174
|
+
class ConditionalLineSegments extends LineSegments {
|
|
175
|
+
|
|
176
|
+
constructor( geometry, material ) {
|
|
177
|
+
|
|
178
|
+
super( geometry, material );
|
|
179
|
+
this.isConditionalLine = true;
|
|
180
|
+
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
}
|
|
184
|
+
|
|
172
185
|
function generateFaceNormals( faces ) {
|
|
173
186
|
|
|
174
187
|
for ( let i = 0, l = faces.length; i < l; i ++ ) {
|
|
@@ -523,13 +536,7 @@ function smoothNormals( faces, lineSegments, checkSubSegments = false ) {
|
|
|
523
536
|
|
|
524
537
|
function isPartType( type ) {
|
|
525
538
|
|
|
526
|
-
return type === 'Part';
|
|
527
|
-
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
function isModelType( type ) {
|
|
531
|
-
|
|
532
|
-
return type === 'Model' || type === 'Unofficial_Model';
|
|
539
|
+
return type === 'Part' || type === 'Unofficial_Part';
|
|
533
540
|
|
|
534
541
|
}
|
|
535
542
|
|
|
@@ -628,12 +635,13 @@ class LineParser {
|
|
|
628
635
|
|
|
629
636
|
}
|
|
630
637
|
|
|
638
|
+
// Fetches and parses an intermediate representation of LDraw parts files.
|
|
631
639
|
class LDrawParsedCache {
|
|
632
640
|
|
|
633
641
|
constructor( loader ) {
|
|
634
642
|
|
|
635
643
|
this.loader = loader;
|
|
636
|
-
this.
|
|
644
|
+
this._cache = {};
|
|
637
645
|
|
|
638
646
|
}
|
|
639
647
|
|
|
@@ -680,10 +688,13 @@ class LDrawParsedCache {
|
|
|
680
688
|
result.type = original.type;
|
|
681
689
|
result.category = original.category;
|
|
682
690
|
result.keywords = original.keywords;
|
|
691
|
+
result.author = original.author;
|
|
683
692
|
result.subobjects = original.subobjects;
|
|
693
|
+
result.fileName = original.fileName;
|
|
684
694
|
result.totalFaces = original.totalFaces;
|
|
685
695
|
result.startingConstructionStep = original.startingConstructionStep;
|
|
686
696
|
result.materials = original.materials;
|
|
697
|
+
result.group = null;
|
|
687
698
|
return result;
|
|
688
699
|
|
|
689
700
|
}
|
|
@@ -691,7 +702,7 @@ class LDrawParsedCache {
|
|
|
691
702
|
async fetchData( fileName ) {
|
|
692
703
|
|
|
693
704
|
let triedLowerCase = false;
|
|
694
|
-
let locationState =
|
|
705
|
+
let locationState = FILE_LOCATION_TRY_PARTS;
|
|
695
706
|
while ( locationState !== FILE_LOCATION_NOT_FOUND ) {
|
|
696
707
|
|
|
697
708
|
let subobjectURL = fileName;
|
|
@@ -734,7 +745,7 @@ class LDrawParsedCache {
|
|
|
734
745
|
fileName = fileName.toLowerCase();
|
|
735
746
|
subobjectURL = fileName;
|
|
736
747
|
triedLowerCase = true;
|
|
737
|
-
locationState =
|
|
748
|
+
locationState = FILE_LOCATION_TRY_PARTS;
|
|
738
749
|
|
|
739
750
|
}
|
|
740
751
|
|
|
@@ -765,7 +776,7 @@ class LDrawParsedCache {
|
|
|
765
776
|
|
|
766
777
|
}
|
|
767
778
|
|
|
768
|
-
parse( text ) {
|
|
779
|
+
parse( text, fileName = null ) {
|
|
769
780
|
|
|
770
781
|
const loader = this.loader;
|
|
771
782
|
|
|
@@ -778,13 +789,14 @@ class LDrawParsedCache {
|
|
|
778
789
|
|
|
779
790
|
const getLocalMaterial = colorCode => {
|
|
780
791
|
|
|
781
|
-
return
|
|
792
|
+
return materials[ colorCode ] || null;
|
|
782
793
|
|
|
783
794
|
};
|
|
784
795
|
|
|
785
796
|
let type = 'Model';
|
|
786
797
|
let category = null;
|
|
787
798
|
let keywords = null;
|
|
799
|
+
let author = null;
|
|
788
800
|
let totalFaces = 0;
|
|
789
801
|
|
|
790
802
|
// split into lines
|
|
@@ -986,6 +998,12 @@ class LDrawParsedCache {
|
|
|
986
998
|
|
|
987
999
|
break;
|
|
988
1000
|
|
|
1001
|
+
case 'Author:':
|
|
1002
|
+
|
|
1003
|
+
author = lp.getToken();
|
|
1004
|
+
|
|
1005
|
+
break;
|
|
1006
|
+
|
|
989
1007
|
default:
|
|
990
1008
|
// Other meta directives are not implemented
|
|
991
1009
|
break;
|
|
@@ -1212,39 +1230,389 @@ class LDrawParsedCache {
|
|
|
1212
1230
|
type,
|
|
1213
1231
|
category,
|
|
1214
1232
|
keywords,
|
|
1233
|
+
author,
|
|
1215
1234
|
subobjects,
|
|
1216
1235
|
totalFaces,
|
|
1217
1236
|
startingConstructionStep,
|
|
1218
|
-
materials
|
|
1237
|
+
materials,
|
|
1238
|
+
fileName,
|
|
1239
|
+
group: null
|
|
1219
1240
|
};
|
|
1220
1241
|
|
|
1221
1242
|
}
|
|
1222
1243
|
|
|
1223
|
-
|
|
1244
|
+
// returns an (optionally cloned) instance of the data
|
|
1245
|
+
getData( fileName, clone = true ) {
|
|
1224
1246
|
|
|
1225
1247
|
const key = fileName.toLowerCase();
|
|
1226
|
-
|
|
1248
|
+
const result = this._cache[ key ];
|
|
1249
|
+
if ( result === null || result instanceof Promise ) {
|
|
1227
1250
|
|
|
1228
|
-
|
|
1251
|
+
return null;
|
|
1229
1252
|
|
|
1230
|
-
|
|
1253
|
+
}
|
|
1231
1254
|
|
|
1232
|
-
|
|
1255
|
+
if ( clone ) {
|
|
1256
|
+
|
|
1257
|
+
return this.cloneResult( result );
|
|
1258
|
+
|
|
1259
|
+
} else {
|
|
1260
|
+
|
|
1261
|
+
return result;
|
|
1233
1262
|
|
|
1234
1263
|
}
|
|
1235
1264
|
|
|
1236
|
-
|
|
1265
|
+
}
|
|
1237
1266
|
|
|
1238
|
-
|
|
1267
|
+
// kicks off a fetch and parse of the requested data if it hasn't already been loaded. Returns when
|
|
1268
|
+
// the data is ready to use and can be retrieved synchronously with "getData".
|
|
1269
|
+
async ensureDataLoaded( fileName ) {
|
|
1239
1270
|
|
|
1240
|
-
|
|
1271
|
+
const key = fileName.toLowerCase();
|
|
1272
|
+
if ( ! ( key in this._cache ) ) {
|
|
1273
|
+
|
|
1274
|
+
// replace the promise with a copy of the parsed data for immediate processing
|
|
1275
|
+
this._cache[ key ] = this.fetchData( fileName ).then( text => {
|
|
1276
|
+
|
|
1277
|
+
const info = this.parse( text, fileName );
|
|
1278
|
+
this._cache[ key ] = info;
|
|
1279
|
+
return info;
|
|
1280
|
+
|
|
1281
|
+
} );
|
|
1282
|
+
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
await this._cache[ key ];
|
|
1241
1286
|
|
|
1242
1287
|
}
|
|
1243
1288
|
|
|
1289
|
+
// sets the data in the cache from parsed data
|
|
1244
1290
|
setData( fileName, text ) {
|
|
1245
1291
|
|
|
1246
1292
|
const key = fileName.toLowerCase();
|
|
1247
|
-
this.
|
|
1293
|
+
this._cache[ key ] = this.parse( text, fileName );
|
|
1294
|
+
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
// returns the material for an associated color code. If the color code is 16 for a face or 24 for
|
|
1300
|
+
// an edge then the passthroughColorCode is used.
|
|
1301
|
+
function getMaterialFromCode( colorCode, parentColorCode, materialHierarchy, forEdge ) {
|
|
1302
|
+
|
|
1303
|
+
const isPassthrough = ! forEdge && colorCode === MAIN_COLOUR_CODE || forEdge && colorCode === MAIN_EDGE_COLOUR_CODE;
|
|
1304
|
+
if ( isPassthrough ) {
|
|
1305
|
+
|
|
1306
|
+
colorCode = parentColorCode;
|
|
1307
|
+
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
return materialHierarchy[ colorCode ] || null;
|
|
1311
|
+
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
// Class used to parse and build LDraw parts as three.js objects and cache them if they're a "Part" type.
|
|
1315
|
+
class LDrawPartsGeometryCache {
|
|
1316
|
+
|
|
1317
|
+
constructor( loader ) {
|
|
1318
|
+
|
|
1319
|
+
this.loader = loader;
|
|
1320
|
+
this.parseCache = new LDrawParsedCache( loader );
|
|
1321
|
+
this._cache = {};
|
|
1322
|
+
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
// Convert the given file information into a mesh by processing subobjects.
|
|
1326
|
+
async processIntoMesh( info ) {
|
|
1327
|
+
|
|
1328
|
+
const loader = this.loader;
|
|
1329
|
+
const parseCache = this.parseCache;
|
|
1330
|
+
const faceMaterials = new Set();
|
|
1331
|
+
|
|
1332
|
+
// Processes the part subobject information to load child parts and merge geometry onto part
|
|
1333
|
+
// piece object.
|
|
1334
|
+
const processInfoSubobjects = async ( info, subobject = null ) => {
|
|
1335
|
+
|
|
1336
|
+
const subobjects = info.subobjects;
|
|
1337
|
+
const promises = [];
|
|
1338
|
+
|
|
1339
|
+
// Trigger load of all subobjects. If a subobject isn't a primitive then load it as a separate
|
|
1340
|
+
// group which lets instruction steps apply correctly.
|
|
1341
|
+
for ( let i = 0, l = subobjects.length; i < l; i ++ ) {
|
|
1342
|
+
|
|
1343
|
+
const subobject = subobjects[ i ];
|
|
1344
|
+
const promise = parseCache.ensureDataLoaded( subobject.fileName ).then( () => {
|
|
1345
|
+
|
|
1346
|
+
const subobjectInfo = parseCache.getData( subobject.fileName, false );
|
|
1347
|
+
if ( ! isPrimitiveType( subobjectInfo.type ) ) {
|
|
1348
|
+
|
|
1349
|
+
return this.loadModel( subobject.fileName ).catch( error => {
|
|
1350
|
+
|
|
1351
|
+
console.warn( error );
|
|
1352
|
+
return null;
|
|
1353
|
+
|
|
1354
|
+
} );
|
|
1355
|
+
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1358
|
+
return processInfoSubobjects( parseCache.getData( subobject.fileName ), subobject );
|
|
1359
|
+
|
|
1360
|
+
} );
|
|
1361
|
+
|
|
1362
|
+
promises.push( promise );
|
|
1363
|
+
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
const group = new Group();
|
|
1367
|
+
group.userData.category = info.category;
|
|
1368
|
+
group.userData.keywords = info.keywords;
|
|
1369
|
+
group.userData.author = info.author;
|
|
1370
|
+
group.userData.type = info.type;
|
|
1371
|
+
group.userData.fileName = info.fileName;
|
|
1372
|
+
info.group = group;
|
|
1373
|
+
|
|
1374
|
+
const subobjectInfos = await Promise.all( promises );
|
|
1375
|
+
for ( let i = 0, l = subobjectInfos.length; i < l; i ++ ) {
|
|
1376
|
+
|
|
1377
|
+
const subobject = info.subobjects[ i ];
|
|
1378
|
+
const subobjectInfo = subobjectInfos[ i ];
|
|
1379
|
+
|
|
1380
|
+
if ( subobjectInfo === null ) {
|
|
1381
|
+
|
|
1382
|
+
// the subobject failed to load
|
|
1383
|
+
continue;
|
|
1384
|
+
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
// if the subobject was loaded as a separate group then apply the parent scopes materials
|
|
1388
|
+
if ( subobjectInfo.isGroup ) {
|
|
1389
|
+
|
|
1390
|
+
const subobjectGroup = subobjectInfo;
|
|
1391
|
+
subobject.matrix.decompose( subobjectGroup.position, subobjectGroup.quaternion, subobjectGroup.scale );
|
|
1392
|
+
subobjectGroup.userData.startingConstructionStep = subobject.startingConstructionStep;
|
|
1393
|
+
subobjectGroup.name = subobject.fileName;
|
|
1394
|
+
|
|
1395
|
+
loader.applyMaterialsToMesh( subobjectGroup, subobject.colorCode, info.materials );
|
|
1396
|
+
subobjectGroup.userData.colorCode = subobject.colorCode;
|
|
1397
|
+
|
|
1398
|
+
group.add( subobjectGroup );
|
|
1399
|
+
continue;
|
|
1400
|
+
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
// add the subobject group if it has children in case it has both children and primitives
|
|
1404
|
+
if ( subobjectInfo.group.children.length ) {
|
|
1405
|
+
|
|
1406
|
+
group.add( subobjectInfo.group );
|
|
1407
|
+
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
// transform the primitives into the local space of the parent piece and append them to
|
|
1411
|
+
// to the parent primitives list.
|
|
1412
|
+
const parentLineSegments = info.lineSegments;
|
|
1413
|
+
const parentConditionalSegments = info.conditionalSegments;
|
|
1414
|
+
const parentFaces = info.faces;
|
|
1415
|
+
|
|
1416
|
+
const lineSegments = subobjectInfo.lineSegments;
|
|
1417
|
+
const conditionalSegments = subobjectInfo.conditionalSegments;
|
|
1418
|
+
|
|
1419
|
+
const faces = subobjectInfo.faces;
|
|
1420
|
+
const matrix = subobject.matrix;
|
|
1421
|
+
const inverted = subobject.inverted;
|
|
1422
|
+
const matrixScaleInverted = matrix.determinant() < 0;
|
|
1423
|
+
const colorCode = subobject.colorCode;
|
|
1424
|
+
|
|
1425
|
+
const lineColorCode = colorCode === MAIN_COLOUR_CODE ? MAIN_EDGE_COLOUR_CODE : colorCode;
|
|
1426
|
+
for ( let i = 0, l = lineSegments.length; i < l; i ++ ) {
|
|
1427
|
+
|
|
1428
|
+
const ls = lineSegments[ i ];
|
|
1429
|
+
const vertices = ls.vertices;
|
|
1430
|
+
vertices[ 0 ].applyMatrix4( matrix );
|
|
1431
|
+
vertices[ 1 ].applyMatrix4( matrix );
|
|
1432
|
+
ls.colorCode = ls.colorCode === MAIN_EDGE_COLOUR_CODE ? lineColorCode : ls.colorCode;
|
|
1433
|
+
ls.material = ls.material || getMaterialFromCode( ls.colorCode, ls.colorCode, info.materials, true );
|
|
1434
|
+
|
|
1435
|
+
parentLineSegments.push( ls );
|
|
1436
|
+
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
for ( let i = 0, l = conditionalSegments.length; i < l; i ++ ) {
|
|
1440
|
+
|
|
1441
|
+
const os = conditionalSegments[ i ];
|
|
1442
|
+
const vertices = os.vertices;
|
|
1443
|
+
const controlPoints = os.controlPoints;
|
|
1444
|
+
vertices[ 0 ].applyMatrix4( matrix );
|
|
1445
|
+
vertices[ 1 ].applyMatrix4( matrix );
|
|
1446
|
+
controlPoints[ 0 ].applyMatrix4( matrix );
|
|
1447
|
+
controlPoints[ 1 ].applyMatrix4( matrix );
|
|
1448
|
+
os.colorCode = os.colorCode === MAIN_EDGE_COLOUR_CODE ? lineColorCode : os.colorCode;
|
|
1449
|
+
os.material = os.material || getMaterialFromCode( os.colorCode, os.colorCode, info.materials, true );
|
|
1450
|
+
|
|
1451
|
+
parentConditionalSegments.push( os );
|
|
1452
|
+
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
for ( let i = 0, l = faces.length; i < l; i ++ ) {
|
|
1456
|
+
|
|
1457
|
+
const tri = faces[ i ];
|
|
1458
|
+
const vertices = tri.vertices;
|
|
1459
|
+
for ( let i = 0, l = vertices.length; i < l; i ++ ) {
|
|
1460
|
+
|
|
1461
|
+
vertices[ i ].applyMatrix4( matrix );
|
|
1462
|
+
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
tri.colorCode = tri.colorCode === MAIN_COLOUR_CODE ? colorCode : tri.colorCode;
|
|
1466
|
+
tri.material = tri.material || getMaterialFromCode( tri.colorCode, colorCode, info.materials, false );
|
|
1467
|
+
faceMaterials.add( tri.colorCode );
|
|
1468
|
+
|
|
1469
|
+
// If the scale of the object is negated then the triangle winding order
|
|
1470
|
+
// needs to be flipped.
|
|
1471
|
+
if ( matrixScaleInverted !== inverted ) {
|
|
1472
|
+
|
|
1473
|
+
vertices.reverse();
|
|
1474
|
+
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
parentFaces.push( tri );
|
|
1478
|
+
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
info.totalFaces += subobjectInfo.totalFaces;
|
|
1482
|
+
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
// Apply the parent subobjects pass through material code to this object. This is done several times due
|
|
1486
|
+
// to material scoping.
|
|
1487
|
+
if ( subobject ) {
|
|
1488
|
+
|
|
1489
|
+
loader.applyMaterialsToMesh( group, subobject.colorCode, info.materials );
|
|
1490
|
+
group.userData.colorCode = subobject.colorCode;
|
|
1491
|
+
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
return info;
|
|
1495
|
+
|
|
1496
|
+
};
|
|
1497
|
+
|
|
1498
|
+
// Track material use to see if we need to use the normal smooth slow path for hard edges.
|
|
1499
|
+
for ( let i = 0, l = info.faces; i < l; i ++ ) {
|
|
1500
|
+
|
|
1501
|
+
faceMaterials.add( info.faces[ i ].colorCode );
|
|
1502
|
+
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
await processInfoSubobjects( info );
|
|
1506
|
+
|
|
1507
|
+
if ( loader.smoothNormals ) {
|
|
1508
|
+
|
|
1509
|
+
const checkSubSegments = faceMaterials.size > 1;
|
|
1510
|
+
generateFaceNormals( info.faces );
|
|
1511
|
+
smoothNormals( info.faces, info.lineSegments, checkSubSegments );
|
|
1512
|
+
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
// Add the primitive objects and metadata.
|
|
1516
|
+
const group = info.group;
|
|
1517
|
+
if ( info.faces.length > 0 ) {
|
|
1518
|
+
|
|
1519
|
+
group.add( createObject( info.faces, 3, false, info.totalFaces ) );
|
|
1520
|
+
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
if ( info.lineSegments.length > 0 ) {
|
|
1524
|
+
|
|
1525
|
+
group.add( createObject( info.lineSegments, 2 ) );
|
|
1526
|
+
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
if ( info.conditionalSegments.length > 0 ) {
|
|
1530
|
+
|
|
1531
|
+
group.add( createObject( info.conditionalSegments, 2, true ) );
|
|
1532
|
+
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
return group;
|
|
1536
|
+
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1539
|
+
hasCachedModel( fileName ) {
|
|
1540
|
+
|
|
1541
|
+
return fileName !== null && fileName.toLowerCase() in this._cache;
|
|
1542
|
+
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
async getCachedModel( fileName ) {
|
|
1546
|
+
|
|
1547
|
+
if ( fileName !== null && this.hasCachedModel( fileName ) ) {
|
|
1548
|
+
|
|
1549
|
+
const key = fileName.toLowerCase();
|
|
1550
|
+
const group = await this._cache[ key ];
|
|
1551
|
+
return group.clone();
|
|
1552
|
+
|
|
1553
|
+
} else {
|
|
1554
|
+
|
|
1555
|
+
return null;
|
|
1556
|
+
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
// Loads and parses the model with the given file name. Returns a cached copy if available.
|
|
1562
|
+
async loadModel( fileName ) {
|
|
1563
|
+
|
|
1564
|
+
const parseCache = this.parseCache;
|
|
1565
|
+
const key = fileName.toLowerCase();
|
|
1566
|
+
if ( this.hasCachedModel( fileName ) ) {
|
|
1567
|
+
|
|
1568
|
+
// Return cached model if available.
|
|
1569
|
+
return this.getCachedModel( fileName );
|
|
1570
|
+
|
|
1571
|
+
} else {
|
|
1572
|
+
|
|
1573
|
+
// Otherwise parse a new model.
|
|
1574
|
+
// Ensure the file data is loaded and pre parsed.
|
|
1575
|
+
await parseCache.ensureDataLoaded( fileName );
|
|
1576
|
+
|
|
1577
|
+
const info = parseCache.getData( fileName );
|
|
1578
|
+
const promise = this.processIntoMesh( info );
|
|
1579
|
+
|
|
1580
|
+
// Now that the file has loaded it's possible that another part parse has been waiting in parallel
|
|
1581
|
+
// so check the cache again to see if it's been added since the last async operation so we don't
|
|
1582
|
+
// do unnecessary work.
|
|
1583
|
+
if ( this.hasCachedModel( fileName ) ) {
|
|
1584
|
+
|
|
1585
|
+
return this.getCachedModel( fileName );
|
|
1586
|
+
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
// Cache object if it's a part so it can be reused later.
|
|
1590
|
+
if ( isPartType( info.type ) ) {
|
|
1591
|
+
|
|
1592
|
+
this._cache[ key ] = promise;
|
|
1593
|
+
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
// return a copy
|
|
1597
|
+
const group = await promise;
|
|
1598
|
+
return group.clone();
|
|
1599
|
+
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1604
|
+
// parses the given model text into a renderable object. Returns cached copy if available.
|
|
1605
|
+
async parseModel( text ) {
|
|
1606
|
+
|
|
1607
|
+
const parseCache = this.parseCache;
|
|
1608
|
+
const info = parseCache.parse( text );
|
|
1609
|
+
if ( isPartType( info.type ) && this.hasCachedModel( info.fileName ) ) {
|
|
1610
|
+
|
|
1611
|
+
return this.getCachedModel( info.fileName );
|
|
1612
|
+
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1615
|
+
return this.processIntoMesh( info );
|
|
1248
1616
|
|
|
1249
1617
|
}
|
|
1250
1618
|
|
|
@@ -1367,7 +1735,7 @@ function createObject( elements, elementSize, isConditionalSegments = false, tot
|
|
|
1367
1735
|
|
|
1368
1736
|
}
|
|
1369
1737
|
|
|
1370
|
-
if ( prevMaterial !== elem.
|
|
1738
|
+
if ( prevMaterial !== elem.colorCode ) {
|
|
1371
1739
|
|
|
1372
1740
|
if ( prevMaterial !== null ) {
|
|
1373
1741
|
|
|
@@ -1376,25 +1744,36 @@ function createObject( elements, elementSize, isConditionalSegments = false, tot
|
|
|
1376
1744
|
}
|
|
1377
1745
|
|
|
1378
1746
|
const material = elem.material;
|
|
1379
|
-
if ( elementSize === 3 ) {
|
|
1380
1747
|
|
|
1381
|
-
|
|
1748
|
+
if ( material !== null ) {
|
|
1382
1749
|
|
|
1383
|
-
|
|
1750
|
+
if ( elementSize === 3 ) {
|
|
1384
1751
|
|
|
1385
|
-
|
|
1752
|
+
materials.push( material );
|
|
1386
1753
|
|
|
1387
|
-
|
|
1754
|
+
} else if ( elementSize === 2 ) {
|
|
1388
1755
|
|
|
1389
|
-
|
|
1756
|
+
if ( isConditionalSegments ) {
|
|
1757
|
+
|
|
1758
|
+
materials.push( material.userData.edgeMaterial.userData.conditionalEdgeMaterial );
|
|
1390
1759
|
|
|
1391
|
-
|
|
1760
|
+
} else {
|
|
1761
|
+
|
|
1762
|
+
materials.push( material.userData.edgeMaterial );
|
|
1763
|
+
|
|
1764
|
+
}
|
|
1392
1765
|
|
|
1393
1766
|
}
|
|
1394
1767
|
|
|
1768
|
+
} else {
|
|
1769
|
+
|
|
1770
|
+
// If a material has not been made available yet then keep the color code string in the material array
|
|
1771
|
+
// to save the spot for the material once a parent scopes materials are being applied to the object.
|
|
1772
|
+
materials.push( elem.colorCode );
|
|
1773
|
+
|
|
1395
1774
|
}
|
|
1396
1775
|
|
|
1397
|
-
prevMaterial = elem.
|
|
1776
|
+
prevMaterial = elem.colorCode;
|
|
1398
1777
|
index0 = offset / 3;
|
|
1399
1778
|
numGroupVerts = vertices.length;
|
|
1400
1779
|
|
|
@@ -1426,7 +1805,15 @@ function createObject( elements, elementSize, isConditionalSegments = false, tot
|
|
|
1426
1805
|
|
|
1427
1806
|
if ( elementSize === 2 ) {
|
|
1428
1807
|
|
|
1429
|
-
|
|
1808
|
+
if ( isConditionalSegments ) {
|
|
1809
|
+
|
|
1810
|
+
object3d = new ConditionalLineSegments( bufferGeometry, materials.length === 1 ? materials[ 0 ] : materials );
|
|
1811
|
+
|
|
1812
|
+
} else {
|
|
1813
|
+
|
|
1814
|
+
object3d = new LineSegments( bufferGeometry, materials.length === 1 ? materials[ 0 ] : materials );
|
|
1815
|
+
|
|
1816
|
+
}
|
|
1430
1817
|
|
|
1431
1818
|
} else if ( elementSize === 3 ) {
|
|
1432
1819
|
|
|
@@ -1486,9 +1873,6 @@ function createObject( elements, elementSize, isConditionalSegments = false, tot
|
|
|
1486
1873
|
|
|
1487
1874
|
//
|
|
1488
1875
|
|
|
1489
|
-
const MAIN_COLOUR_CODE = '16';
|
|
1490
|
-
const MAIN_EDGE_COLOUR_CODE = '24';
|
|
1491
|
-
|
|
1492
1876
|
class LDrawLoader extends Loader {
|
|
1493
1877
|
|
|
1494
1878
|
constructor( manager ) {
|
|
@@ -1497,21 +1881,16 @@ class LDrawLoader extends Loader {
|
|
|
1497
1881
|
|
|
1498
1882
|
// Array of THREE.Material
|
|
1499
1883
|
this.materials = [];
|
|
1884
|
+
this.materialLibrary = {};
|
|
1500
1885
|
|
|
1501
|
-
// Not using THREE.Cache here because it returns the previous HTML error response instead of calling onError()
|
|
1502
1886
|
// This also allows to handle the embedded text files ("0 FILE" lines)
|
|
1503
|
-
this.
|
|
1887
|
+
this.partsCache = new LDrawPartsGeometryCache( this );
|
|
1504
1888
|
|
|
1505
1889
|
// 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.
|
|
1506
1890
|
this.fileMap = {};
|
|
1507
1891
|
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
// Add default main triangle and line edge materials (used in pieces that can be colored with a main color)
|
|
1511
|
-
this.setMaterials( [
|
|
1512
|
-
this.parseColorMetaDirective( new LineParser( 'Main_Colour CODE 16 VALUE #FF8080 EDGE #333333' ) ),
|
|
1513
|
-
this.parseColorMetaDirective( new LineParser( 'Edge_Colour CODE 24 VALUE #A0A0A0 EDGE #333333' ) )
|
|
1514
|
-
] );
|
|
1892
|
+
// Initializes the materials library with default materials
|
|
1893
|
+
this.setMaterials( [] );
|
|
1515
1894
|
|
|
1516
1895
|
// If this flag is set to true the vertex normals will be smoothed.
|
|
1517
1896
|
this.smoothNormals = true;
|
|
@@ -1519,6 +1898,16 @@ class LDrawLoader extends Loader {
|
|
|
1519
1898
|
// The path to load parts from the LDraw parts library from.
|
|
1520
1899
|
this.partsLibraryPath = '';
|
|
1521
1900
|
|
|
1901
|
+
// Material assigned to not available colors for meshes and edges
|
|
1902
|
+
this.missingColorMaterial = new MeshStandardMaterial( { color: 0xFF00FF, roughness: 0.3, metalness: 0 } );
|
|
1903
|
+
this.missingColorMaterial.name = 'Missing material';
|
|
1904
|
+
this.missingEdgeColorMaterial = new LineBasicMaterial( { color: 0xFF00FF } );
|
|
1905
|
+
this.missingEdgeColorMaterial.name = 'Missing material - Edge';
|
|
1906
|
+
this.missingConditionalEdgeColorMaterial = new LDrawConditionalLineMaterial( { fog: true, color: 0xFF00FF } );
|
|
1907
|
+
this.missingConditionalEdgeColorMaterial.name = 'Missing material - Conditional Edge';
|
|
1908
|
+
this.missingColorMaterial.userData.edgeMaterial = this.missingEdgeColorMaterial;
|
|
1909
|
+
this.missingEdgeColorMaterial.userData.conditionalEdgeMaterial = this.missingConditionalEdgeColorMaterial;
|
|
1910
|
+
|
|
1522
1911
|
}
|
|
1523
1912
|
|
|
1524
1913
|
setPartsLibraryPath( path ) {
|
|
@@ -1564,26 +1953,32 @@ class LDrawLoader extends Loader {
|
|
|
1564
1953
|
fileLoader.setWithCredentials( this.withCredentials );
|
|
1565
1954
|
fileLoader.load( url, text => {
|
|
1566
1955
|
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
.then(
|
|
1956
|
+
this.partsCache
|
|
1957
|
+
.parseModel( text, this.materialLibrary )
|
|
1958
|
+
.then( group => {
|
|
1570
1959
|
|
|
1571
|
-
|
|
1960
|
+
this.applyMaterialsToMesh( group, MAIN_COLOUR_CODE, this.materialLibrary, true );
|
|
1961
|
+
this.computeConstructionSteps( group );
|
|
1962
|
+
group.userData.fileName = url;
|
|
1963
|
+
onLoad( group );
|
|
1572
1964
|
|
|
1573
|
-
} )
|
|
1965
|
+
} )
|
|
1966
|
+
.catch( onError );
|
|
1574
1967
|
|
|
1575
1968
|
}, onProgress, onError );
|
|
1576
1969
|
|
|
1577
1970
|
}
|
|
1578
1971
|
|
|
1579
|
-
parse( text,
|
|
1972
|
+
parse( text, onLoad ) {
|
|
1580
1973
|
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
.then( function ( result ) {
|
|
1974
|
+
this.partsCache
|
|
1975
|
+
.parseModel( text, this.materialLibrary )
|
|
1976
|
+
.then( group => {
|
|
1585
1977
|
|
|
1586
|
-
|
|
1978
|
+
this.applyMaterialsToMesh( group, MAIN_COLOUR_CODE, this.materialLibrary, true );
|
|
1979
|
+
this.computeConstructionSteps( group );
|
|
1980
|
+
group.userData.fileName = '';
|
|
1981
|
+
onLoad( group );
|
|
1587
1982
|
|
|
1588
1983
|
} );
|
|
1589
1984
|
|
|
@@ -1591,11 +1986,17 @@ class LDrawLoader extends Loader {
|
|
|
1591
1986
|
|
|
1592
1987
|
setMaterials( materials ) {
|
|
1593
1988
|
|
|
1594
|
-
|
|
1595
|
-
this.
|
|
1596
|
-
|
|
1989
|
+
this.materialLibrary = {};
|
|
1990
|
+
this.materials = [];
|
|
1991
|
+
for ( let i = 0, l = materials.length; i < l; i ++ ) {
|
|
1992
|
+
|
|
1993
|
+
this.addMaterial( materials[ i ] );
|
|
1994
|
+
|
|
1995
|
+
}
|
|
1597
1996
|
|
|
1598
|
-
|
|
1997
|
+
// Add default main triangle and line edge materials (used in pieces that can be colored with a main color)
|
|
1998
|
+
this.addMaterial( this.parseColorMetaDirective( new LineParser( 'Main_Colour CODE 16 VALUE #FF8080 EDGE #333333' ) ) );
|
|
1999
|
+
this.addMaterial( this.parseColorMetaDirective( new LineParser( 'Edge_Colour CODE 24 VALUE #A0A0A0 EDGE #333333' ) ) );
|
|
1599
2000
|
|
|
1600
2001
|
return this;
|
|
1601
2002
|
|
|
@@ -1609,121 +2010,148 @@ class LDrawLoader extends Loader {
|
|
|
1609
2010
|
|
|
1610
2011
|
}
|
|
1611
2012
|
|
|
1612
|
-
|
|
2013
|
+
addMaterial( material ) {
|
|
1613
2014
|
|
|
1614
|
-
// Adds a
|
|
2015
|
+
// Adds a material to the material library which is on top of the parse scopes stack. And also to the materials array
|
|
1615
2016
|
|
|
1616
|
-
const matLib =
|
|
2017
|
+
const matLib = this.materialLibrary;
|
|
2018
|
+
if ( ! matLib[ material.userData.code ] ) {
|
|
1617
2019
|
|
|
1618
|
-
|
|
2020
|
+
this.materials.push( material );
|
|
2021
|
+
matLib[ material.userData.code ] = material;
|
|
1619
2022
|
|
|
1620
|
-
|
|
2023
|
+
}
|
|
1621
2024
|
|
|
1622
|
-
|
|
1623
|
-
matLib[ material.userData.code ] = material;
|
|
2025
|
+
return this;
|
|
1624
2026
|
|
|
1625
|
-
|
|
2027
|
+
}
|
|
1626
2028
|
|
|
1627
|
-
|
|
2029
|
+
getMaterial( colorCode ) {
|
|
1628
2030
|
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
inverted: false,
|
|
1638
|
-
category: null,
|
|
1639
|
-
keywords: null,
|
|
1640
|
-
|
|
1641
|
-
// Current subobject
|
|
1642
|
-
currentFileName: null,
|
|
1643
|
-
mainColorCode: parentScope ? parentScope.mainColorCode : MAIN_COLOUR_CODE,
|
|
1644
|
-
mainEdgeColorCode: parentScope ? parentScope.mainEdgeColorCode : MAIN_EDGE_COLOUR_CODE,
|
|
1645
|
-
matrix: new Matrix4(),
|
|
1646
|
-
type: 'Model',
|
|
1647
|
-
groupObject: null,
|
|
1648
|
-
|
|
1649
|
-
// If false, it is a root material scope previous to parse
|
|
1650
|
-
isFromParse: true,
|
|
1651
|
-
|
|
1652
|
-
faces: [],
|
|
1653
|
-
lineSegments: [],
|
|
1654
|
-
conditionalSegments: [],
|
|
1655
|
-
totalFaces: 0,
|
|
1656
|
-
faceMaterials: new Set(),
|
|
1657
|
-
|
|
1658
|
-
// If true, this object is the start of a construction step
|
|
1659
|
-
startingConstructionStep: false
|
|
1660
|
-
};
|
|
2031
|
+
if ( colorCode.startsWith( '0x2' ) ) {
|
|
2032
|
+
|
|
2033
|
+
// Special 'direct' material value (RGB color)
|
|
2034
|
+
const color = colorCode.substring( 3 );
|
|
2035
|
+
|
|
2036
|
+
return this.parseColorMetaDirective( new LineParser( 'Direct_Color_' + color + ' CODE -1 VALUE #' + color + ' EDGE #' + color + '' ) );
|
|
2037
|
+
|
|
2038
|
+
}
|
|
1661
2039
|
|
|
1662
|
-
return
|
|
2040
|
+
return this.materialLibrary[ colorCode ] || null;
|
|
1663
2041
|
|
|
1664
2042
|
}
|
|
1665
2043
|
|
|
1666
|
-
|
|
2044
|
+
// Applies the appropriate materials to a prebuilt hierarchy of geometry. Assumes that color codes are present
|
|
2045
|
+
// in the material array if they need to be filled in.
|
|
2046
|
+
applyMaterialsToMesh( group, parentColorCode, materialHierarchy, finalMaterialPass = false ) {
|
|
1667
2047
|
|
|
1668
|
-
//
|
|
2048
|
+
// find any missing materials as indicated by a color code string and replace it with a material from the current material lib
|
|
2049
|
+
const loader = this;
|
|
2050
|
+
const parentIsPassthrough = parentColorCode === MAIN_COLOUR_CODE;
|
|
2051
|
+
group.traverse( c => {
|
|
1669
2052
|
|
|
1670
|
-
|
|
2053
|
+
if ( c.isMesh || c.isLineSegments ) {
|
|
1671
2054
|
|
|
1672
|
-
|
|
2055
|
+
if ( Array.isArray( c.material ) ) {
|
|
1673
2056
|
|
|
1674
|
-
|
|
2057
|
+
for ( let i = 0, l = c.material.length; i < l; i ++ ) {
|
|
1675
2058
|
|
|
1676
|
-
|
|
2059
|
+
if ( ! c.material[ i ].isMaterial ) {
|
|
1677
2060
|
|
|
1678
|
-
|
|
2061
|
+
c.material[ i ] = getMaterial( c, c.material[ i ] );
|
|
1679
2062
|
|
|
1680
|
-
|
|
2063
|
+
}
|
|
1681
2064
|
|
|
1682
|
-
|
|
2065
|
+
}
|
|
1683
2066
|
|
|
1684
|
-
|
|
2067
|
+
} else if ( ! c.material.isMaterial ) {
|
|
1685
2068
|
|
|
1686
|
-
|
|
2069
|
+
c.material = getMaterial( c, c.material );
|
|
1687
2070
|
|
|
1688
|
-
|
|
2071
|
+
}
|
|
1689
2072
|
|
|
1690
|
-
|
|
2073
|
+
}
|
|
1691
2074
|
|
|
1692
|
-
|
|
2075
|
+
} );
|
|
1693
2076
|
|
|
1694
|
-
return this.parseColorMetaDirective( new LineParser( 'Direct_Color_' + color + ' CODE -1 VALUE #' + color + ' EDGE #' + color + '' ) );
|
|
1695
2077
|
|
|
1696
|
-
|
|
2078
|
+
// Returns the appropriate material for the object (line or face) given color code. If the code is "pass through"
|
|
2079
|
+
// (24 for lines, 16 for edges) then the pass through color code is used. If that is also pass through then it's
|
|
2080
|
+
// simply returned for the subsequent material application.
|
|
2081
|
+
function getMaterial( c, colorCode ) {
|
|
2082
|
+
|
|
2083
|
+
// if our parent is a passthrough color code and we don't have the current material color available then
|
|
2084
|
+
// return early.
|
|
2085
|
+
if ( parentIsPassthrough && ! ( colorCode in materialHierarchy ) && ! finalMaterialPass ) {
|
|
2086
|
+
|
|
2087
|
+
return colorCode;
|
|
2088
|
+
|
|
2089
|
+
}
|
|
2090
|
+
|
|
2091
|
+
const forEdge = c.isLineSegments || c.isConditionalLine;
|
|
2092
|
+
const isPassthrough = ! forEdge && colorCode === MAIN_COLOUR_CODE || forEdge && colorCode === MAIN_EDGE_COLOUR_CODE;
|
|
2093
|
+
if ( isPassthrough ) {
|
|
2094
|
+
|
|
2095
|
+
colorCode = parentColorCode;
|
|
2096
|
+
|
|
2097
|
+
}
|
|
2098
|
+
|
|
2099
|
+
let material = null;
|
|
2100
|
+
if ( colorCode in materialHierarchy ) {
|
|
2101
|
+
|
|
2102
|
+
material = materialHierarchy[ colorCode ];
|
|
2103
|
+
|
|
2104
|
+
} else if ( finalMaterialPass ) {
|
|
2105
|
+
|
|
2106
|
+
// see if we can get the final material from from the "getMaterial" function which will attempt to
|
|
2107
|
+
// parse the "direct" colors
|
|
2108
|
+
material = loader.getMaterial( colorCode );
|
|
2109
|
+
if ( material === null ) {
|
|
1697
2110
|
|
|
1698
|
-
|
|
2111
|
+
// otherwise throw a warning if this is final opportunity to set the material
|
|
2112
|
+
console.warn( `LDrawLoader: Material properties for code ${ colorCode } not available.` );
|
|
1699
2113
|
|
|
1700
|
-
|
|
2114
|
+
// And return the 'missing color' material
|
|
2115
|
+
material = loader.missingColorMaterial;
|
|
1701
2116
|
|
|
1702
|
-
|
|
2117
|
+
}
|
|
1703
2118
|
|
|
1704
|
-
return material;
|
|
1705
2119
|
|
|
1706
2120
|
} else {
|
|
1707
2121
|
|
|
1708
|
-
|
|
2122
|
+
return colorCode;
|
|
1709
2123
|
|
|
1710
2124
|
}
|
|
1711
2125
|
|
|
1712
|
-
|
|
2126
|
+
if ( c.isLineSegments ) {
|
|
2127
|
+
|
|
2128
|
+
material = material.userData.edgeMaterial;
|
|
2129
|
+
|
|
2130
|
+
if ( c.isConditionalLine ) {
|
|
2131
|
+
|
|
2132
|
+
material = material.userData.conditionalEdgeMaterial;
|
|
2133
|
+
|
|
2134
|
+
}
|
|
1713
2135
|
|
|
1714
|
-
|
|
1715
|
-
|
|
2136
|
+
}
|
|
2137
|
+
|
|
2138
|
+
return material;
|
|
2139
|
+
|
|
2140
|
+
}
|
|
1716
2141
|
|
|
1717
2142
|
}
|
|
1718
2143
|
|
|
1719
2144
|
getMainMaterial() {
|
|
1720
2145
|
|
|
1721
2146
|
return this.getMaterial( MAIN_COLOUR_CODE );
|
|
2147
|
+
|
|
1722
2148
|
}
|
|
1723
2149
|
|
|
1724
2150
|
getMainEdgeMaterial() {
|
|
1725
2151
|
|
|
1726
|
-
|
|
2152
|
+
const mat = this.getMaterial( MAIN_EDGE_COLOUR_CODE );
|
|
2153
|
+
return mat ? mat.userData.edgeMaterial : null;
|
|
2154
|
+
|
|
1727
2155
|
}
|
|
1728
2156
|
|
|
1729
2157
|
parseColorMetaDirective( lineParser ) {
|
|
@@ -1765,113 +2193,113 @@ class LDrawLoader extends Loader {
|
|
|
1765
2193
|
|
|
1766
2194
|
}
|
|
1767
2195
|
|
|
1768
|
-
|
|
2196
|
+
if ( ! parseLuminance( token ) ) {
|
|
1769
2197
|
|
|
1770
|
-
|
|
2198
|
+
switch ( token.toUpperCase() ) {
|
|
1771
2199
|
|
|
1772
|
-
|
|
1773
|
-
break;
|
|
2200
|
+
case 'CODE':
|
|
1774
2201
|
|
|
1775
|
-
|
|
2202
|
+
code = lineParser.getToken();
|
|
2203
|
+
break;
|
|
1776
2204
|
|
|
1777
|
-
|
|
1778
|
-
if ( color.startsWith( '0x' ) ) {
|
|
2205
|
+
case 'VALUE':
|
|
1779
2206
|
|
|
1780
|
-
color =
|
|
2207
|
+
color = lineParser.getToken();
|
|
2208
|
+
if ( color.startsWith( '0x' ) ) {
|
|
1781
2209
|
|
|
1782
|
-
|
|
2210
|
+
color = '#' + color.substring( 2 );
|
|
1783
2211
|
|
|
1784
|
-
|
|
2212
|
+
} else if ( ! color.startsWith( '#' ) ) {
|
|
1785
2213
|
|
|
1786
|
-
|
|
2214
|
+
throw new Error( 'LDrawLoader: Invalid color while parsing material' + lineParser.getLineNumberString() + '.' );
|
|
1787
2215
|
|
|
1788
|
-
|
|
2216
|
+
}
|
|
1789
2217
|
|
|
1790
|
-
|
|
2218
|
+
break;
|
|
1791
2219
|
|
|
1792
|
-
|
|
1793
|
-
if ( edgeColor.startsWith( '0x' ) ) {
|
|
2220
|
+
case 'EDGE':
|
|
1794
2221
|
|
|
1795
|
-
edgeColor =
|
|
2222
|
+
edgeColor = lineParser.getToken();
|
|
2223
|
+
if ( edgeColor.startsWith( '0x' ) ) {
|
|
1796
2224
|
|
|
1797
|
-
|
|
2225
|
+
edgeColor = '#' + edgeColor.substring( 2 );
|
|
1798
2226
|
|
|
1799
|
-
|
|
1800
|
-
edgeMaterial = this.getMaterial( edgeColor );
|
|
1801
|
-
if ( ! edgeMaterial ) {
|
|
2227
|
+
} else if ( ! edgeColor.startsWith( '#' ) ) {
|
|
1802
2228
|
|
|
1803
|
-
|
|
2229
|
+
// Try to see if edge color is a color code
|
|
2230
|
+
edgeMaterial = this.getMaterial( edgeColor );
|
|
2231
|
+
if ( ! edgeMaterial ) {
|
|
1804
2232
|
|
|
1805
|
-
|
|
2233
|
+
throw new Error( 'LDrawLoader: Invalid edge color while parsing material' + lineParser.getLineNumberString() + '.' );
|
|
1806
2234
|
|
|
1807
|
-
|
|
1808
|
-
edgeMaterial = edgeMaterial.userData.edgeMaterial;
|
|
2235
|
+
}
|
|
1809
2236
|
|
|
1810
|
-
|
|
2237
|
+
// Get the edge material for this triangle material
|
|
2238
|
+
edgeMaterial = edgeMaterial.userData.edgeMaterial;
|
|
1811
2239
|
|
|
1812
|
-
|
|
2240
|
+
}
|
|
1813
2241
|
|
|
1814
|
-
|
|
2242
|
+
break;
|
|
1815
2243
|
|
|
1816
|
-
|
|
2244
|
+
case 'ALPHA':
|
|
1817
2245
|
|
|
1818
|
-
|
|
2246
|
+
alpha = parseInt( lineParser.getToken() );
|
|
1819
2247
|
|
|
1820
|
-
|
|
2248
|
+
if ( isNaN( alpha ) ) {
|
|
1821
2249
|
|
|
1822
|
-
|
|
2250
|
+
throw new Error( 'LDrawLoader: Invalid alpha value in material definition' + lineParser.getLineNumberString() + '.' );
|
|
1823
2251
|
|
|
1824
|
-
|
|
2252
|
+
}
|
|
1825
2253
|
|
|
1826
|
-
|
|
2254
|
+
alpha = Math.max( 0, Math.min( 1, alpha / 255 ) );
|
|
1827
2255
|
|
|
1828
|
-
|
|
2256
|
+
if ( alpha < 1 ) {
|
|
1829
2257
|
|
|
1830
|
-
|
|
2258
|
+
isTransparent = true;
|
|
1831
2259
|
|
|
1832
|
-
|
|
2260
|
+
}
|
|
1833
2261
|
|
|
1834
|
-
|
|
2262
|
+
break;
|
|
1835
2263
|
|
|
1836
|
-
|
|
2264
|
+
case 'LUMINANCE':
|
|
1837
2265
|
|
|
1838
|
-
|
|
2266
|
+
if ( ! parseLuminance( lineParser.getToken() ) ) {
|
|
1839
2267
|
|
|
1840
|
-
|
|
2268
|
+
throw new Error( 'LDrawLoader: Invalid luminance value in material definition' + LineParser.getLineNumberString() + '.' );
|
|
1841
2269
|
|
|
1842
|
-
|
|
2270
|
+
}
|
|
1843
2271
|
|
|
1844
|
-
|
|
2272
|
+
break;
|
|
1845
2273
|
|
|
1846
|
-
|
|
2274
|
+
case 'CHROME':
|
|
2275
|
+
finishType = FINISH_TYPE_CHROME;
|
|
2276
|
+
break;
|
|
1847
2277
|
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
2278
|
+
case 'PEARLESCENT':
|
|
2279
|
+
finishType = FINISH_TYPE_PEARLESCENT;
|
|
2280
|
+
break;
|
|
1851
2281
|
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
2282
|
+
case 'RUBBER':
|
|
2283
|
+
finishType = FINISH_TYPE_RUBBER;
|
|
2284
|
+
break;
|
|
1855
2285
|
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
2286
|
+
case 'MATTE_METALLIC':
|
|
2287
|
+
finishType = FINISH_TYPE_MATTE_METALLIC;
|
|
2288
|
+
break;
|
|
1859
2289
|
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
2290
|
+
case 'METAL':
|
|
2291
|
+
finishType = FINISH_TYPE_METAL;
|
|
2292
|
+
break;
|
|
1863
2293
|
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
2294
|
+
case 'MATERIAL':
|
|
2295
|
+
// Not implemented
|
|
2296
|
+
lineParser.setToEnd();
|
|
2297
|
+
break;
|
|
1867
2298
|
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
lineParser.setToEnd();
|
|
1871
|
-
break;
|
|
2299
|
+
default:
|
|
2300
|
+
throw new Error( 'LDrawLoader: Unknown token "' + token + '" while parsing material' + lineParser.getLineNumberString() + '.' );
|
|
1872
2301
|
|
|
1873
|
-
|
|
1874
|
-
throw new Error( 'LDrawLoader: Unknown token "' + token + '" while parsing material' + lineParser.getLineNumberString() + '.' );
|
|
2302
|
+
}
|
|
1875
2303
|
|
|
1876
2304
|
}
|
|
1877
2305
|
|
|
@@ -1926,6 +2354,7 @@ class LDrawLoader extends Loader {
|
|
|
1926
2354
|
material.premultipliedAlpha = true;
|
|
1927
2355
|
material.opacity = alpha;
|
|
1928
2356
|
material.depthWrite = ! isTransparent;
|
|
2357
|
+
material.color.convertSRGBToLinear();
|
|
1929
2358
|
|
|
1930
2359
|
material.polygonOffset = true;
|
|
1931
2360
|
material.polygonOffsetFactor = 1;
|
|
@@ -1947,6 +2376,7 @@ class LDrawLoader extends Loader {
|
|
|
1947
2376
|
} );
|
|
1948
2377
|
edgeMaterial.userData.code = code;
|
|
1949
2378
|
edgeMaterial.name = name + ' - Edge';
|
|
2379
|
+
edgeMaterial.color.convertSRGBToLinear();
|
|
1950
2380
|
|
|
1951
2381
|
// This is the material used for conditional edges
|
|
1952
2382
|
edgeMaterial.userData.conditionalEdgeMaterial = new LDrawConditionalLineMaterial( {
|
|
@@ -1958,6 +2388,9 @@ class LDrawLoader extends Loader {
|
|
|
1958
2388
|
opacity: alpha,
|
|
1959
2389
|
|
|
1960
2390
|
} );
|
|
2391
|
+
edgeMaterial.userData.conditionalEdgeMaterial.color.convertSRGBToLinear();
|
|
2392
|
+
edgeMaterial.userData.conditionalEdgeMaterial.userData.code = code;
|
|
2393
|
+
edgeMaterial.userData.conditionalEdgeMaterial.name = name + ' - Conditional Edge';
|
|
1961
2394
|
|
|
1962
2395
|
}
|
|
1963
2396
|
|
|
@@ -1966,113 +2399,35 @@ class LDrawLoader extends Loader {
|
|
|
1966
2399
|
|
|
1967
2400
|
material.userData.edgeMaterial = edgeMaterial;
|
|
1968
2401
|
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
}
|
|
1972
|
-
|
|
1973
|
-
//
|
|
1974
|
-
|
|
1975
|
-
objectParse( info, parseScope ) {
|
|
1976
|
-
|
|
1977
|
-
// Retrieve data from the parent parse scope
|
|
1978
|
-
const currentParseScope = parseScope;
|
|
1979
|
-
const parentParseScope = currentParseScope.parentScope;
|
|
1980
|
-
|
|
1981
|
-
// Main color codes passed to this subobject (or default codes 16 and 24 if it is the root object)
|
|
1982
|
-
const mainColorCode = currentParseScope.mainColorCode;
|
|
1983
|
-
const mainEdgeColorCode = currentParseScope.mainEdgeColorCode;
|
|
1984
|
-
|
|
1985
|
-
const parseColorCode = ( colorCode, forEdge ) => {
|
|
1986
|
-
|
|
1987
|
-
// Parses next color code and returns a THREE.Material
|
|
1988
|
-
|
|
1989
|
-
if ( ! forEdge && colorCode === MAIN_COLOUR_CODE ) {
|
|
1990
|
-
|
|
1991
|
-
colorCode = mainColorCode;
|
|
1992
|
-
|
|
1993
|
-
}
|
|
1994
|
-
|
|
1995
|
-
if ( forEdge && colorCode === MAIN_EDGE_COLOUR_CODE ) {
|
|
1996
|
-
|
|
1997
|
-
colorCode = mainEdgeColorCode;
|
|
1998
|
-
|
|
1999
|
-
}
|
|
2000
|
-
|
|
2001
|
-
const material = this.getMaterial( colorCode, currentParseScope );
|
|
2002
|
-
|
|
2003
|
-
if ( ! material ) {
|
|
2004
|
-
|
|
2005
|
-
throw new Error( 'LDrawLoader: Unknown color code "' + colorCode + '" is used but it was not defined previously.' );
|
|
2006
|
-
|
|
2007
|
-
}
|
|
2008
|
-
|
|
2009
|
-
return material;
|
|
2010
|
-
|
|
2011
|
-
};
|
|
2012
|
-
|
|
2013
|
-
const faces = info.faces;
|
|
2014
|
-
const lineSegments = info.lineSegments;
|
|
2015
|
-
const conditionalSegments = info.conditionalSegments;
|
|
2016
|
-
const materials = info.materials;
|
|
2017
|
-
if ( currentParseScope.inverted ) {
|
|
2018
|
-
|
|
2019
|
-
faces.reverse();
|
|
2020
|
-
|
|
2021
|
-
}
|
|
2022
|
-
|
|
2023
|
-
for ( const colorCode in materials ) {
|
|
2024
|
-
|
|
2025
|
-
this.addMaterial( materials[ colorCode ], currentParseScope );
|
|
2402
|
+
this.addMaterial( material );
|
|
2026
2403
|
|
|
2027
|
-
|
|
2404
|
+
return material;
|
|
2028
2405
|
|
|
2029
|
-
|
|
2406
|
+
function parseLuminance( token ) {
|
|
2030
2407
|
|
|
2031
|
-
|
|
2032
|
-
if ( face.material === null ) {
|
|
2408
|
+
// Returns success
|
|
2033
2409
|
|
|
2034
|
-
|
|
2410
|
+
let lum;
|
|
2035
2411
|
|
|
2036
|
-
|
|
2412
|
+
if ( token.startsWith( 'LUMINANCE' ) ) {
|
|
2037
2413
|
|
|
2038
|
-
|
|
2414
|
+
lum = parseInt( token.substring( 9 ) );
|
|
2039
2415
|
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
const ls = lineSegments[ i ];
|
|
2043
|
-
if ( ls.material === null ) {
|
|
2416
|
+
} else {
|
|
2044
2417
|
|
|
2045
|
-
|
|
2418
|
+
lum = parseInt( token );
|
|
2046
2419
|
|
|
2047
2420
|
}
|
|
2048
2421
|
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
for ( let i = 0, l = conditionalSegments.length; i < l; i ++ ) {
|
|
2052
|
-
|
|
2053
|
-
const cs = conditionalSegments[ i ];
|
|
2054
|
-
if ( cs.material === null ) {
|
|
2422
|
+
if ( isNaN( lum ) ) {
|
|
2055
2423
|
|
|
2056
|
-
|
|
2424
|
+
return false;
|
|
2057
2425
|
|
|
2058
2426
|
}
|
|
2059
2427
|
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
currentParseScope.faces = info.faces;
|
|
2063
|
-
currentParseScope.conditionalSegments = info.conditionalSegments;
|
|
2064
|
-
currentParseScope.lineSegments = info.lineSegments;
|
|
2065
|
-
currentParseScope.category = info.category;
|
|
2066
|
-
currentParseScope.keywords = info.keywords;
|
|
2067
|
-
currentParseScope.subobjects = info.subobjects;
|
|
2068
|
-
currentParseScope.type = info.type;
|
|
2069
|
-
currentParseScope.totalFaces = info.totalFaces;
|
|
2428
|
+
luminance = Math.max( 0, Math.min( 1, lum / 255 ) );
|
|
2070
2429
|
|
|
2071
|
-
|
|
2072
|
-
if ( isRoot || ! isPrimitiveType( info.type ) ) {
|
|
2073
|
-
|
|
2074
|
-
currentParseScope.groupObject = new Group();
|
|
2075
|
-
currentParseScope.groupObject.userData.startingConstructionStep = currentParseScope.startingConstructionStep;
|
|
2430
|
+
return true;
|
|
2076
2431
|
|
|
2077
2432
|
}
|
|
2078
2433
|
|
|
@@ -2104,215 +2459,6 @@ class LDrawLoader extends Loader {
|
|
|
2104
2459
|
|
|
2105
2460
|
}
|
|
2106
2461
|
|
|
2107
|
-
finalizeObject( subobjectParseScope ) {
|
|
2108
|
-
|
|
2109
|
-
// fail gracefully if an object could not be loaded
|
|
2110
|
-
if ( subobjectParseScope === null ) {
|
|
2111
|
-
|
|
2112
|
-
return;
|
|
2113
|
-
|
|
2114
|
-
}
|
|
2115
|
-
|
|
2116
|
-
const parentParseScope = subobjectParseScope.parentScope;
|
|
2117
|
-
|
|
2118
|
-
// Smooth the normals if this is a part or if this is a case where the subpart
|
|
2119
|
-
// is added directly into the parent model (meaning it will never get smoothed by
|
|
2120
|
-
// being added to a part)
|
|
2121
|
-
const doSmooth =
|
|
2122
|
-
isPartType( subobjectParseScope.type ) ||
|
|
2123
|
-
(
|
|
2124
|
-
isPrimitiveType( subobjectParseScope.type ) &&
|
|
2125
|
-
isModelType( subobjectParseScope.parentScope.type )
|
|
2126
|
-
);
|
|
2127
|
-
|
|
2128
|
-
if ( this.smoothNormals && doSmooth ) {
|
|
2129
|
-
|
|
2130
|
-
generateFaceNormals( subobjectParseScope.faces );
|
|
2131
|
-
|
|
2132
|
-
// only check subsetgments if we have multiple materials in a single part because this seems to be the case where it's needed most --
|
|
2133
|
-
// there may be cases where a single edge line crosses over polygon edges that are broken up by multiple materials.
|
|
2134
|
-
const checkSubSegments = subobjectParseScope.faceMaterials.size > 1;
|
|
2135
|
-
smoothNormals( subobjectParseScope.faces, subobjectParseScope.lineSegments, checkSubSegments );
|
|
2136
|
-
|
|
2137
|
-
}
|
|
2138
|
-
|
|
2139
|
-
const isRoot = ! parentParseScope.isFromParse;
|
|
2140
|
-
if ( ! isPrimitiveType( subobjectParseScope.type ) || isRoot ) {
|
|
2141
|
-
|
|
2142
|
-
const objGroup = subobjectParseScope.groupObject;
|
|
2143
|
-
|
|
2144
|
-
if ( subobjectParseScope.faces.length > 0 ) {
|
|
2145
|
-
|
|
2146
|
-
objGroup.add( createObject( subobjectParseScope.faces, 3, false, subobjectParseScope.totalFaces ) );
|
|
2147
|
-
|
|
2148
|
-
}
|
|
2149
|
-
|
|
2150
|
-
if ( subobjectParseScope.lineSegments.length > 0 ) {
|
|
2151
|
-
|
|
2152
|
-
objGroup.add( createObject( subobjectParseScope.lineSegments, 2 ) );
|
|
2153
|
-
|
|
2154
|
-
}
|
|
2155
|
-
|
|
2156
|
-
if ( subobjectParseScope.conditionalSegments.length > 0 ) {
|
|
2157
|
-
|
|
2158
|
-
objGroup.add( createObject( subobjectParseScope.conditionalSegments, 2, true ) );
|
|
2159
|
-
|
|
2160
|
-
}
|
|
2161
|
-
|
|
2162
|
-
if ( parentParseScope.groupObject ) {
|
|
2163
|
-
|
|
2164
|
-
objGroup.name = subobjectParseScope.fileName;
|
|
2165
|
-
objGroup.userData.category = subobjectParseScope.category;
|
|
2166
|
-
objGroup.userData.keywords = subobjectParseScope.keywords;
|
|
2167
|
-
subobjectParseScope.matrix.decompose( objGroup.position, objGroup.quaternion, objGroup.scale );
|
|
2168
|
-
|
|
2169
|
-
parentParseScope.groupObject.add( objGroup );
|
|
2170
|
-
|
|
2171
|
-
}
|
|
2172
|
-
|
|
2173
|
-
} else {
|
|
2174
|
-
|
|
2175
|
-
const parentLineSegments = parentParseScope.lineSegments;
|
|
2176
|
-
const parentConditionalSegments = parentParseScope.conditionalSegments;
|
|
2177
|
-
const parentFaces = parentParseScope.faces;
|
|
2178
|
-
const parentFaceMaterials = parentParseScope.faceMaterials;
|
|
2179
|
-
|
|
2180
|
-
const lineSegments = subobjectParseScope.lineSegments;
|
|
2181
|
-
const conditionalSegments = subobjectParseScope.conditionalSegments;
|
|
2182
|
-
const faces = subobjectParseScope.faces;
|
|
2183
|
-
const faceMaterials = subobjectParseScope.faceMaterials;
|
|
2184
|
-
const matrix = subobjectParseScope.matrix;
|
|
2185
|
-
const matrixScaleInverted = matrix.determinant() < 0;
|
|
2186
|
-
|
|
2187
|
-
for ( let i = 0, l = lineSegments.length; i < l; i ++ ) {
|
|
2188
|
-
|
|
2189
|
-
const ls = lineSegments[ i ];
|
|
2190
|
-
const vertices = ls.vertices;
|
|
2191
|
-
vertices[ 0 ].applyMatrix4( matrix );
|
|
2192
|
-
vertices[ 1 ].applyMatrix4( matrix );
|
|
2193
|
-
|
|
2194
|
-
parentLineSegments.push( ls );
|
|
2195
|
-
|
|
2196
|
-
}
|
|
2197
|
-
|
|
2198
|
-
for ( let i = 0, l = conditionalSegments.length; i < l; i ++ ) {
|
|
2199
|
-
|
|
2200
|
-
const os = conditionalSegments[ i ];
|
|
2201
|
-
const vertices = os.vertices;
|
|
2202
|
-
const controlPoints = os.controlPoints;
|
|
2203
|
-
vertices[ 0 ].applyMatrix4( matrix );
|
|
2204
|
-
vertices[ 1 ].applyMatrix4( matrix );
|
|
2205
|
-
controlPoints[ 0 ].applyMatrix4( matrix );
|
|
2206
|
-
controlPoints[ 1 ].applyMatrix4( matrix );
|
|
2207
|
-
|
|
2208
|
-
parentConditionalSegments.push( os );
|
|
2209
|
-
|
|
2210
|
-
}
|
|
2211
|
-
|
|
2212
|
-
for ( let i = 0, l = faces.length; i < l; i ++ ) {
|
|
2213
|
-
|
|
2214
|
-
const tri = faces[ i ];
|
|
2215
|
-
const vertices = tri.vertices;
|
|
2216
|
-
for ( let i = 0, l = vertices.length; i < l; i ++ ) {
|
|
2217
|
-
|
|
2218
|
-
vertices[ i ].applyMatrix4( matrix );
|
|
2219
|
-
|
|
2220
|
-
}
|
|
2221
|
-
|
|
2222
|
-
// If the scale of the object is negated then the triangle winding order
|
|
2223
|
-
// needs to be flipped.
|
|
2224
|
-
if ( matrixScaleInverted !== subobjectParseScope.inverted ) {
|
|
2225
|
-
|
|
2226
|
-
vertices.reverse();
|
|
2227
|
-
|
|
2228
|
-
}
|
|
2229
|
-
|
|
2230
|
-
parentFaces.push( tri );
|
|
2231
|
-
|
|
2232
|
-
}
|
|
2233
|
-
|
|
2234
|
-
parentParseScope.totalFaces += subobjectParseScope.totalFaces;
|
|
2235
|
-
faceMaterials.forEach( material => parentFaceMaterials.add( material ) );
|
|
2236
|
-
|
|
2237
|
-
}
|
|
2238
|
-
|
|
2239
|
-
}
|
|
2240
|
-
|
|
2241
|
-
async processObject( parsedInfo, subobject, url, parentScope ) {
|
|
2242
|
-
|
|
2243
|
-
const scope = this;
|
|
2244
|
-
|
|
2245
|
-
const parseScope = this.newParseScopeLevel( null, parentScope );
|
|
2246
|
-
parseScope.url = url;
|
|
2247
|
-
|
|
2248
|
-
// Set current matrix
|
|
2249
|
-
if ( subobject ) {
|
|
2250
|
-
|
|
2251
|
-
parseScope.matrix.copy( subobject.matrix );
|
|
2252
|
-
parseScope.inverted = subobject.inverted;
|
|
2253
|
-
parseScope.startingConstructionStep = subobject.startingConstructionStep;
|
|
2254
|
-
parseScope.fileName = subobject.fileName;
|
|
2255
|
-
if ( subobject.colorCode === MAIN_COLOUR_CODE && parentScope ) {
|
|
2256
|
-
|
|
2257
|
-
parseScope.mainColorCode = parentScope.mainColorCode;
|
|
2258
|
-
parseScope.mainEdgeColorCode = parentScope.mainEdgeColorCode;
|
|
2259
|
-
|
|
2260
|
-
} else if ( subobject.colorCode !== MAIN_COLOUR_CODE ) {
|
|
2261
|
-
|
|
2262
|
-
parseScope.mainColorCode = subobject.colorCode;
|
|
2263
|
-
parseScope.mainEdgeColorCode = subobject.colorCode;
|
|
2264
|
-
|
|
2265
|
-
}
|
|
2266
|
-
|
|
2267
|
-
}
|
|
2268
|
-
|
|
2269
|
-
// Parse the object
|
|
2270
|
-
this.objectParse( parsedInfo, parseScope );
|
|
2271
|
-
|
|
2272
|
-
const subobjects = parseScope.subobjects;
|
|
2273
|
-
const promises = [];
|
|
2274
|
-
for ( let i = 0, l = subobjects.length; i < l; i ++ ) {
|
|
2275
|
-
|
|
2276
|
-
promises.push( loadSubobject( subobjects[ i ] ) );
|
|
2277
|
-
|
|
2278
|
-
}
|
|
2279
|
-
|
|
2280
|
-
// Kick off of the downloads in parallel but process all the subobjects
|
|
2281
|
-
// in order so all the assembly instructions are correct
|
|
2282
|
-
const subobjectScopes = await Promise.all( promises );
|
|
2283
|
-
for ( let i = 0, l = subobjectScopes.length; i < l; i ++ ) {
|
|
2284
|
-
|
|
2285
|
-
this.finalizeObject( subobjectScopes[ i ] );
|
|
2286
|
-
|
|
2287
|
-
}
|
|
2288
|
-
|
|
2289
|
-
// If it is root object then finalize this object and compute construction steps
|
|
2290
|
-
if ( ! parentScope.isFromParse ) {
|
|
2291
|
-
|
|
2292
|
-
this.finalizeObject( parseScope );
|
|
2293
|
-
this.computeConstructionSteps( parseScope.groupObject );
|
|
2294
|
-
|
|
2295
|
-
}
|
|
2296
|
-
|
|
2297
|
-
return parseScope;
|
|
2298
|
-
|
|
2299
|
-
function loadSubobject( subobject ) {
|
|
2300
|
-
|
|
2301
|
-
return scope.parseCache.loadData( subobject.fileName ).then( function ( parsedInfo ) {
|
|
2302
|
-
|
|
2303
|
-
return scope.processObject( parsedInfo, subobject, url, parseScope );
|
|
2304
|
-
|
|
2305
|
-
} ).catch( function ( err ) {
|
|
2306
|
-
|
|
2307
|
-
console.warn( err );
|
|
2308
|
-
return null;
|
|
2309
|
-
|
|
2310
|
-
} );
|
|
2311
|
-
|
|
2312
|
-
}
|
|
2313
|
-
|
|
2314
|
-
}
|
|
2315
|
-
|
|
2316
2462
|
}
|
|
2317
2463
|
|
|
2318
2464
|
export { LDrawLoader };
|