super-three 0.136.0 → 0.141.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +24 -26
- package/build/three.cjs +35889 -0
- package/build/three.js +4837 -6036
- package/build/three.min.js +2 -2
- package/build/three.module.js +16548 -17930
- package/examples/js/animation/CCDIKSolver.js +3 -2
- package/examples/js/animation/MMDAnimationHelper.js +3 -1
- package/examples/js/animation/MMDPhysics.js +3 -3
- package/examples/js/cameras/CinematicCamera.js +2 -7
- package/examples/js/controls/ArcballControls.js +3 -1
- package/examples/js/controls/PointerLockControls.js +3 -2
- package/examples/js/controls/TrackballControls.js +1 -4
- package/examples/js/controls/TransformControls.js +5 -6
- package/examples/js/controls/experimental/CameraControls.js +8 -4
- 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 +7 -4
- package/examples/js/effects/AsciiEffect.js +10 -29
- package/examples/js/exporters/ColladaExporter.js +29 -7
- package/examples/js/exporters/EXRExporter.js +458 -0
- package/examples/js/exporters/GLTFExporter.js +233 -105
- package/examples/js/exporters/MMDExporter.js +1 -1
- package/examples/js/exporters/OBJExporter.js +12 -18
- package/examples/js/exporters/PLYExporter.js +15 -20
- package/examples/js/exporters/USDZExporter.js +13 -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/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 +1 -1
- 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/BasisTextureLoader.js +1 -0
- package/examples/js/loaders/ColladaLoader.js +33 -12
- package/examples/js/loaders/DDSLoader.js +23 -30
- package/examples/js/loaders/EXRLoader.js +314 -294
- package/examples/js/loaders/FBXLoader.js +11 -0
- package/examples/js/loaders/FontLoader.js +1 -2
- package/examples/js/loaders/GCodeLoader.js +0 -1
- package/examples/js/loaders/GLTFLoader.js +250 -61
- package/examples/js/loaders/HDRCubeTextureLoader.js +0 -2
- package/examples/js/loaders/KMZLoader.js +1 -1
- package/examples/js/loaders/KTX2Loader.js +1 -9
- package/examples/js/loaders/LDrawLoader.js +1342 -962
- package/examples/js/loaders/LUT3dlLoader.js +18 -11
- package/examples/js/loaders/LUTCubeLoader.js +4 -5
- 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 +9 -5
- package/examples/js/loaders/PCDLoader.js +24 -15
- package/examples/js/loaders/PDBLoader.js +11 -11
- package/examples/js/loaders/PLYLoader.js +5 -1
- package/examples/js/loaders/RGBELoader.js +9 -17
- package/examples/js/loaders/RGBMLoader.js +13 -16
- package/examples/js/loaders/STLLoader.js +1 -1
- package/examples/js/loaders/SVGLoader.js +21 -11
- package/examples/js/loaders/VOXLoader.js +3 -4
- package/examples/js/loaders/VRMLLoader.js +9 -21
- package/examples/js/loaders/VTKLoader.js +260 -295
- package/examples/js/loaders/lwo/LWO2Parser.js +4 -4
- package/examples/js/loaders/lwo/LWO3Parser.js +4 -4
- package/examples/js/math/ConvexHull.js +13 -28
- package/examples/js/math/Lut.js +27 -26
- package/examples/js/misc/MorphAnimMesh.js +2 -2
- package/examples/js/misc/ProgressiveLightMap.js +1 -1
- package/examples/js/misc/Volume.js +39 -48
- package/examples/js/misc/VolumeSlice.js +21 -21
- package/examples/js/modifiers/CurveModifier.js +8 -7
- package/examples/js/modifiers/EdgeSplitModifier.js +0 -13
- package/examples/js/modifiers/SimplifyModifier.js +1 -18
- package/examples/js/modifiers/TessellateModifier.js +0 -7
- 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 +10 -16
- package/examples/js/objects/ReflectorForSSRPass.js +1 -11
- package/examples/js/objects/Refractor.js +10 -16
- package/examples/js/objects/ShadowMesh.js +1 -2
- package/examples/js/objects/Sky.js +1 -1
- package/examples/js/objects/Water.js +2 -15
- 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/GlitchPass.js +4 -5
- package/examples/js/postprocessing/LUTPass.js +2 -2
- package/examples/js/postprocessing/OutlinePass.js +8 -17
- package/examples/js/postprocessing/SAOPass.js +2 -7
- package/examples/js/postprocessing/SMAAPass.js +2 -9
- package/examples/js/postprocessing/SSAARenderPass.js +1 -6
- package/examples/js/postprocessing/SSAOPass.js +9 -21
- package/examples/js/postprocessing/SSRPass.js +3 -8
- package/examples/js/postprocessing/SavePass.js +1 -5
- package/examples/js/postprocessing/TAARenderPass.js +4 -4
- package/examples/js/postprocessing/UnrealBloomPass.js +3 -12
- package/examples/js/renderers/CSS2DRenderer.js +20 -19
- package/examples/js/renderers/CSS3DRenderer.js +40 -36
- package/examples/js/renderers/Projector.js +97 -124
- 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/DigitalGlitch.js +3 -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/MMDToonShader.js +0 -1
- package/examples/js/shaders/SSAOShader.js +1 -1
- package/examples/js/shaders/SSRShader.js +3 -3
- package/examples/js/shaders/ToneMapShader.js +1 -1
- package/examples/js/utils/BufferGeometryUtils.js +282 -22
- package/examples/js/utils/GPUStatsPanel.js +1 -1
- package/examples/js/utils/LDrawUtils.js +182 -0
- package/examples/js/utils/SceneUtils.js +59 -0
- 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 +2 -2
- package/examples/jsm/cameras/CinematicCamera.js +2 -5
- package/examples/jsm/{WebGL.js → capabilities/WebGL.js} +2 -2
- package/examples/jsm/{renderers/webgpu → capabilities}/WebGPU.js +7 -1
- package/examples/jsm/controls/ArcballControls.js +3 -1
- package/examples/jsm/controls/PointerLockControls.js +4 -2
- package/examples/jsm/controls/TrackballControls.js +1 -4
- package/examples/jsm/controls/TransformControls.js +6 -6
- package/examples/jsm/controls/experimental/CameraControls.js +2 -2
- 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 +4 -4
- package/examples/jsm/effects/AsciiEffect.js +9 -22
- package/examples/jsm/exporters/ColladaExporter.js +31 -6
- package/examples/jsm/exporters/EXRExporter.js +507 -0
- package/examples/jsm/exporters/GLTFExporter.js +261 -103
- package/examples/jsm/exporters/KTX2Exporter.js +281 -0
- package/examples/jsm/exporters/MMDExporter.js +1 -1
- package/examples/jsm/exporters/OBJExporter.js +11 -18
- package/examples/jsm/exporters/PLYExporter.js +23 -21
- package/examples/jsm/exporters/USDZExporter.js +12 -0
- 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/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 +1 -1
- package/examples/jsm/libs/flow.module.js +947 -183
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/libs/lil-gui.module.min.js +2 -2
- package/examples/jsm/libs/mikktspace.module.js +128 -0
- package/examples/jsm/libs/opentype.module.js +14568 -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/BasisTextureLoader.js +7 -0
- package/examples/jsm/loaders/ColladaLoader.js +40 -12
- package/examples/jsm/loaders/DDSLoader.js +21 -28
- package/examples/jsm/loaders/EXRLoader.js +309 -293
- package/examples/jsm/loaders/FBXLoader.js +11 -0
- package/examples/jsm/loaders/FontLoader.js +2 -2
- package/examples/jsm/loaders/GCodeLoader.js +0 -1
- package/examples/jsm/loaders/GLTFLoader.js +263 -68
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +1 -4
- package/examples/jsm/loaders/KMZLoader.js +1 -1
- package/examples/jsm/loaders/KTX2Loader.js +1 -10
- package/examples/jsm/loaders/LDrawLoader.js +1335 -988
- package/examples/jsm/loaders/LUT3dlLoader.js +19 -14
- package/examples/jsm/loaders/LUTCubeLoader.js +5 -7
- 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 +11 -7
- package/examples/jsm/loaders/PCDLoader.js +25 -17
- package/examples/jsm/loaders/PDBLoader.js +11 -11
- package/examples/jsm/loaders/PLYLoader.js +10 -2
- package/examples/jsm/loaders/RGBELoader.js +11 -20
- package/examples/jsm/loaders/RGBMLoader.js +15 -12
- package/examples/jsm/loaders/STLLoader.js +1 -1
- package/examples/jsm/loaders/SVGLoader.js +26 -11
- package/examples/jsm/loaders/TTFLoader.js +1 -1
- package/examples/jsm/loaders/VOXLoader.js +5 -5
- package/examples/jsm/loaders/VRMLLoader.js +9 -23
- package/examples/jsm/loaders/VTKLoader.js +256 -284
- package/examples/jsm/loaders/ifc/web-ifc-api.js +9 -8
- package/examples/jsm/loaders/lwo/LWO2Parser.js +4 -4
- package/examples/jsm/loaders/lwo/LWO3Parser.js +4 -4
- package/examples/jsm/math/ConvexHull.js +13 -28
- package/examples/jsm/math/Lut.js +35 -25
- package/examples/jsm/misc/MorphAnimMesh.js +2 -2
- package/examples/jsm/misc/ProgressiveLightMap.js +1 -1
- package/examples/jsm/misc/Volume.js +39 -46
- package/examples/jsm/misc/VolumeSlice.js +21 -21
- package/examples/jsm/modifiers/CurveModifier.js +9 -8
- package/examples/jsm/modifiers/EdgeSplitModifier.js +0 -13
- package/examples/jsm/modifiers/SimplifyModifier.js +1 -18
- package/examples/jsm/modifiers/TessellateModifier.js +0 -7
- package/examples/jsm/node-editor/NodeEditor.js +485 -163
- 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 +283 -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 +103 -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/ReflectNode.js +34 -121
- 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/{renderers/nodes → nodes}/core/CodeNode.js +2 -30
- 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 +26 -67
- 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 +228 -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 +69 -37
- package/examples/jsm/{renderers/nodes → nodes}/core/NodeVar.js +2 -2
- package/examples/jsm/{renderers/nodes → nodes}/core/NodeVary.js +2 -2
- 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 → nodes}/core/VaryNode.js +0 -0
- package/examples/jsm/{renderers/nodes → nodes}/core/constants.js +0 -0
- package/examples/jsm/nodes/display/ColorSpaceNode.js +95 -0
- package/examples/jsm/nodes/display/FrontFacingNode.js +21 -0
- package/examples/jsm/nodes/display/NormalMapNode.js +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/gpgpu/ComputeNode.js +63 -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 +65 -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 +42 -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 +65 -0
- package/examples/jsm/{renderers/nodes → nodes}/materials/MeshBasicNodeMaterial.js +13 -4
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +162 -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 +84 -16
- package/examples/jsm/nodes/math/CondNode.js +26 -95
- package/examples/jsm/nodes/math/MathNode.js +164 -187
- package/examples/jsm/nodes/math/OperatorNode.js +161 -41
- package/examples/jsm/{renderers/nodes → nodes}/parsers/GLSLNodeFunction.js +2 -2
- 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 +274 -0
- package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +106 -0
- package/examples/jsm/{renderers/nodes → nodes}/utils/ArrayElementNode.js +3 -3
- package/examples/jsm/{renderers/nodes → nodes}/utils/ConvertNode.js +11 -3
- package/examples/jsm/nodes/utils/JoinNode.js +17 -89
- package/examples/jsm/nodes/utils/MatcapUVNode.js +25 -0
- package/examples/jsm/nodes/utils/MaxMipLevelNode.js +32 -0
- package/examples/jsm/{renderers/nodes → nodes}/utils/OscNode.js +18 -2
- package/examples/jsm/{renderers/nodes → nodes}/utils/SplitNode.js +35 -4
- package/examples/jsm/{renderers/nodes → nodes}/utils/SpriteSheetUVNode.js +3 -3
- package/examples/jsm/nodes/utils/TimerNode.js +30 -65
- package/examples/jsm/objects/Lensflare.js +6 -6
- package/examples/jsm/objects/LightningStorm.js +4 -4
- package/examples/jsm/objects/MarchingCubes.js +5 -9
- package/examples/jsm/objects/Reflector.js +8 -19
- package/examples/jsm/objects/ReflectorForSSRPass.js +2 -14
- package/examples/jsm/objects/Refractor.js +8 -19
- package/examples/jsm/objects/ShadowMesh.js +2 -2
- package/examples/jsm/objects/Sky.js +2 -2
- package/examples/jsm/objects/Water.js +3 -18
- 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/GlitchPass.js +7 -6
- package/examples/jsm/postprocessing/LUTPass.js +2 -2
- package/examples/jsm/postprocessing/OutlinePass.js +8 -15
- package/examples/jsm/postprocessing/SAOPass.js +2 -9
- package/examples/jsm/postprocessing/SMAAPass.js +2 -11
- package/examples/jsm/postprocessing/SSAARenderPass.js +1 -4
- package/examples/jsm/postprocessing/SSAOPass.js +13 -25
- package/examples/jsm/postprocessing/SSRPass.js +3 -9
- package/examples/jsm/postprocessing/SavePass.js +1 -3
- package/examples/jsm/postprocessing/TAARenderPass.js +4 -4
- package/examples/jsm/postprocessing/UnrealBloomPass.js +3 -8
- package/examples/jsm/renderers/CSS2DRenderer.js +21 -19
- package/examples/jsm/renderers/CSS3DRenderer.js +39 -34
- package/examples/jsm/renderers/Projector.js +101 -128
- package/examples/jsm/renderers/SVGRenderer.js +4 -4
- package/examples/jsm/renderers/webgl/nodes/SlotNode.js +1 -1
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +127 -23
- package/examples/jsm/renderers/webgl/nodes/WebGLNodes.js +14 -3
- package/examples/jsm/renderers/webgl/nodes/WebGLPhysicalContextNode.js +5 -5
- package/examples/jsm/renderers/webgpu/WebGPUAttributes.js +4 -4
- package/examples/jsm/renderers/webgpu/WebGPUBackground.js +16 -10
- 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 +14 -7
- package/examples/jsm/renderers/webgpu/WebGPUInfo.js +1 -1
- package/examples/jsm/renderers/webgpu/WebGPUObjects.js +0 -6
- package/examples/jsm/renderers/webgpu/WebGPURenderPipeline.js +20 -20
- package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +2 -1
- package/examples/jsm/renderers/webgpu/WebGPURenderStates.js +66 -0
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +49 -28
- 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 +23 -20
- package/examples/jsm/renderers/webgpu/WebGPUTextures.js +38 -20
- 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/constants.js +3 -2
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +276 -278
- 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/DigitalGlitch.js +3 -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/MMDToonShader.js +0 -1
- package/examples/jsm/shaders/SSAOShader.js +1 -1
- package/examples/jsm/shaders/SSRShader.js +3 -3
- package/examples/jsm/shaders/ToneMapShader.js +1 -1
- package/examples/jsm/utils/BufferGeometryUtils.js +292 -22
- package/examples/jsm/utils/GPUStatsPanel.js +1 -1
- package/examples/jsm/utils/LDrawUtils.js +202 -0
- package/examples/jsm/utils/SceneUtils.js +76 -2
- 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 +3 -3
- package/examples/jsm/webxr/Text2D.js +1 -1
- package/examples/jsm/webxr/VRButton.js +39 -1
- package/examples/jsm/webxr/XREstimatedLight.js +2 -0
- package/examples/jsm/webxr/XRHandMeshModel.js +3 -7
- package/examples/jsm/webxr/XRHandModelFactory.js +3 -0
- package/package.json +53 -25
- package/src/Three.Legacy.js +41 -1912
- package/src/Three.js +6 -3
- package/src/animation/AnimationClip.js +1 -1
- package/src/animation/AnimationMixer.js +6 -3
- package/src/animation/AnimationObjectGroup.js +2 -2
- package/src/animation/PropertyBinding.js +8 -18
- 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 +8 -1
- package/src/cameras/OrthographicCamera.js +2 -2
- package/src/cameras/PerspectiveCamera.js +2 -2
- package/src/constants.js +8 -18
- package/src/core/BufferAttribute.js +7 -12
- package/src/core/BufferGeometry.js +6 -6
- package/src/core/GLBufferAttribute.js +2 -2
- package/src/core/InstancedBufferAttribute.js +2 -2
- package/src/core/InstancedBufferGeometry.js +2 -2
- package/src/core/InstancedInterleavedBuffer.js +2 -2
- package/src/core/InterleavedBuffer.js +2 -2
- package/src/core/InterleavedBufferAttribute.js +5 -11
- package/src/core/Object3D.js +6 -3
- package/src/core/Raycaster.js +2 -2
- package/src/extras/DataUtils.js +127 -40
- package/src/extras/Earcut.js +2 -2
- package/src/extras/ImageUtils.js +63 -0
- package/src/extras/PMREMGenerator.js +152 -174
- package/src/extras/core/CurvePath.js +3 -3
- package/src/extras/core/ShapePath.js +5 -6
- package/src/extras/curves/ArcCurve.js +2 -2
- package/src/extras/curves/CatmullRomCurve3.js +2 -2
- 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/CapsuleGeometry.js +33 -0
- package/src/geometries/ExtrudeGeometry.js +2 -0
- package/src/geometries/Geometries.js +1 -0
- package/src/geometries/LatheGeometry.js +1 -1
- package/src/geometries/TorusKnotGeometry.js +2 -2
- package/src/geometries/WireframeGeometry.js +3 -2
- package/src/helpers/BoxHelper.js +2 -2
- package/src/helpers/PointLightHelper.js +1 -1
- package/src/helpers/SkeletonHelper.js +3 -2
- 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 +4 -4
- package/src/lights/SpotLightShadow.js +2 -2
- package/src/loaders/FileLoader.js +23 -4
- package/src/loaders/ImageBitmapLoader.js +2 -2
- package/src/loaders/ImageLoader.js +1 -1
- package/src/loaders/LoaderUtils.js +1 -1
- package/src/loaders/MaterialLoader.js +8 -3
- package/src/loaders/ObjectLoader.js +23 -25
- package/src/materials/LineBasicMaterial.js +6 -13
- package/src/materials/LineDashedMaterial.js +2 -15
- package/src/materials/Material.js +49 -15
- package/src/materials/Materials.js +66 -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 +6 -34
- 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 +3 -17
- 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 +85 -36
- 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 +76 -7
- package/src/math/Matrix3.js +2 -2
- package/src/math/Matrix4.js +2 -3
- package/src/math/Plane.js +2 -2
- package/src/math/Quaternion.js +12 -3
- package/src/math/Spherical.js +1 -1
- package/src/math/SphericalHarmonics3.js +2 -2
- package/src/math/Vector2.js +2 -2
- package/src/math/Vector3.js +12 -3
- package/src/math/Vector4.js +2 -2
- 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 -16
- package/src/renderers/WebGLMultipleRenderTargets.js +8 -5
- package/src/renderers/WebGLRenderTarget.js +19 -18
- package/src/renderers/WebGLRenderer.js +112 -133
- package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +46 -0
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +1 -0
- package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +12 -13
- package/src/renderers/shaders/ShaderChunk/dithering_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +0 -2
- package/src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js +0 -4
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +0 -2
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +3 -19
- package/src/renderers/shaders/ShaderChunk/iridescence_fragment.glsl.js +107 -0
- package/src/renderers/shaders/ShaderChunk/iridescence_pars_fragment.glsl.js +14 -0
- package/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +1 -7
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +25 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +1 -7
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +25 -2
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +43 -5
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +10 -3
- package/src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js +1 -2
- 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/skinning_pars_vertex.glsl.js +16 -31
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +9 -8
- package/src/renderers/shaders/ShaderChunk.js +6 -0
- package/src/renderers/shaders/ShaderLib/background.glsl.js +8 -2
- package/src/renderers/shaders/ShaderLib/equirect.glsl.js +1 -3
- package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +3 -2
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +2 -2
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +6 -0
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +1 -0
- 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 +8 -2
- package/src/renderers/shaders/UniformsLib.js +2 -2
- package/src/renderers/webgl/WebGLAttributes.js +6 -6
- package/src/renderers/webgl/WebGLBackground.js +5 -2
- package/src/renderers/webgl/WebGLBindingStates.js +57 -29
- package/src/renderers/webgl/WebGLCubeMaps.js +0 -4
- package/src/renderers/webgl/WebGLCubeUVMaps.js +29 -16
- package/src/renderers/webgl/WebGLGeometries.js +2 -2
- package/src/renderers/webgl/WebGLLights.js +0 -1
- package/src/renderers/webgl/WebGLMaterials.js +72 -187
- package/src/renderers/webgl/WebGLMorphtargets.js +59 -23
- package/src/renderers/webgl/WebGLProgram.js +56 -30
- package/src/renderers/webgl/WebGLPrograms.js +80 -130
- package/src/renderers/webgl/WebGLShaderCache.js +4 -3
- package/src/renderers/webgl/WebGLShadowMap.js +6 -8
- package/src/renderers/webgl/WebGLState.js +83 -2
- package/src/renderers/webgl/WebGLTextures.js +618 -375
- package/src/renderers/webgl/WebGLUniforms.js +79 -80
- package/src/renderers/webgl/WebGLUtils.js +97 -30
- package/src/renderers/webxr/WebXRManager.js +64 -47
- package/src/scenes/Fog.js +2 -2
- package/src/scenes/FogExp2.js +2 -2
- package/src/scenes/Scene.js +2 -2
- 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 +29 -98
- package/src/textures/VideoTexture.js +2 -4
- package/src/utils.js +15 -1
- package/examples/js/WebGL.js +0 -90
- package/examples/js/csm/Frustum.js +0 -133
- package/examples/js/deprecated/Geometry.js +0 -1656
- 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/js/utils/RoughnessMipmapper.js +0 -268
- 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/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 -154
- 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/postprocessing/SSRrPass.js +0 -579
- package/examples/jsm/renderers/nodes/Nodes.js +0 -164
- package/examples/jsm/renderers/nodes/ShaderNode.js +0 -346
- 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/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/ColorSpaceNode.js +0 -133
- 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 -79
- 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 -241
- 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/JoinNode.js +0 -42
- package/examples/jsm/renderers/nodes/utils/TimerNode.js +0 -47
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeUniformsGroup.js +0 -20
- package/examples/jsm/shaders/SSRrShader.js +0 -307
- package/examples/jsm/utils/RoughnessMipmapper.js +0 -288
- package/src/renderers/WebGLMultisampleRenderTarget.js +0 -33
|
@@ -1,1869 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Box3,
|
|
3
|
-
BufferAttribute,
|
|
4
|
-
BufferGeometry,
|
|
5
|
-
Color,
|
|
6
|
-
EventDispatcher,
|
|
7
|
-
Float32BufferAttribute,
|
|
8
|
-
Matrix3,
|
|
9
|
-
Matrix4,
|
|
10
|
-
MathUtils,
|
|
11
|
-
Object3D,
|
|
12
|
-
Sphere,
|
|
13
|
-
Vector2,
|
|
14
|
-
Vector3
|
|
15
|
-
} from 'three';
|
|
16
|
-
|
|
17
|
-
const _m1 = new Matrix4();
|
|
18
|
-
const _obj = new Object3D();
|
|
19
|
-
const _offset = new Vector3();
|
|
20
|
-
|
|
21
|
-
class Geometry extends EventDispatcher {
|
|
22
|
-
|
|
23
|
-
constructor() {
|
|
24
|
-
|
|
25
|
-
super();
|
|
26
|
-
|
|
27
|
-
this.uuid = MathUtils.generateUUID();
|
|
28
|
-
|
|
29
|
-
this.name = '';
|
|
30
|
-
this.type = 'Geometry';
|
|
31
|
-
|
|
32
|
-
this.vertices = [];
|
|
33
|
-
this.colors = [];
|
|
34
|
-
this.faces = [];
|
|
35
|
-
this.faceVertexUvs = [[]];
|
|
36
|
-
|
|
37
|
-
this.morphTargets = [];
|
|
38
|
-
this.morphNormals = [];
|
|
39
|
-
|
|
40
|
-
this.skinWeights = [];
|
|
41
|
-
this.skinIndices = [];
|
|
42
|
-
|
|
43
|
-
this.lineDistances = [];
|
|
44
|
-
|
|
45
|
-
this.boundingBox = null;
|
|
46
|
-
this.boundingSphere = null;
|
|
47
|
-
|
|
48
|
-
// update flags
|
|
49
|
-
|
|
50
|
-
this.elementsNeedUpdate = false;
|
|
51
|
-
this.verticesNeedUpdate = false;
|
|
52
|
-
this.uvsNeedUpdate = false;
|
|
53
|
-
this.normalsNeedUpdate = false;
|
|
54
|
-
this.colorsNeedUpdate = false;
|
|
55
|
-
this.lineDistancesNeedUpdate = false;
|
|
56
|
-
this.groupsNeedUpdate = false;
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
applyMatrix4( matrix ) {
|
|
61
|
-
|
|
62
|
-
const normalMatrix = new Matrix3().getNormalMatrix( matrix );
|
|
63
|
-
|
|
64
|
-
for ( let i = 0, il = this.vertices.length; i < il; i ++ ) {
|
|
65
|
-
|
|
66
|
-
const vertex = this.vertices[ i ];
|
|
67
|
-
vertex.applyMatrix4( matrix );
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
for ( let i = 0, il = this.faces.length; i < il; i ++ ) {
|
|
72
|
-
|
|
73
|
-
const face = this.faces[ i ];
|
|
74
|
-
face.normal.applyMatrix3( normalMatrix ).normalize();
|
|
75
|
-
|
|
76
|
-
for ( let j = 0, jl = face.vertexNormals.length; j < jl; j ++ ) {
|
|
77
|
-
|
|
78
|
-
face.vertexNormals[ j ].applyMatrix3( normalMatrix ).normalize();
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if ( this.boundingBox !== null ) {
|
|
85
|
-
|
|
86
|
-
this.computeBoundingBox();
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
if ( this.boundingSphere !== null ) {
|
|
91
|
-
|
|
92
|
-
this.computeBoundingSphere();
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
this.verticesNeedUpdate = true;
|
|
97
|
-
this.normalsNeedUpdate = true;
|
|
98
|
-
|
|
99
|
-
return this;
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
rotateX( angle ) {
|
|
104
|
-
|
|
105
|
-
// rotate geometry around world x-axis
|
|
106
|
-
|
|
107
|
-
_m1.makeRotationX( angle );
|
|
108
|
-
|
|
109
|
-
this.applyMatrix4( _m1 );
|
|
110
|
-
|
|
111
|
-
return this;
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
rotateY( angle ) {
|
|
116
|
-
|
|
117
|
-
// rotate geometry around world y-axis
|
|
118
|
-
|
|
119
|
-
_m1.makeRotationY( angle );
|
|
120
|
-
|
|
121
|
-
this.applyMatrix4( _m1 );
|
|
122
|
-
|
|
123
|
-
return this;
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
rotateZ( angle ) {
|
|
128
|
-
|
|
129
|
-
// rotate geometry around world z-axis
|
|
130
|
-
|
|
131
|
-
_m1.makeRotationZ( angle );
|
|
132
|
-
|
|
133
|
-
this.applyMatrix4( _m1 );
|
|
134
|
-
|
|
135
|
-
return this;
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
translate( x, y, z ) {
|
|
140
|
-
|
|
141
|
-
// translate geometry
|
|
142
|
-
|
|
143
|
-
_m1.makeTranslation( x, y, z );
|
|
144
|
-
|
|
145
|
-
this.applyMatrix4( _m1 );
|
|
146
|
-
|
|
147
|
-
return this;
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
scale( x, y, z ) {
|
|
152
|
-
|
|
153
|
-
// scale geometry
|
|
154
|
-
|
|
155
|
-
_m1.makeScale( x, y, z );
|
|
156
|
-
|
|
157
|
-
this.applyMatrix4( _m1 );
|
|
158
|
-
|
|
159
|
-
return this;
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
lookAt( vector ) {
|
|
164
|
-
|
|
165
|
-
_obj.lookAt( vector );
|
|
166
|
-
|
|
167
|
-
_obj.updateMatrix();
|
|
168
|
-
|
|
169
|
-
this.applyMatrix4( _obj.matrix );
|
|
170
|
-
|
|
171
|
-
return this;
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
fromBufferGeometry( geometry ) {
|
|
176
|
-
|
|
177
|
-
const scope = this;
|
|
178
|
-
|
|
179
|
-
const index = geometry.index !== null ? geometry.index : undefined;
|
|
180
|
-
const attributes = geometry.attributes;
|
|
181
|
-
|
|
182
|
-
if ( attributes.position === undefined ) {
|
|
183
|
-
|
|
184
|
-
console.error( 'THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion.' );
|
|
185
|
-
return this;
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
const position = attributes.position;
|
|
190
|
-
const normal = attributes.normal;
|
|
191
|
-
const color = attributes.color;
|
|
192
|
-
const uv = attributes.uv;
|
|
193
|
-
const uv2 = attributes.uv2;
|
|
194
|
-
|
|
195
|
-
if ( uv2 !== undefined ) this.faceVertexUvs[ 1 ] = [];
|
|
196
|
-
|
|
197
|
-
for ( let i = 0; i < position.count; i ++ ) {
|
|
198
|
-
|
|
199
|
-
scope.vertices.push( new Vector3().fromBufferAttribute( position, i ) );
|
|
200
|
-
|
|
201
|
-
if ( color !== undefined ) {
|
|
202
|
-
|
|
203
|
-
scope.colors.push( new Color().fromBufferAttribute( color, i ) );
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
function addFace( a, b, c, materialIndex ) {
|
|
210
|
-
|
|
211
|
-
const vertexColors = ( color === undefined ) ? [] : [
|
|
212
|
-
scope.colors[ a ].clone(),
|
|
213
|
-
scope.colors[ b ].clone(),
|
|
214
|
-
scope.colors[ c ].clone()
|
|
215
|
-
];
|
|
216
|
-
|
|
217
|
-
const vertexNormals = ( normal === undefined ) ? [] : [
|
|
218
|
-
new Vector3().fromBufferAttribute( normal, a ),
|
|
219
|
-
new Vector3().fromBufferAttribute( normal, b ),
|
|
220
|
-
new Vector3().fromBufferAttribute( normal, c )
|
|
221
|
-
];
|
|
222
|
-
|
|
223
|
-
const face = new Face3( a, b, c, vertexNormals, vertexColors, materialIndex );
|
|
224
|
-
|
|
225
|
-
scope.faces.push( face );
|
|
226
|
-
|
|
227
|
-
if ( uv !== undefined ) {
|
|
228
|
-
|
|
229
|
-
scope.faceVertexUvs[ 0 ].push( [
|
|
230
|
-
new Vector2().fromBufferAttribute( uv, a ),
|
|
231
|
-
new Vector2().fromBufferAttribute( uv, b ),
|
|
232
|
-
new Vector2().fromBufferAttribute( uv, c )
|
|
233
|
-
] );
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
if ( uv2 !== undefined ) {
|
|
238
|
-
|
|
239
|
-
scope.faceVertexUvs[ 1 ].push( [
|
|
240
|
-
new Vector2().fromBufferAttribute( uv2, a ),
|
|
241
|
-
new Vector2().fromBufferAttribute( uv2, b ),
|
|
242
|
-
new Vector2().fromBufferAttribute( uv2, c )
|
|
243
|
-
] );
|
|
244
|
-
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
const groups = geometry.groups;
|
|
250
|
-
|
|
251
|
-
if ( groups.length > 0 ) {
|
|
252
|
-
|
|
253
|
-
for ( let i = 0; i < groups.length; i ++ ) {
|
|
254
|
-
|
|
255
|
-
const group = groups[ i ];
|
|
256
|
-
|
|
257
|
-
const start = group.start;
|
|
258
|
-
const count = group.count;
|
|
259
|
-
|
|
260
|
-
for ( let j = start, jl = start + count; j < jl; j += 3 ) {
|
|
261
|
-
|
|
262
|
-
if ( index !== undefined ) {
|
|
263
|
-
|
|
264
|
-
addFace( index.getX( j ), index.getX( j + 1 ), index.getX( j + 2 ), group.materialIndex );
|
|
265
|
-
|
|
266
|
-
} else {
|
|
267
|
-
|
|
268
|
-
addFace( j, j + 1, j + 2, group.materialIndex );
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
} else {
|
|
277
|
-
|
|
278
|
-
if ( index !== undefined ) {
|
|
279
|
-
|
|
280
|
-
for ( let i = 0; i < index.count; i += 3 ) {
|
|
281
|
-
|
|
282
|
-
addFace( index.getX( i ), index.getX( i + 1 ), index.getX( i + 2 ) );
|
|
283
|
-
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
} else {
|
|
287
|
-
|
|
288
|
-
for ( let i = 0; i < position.count; i += 3 ) {
|
|
289
|
-
|
|
290
|
-
addFace( i, i + 1, i + 2 );
|
|
291
|
-
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
this.computeFaceNormals();
|
|
299
|
-
|
|
300
|
-
if ( geometry.boundingBox !== null ) {
|
|
301
|
-
|
|
302
|
-
this.boundingBox = geometry.boundingBox.clone();
|
|
303
|
-
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
if ( geometry.boundingSphere !== null ) {
|
|
307
|
-
|
|
308
|
-
this.boundingSphere = geometry.boundingSphere.clone();
|
|
309
|
-
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
return this;
|
|
313
|
-
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
center() {
|
|
317
|
-
|
|
318
|
-
this.computeBoundingBox();
|
|
319
|
-
|
|
320
|
-
this.boundingBox.getCenter( _offset ).negate();
|
|
321
|
-
|
|
322
|
-
this.translate( _offset.x, _offset.y, _offset.z );
|
|
323
|
-
|
|
324
|
-
return this;
|
|
325
|
-
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
normalize() {
|
|
329
|
-
|
|
330
|
-
this.computeBoundingSphere();
|
|
331
|
-
|
|
332
|
-
const center = this.boundingSphere.center;
|
|
333
|
-
const radius = this.boundingSphere.radius;
|
|
334
|
-
|
|
335
|
-
const s = radius === 0 ? 1 : 1.0 / radius;
|
|
336
|
-
|
|
337
|
-
const matrix = new Matrix4();
|
|
338
|
-
matrix.set(
|
|
339
|
-
s, 0, 0, - s * center.x,
|
|
340
|
-
0, s, 0, - s * center.y,
|
|
341
|
-
0, 0, s, - s * center.z,
|
|
342
|
-
0, 0, 0, 1
|
|
343
|
-
);
|
|
344
|
-
|
|
345
|
-
this.applyMatrix4( matrix );
|
|
346
|
-
|
|
347
|
-
return this;
|
|
348
|
-
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
computeFaceNormals() {
|
|
352
|
-
|
|
353
|
-
const cb = new Vector3(), ab = new Vector3();
|
|
354
|
-
|
|
355
|
-
for ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {
|
|
356
|
-
|
|
357
|
-
const face = this.faces[ f ];
|
|
358
|
-
|
|
359
|
-
const vA = this.vertices[ face.a ];
|
|
360
|
-
const vB = this.vertices[ face.b ];
|
|
361
|
-
const vC = this.vertices[ face.c ];
|
|
362
|
-
|
|
363
|
-
cb.subVectors( vC, vB );
|
|
364
|
-
ab.subVectors( vA, vB );
|
|
365
|
-
cb.cross( ab );
|
|
366
|
-
|
|
367
|
-
cb.normalize();
|
|
368
|
-
|
|
369
|
-
face.normal.copy( cb );
|
|
370
|
-
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
computeVertexNormals( areaWeighted = true ) {
|
|
376
|
-
|
|
377
|
-
const vertices = new Array( this.vertices.length );
|
|
378
|
-
|
|
379
|
-
for ( let v = 0, vl = this.vertices.length; v < vl; v ++ ) {
|
|
380
|
-
|
|
381
|
-
vertices[ v ] = new Vector3();
|
|
382
|
-
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
if ( areaWeighted ) {
|
|
386
|
-
|
|
387
|
-
// vertex normals weighted by triangle areas
|
|
388
|
-
// http://www.iquilezles.org/www/articles/normals/normals.htm
|
|
389
|
-
|
|
390
|
-
const cb = new Vector3(), ab = new Vector3();
|
|
391
|
-
|
|
392
|
-
for ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {
|
|
393
|
-
|
|
394
|
-
const face = this.faces[ f ];
|
|
395
|
-
|
|
396
|
-
const vA = this.vertices[ face.a ];
|
|
397
|
-
const vB = this.vertices[ face.b ];
|
|
398
|
-
const vC = this.vertices[ face.c ];
|
|
399
|
-
|
|
400
|
-
cb.subVectors( vC, vB );
|
|
401
|
-
ab.subVectors( vA, vB );
|
|
402
|
-
cb.cross( ab );
|
|
403
|
-
|
|
404
|
-
vertices[ face.a ].add( cb );
|
|
405
|
-
vertices[ face.b ].add( cb );
|
|
406
|
-
vertices[ face.c ].add( cb );
|
|
407
|
-
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
} else {
|
|
411
|
-
|
|
412
|
-
this.computeFaceNormals();
|
|
413
|
-
|
|
414
|
-
for ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {
|
|
415
|
-
|
|
416
|
-
const face = this.faces[ f ];
|
|
417
|
-
|
|
418
|
-
vertices[ face.a ].add( face.normal );
|
|
419
|
-
vertices[ face.b ].add( face.normal );
|
|
420
|
-
vertices[ face.c ].add( face.normal );
|
|
421
|
-
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
for ( let v = 0, vl = this.vertices.length; v < vl; v ++ ) {
|
|
427
|
-
|
|
428
|
-
vertices[ v ].normalize();
|
|
429
|
-
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
for ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {
|
|
433
|
-
|
|
434
|
-
const face = this.faces[ f ];
|
|
435
|
-
|
|
436
|
-
const vertexNormals = face.vertexNormals;
|
|
437
|
-
|
|
438
|
-
if ( vertexNormals.length === 3 ) {
|
|
439
|
-
|
|
440
|
-
vertexNormals[ 0 ].copy( vertices[ face.a ] );
|
|
441
|
-
vertexNormals[ 1 ].copy( vertices[ face.b ] );
|
|
442
|
-
vertexNormals[ 2 ].copy( vertices[ face.c ] );
|
|
443
|
-
|
|
444
|
-
} else {
|
|
445
|
-
|
|
446
|
-
vertexNormals[ 0 ] = vertices[ face.a ].clone();
|
|
447
|
-
vertexNormals[ 1 ] = vertices[ face.b ].clone();
|
|
448
|
-
vertexNormals[ 2 ] = vertices[ face.c ].clone();
|
|
449
|
-
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
if ( this.faces.length > 0 ) {
|
|
455
|
-
|
|
456
|
-
this.normalsNeedUpdate = true;
|
|
457
|
-
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
computeFlatVertexNormals() {
|
|
463
|
-
|
|
464
|
-
this.computeFaceNormals();
|
|
465
|
-
|
|
466
|
-
for ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {
|
|
467
|
-
|
|
468
|
-
const face = this.faces[ f ];
|
|
469
|
-
|
|
470
|
-
const vertexNormals = face.vertexNormals;
|
|
471
|
-
|
|
472
|
-
if ( vertexNormals.length === 3 ) {
|
|
473
|
-
|
|
474
|
-
vertexNormals[ 0 ].copy( face.normal );
|
|
475
|
-
vertexNormals[ 1 ].copy( face.normal );
|
|
476
|
-
vertexNormals[ 2 ].copy( face.normal );
|
|
477
|
-
|
|
478
|
-
} else {
|
|
479
|
-
|
|
480
|
-
vertexNormals[ 0 ] = face.normal.clone();
|
|
481
|
-
vertexNormals[ 1 ] = face.normal.clone();
|
|
482
|
-
vertexNormals[ 2 ] = face.normal.clone();
|
|
483
|
-
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
if ( this.faces.length > 0 ) {
|
|
489
|
-
|
|
490
|
-
this.normalsNeedUpdate = true;
|
|
491
|
-
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
computeMorphNormals() {
|
|
497
|
-
|
|
498
|
-
// save original normals
|
|
499
|
-
// - create temp variables on first access
|
|
500
|
-
// otherwise just copy (for faster repeated calls)
|
|
501
|
-
|
|
502
|
-
for ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {
|
|
503
|
-
|
|
504
|
-
const face = this.faces[ f ];
|
|
505
|
-
|
|
506
|
-
if ( ! face.__originalFaceNormal ) {
|
|
507
|
-
|
|
508
|
-
face.__originalFaceNormal = face.normal.clone();
|
|
509
|
-
|
|
510
|
-
} else {
|
|
511
|
-
|
|
512
|
-
face.__originalFaceNormal.copy( face.normal );
|
|
513
|
-
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
if ( ! face.__originalVertexNormals ) face.__originalVertexNormals = [];
|
|
517
|
-
|
|
518
|
-
for ( let i = 0, il = face.vertexNormals.length; i < il; i ++ ) {
|
|
519
|
-
|
|
520
|
-
if ( ! face.__originalVertexNormals[ i ] ) {
|
|
521
|
-
|
|
522
|
-
face.__originalVertexNormals[ i ] = face.vertexNormals[ i ].clone();
|
|
523
|
-
|
|
524
|
-
} else {
|
|
525
|
-
|
|
526
|
-
face.__originalVertexNormals[ i ].copy( face.vertexNormals[ i ] );
|
|
527
|
-
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
// use temp geometry to compute face and vertex normals for each morph
|
|
535
|
-
|
|
536
|
-
const tmpGeo = new Geometry();
|
|
537
|
-
tmpGeo.faces = this.faces;
|
|
538
|
-
|
|
539
|
-
for ( let i = 0, il = this.morphTargets.length; i < il; i ++ ) {
|
|
540
|
-
|
|
541
|
-
// create on first access
|
|
542
|
-
|
|
543
|
-
if ( ! this.morphNormals[ i ] ) {
|
|
544
|
-
|
|
545
|
-
this.morphNormals[ i ] = {};
|
|
546
|
-
this.morphNormals[ i ].faceNormals = [];
|
|
547
|
-
this.morphNormals[ i ].vertexNormals = [];
|
|
548
|
-
|
|
549
|
-
const dstNormalsFace = this.morphNormals[ i ].faceNormals;
|
|
550
|
-
const dstNormalsVertex = this.morphNormals[ i ].vertexNormals;
|
|
551
|
-
|
|
552
|
-
for ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {
|
|
553
|
-
|
|
554
|
-
const faceNormal = new Vector3();
|
|
555
|
-
const vertexNormals = { a: new Vector3(), b: new Vector3(), c: new Vector3() };
|
|
556
|
-
|
|
557
|
-
dstNormalsFace.push( faceNormal );
|
|
558
|
-
dstNormalsVertex.push( vertexNormals );
|
|
559
|
-
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
const morphNormals = this.morphNormals[ i ];
|
|
565
|
-
|
|
566
|
-
// set vertices to morph target
|
|
567
|
-
|
|
568
|
-
tmpGeo.vertices = this.morphTargets[ i ].vertices;
|
|
569
|
-
|
|
570
|
-
// compute morph normals
|
|
571
|
-
|
|
572
|
-
tmpGeo.computeFaceNormals();
|
|
573
|
-
tmpGeo.computeVertexNormals();
|
|
574
|
-
|
|
575
|
-
// store morph normals
|
|
576
|
-
|
|
577
|
-
for ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {
|
|
578
|
-
|
|
579
|
-
const face = this.faces[ f ];
|
|
580
|
-
|
|
581
|
-
const faceNormal = morphNormals.faceNormals[ f ];
|
|
582
|
-
const vertexNormals = morphNormals.vertexNormals[ f ];
|
|
583
|
-
|
|
584
|
-
faceNormal.copy( face.normal );
|
|
585
|
-
|
|
586
|
-
vertexNormals.a.copy( face.vertexNormals[ 0 ] );
|
|
587
|
-
vertexNormals.b.copy( face.vertexNormals[ 1 ] );
|
|
588
|
-
vertexNormals.c.copy( face.vertexNormals[ 2 ] );
|
|
589
|
-
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
// restore original normals
|
|
595
|
-
|
|
596
|
-
for ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {
|
|
597
|
-
|
|
598
|
-
const face = this.faces[ f ];
|
|
599
|
-
|
|
600
|
-
face.normal = face.__originalFaceNormal;
|
|
601
|
-
face.vertexNormals = face.__originalVertexNormals;
|
|
602
|
-
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
computeBoundingBox() {
|
|
608
|
-
|
|
609
|
-
if ( this.boundingBox === null ) {
|
|
610
|
-
|
|
611
|
-
this.boundingBox = new Box3();
|
|
612
|
-
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
this.boundingBox.setFromPoints( this.vertices );
|
|
616
|
-
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
computeBoundingSphere() {
|
|
620
|
-
|
|
621
|
-
if ( this.boundingSphere === null ) {
|
|
622
|
-
|
|
623
|
-
this.boundingSphere = new Sphere();
|
|
624
|
-
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
this.boundingSphere.setFromPoints( this.vertices );
|
|
628
|
-
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
merge( geometry, matrix, materialIndexOffset = 0 ) {
|
|
632
|
-
|
|
633
|
-
if ( ! ( geometry && geometry.isGeometry ) ) {
|
|
634
|
-
|
|
635
|
-
console.error( 'THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.', geometry );
|
|
636
|
-
return;
|
|
637
|
-
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
let normalMatrix;
|
|
641
|
-
const vertexOffset = this.vertices.length,
|
|
642
|
-
vertices1 = this.vertices,
|
|
643
|
-
vertices2 = geometry.vertices,
|
|
644
|
-
faces1 = this.faces,
|
|
645
|
-
faces2 = geometry.faces,
|
|
646
|
-
colors1 = this.colors,
|
|
647
|
-
colors2 = geometry.colors;
|
|
648
|
-
|
|
649
|
-
if ( matrix !== undefined ) {
|
|
650
|
-
|
|
651
|
-
normalMatrix = new Matrix3().getNormalMatrix( matrix );
|
|
652
|
-
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
// vertices
|
|
656
|
-
|
|
657
|
-
for ( let i = 0, il = vertices2.length; i < il; i ++ ) {
|
|
658
|
-
|
|
659
|
-
const vertex = vertices2[ i ];
|
|
660
|
-
|
|
661
|
-
const vertexCopy = vertex.clone();
|
|
662
|
-
|
|
663
|
-
if ( matrix !== undefined ) vertexCopy.applyMatrix4( matrix );
|
|
664
|
-
|
|
665
|
-
vertices1.push( vertexCopy );
|
|
666
|
-
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
// colors
|
|
670
|
-
|
|
671
|
-
for ( let i = 0, il = colors2.length; i < il; i ++ ) {
|
|
672
|
-
|
|
673
|
-
colors1.push( colors2[ i ].clone() );
|
|
674
|
-
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
// faces
|
|
678
|
-
|
|
679
|
-
for ( let i = 0, il = faces2.length; i < il; i ++ ) {
|
|
680
|
-
|
|
681
|
-
const face = faces2[ i ];
|
|
682
|
-
let normal, color;
|
|
683
|
-
const faceVertexNormals = face.vertexNormals,
|
|
684
|
-
faceVertexColors = face.vertexColors;
|
|
685
|
-
|
|
686
|
-
const faceCopy = new Face3( face.a + vertexOffset, face.b + vertexOffset, face.c + vertexOffset );
|
|
687
|
-
faceCopy.normal.copy( face.normal );
|
|
688
|
-
|
|
689
|
-
if ( normalMatrix !== undefined ) {
|
|
690
|
-
|
|
691
|
-
faceCopy.normal.applyMatrix3( normalMatrix ).normalize();
|
|
692
|
-
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
for ( let j = 0, jl = faceVertexNormals.length; j < jl; j ++ ) {
|
|
696
|
-
|
|
697
|
-
normal = faceVertexNormals[ j ].clone();
|
|
698
|
-
|
|
699
|
-
if ( normalMatrix !== undefined ) {
|
|
700
|
-
|
|
701
|
-
normal.applyMatrix3( normalMatrix ).normalize();
|
|
702
|
-
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
faceCopy.vertexNormals.push( normal );
|
|
706
|
-
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
faceCopy.color.copy( face.color );
|
|
710
|
-
|
|
711
|
-
for ( let j = 0, jl = faceVertexColors.length; j < jl; j ++ ) {
|
|
712
|
-
|
|
713
|
-
color = faceVertexColors[ j ];
|
|
714
|
-
faceCopy.vertexColors.push( color.clone() );
|
|
715
|
-
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
faceCopy.materialIndex = face.materialIndex + materialIndexOffset;
|
|
719
|
-
|
|
720
|
-
faces1.push( faceCopy );
|
|
721
|
-
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
// uvs
|
|
725
|
-
|
|
726
|
-
for ( let i = 0, il = geometry.faceVertexUvs.length; i < il; i ++ ) {
|
|
727
|
-
|
|
728
|
-
const faceVertexUvs2 = geometry.faceVertexUvs[ i ];
|
|
729
|
-
|
|
730
|
-
if ( this.faceVertexUvs[ i ] === undefined ) this.faceVertexUvs[ i ] = [];
|
|
731
|
-
|
|
732
|
-
for ( let j = 0, jl = faceVertexUvs2.length; j < jl; j ++ ) {
|
|
733
|
-
|
|
734
|
-
const uvs2 = faceVertexUvs2[ j ], uvsCopy = [];
|
|
735
|
-
|
|
736
|
-
for ( let k = 0, kl = uvs2.length; k < kl; k ++ ) {
|
|
737
|
-
|
|
738
|
-
uvsCopy.push( uvs2[ k ].clone() );
|
|
739
|
-
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
this.faceVertexUvs[ i ].push( uvsCopy );
|
|
743
|
-
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
mergeMesh( mesh ) {
|
|
751
|
-
|
|
752
|
-
if ( ! ( mesh && mesh.isMesh ) ) {
|
|
753
|
-
|
|
754
|
-
console.error( 'THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.', mesh );
|
|
755
|
-
return;
|
|
756
|
-
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
if ( mesh.matrixAutoUpdate ) mesh.updateMatrix();
|
|
760
|
-
|
|
761
|
-
this.merge( mesh.geometry, mesh.matrix );
|
|
762
|
-
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
/*
|
|
766
|
-
* Checks for duplicate vertices with hashmap.
|
|
767
|
-
* Duplicated vertices are removed
|
|
768
|
-
* and faces' vertices are updated.
|
|
769
|
-
*/
|
|
770
|
-
|
|
771
|
-
mergeVertices( precisionPoints = 4 ) {
|
|
772
|
-
|
|
773
|
-
const verticesMap = {}; // Hashmap for looking up vertices by position coordinates (and making sure they are unique)
|
|
774
|
-
const unique = [], changes = [];
|
|
775
|
-
|
|
776
|
-
const precision = Math.pow( 10, precisionPoints );
|
|
777
|
-
|
|
778
|
-
for ( let i = 0, il = this.vertices.length; i < il; i ++ ) {
|
|
779
|
-
|
|
780
|
-
const v = this.vertices[ i ];
|
|
781
|
-
const key = Math.round( v.x * precision ) + '_' + Math.round( v.y * precision ) + '_' + Math.round( v.z * precision );
|
|
782
|
-
|
|
783
|
-
if ( verticesMap[ key ] === undefined ) {
|
|
784
|
-
|
|
785
|
-
verticesMap[ key ] = i;
|
|
786
|
-
unique.push( this.vertices[ i ] );
|
|
787
|
-
changes[ i ] = unique.length - 1;
|
|
788
|
-
|
|
789
|
-
} else {
|
|
790
|
-
|
|
791
|
-
//console.log('Duplicate vertex found. ', i, ' could be using ', verticesMap[key]);
|
|
792
|
-
changes[ i ] = changes[ verticesMap[ key ] ];
|
|
793
|
-
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
// if faces are completely degenerate after merging vertices, we
|
|
800
|
-
// have to remove them from the geometry.
|
|
801
|
-
const faceIndicesToRemove = [];
|
|
802
|
-
|
|
803
|
-
for ( let i = 0, il = this.faces.length; i < il; i ++ ) {
|
|
804
|
-
|
|
805
|
-
const face = this.faces[ i ];
|
|
806
|
-
|
|
807
|
-
face.a = changes[ face.a ];
|
|
808
|
-
face.b = changes[ face.b ];
|
|
809
|
-
face.c = changes[ face.c ];
|
|
810
|
-
|
|
811
|
-
const indices = [ face.a, face.b, face.c ];
|
|
812
|
-
|
|
813
|
-
// if any duplicate vertices are found in a Face3
|
|
814
|
-
// we have to remove the face as nothing can be saved
|
|
815
|
-
for ( let n = 0; n < 3; n ++ ) {
|
|
816
|
-
|
|
817
|
-
if ( indices[ n ] === indices[ ( n + 1 ) % 3 ] ) {
|
|
818
|
-
|
|
819
|
-
faceIndicesToRemove.push( i );
|
|
820
|
-
break;
|
|
821
|
-
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
}
|
|
827
|
-
|
|
828
|
-
for ( let i = faceIndicesToRemove.length - 1; i >= 0; i -- ) {
|
|
829
|
-
|
|
830
|
-
const idx = faceIndicesToRemove[ i ];
|
|
831
|
-
|
|
832
|
-
this.faces.splice( idx, 1 );
|
|
833
|
-
|
|
834
|
-
for ( let j = 0, jl = this.faceVertexUvs.length; j < jl; j ++ ) {
|
|
835
|
-
|
|
836
|
-
this.faceVertexUvs[ j ].splice( idx, 1 );
|
|
837
|
-
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
// Use unique set of vertices
|
|
843
|
-
|
|
844
|
-
const diff = this.vertices.length - unique.length;
|
|
845
|
-
this.vertices = unique;
|
|
846
|
-
return diff;
|
|
847
|
-
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
setFromPoints( points ) {
|
|
851
|
-
|
|
852
|
-
this.vertices = [];
|
|
853
|
-
|
|
854
|
-
for ( let i = 0, l = points.length; i < l; i ++ ) {
|
|
855
|
-
|
|
856
|
-
const point = points[ i ];
|
|
857
|
-
this.vertices.push( new Vector3( point.x, point.y, point.z || 0 ) );
|
|
858
|
-
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
return this;
|
|
862
|
-
|
|
863
|
-
}
|
|
864
|
-
|
|
865
|
-
sortFacesByMaterialIndex() {
|
|
866
|
-
|
|
867
|
-
const faces = this.faces;
|
|
868
|
-
const length = faces.length;
|
|
869
|
-
|
|
870
|
-
// tag faces
|
|
871
|
-
|
|
872
|
-
for ( let i = 0; i < length; i ++ ) {
|
|
873
|
-
|
|
874
|
-
faces[ i ]._id = i;
|
|
875
|
-
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
// sort faces
|
|
879
|
-
|
|
880
|
-
function materialIndexSort( a, b ) {
|
|
881
|
-
|
|
882
|
-
return a.materialIndex - b.materialIndex;
|
|
883
|
-
|
|
884
|
-
}
|
|
885
|
-
|
|
886
|
-
faces.sort( materialIndexSort );
|
|
887
|
-
|
|
888
|
-
// sort uvs
|
|
889
|
-
|
|
890
|
-
const uvs1 = this.faceVertexUvs[ 0 ];
|
|
891
|
-
const uvs2 = this.faceVertexUvs[ 1 ];
|
|
892
|
-
|
|
893
|
-
let newUvs1, newUvs2;
|
|
894
|
-
|
|
895
|
-
if ( uvs1 && uvs1.length === length ) newUvs1 = [];
|
|
896
|
-
if ( uvs2 && uvs2.length === length ) newUvs2 = [];
|
|
897
|
-
|
|
898
|
-
for ( let i = 0; i < length; i ++ ) {
|
|
899
|
-
|
|
900
|
-
const id = faces[ i ]._id;
|
|
901
|
-
|
|
902
|
-
if ( newUvs1 ) newUvs1.push( uvs1[ id ] );
|
|
903
|
-
if ( newUvs2 ) newUvs2.push( uvs2[ id ] );
|
|
904
|
-
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
if ( newUvs1 ) this.faceVertexUvs[ 0 ] = newUvs1;
|
|
908
|
-
if ( newUvs2 ) this.faceVertexUvs[ 1 ] = newUvs2;
|
|
909
|
-
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
toJSON() {
|
|
913
|
-
|
|
914
|
-
const data = {
|
|
915
|
-
metadata: {
|
|
916
|
-
version: 4.5,
|
|
917
|
-
type: 'Geometry',
|
|
918
|
-
generator: 'Geometry.toJSON'
|
|
919
|
-
}
|
|
920
|
-
};
|
|
921
|
-
|
|
922
|
-
// standard Geometry serialization
|
|
923
|
-
|
|
924
|
-
data.uuid = this.uuid;
|
|
925
|
-
data.type = this.type;
|
|
926
|
-
if ( this.name !== '' ) data.name = this.name;
|
|
927
|
-
|
|
928
|
-
if ( this.parameters !== undefined ) {
|
|
929
|
-
|
|
930
|
-
const parameters = this.parameters;
|
|
931
|
-
|
|
932
|
-
for ( const key in parameters ) {
|
|
933
|
-
|
|
934
|
-
if ( parameters[ key ] !== undefined ) data[ key ] = parameters[ key ];
|
|
935
|
-
|
|
936
|
-
}
|
|
937
|
-
|
|
938
|
-
return data;
|
|
939
|
-
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
const vertices = [];
|
|
943
|
-
|
|
944
|
-
for ( let i = 0; i < this.vertices.length; i ++ ) {
|
|
945
|
-
|
|
946
|
-
const vertex = this.vertices[ i ];
|
|
947
|
-
vertices.push( vertex.x, vertex.y, vertex.z );
|
|
948
|
-
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
const faces = [];
|
|
952
|
-
const normals = [];
|
|
953
|
-
const normalsHash = {};
|
|
954
|
-
const colors = [];
|
|
955
|
-
const colorsHash = {};
|
|
956
|
-
const uvs = [];
|
|
957
|
-
const uvsHash = {};
|
|
958
|
-
|
|
959
|
-
for ( let i = 0; i < this.faces.length; i ++ ) {
|
|
960
|
-
|
|
961
|
-
const face = this.faces[ i ];
|
|
962
|
-
|
|
963
|
-
const hasMaterial = true;
|
|
964
|
-
const hasFaceUv = false; // deprecated
|
|
965
|
-
const hasFaceVertexUv = this.faceVertexUvs[ 0 ][ i ] !== undefined;
|
|
966
|
-
const hasFaceNormal = face.normal.length() > 0;
|
|
967
|
-
const hasFaceVertexNormal = face.vertexNormals.length > 0;
|
|
968
|
-
const hasFaceColor = face.color.r !== 1 || face.color.g !== 1 || face.color.b !== 1;
|
|
969
|
-
const hasFaceVertexColor = face.vertexColors.length > 0;
|
|
970
|
-
|
|
971
|
-
let faceType = 0;
|
|
972
|
-
|
|
973
|
-
faceType = setBit( faceType, 0, 0 ); // isQuad
|
|
974
|
-
faceType = setBit( faceType, 1, hasMaterial );
|
|
975
|
-
faceType = setBit( faceType, 2, hasFaceUv );
|
|
976
|
-
faceType = setBit( faceType, 3, hasFaceVertexUv );
|
|
977
|
-
faceType = setBit( faceType, 4, hasFaceNormal );
|
|
978
|
-
faceType = setBit( faceType, 5, hasFaceVertexNormal );
|
|
979
|
-
faceType = setBit( faceType, 6, hasFaceColor );
|
|
980
|
-
faceType = setBit( faceType, 7, hasFaceVertexColor );
|
|
981
|
-
|
|
982
|
-
faces.push( faceType );
|
|
983
|
-
faces.push( face.a, face.b, face.c );
|
|
984
|
-
faces.push( face.materialIndex );
|
|
985
|
-
|
|
986
|
-
if ( hasFaceVertexUv ) {
|
|
987
|
-
|
|
988
|
-
const faceVertexUvs = this.faceVertexUvs[ 0 ][ i ];
|
|
989
|
-
|
|
990
|
-
faces.push(
|
|
991
|
-
getUvIndex( faceVertexUvs[ 0 ] ),
|
|
992
|
-
getUvIndex( faceVertexUvs[ 1 ] ),
|
|
993
|
-
getUvIndex( faceVertexUvs[ 2 ] )
|
|
994
|
-
);
|
|
995
|
-
|
|
996
|
-
}
|
|
997
|
-
|
|
998
|
-
if ( hasFaceNormal ) {
|
|
999
|
-
|
|
1000
|
-
faces.push( getNormalIndex( face.normal ) );
|
|
1001
|
-
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
|
-
if ( hasFaceVertexNormal ) {
|
|
1005
|
-
|
|
1006
|
-
const vertexNormals = face.vertexNormals;
|
|
1007
|
-
|
|
1008
|
-
faces.push(
|
|
1009
|
-
getNormalIndex( vertexNormals[ 0 ] ),
|
|
1010
|
-
getNormalIndex( vertexNormals[ 1 ] ),
|
|
1011
|
-
getNormalIndex( vertexNormals[ 2 ] )
|
|
1012
|
-
);
|
|
1013
|
-
|
|
1014
|
-
}
|
|
1015
|
-
|
|
1016
|
-
if ( hasFaceColor ) {
|
|
1017
|
-
|
|
1018
|
-
faces.push( getColorIndex( face.color ) );
|
|
1019
|
-
|
|
1020
|
-
}
|
|
1021
|
-
|
|
1022
|
-
if ( hasFaceVertexColor ) {
|
|
1023
|
-
|
|
1024
|
-
const vertexColors = face.vertexColors;
|
|
1025
|
-
|
|
1026
|
-
faces.push(
|
|
1027
|
-
getColorIndex( vertexColors[ 0 ] ),
|
|
1028
|
-
getColorIndex( vertexColors[ 1 ] ),
|
|
1029
|
-
getColorIndex( vertexColors[ 2 ] )
|
|
1030
|
-
);
|
|
1031
|
-
|
|
1032
|
-
}
|
|
1033
|
-
|
|
1034
|
-
}
|
|
1035
|
-
|
|
1036
|
-
function setBit( value, position, enabled ) {
|
|
1037
|
-
|
|
1038
|
-
return enabled ? value | ( 1 << position ) : value & ( ~ ( 1 << position ) );
|
|
1039
|
-
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
function getNormalIndex( normal ) {
|
|
1043
|
-
|
|
1044
|
-
const hash = normal.x.toString() + normal.y.toString() + normal.z.toString();
|
|
1045
|
-
|
|
1046
|
-
if ( normalsHash[ hash ] !== undefined ) {
|
|
1047
|
-
|
|
1048
|
-
return normalsHash[ hash ];
|
|
1049
|
-
|
|
1050
|
-
}
|
|
1051
|
-
|
|
1052
|
-
normalsHash[ hash ] = normals.length / 3;
|
|
1053
|
-
normals.push( normal.x, normal.y, normal.z );
|
|
1054
|
-
|
|
1055
|
-
return normalsHash[ hash ];
|
|
1056
|
-
|
|
1057
|
-
}
|
|
1058
|
-
|
|
1059
|
-
function getColorIndex( color ) {
|
|
1060
|
-
|
|
1061
|
-
const hash = color.r.toString() + color.g.toString() + color.b.toString();
|
|
1062
|
-
|
|
1063
|
-
if ( colorsHash[ hash ] !== undefined ) {
|
|
1064
|
-
|
|
1065
|
-
return colorsHash[ hash ];
|
|
1066
|
-
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
colorsHash[ hash ] = colors.length;
|
|
1070
|
-
colors.push( color.getHex() );
|
|
1071
|
-
|
|
1072
|
-
return colorsHash[ hash ];
|
|
1073
|
-
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
function getUvIndex( uv ) {
|
|
1077
|
-
|
|
1078
|
-
const hash = uv.x.toString() + uv.y.toString();
|
|
1079
|
-
|
|
1080
|
-
if ( uvsHash[ hash ] !== undefined ) {
|
|
1081
|
-
|
|
1082
|
-
return uvsHash[ hash ];
|
|
1083
|
-
|
|
1084
|
-
}
|
|
1085
|
-
|
|
1086
|
-
uvsHash[ hash ] = uvs.length / 2;
|
|
1087
|
-
uvs.push( uv.x, uv.y );
|
|
1088
|
-
|
|
1089
|
-
return uvsHash[ hash ];
|
|
1090
|
-
|
|
1091
|
-
}
|
|
1092
|
-
|
|
1093
|
-
data.data = {};
|
|
1094
|
-
|
|
1095
|
-
data.data.vertices = vertices;
|
|
1096
|
-
data.data.normals = normals;
|
|
1097
|
-
if ( colors.length > 0 ) data.data.colors = colors;
|
|
1098
|
-
if ( uvs.length > 0 ) data.data.uvs = [ uvs ]; // temporal backward compatibility
|
|
1099
|
-
data.data.faces = faces;
|
|
1100
|
-
|
|
1101
|
-
return data;
|
|
1102
|
-
|
|
1103
|
-
}
|
|
1104
|
-
|
|
1105
|
-
clone() {
|
|
1106
|
-
|
|
1107
|
-
/*
|
|
1108
|
-
// Handle primitives
|
|
1109
|
-
|
|
1110
|
-
const parameters = this.parameters;
|
|
1111
|
-
|
|
1112
|
-
if ( parameters !== undefined ) {
|
|
1113
|
-
|
|
1114
|
-
const values = [];
|
|
1115
|
-
|
|
1116
|
-
for ( const key in parameters ) {
|
|
1117
|
-
|
|
1118
|
-
values.push( parameters[ key ] );
|
|
1119
|
-
|
|
1120
|
-
}
|
|
1121
|
-
|
|
1122
|
-
const geometry = Object.create( this.constructor.prototype );
|
|
1123
|
-
this.constructor.apply( geometry, values );
|
|
1124
|
-
return geometry;
|
|
1125
|
-
|
|
1126
|
-
}
|
|
1127
|
-
|
|
1128
|
-
return new this.constructor().copy( this );
|
|
1129
|
-
*/
|
|
1130
|
-
|
|
1131
|
-
return new Geometry().copy( this );
|
|
1132
|
-
|
|
1133
|
-
}
|
|
1134
|
-
|
|
1135
|
-
copy( source ) {
|
|
1136
|
-
|
|
1137
|
-
// reset
|
|
1138
|
-
|
|
1139
|
-
this.vertices = [];
|
|
1140
|
-
this.colors = [];
|
|
1141
|
-
this.faces = [];
|
|
1142
|
-
this.faceVertexUvs = [[]];
|
|
1143
|
-
this.morphTargets = [];
|
|
1144
|
-
this.morphNormals = [];
|
|
1145
|
-
this.skinWeights = [];
|
|
1146
|
-
this.skinIndices = [];
|
|
1147
|
-
this.lineDistances = [];
|
|
1148
|
-
this.boundingBox = null;
|
|
1149
|
-
this.boundingSphere = null;
|
|
1150
|
-
|
|
1151
|
-
// name
|
|
1152
|
-
|
|
1153
|
-
this.name = source.name;
|
|
1154
|
-
|
|
1155
|
-
// vertices
|
|
1156
|
-
|
|
1157
|
-
const vertices = source.vertices;
|
|
1158
|
-
|
|
1159
|
-
for ( let i = 0, il = vertices.length; i < il; i ++ ) {
|
|
1160
|
-
|
|
1161
|
-
this.vertices.push( vertices[ i ].clone() );
|
|
1162
|
-
|
|
1163
|
-
}
|
|
1164
|
-
|
|
1165
|
-
// colors
|
|
1166
|
-
|
|
1167
|
-
const colors = source.colors;
|
|
1168
|
-
|
|
1169
|
-
for ( let i = 0, il = colors.length; i < il; i ++ ) {
|
|
1170
|
-
|
|
1171
|
-
this.colors.push( colors[ i ].clone() );
|
|
1172
|
-
|
|
1173
|
-
}
|
|
1174
|
-
|
|
1175
|
-
// faces
|
|
1176
|
-
|
|
1177
|
-
const faces = source.faces;
|
|
1178
|
-
|
|
1179
|
-
for ( let i = 0, il = faces.length; i < il; i ++ ) {
|
|
1180
|
-
|
|
1181
|
-
this.faces.push( faces[ i ].clone() );
|
|
1182
|
-
|
|
1183
|
-
}
|
|
1184
|
-
|
|
1185
|
-
// face vertex uvs
|
|
1186
|
-
|
|
1187
|
-
for ( let i = 0, il = source.faceVertexUvs.length; i < il; i ++ ) {
|
|
1188
|
-
|
|
1189
|
-
const faceVertexUvs = source.faceVertexUvs[ i ];
|
|
1190
|
-
|
|
1191
|
-
if ( this.faceVertexUvs[ i ] === undefined ) {
|
|
1192
|
-
|
|
1193
|
-
this.faceVertexUvs[ i ] = [];
|
|
1194
|
-
|
|
1195
|
-
}
|
|
1196
|
-
|
|
1197
|
-
for ( let j = 0, jl = faceVertexUvs.length; j < jl; j ++ ) {
|
|
1198
|
-
|
|
1199
|
-
const uvs = faceVertexUvs[ j ], uvsCopy = [];
|
|
1200
|
-
|
|
1201
|
-
for ( let k = 0, kl = uvs.length; k < kl; k ++ ) {
|
|
1202
|
-
|
|
1203
|
-
const uv = uvs[ k ];
|
|
1204
|
-
|
|
1205
|
-
uvsCopy.push( uv.clone() );
|
|
1206
|
-
|
|
1207
|
-
}
|
|
1208
|
-
|
|
1209
|
-
this.faceVertexUvs[ i ].push( uvsCopy );
|
|
1210
|
-
|
|
1211
|
-
}
|
|
1212
|
-
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
|
-
// morph targets
|
|
1216
|
-
|
|
1217
|
-
const morphTargets = source.morphTargets;
|
|
1218
|
-
|
|
1219
|
-
for ( let i = 0, il = morphTargets.length; i < il; i ++ ) {
|
|
1220
|
-
|
|
1221
|
-
const morphTarget = {};
|
|
1222
|
-
morphTarget.name = morphTargets[ i ].name;
|
|
1223
|
-
|
|
1224
|
-
// vertices
|
|
1225
|
-
|
|
1226
|
-
if ( morphTargets[ i ].vertices !== undefined ) {
|
|
1227
|
-
|
|
1228
|
-
morphTarget.vertices = [];
|
|
1229
|
-
|
|
1230
|
-
for ( let j = 0, jl = morphTargets[ i ].vertices.length; j < jl; j ++ ) {
|
|
1231
|
-
|
|
1232
|
-
morphTarget.vertices.push( morphTargets[ i ].vertices[ j ].clone() );
|
|
1233
|
-
|
|
1234
|
-
}
|
|
1235
|
-
|
|
1236
|
-
}
|
|
1237
|
-
|
|
1238
|
-
// normals
|
|
1239
|
-
|
|
1240
|
-
if ( morphTargets[ i ].normals !== undefined ) {
|
|
1241
|
-
|
|
1242
|
-
morphTarget.normals = [];
|
|
1243
|
-
|
|
1244
|
-
for ( let j = 0, jl = morphTargets[ i ].normals.length; j < jl; j ++ ) {
|
|
1245
|
-
|
|
1246
|
-
morphTarget.normals.push( morphTargets[ i ].normals[ j ].clone() );
|
|
1247
|
-
|
|
1248
|
-
}
|
|
1249
|
-
|
|
1250
|
-
}
|
|
1251
|
-
|
|
1252
|
-
this.morphTargets.push( morphTarget );
|
|
1253
|
-
|
|
1254
|
-
}
|
|
1255
|
-
|
|
1256
|
-
// morph normals
|
|
1257
|
-
|
|
1258
|
-
const morphNormals = source.morphNormals;
|
|
1259
|
-
|
|
1260
|
-
for ( let i = 0, il = morphNormals.length; i < il; i ++ ) {
|
|
1261
|
-
|
|
1262
|
-
const morphNormal = {};
|
|
1263
|
-
|
|
1264
|
-
// vertex normals
|
|
1265
|
-
|
|
1266
|
-
if ( morphNormals[ i ].vertexNormals !== undefined ) {
|
|
1267
|
-
|
|
1268
|
-
morphNormal.vertexNormals = [];
|
|
1269
|
-
|
|
1270
|
-
for ( let j = 0, jl = morphNormals[ i ].vertexNormals.length; j < jl; j ++ ) {
|
|
1271
|
-
|
|
1272
|
-
const srcVertexNormal = morphNormals[ i ].vertexNormals[ j ];
|
|
1273
|
-
const destVertexNormal = {};
|
|
1274
|
-
|
|
1275
|
-
destVertexNormal.a = srcVertexNormal.a.clone();
|
|
1276
|
-
destVertexNormal.b = srcVertexNormal.b.clone();
|
|
1277
|
-
destVertexNormal.c = srcVertexNormal.c.clone();
|
|
1278
|
-
|
|
1279
|
-
morphNormal.vertexNormals.push( destVertexNormal );
|
|
1280
|
-
|
|
1281
|
-
}
|
|
1282
|
-
|
|
1283
|
-
}
|
|
1284
|
-
|
|
1285
|
-
// face normals
|
|
1286
|
-
|
|
1287
|
-
if ( morphNormals[ i ].faceNormals !== undefined ) {
|
|
1288
|
-
|
|
1289
|
-
morphNormal.faceNormals = [];
|
|
1290
|
-
|
|
1291
|
-
for ( let j = 0, jl = morphNormals[ i ].faceNormals.length; j < jl; j ++ ) {
|
|
1292
|
-
|
|
1293
|
-
morphNormal.faceNormals.push( morphNormals[ i ].faceNormals[ j ].clone() );
|
|
1294
|
-
|
|
1295
|
-
}
|
|
1296
|
-
|
|
1297
|
-
}
|
|
1298
|
-
|
|
1299
|
-
this.morphNormals.push( morphNormal );
|
|
1300
|
-
|
|
1301
|
-
}
|
|
1302
|
-
|
|
1303
|
-
// skin weights
|
|
1304
|
-
|
|
1305
|
-
const skinWeights = source.skinWeights;
|
|
1306
|
-
|
|
1307
|
-
for ( let i = 0, il = skinWeights.length; i < il; i ++ ) {
|
|
1308
|
-
|
|
1309
|
-
this.skinWeights.push( skinWeights[ i ].clone() );
|
|
1310
|
-
|
|
1311
|
-
}
|
|
1312
|
-
|
|
1313
|
-
// skin indices
|
|
1314
|
-
|
|
1315
|
-
const skinIndices = source.skinIndices;
|
|
1316
|
-
|
|
1317
|
-
for ( let i = 0, il = skinIndices.length; i < il; i ++ ) {
|
|
1318
|
-
|
|
1319
|
-
this.skinIndices.push( skinIndices[ i ].clone() );
|
|
1320
|
-
|
|
1321
|
-
}
|
|
1322
|
-
|
|
1323
|
-
// line distances
|
|
1324
|
-
|
|
1325
|
-
const lineDistances = source.lineDistances;
|
|
1326
|
-
|
|
1327
|
-
for ( let i = 0, il = lineDistances.length; i < il; i ++ ) {
|
|
1328
|
-
|
|
1329
|
-
this.lineDistances.push( lineDistances[ i ] );
|
|
1330
|
-
|
|
1331
|
-
}
|
|
1332
|
-
|
|
1333
|
-
// bounding box
|
|
1334
|
-
|
|
1335
|
-
const boundingBox = source.boundingBox;
|
|
1336
|
-
|
|
1337
|
-
if ( boundingBox !== null ) {
|
|
1338
|
-
|
|
1339
|
-
this.boundingBox = boundingBox.clone();
|
|
1340
|
-
|
|
1341
|
-
}
|
|
1342
|
-
|
|
1343
|
-
// bounding sphere
|
|
1344
|
-
|
|
1345
|
-
const boundingSphere = source.boundingSphere;
|
|
1346
|
-
|
|
1347
|
-
if ( boundingSphere !== null ) {
|
|
1348
|
-
|
|
1349
|
-
this.boundingSphere = boundingSphere.clone();
|
|
1350
|
-
|
|
1351
|
-
}
|
|
1352
|
-
|
|
1353
|
-
// update flags
|
|
1354
|
-
|
|
1355
|
-
this.elementsNeedUpdate = source.elementsNeedUpdate;
|
|
1356
|
-
this.verticesNeedUpdate = source.verticesNeedUpdate;
|
|
1357
|
-
this.uvsNeedUpdate = source.uvsNeedUpdate;
|
|
1358
|
-
this.normalsNeedUpdate = source.normalsNeedUpdate;
|
|
1359
|
-
this.colorsNeedUpdate = source.colorsNeedUpdate;
|
|
1360
|
-
this.lineDistancesNeedUpdate = source.lineDistancesNeedUpdate;
|
|
1361
|
-
this.groupsNeedUpdate = source.groupsNeedUpdate;
|
|
1362
|
-
|
|
1363
|
-
return this;
|
|
1364
|
-
|
|
1365
|
-
}
|
|
1366
|
-
|
|
1367
|
-
toBufferGeometry() {
|
|
1368
|
-
|
|
1369
|
-
const geometry = new DirectGeometry().fromGeometry( this );
|
|
1370
|
-
|
|
1371
|
-
const buffergeometry = new BufferGeometry();
|
|
1372
|
-
|
|
1373
|
-
const positions = new Float32Array( geometry.vertices.length * 3 );
|
|
1374
|
-
buffergeometry.setAttribute( 'position', new BufferAttribute( positions, 3 ).copyVector3sArray( geometry.vertices ) );
|
|
1375
|
-
|
|
1376
|
-
if ( geometry.normals.length > 0 ) {
|
|
1377
|
-
|
|
1378
|
-
const normals = new Float32Array( geometry.normals.length * 3 );
|
|
1379
|
-
buffergeometry.setAttribute( 'normal', new BufferAttribute( normals, 3 ).copyVector3sArray( geometry.normals ) );
|
|
1380
|
-
|
|
1381
|
-
}
|
|
1382
|
-
|
|
1383
|
-
if ( geometry.colors.length > 0 ) {
|
|
1384
|
-
|
|
1385
|
-
const colors = new Float32Array( geometry.colors.length * 3 );
|
|
1386
|
-
buffergeometry.setAttribute( 'color', new BufferAttribute( colors, 3 ).copyColorsArray( geometry.colors ) );
|
|
1387
|
-
|
|
1388
|
-
}
|
|
1389
|
-
|
|
1390
|
-
if ( geometry.uvs.length > 0 ) {
|
|
1391
|
-
|
|
1392
|
-
const uvs = new Float32Array( geometry.uvs.length * 2 );
|
|
1393
|
-
buffergeometry.setAttribute( 'uv', new BufferAttribute( uvs, 2 ).copyVector2sArray( geometry.uvs ) );
|
|
1394
|
-
|
|
1395
|
-
}
|
|
1396
|
-
|
|
1397
|
-
if ( geometry.uvs2.length > 0 ) {
|
|
1398
|
-
|
|
1399
|
-
const uvs2 = new Float32Array( geometry.uvs2.length * 2 );
|
|
1400
|
-
buffergeometry.setAttribute( 'uv2', new BufferAttribute( uvs2, 2 ).copyVector2sArray( geometry.uvs2 ) );
|
|
1401
|
-
|
|
1402
|
-
}
|
|
1403
|
-
|
|
1404
|
-
// groups
|
|
1405
|
-
|
|
1406
|
-
buffergeometry.groups = geometry.groups;
|
|
1407
|
-
|
|
1408
|
-
// morphs
|
|
1409
|
-
|
|
1410
|
-
for ( const name in geometry.morphTargets ) {
|
|
1411
|
-
|
|
1412
|
-
const array = [];
|
|
1413
|
-
const morphTargets = geometry.morphTargets[ name ];
|
|
1414
|
-
|
|
1415
|
-
for ( let i = 0, l = morphTargets.length; i < l; i ++ ) {
|
|
1416
|
-
|
|
1417
|
-
const morphTarget = morphTargets[ i ];
|
|
1418
|
-
|
|
1419
|
-
const attribute = new Float32BufferAttribute( morphTarget.data.length * 3, 3 );
|
|
1420
|
-
attribute.name = morphTarget.name;
|
|
1421
|
-
|
|
1422
|
-
array.push( attribute.copyVector3sArray( morphTarget.data ) );
|
|
1423
|
-
|
|
1424
|
-
}
|
|
1425
|
-
|
|
1426
|
-
buffergeometry.morphAttributes[ name ] = array;
|
|
1427
|
-
|
|
1428
|
-
}
|
|
1429
|
-
|
|
1430
|
-
// skinning
|
|
1431
|
-
|
|
1432
|
-
if ( geometry.skinIndices.length > 0 ) {
|
|
1433
|
-
|
|
1434
|
-
const skinIndices = new Float32BufferAttribute( geometry.skinIndices.length * 4, 4 );
|
|
1435
|
-
buffergeometry.setAttribute( 'skinIndex', skinIndices.copyVector4sArray( geometry.skinIndices ) );
|
|
1436
|
-
|
|
1437
|
-
}
|
|
1438
|
-
|
|
1439
|
-
if ( geometry.skinWeights.length > 0 ) {
|
|
1440
|
-
|
|
1441
|
-
const skinWeights = new Float32BufferAttribute( geometry.skinWeights.length * 4, 4 );
|
|
1442
|
-
buffergeometry.setAttribute( 'skinWeight', skinWeights.copyVector4sArray( geometry.skinWeights ) );
|
|
1443
|
-
|
|
1444
|
-
}
|
|
1445
|
-
|
|
1446
|
-
//
|
|
1447
|
-
|
|
1448
|
-
if ( geometry.boundingSphere !== null ) {
|
|
1449
|
-
|
|
1450
|
-
buffergeometry.boundingSphere = geometry.boundingSphere.clone();
|
|
1451
|
-
|
|
1452
|
-
}
|
|
1453
|
-
|
|
1454
|
-
if ( geometry.boundingBox !== null ) {
|
|
1455
|
-
|
|
1456
|
-
buffergeometry.boundingBox = geometry.boundingBox.clone();
|
|
1457
|
-
|
|
1458
|
-
}
|
|
1459
|
-
|
|
1460
|
-
return buffergeometry;
|
|
1461
|
-
|
|
1462
|
-
}
|
|
1463
|
-
|
|
1464
|
-
computeTangents() {
|
|
1465
|
-
|
|
1466
|
-
console.error( 'THREE.Geometry: .computeTangents() has been removed.' );
|
|
1467
|
-
|
|
1468
|
-
}
|
|
1469
|
-
|
|
1470
|
-
computeLineDistances() {
|
|
1471
|
-
|
|
1472
|
-
console.error( 'THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.' );
|
|
1473
|
-
|
|
1474
|
-
}
|
|
1475
|
-
|
|
1476
|
-
applyMatrix( matrix ) {
|
|
1477
|
-
|
|
1478
|
-
console.warn( 'THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4().' );
|
|
1479
|
-
return this.applyMatrix4( matrix );
|
|
1480
|
-
|
|
1481
|
-
}
|
|
1482
|
-
|
|
1483
|
-
dispose() {
|
|
1484
|
-
|
|
1485
|
-
this.dispatchEvent( { type: 'dispose' } );
|
|
1486
|
-
|
|
1487
|
-
}
|
|
1488
|
-
|
|
1489
|
-
static createBufferGeometryFromObject( object ) {
|
|
1490
|
-
|
|
1491
|
-
let buffergeometry = new BufferGeometry();
|
|
1492
|
-
|
|
1493
|
-
const geometry = object.geometry;
|
|
1494
|
-
|
|
1495
|
-
if ( object.isPoints || object.isLine ) {
|
|
1496
|
-
|
|
1497
|
-
const positions = new Float32BufferAttribute( geometry.vertices.length * 3, 3 );
|
|
1498
|
-
const colors = new Float32BufferAttribute( geometry.colors.length * 3, 3 );
|
|
1499
|
-
|
|
1500
|
-
buffergeometry.setAttribute( 'position', positions.copyVector3sArray( geometry.vertices ) );
|
|
1501
|
-
buffergeometry.setAttribute( 'color', colors.copyColorsArray( geometry.colors ) );
|
|
1502
|
-
|
|
1503
|
-
if ( geometry.lineDistances && geometry.lineDistances.length === geometry.vertices.length ) {
|
|
1504
|
-
|
|
1505
|
-
const lineDistances = new Float32BufferAttribute( geometry.lineDistances.length, 1 );
|
|
1506
|
-
|
|
1507
|
-
buffergeometry.setAttribute( 'lineDistance', lineDistances.copyArray( geometry.lineDistances ) );
|
|
1508
|
-
|
|
1509
|
-
}
|
|
1510
|
-
|
|
1511
|
-
if ( geometry.boundingSphere !== null ) {
|
|
1512
|
-
|
|
1513
|
-
buffergeometry.boundingSphere = geometry.boundingSphere.clone();
|
|
1514
|
-
|
|
1515
|
-
}
|
|
1516
|
-
|
|
1517
|
-
if ( geometry.boundingBox !== null ) {
|
|
1518
|
-
|
|
1519
|
-
buffergeometry.boundingBox = geometry.boundingBox.clone();
|
|
1520
|
-
|
|
1521
|
-
}
|
|
1522
|
-
|
|
1523
|
-
} else if ( object.isMesh ) {
|
|
1524
|
-
|
|
1525
|
-
buffergeometry = geometry.toBufferGeometry();
|
|
1526
|
-
|
|
1527
|
-
}
|
|
1528
|
-
|
|
1529
|
-
return buffergeometry;
|
|
1530
|
-
|
|
1531
|
-
}
|
|
1532
|
-
|
|
1533
|
-
}
|
|
1534
|
-
|
|
1535
|
-
Geometry.prototype.isGeometry = true;
|
|
1536
|
-
|
|
1537
|
-
class DirectGeometry {
|
|
1538
|
-
|
|
1539
|
-
constructor() {
|
|
1540
|
-
|
|
1541
|
-
this.vertices = [];
|
|
1542
|
-
this.normals = [];
|
|
1543
|
-
this.colors = [];
|
|
1544
|
-
this.uvs = [];
|
|
1545
|
-
this.uvs2 = [];
|
|
1546
|
-
|
|
1547
|
-
this.groups = [];
|
|
1548
|
-
|
|
1549
|
-
this.morphTargets = {};
|
|
1550
|
-
|
|
1551
|
-
this.skinWeights = [];
|
|
1552
|
-
this.skinIndices = [];
|
|
1553
|
-
|
|
1554
|
-
// this.lineDistances = [];
|
|
1555
|
-
|
|
1556
|
-
this.boundingBox = null;
|
|
1557
|
-
this.boundingSphere = null;
|
|
1558
|
-
|
|
1559
|
-
// update flags
|
|
1560
|
-
|
|
1561
|
-
this.verticesNeedUpdate = false;
|
|
1562
|
-
this.normalsNeedUpdate = false;
|
|
1563
|
-
this.colorsNeedUpdate = false;
|
|
1564
|
-
this.uvsNeedUpdate = false;
|
|
1565
|
-
this.groupsNeedUpdate = false;
|
|
1566
|
-
|
|
1567
|
-
}
|
|
1568
|
-
|
|
1569
|
-
computeGroups( geometry ) {
|
|
1570
|
-
|
|
1571
|
-
const groups = [];
|
|
1572
|
-
|
|
1573
|
-
let group, i;
|
|
1574
|
-
let materialIndex = undefined;
|
|
1575
|
-
|
|
1576
|
-
const faces = geometry.faces;
|
|
1577
|
-
|
|
1578
|
-
for ( i = 0; i < faces.length; i ++ ) {
|
|
1579
|
-
|
|
1580
|
-
const face = faces[ i ];
|
|
1581
|
-
|
|
1582
|
-
// materials
|
|
1583
|
-
|
|
1584
|
-
if ( face.materialIndex !== materialIndex ) {
|
|
1585
|
-
|
|
1586
|
-
materialIndex = face.materialIndex;
|
|
1587
|
-
|
|
1588
|
-
if ( group !== undefined ) {
|
|
1589
|
-
|
|
1590
|
-
group.count = ( i * 3 ) - group.start;
|
|
1591
|
-
groups.push( group );
|
|
1592
|
-
|
|
1593
|
-
}
|
|
1594
|
-
|
|
1595
|
-
group = {
|
|
1596
|
-
start: i * 3,
|
|
1597
|
-
materialIndex: materialIndex
|
|
1598
|
-
};
|
|
1599
|
-
|
|
1600
|
-
}
|
|
1601
|
-
|
|
1602
|
-
}
|
|
1603
|
-
|
|
1604
|
-
if ( group !== undefined ) {
|
|
1605
|
-
|
|
1606
|
-
group.count = ( i * 3 ) - group.start;
|
|
1607
|
-
groups.push( group );
|
|
1608
|
-
|
|
1609
|
-
}
|
|
1610
|
-
|
|
1611
|
-
this.groups = groups;
|
|
1612
|
-
|
|
1613
|
-
}
|
|
1614
|
-
|
|
1615
|
-
fromGeometry( geometry ) {
|
|
1616
|
-
|
|
1617
|
-
const faces = geometry.faces;
|
|
1618
|
-
const vertices = geometry.vertices;
|
|
1619
|
-
const faceVertexUvs = geometry.faceVertexUvs;
|
|
1620
|
-
|
|
1621
|
-
const hasFaceVertexUv = faceVertexUvs[ 0 ] && faceVertexUvs[ 0 ].length > 0;
|
|
1622
|
-
const hasFaceVertexUv2 = faceVertexUvs[ 1 ] && faceVertexUvs[ 1 ].length > 0;
|
|
1623
|
-
|
|
1624
|
-
// morphs
|
|
1625
|
-
|
|
1626
|
-
const morphTargets = geometry.morphTargets;
|
|
1627
|
-
const morphTargetsLength = morphTargets.length;
|
|
1628
|
-
|
|
1629
|
-
let morphTargetsPosition;
|
|
1630
|
-
|
|
1631
|
-
if ( morphTargetsLength > 0 ) {
|
|
1632
|
-
|
|
1633
|
-
morphTargetsPosition = [];
|
|
1634
|
-
|
|
1635
|
-
for ( let i = 0; i < morphTargetsLength; i ++ ) {
|
|
1636
|
-
|
|
1637
|
-
morphTargetsPosition[ i ] = {
|
|
1638
|
-
name: morphTargets[ i ].name,
|
|
1639
|
-
data: []
|
|
1640
|
-
};
|
|
1641
|
-
|
|
1642
|
-
}
|
|
1643
|
-
|
|
1644
|
-
this.morphTargets.position = morphTargetsPosition;
|
|
1645
|
-
|
|
1646
|
-
}
|
|
1647
|
-
|
|
1648
|
-
const morphNormals = geometry.morphNormals;
|
|
1649
|
-
const morphNormalsLength = morphNormals.length;
|
|
1650
|
-
|
|
1651
|
-
let morphTargetsNormal;
|
|
1652
|
-
|
|
1653
|
-
if ( morphNormalsLength > 0 ) {
|
|
1654
|
-
|
|
1655
|
-
morphTargetsNormal = [];
|
|
1656
|
-
|
|
1657
|
-
for ( let i = 0; i < morphNormalsLength; i ++ ) {
|
|
1658
|
-
|
|
1659
|
-
morphTargetsNormal[ i ] = {
|
|
1660
|
-
name: morphNormals[ i ].name,
|
|
1661
|
-
data: []
|
|
1662
|
-
};
|
|
1663
|
-
|
|
1664
|
-
}
|
|
1665
|
-
|
|
1666
|
-
this.morphTargets.normal = morphTargetsNormal;
|
|
1667
|
-
|
|
1668
|
-
}
|
|
1669
|
-
|
|
1670
|
-
// skins
|
|
1671
|
-
|
|
1672
|
-
const skinIndices = geometry.skinIndices;
|
|
1673
|
-
const skinWeights = geometry.skinWeights;
|
|
1674
|
-
|
|
1675
|
-
const hasSkinIndices = skinIndices.length === vertices.length;
|
|
1676
|
-
const hasSkinWeights = skinWeights.length === vertices.length;
|
|
1677
|
-
|
|
1678
|
-
//
|
|
1679
|
-
|
|
1680
|
-
if ( vertices.length > 0 && faces.length === 0 ) {
|
|
1681
|
-
|
|
1682
|
-
console.error( 'THREE.DirectGeometry: Faceless geometries are not supported.' );
|
|
1683
|
-
|
|
1684
|
-
}
|
|
1685
|
-
|
|
1686
|
-
for ( let i = 0; i < faces.length; i ++ ) {
|
|
1687
|
-
|
|
1688
|
-
const face = faces[ i ];
|
|
1689
|
-
|
|
1690
|
-
this.vertices.push( vertices[ face.a ], vertices[ face.b ], vertices[ face.c ] );
|
|
1691
|
-
|
|
1692
|
-
const vertexNormals = face.vertexNormals;
|
|
1693
|
-
|
|
1694
|
-
if ( vertexNormals.length === 3 ) {
|
|
1695
|
-
|
|
1696
|
-
this.normals.push( vertexNormals[ 0 ], vertexNormals[ 1 ], vertexNormals[ 2 ] );
|
|
1697
|
-
|
|
1698
|
-
} else {
|
|
1699
|
-
|
|
1700
|
-
const normal = face.normal;
|
|
1701
|
-
|
|
1702
|
-
this.normals.push( normal, normal, normal );
|
|
1703
|
-
|
|
1704
|
-
}
|
|
1705
|
-
|
|
1706
|
-
const vertexColors = face.vertexColors;
|
|
1707
|
-
|
|
1708
|
-
if ( vertexColors.length === 3 ) {
|
|
1709
|
-
|
|
1710
|
-
this.colors.push( vertexColors[ 0 ], vertexColors[ 1 ], vertexColors[ 2 ] );
|
|
1711
|
-
|
|
1712
|
-
} else {
|
|
1713
|
-
|
|
1714
|
-
const color = face.color;
|
|
1715
|
-
|
|
1716
|
-
this.colors.push( color, color, color );
|
|
1717
|
-
|
|
1718
|
-
}
|
|
1719
|
-
|
|
1720
|
-
if ( hasFaceVertexUv === true ) {
|
|
1721
|
-
|
|
1722
|
-
const vertexUvs = faceVertexUvs[ 0 ][ i ];
|
|
1723
|
-
|
|
1724
|
-
if ( vertexUvs !== undefined ) {
|
|
1725
|
-
|
|
1726
|
-
this.uvs.push( vertexUvs[ 0 ], vertexUvs[ 1 ], vertexUvs[ 2 ] );
|
|
1727
|
-
|
|
1728
|
-
} else {
|
|
1729
|
-
|
|
1730
|
-
console.warn( 'THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ', i );
|
|
1731
|
-
|
|
1732
|
-
this.uvs.push( new Vector2(), new Vector2(), new Vector2() );
|
|
1733
|
-
|
|
1734
|
-
}
|
|
1735
|
-
|
|
1736
|
-
}
|
|
1737
|
-
|
|
1738
|
-
if ( hasFaceVertexUv2 === true ) {
|
|
1739
|
-
|
|
1740
|
-
const vertexUvs = faceVertexUvs[ 1 ][ i ];
|
|
1741
|
-
|
|
1742
|
-
if ( vertexUvs !== undefined ) {
|
|
1743
|
-
|
|
1744
|
-
this.uvs2.push( vertexUvs[ 0 ], vertexUvs[ 1 ], vertexUvs[ 2 ] );
|
|
1745
|
-
|
|
1746
|
-
} else {
|
|
1747
|
-
|
|
1748
|
-
console.warn( 'THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ', i );
|
|
1749
|
-
|
|
1750
|
-
this.uvs2.push( new Vector2(), new Vector2(), new Vector2() );
|
|
1751
|
-
|
|
1752
|
-
}
|
|
1753
|
-
|
|
1754
|
-
}
|
|
1755
|
-
|
|
1756
|
-
// morphs
|
|
1757
|
-
|
|
1758
|
-
for ( let j = 0; j < morphTargetsLength; j ++ ) {
|
|
1759
|
-
|
|
1760
|
-
const morphTarget = morphTargets[ j ].vertices;
|
|
1761
|
-
|
|
1762
|
-
morphTargetsPosition[ j ].data.push( morphTarget[ face.a ], morphTarget[ face.b ], morphTarget[ face.c ] );
|
|
1763
|
-
|
|
1764
|
-
}
|
|
1765
|
-
|
|
1766
|
-
for ( let j = 0; j < morphNormalsLength; j ++ ) {
|
|
1767
|
-
|
|
1768
|
-
const morphNormal = morphNormals[ j ].vertexNormals[ i ];
|
|
1769
|
-
|
|
1770
|
-
morphTargetsNormal[ j ].data.push( morphNormal.a, morphNormal.b, morphNormal.c );
|
|
1771
|
-
|
|
1772
|
-
}
|
|
1773
|
-
|
|
1774
|
-
// skins
|
|
1775
|
-
|
|
1776
|
-
if ( hasSkinIndices ) {
|
|
1777
|
-
|
|
1778
|
-
this.skinIndices.push( skinIndices[ face.a ], skinIndices[ face.b ], skinIndices[ face.c ] );
|
|
1779
|
-
|
|
1780
|
-
}
|
|
1781
|
-
|
|
1782
|
-
if ( hasSkinWeights ) {
|
|
1783
|
-
|
|
1784
|
-
this.skinWeights.push( skinWeights[ face.a ], skinWeights[ face.b ], skinWeights[ face.c ] );
|
|
1785
|
-
|
|
1786
|
-
}
|
|
1787
|
-
|
|
1788
|
-
}
|
|
1789
|
-
|
|
1790
|
-
this.computeGroups( geometry );
|
|
1791
|
-
|
|
1792
|
-
this.verticesNeedUpdate = geometry.verticesNeedUpdate;
|
|
1793
|
-
this.normalsNeedUpdate = geometry.normalsNeedUpdate;
|
|
1794
|
-
this.colorsNeedUpdate = geometry.colorsNeedUpdate;
|
|
1795
|
-
this.uvsNeedUpdate = geometry.uvsNeedUpdate;
|
|
1796
|
-
this.groupsNeedUpdate = geometry.groupsNeedUpdate;
|
|
1797
|
-
|
|
1798
|
-
if ( geometry.boundingSphere !== null ) {
|
|
1799
|
-
|
|
1800
|
-
this.boundingSphere = geometry.boundingSphere.clone();
|
|
1801
|
-
|
|
1802
|
-
}
|
|
1803
|
-
|
|
1804
|
-
if ( geometry.boundingBox !== null ) {
|
|
1805
|
-
|
|
1806
|
-
this.boundingBox = geometry.boundingBox.clone();
|
|
1807
|
-
|
|
1808
|
-
}
|
|
1809
|
-
|
|
1810
|
-
return this;
|
|
1811
|
-
|
|
1812
|
-
}
|
|
1813
|
-
|
|
1814
|
-
}
|
|
1815
|
-
|
|
1816
|
-
class Face3 {
|
|
1817
|
-
|
|
1818
|
-
constructor( a, b, c, normal, color, materialIndex = 0 ) {
|
|
1819
|
-
|
|
1820
|
-
this.a = a;
|
|
1821
|
-
this.b = b;
|
|
1822
|
-
this.c = c;
|
|
1823
|
-
|
|
1824
|
-
this.normal = ( normal && normal.isVector3 ) ? normal : new Vector3();
|
|
1825
|
-
this.vertexNormals = Array.isArray( normal ) ? normal : [];
|
|
1826
|
-
|
|
1827
|
-
this.color = ( color && color.isColor ) ? color : new Color();
|
|
1828
|
-
this.vertexColors = Array.isArray( color ) ? color : [];
|
|
1829
|
-
|
|
1830
|
-
this.materialIndex = materialIndex;
|
|
1831
|
-
|
|
1832
|
-
}
|
|
1833
|
-
|
|
1834
|
-
clone() {
|
|
1835
|
-
|
|
1836
|
-
return new this.constructor().copy( this );
|
|
1837
|
-
|
|
1838
|
-
}
|
|
1839
|
-
|
|
1840
|
-
copy( source ) {
|
|
1841
|
-
|
|
1842
|
-
this.a = source.a;
|
|
1843
|
-
this.b = source.b;
|
|
1844
|
-
this.c = source.c;
|
|
1845
|
-
|
|
1846
|
-
this.normal.copy( source.normal );
|
|
1847
|
-
this.color.copy( source.color );
|
|
1848
|
-
|
|
1849
|
-
this.materialIndex = source.materialIndex;
|
|
1850
|
-
|
|
1851
|
-
for ( let i = 0, il = source.vertexNormals.length; i < il; i ++ ) {
|
|
1852
|
-
|
|
1853
|
-
this.vertexNormals[ i ] = source.vertexNormals[ i ].clone();
|
|
1854
|
-
|
|
1855
|
-
}
|
|
1856
|
-
|
|
1857
|
-
for ( let i = 0, il = source.vertexColors.length; i < il; i ++ ) {
|
|
1858
|
-
|
|
1859
|
-
this.vertexColors[ i ] = source.vertexColors[ i ].clone();
|
|
1860
|
-
|
|
1861
|
-
}
|
|
1862
|
-
|
|
1863
|
-
return this;
|
|
1864
|
-
|
|
1865
|
-
}
|
|
1866
|
-
|
|
1867
|
-
}
|
|
1868
|
-
|
|
1869
|
-
export { Face3, Geometry };
|