@plastic-software/three 0.179.0 → 0.181.1
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/build/three.cjs +1108 -591
- package/build/three.core.js +616 -345
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +488 -250
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +37 -6
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +6576 -2152
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +6575 -2151
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/fonts/MPLUSRounded1c/MPLUSRounded1c-Regular.typeface.json.zip +0 -0
- package/examples/fonts/MPLUSRounded1c/OFL.txt +91 -0
- package/examples/jsm/Addons.js +1 -1
- package/examples/jsm/animation/CCDIKSolver.js +1 -1
- package/examples/jsm/controls/ArcballControls.js +8 -8
- package/examples/jsm/controls/DragControls.js +7 -57
- package/examples/jsm/controls/FirstPersonControls.js +3 -3
- package/examples/jsm/controls/FlyControls.js +1 -1
- package/examples/jsm/controls/OrbitControls.js +2 -2
- package/examples/jsm/controls/PointerLockControls.js +2 -10
- package/examples/jsm/controls/TrackballControls.js +1 -1
- package/examples/jsm/controls/TransformControls.js +1 -1
- package/examples/jsm/effects/AsciiEffect.js +8 -8
- package/examples/jsm/exporters/DRACOExporter.js +2 -2
- package/examples/jsm/exporters/EXRExporter.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +33 -25
- package/examples/jsm/exporters/KTX2Exporter.js +4 -2
- package/examples/jsm/exporters/PLYExporter.js +1 -1
- package/examples/jsm/exporters/USDZExporter.js +9 -2
- package/examples/jsm/geometries/DecalGeometry.js +2 -2
- package/examples/jsm/geometries/ParametricGeometry.js +1 -1
- package/examples/jsm/geometries/TeapotGeometry.js +2 -2
- package/examples/jsm/geometries/TextGeometry.js +3 -2
- package/examples/jsm/gpgpu/BitonicSort.js +715 -0
- package/examples/jsm/helpers/ViewHelper.js +43 -5
- package/examples/jsm/inspector/Inspector.js +427 -0
- package/examples/jsm/inspector/RendererInspector.js +415 -0
- package/examples/jsm/inspector/tabs/Console.js +204 -0
- package/examples/jsm/inspector/tabs/Parameters.js +332 -0
- package/examples/jsm/inspector/tabs/Performance.js +268 -0
- package/examples/jsm/inspector/tabs/Viewer.js +166 -0
- package/examples/jsm/inspector/ui/Graph.js +95 -0
- package/examples/jsm/inspector/ui/Item.js +170 -0
- package/examples/jsm/inspector/ui/List.js +75 -0
- package/examples/jsm/inspector/ui/Profiler.js +170 -0
- package/examples/jsm/inspector/ui/Style.js +654 -0
- package/examples/jsm/inspector/ui/Tab.js +46 -0
- package/examples/jsm/inspector/ui/Values.js +423 -0
- package/examples/jsm/inspector/ui/utils.js +56 -0
- package/examples/jsm/interactive/HTMLMesh.js +6 -10
- package/examples/jsm/interactive/InteractiveGroup.js +1 -1
- package/examples/jsm/interactive/SelectionBox.js +30 -0
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +1 -1
- package/examples/jsm/lines/Line2.js +3 -3
- package/examples/jsm/lines/LineGeometry.js +1 -1
- package/examples/jsm/lines/LineSegments2.js +2 -2
- package/examples/jsm/lines/Wireframe.js +2 -2
- package/examples/jsm/lines/WireframeGeometry2.js +1 -1
- package/examples/jsm/lines/webgpu/LineSegments2.js +1 -1
- package/examples/jsm/lines/webgpu/Wireframe.js +1 -1
- package/examples/jsm/loaders/3MFLoader.js +1 -1
- package/examples/jsm/loaders/ColladaLoader.js +3 -3
- package/examples/jsm/loaders/DDSLoader.js +1 -1
- package/examples/jsm/loaders/DRACOLoader.js +73 -22
- package/examples/jsm/loaders/EXRLoader.js +5 -5
- package/examples/jsm/loaders/FBXLoader.js +2 -2
- package/examples/jsm/loaders/FontLoader.js +23 -5
- package/examples/jsm/loaders/GLTFLoader.js +14 -8
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +5 -5
- package/examples/jsm/loaders/HDRLoader.js +486 -0
- package/examples/jsm/loaders/KTX2Loader.js +136 -49
- package/examples/jsm/loaders/KTXLoader.js +2 -2
- package/examples/jsm/loaders/LDrawLoader.js +1 -1
- package/examples/jsm/loaders/LUT3dlLoader.js +2 -2
- package/examples/jsm/loaders/LUTCubeLoader.js +1 -1
- package/examples/jsm/loaders/LWOLoader.js +2 -2
- package/examples/jsm/loaders/MaterialXLoader.js +22 -5
- package/examples/jsm/loaders/OBJLoader.js +1 -1
- package/examples/jsm/loaders/PDBLoader.js +1 -1
- package/examples/jsm/loaders/RGBELoader.js +7 -473
- package/examples/jsm/loaders/SVGLoader.js +2 -2
- package/examples/jsm/loaders/TTFLoader.js +4 -4
- package/examples/jsm/loaders/UltraHDRLoader.js +2 -2
- package/examples/jsm/loaders/lwo/IFFParser.js +1 -1
- package/examples/jsm/materials/WoodNodeMaterial.js +533 -0
- package/examples/jsm/math/ColorSpaces.js +19 -1
- package/examples/jsm/math/ConvexHull.js +3 -3
- package/examples/jsm/math/ImprovedNoise.js +1 -1
- package/examples/jsm/math/Lut.js +2 -2
- package/examples/jsm/math/SimplexNoise.js +1 -1
- package/examples/jsm/misc/MD2CharacterComplex.js +1 -1
- package/examples/jsm/misc/ProgressiveLightMap.js +9 -3
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +7 -1
- package/examples/jsm/misc/TubePainter.js +383 -40
- package/examples/jsm/misc/Volume.js +1 -1
- package/examples/jsm/modifiers/SimplifyModifier.js +1 -1
- package/examples/jsm/objects/ReflectorForSSRPass.js +1 -0
- package/examples/jsm/objects/Sky.js +1 -1
- package/examples/jsm/objects/SkyMesh.js +1 -1
- package/examples/jsm/objects/Water.js +3 -3
- package/examples/jsm/objects/WaterMesh.js +6 -6
- package/examples/jsm/postprocessing/GlitchPass.js +2 -2
- package/examples/jsm/postprocessing/OutlinePass.js +1 -1
- package/examples/jsm/postprocessing/SSRPass.js +37 -8
- package/examples/jsm/postprocessing/UnrealBloomPass.js +8 -6
- package/examples/jsm/renderers/CSS2DRenderer.js +16 -5
- package/examples/jsm/renderers/CSS3DRenderer.js +7 -6
- package/examples/jsm/renderers/SVGRenderer.js +1 -1
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +1 -1
- package/examples/jsm/shaders/AfterimageShader.js +1 -1
- package/examples/jsm/shaders/BleachBypassShader.js +1 -1
- package/examples/jsm/shaders/BokehShader.js +1 -1
- package/examples/jsm/shaders/BokehShader2.js +1 -1
- package/examples/jsm/shaders/DotScreenShader.js +1 -1
- package/examples/jsm/shaders/FocusShader.js +1 -1
- package/examples/jsm/shaders/GTAOShader.js +2 -2
- package/examples/jsm/shaders/GodRaysShader.js +1 -1
- package/examples/jsm/shaders/KaleidoShader.js +1 -1
- package/examples/jsm/shaders/PoissonDenoiseShader.js +2 -2
- package/examples/jsm/shaders/SSRShader.js +1 -1
- package/examples/jsm/shaders/SepiaShader.js +1 -1
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +1 -1
- package/examples/jsm/shaders/TriangleBlurShader.js +1 -1
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +1 -1
- package/examples/jsm/shaders/VignetteShader.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +22 -19
- package/examples/jsm/transpiler/TSLEncoder.js +9 -10
- package/examples/jsm/transpiler/WGSLEncoder.js +24 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +26 -24
- package/examples/jsm/tsl/display/AnamorphicNode.js +28 -4
- package/examples/jsm/tsl/display/BloomNode.js +7 -3
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +2 -1
- package/examples/jsm/tsl/display/DenoiseNode.js +2 -0
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +446 -90
- package/examples/jsm/tsl/display/GTAONode.js +53 -5
- package/examples/jsm/tsl/display/GaussianBlurNode.js +49 -35
- package/examples/jsm/tsl/display/OutlineNode.js +13 -2
- package/examples/jsm/tsl/display/SSGINode.js +654 -0
- package/examples/jsm/tsl/display/SSRNode.js +182 -65
- package/examples/jsm/tsl/display/SSSNode.js +488 -0
- package/examples/jsm/tsl/display/TRAANode.js +124 -7
- package/examples/jsm/tsl/display/boxBlur.js +65 -0
- package/examples/jsm/tsl/display/hashBlur.js +16 -18
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +21 -1
- package/examples/jsm/utils/BufferGeometryUtils.js +1 -1
- package/examples/jsm/utils/ShadowMapViewerGPU.js +12 -5
- package/examples/jsm/webxr/OculusHandModel.js +1 -1
- package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
- package/examples/jsm/webxr/XRHandModelFactory.js +2 -6
- package/package.json +5 -10
- package/src/Three.Core.js +4 -2
- package/src/Three.TSL.js +36 -5
- package/src/Three.WebGPU.Nodes.js +2 -0
- package/src/Three.WebGPU.js +2 -0
- package/src/animation/AnimationClip.js +20 -4
- package/src/animation/AnimationMixer.js +3 -3
- package/src/animation/AnimationObjectGroup.js +2 -1
- package/src/animation/KeyframeTrack.js +7 -6
- package/src/animation/PropertyBinding.js +12 -11
- package/src/audio/Audio.js +10 -9
- package/src/audio/PositionalAudio.js +1 -1
- package/src/cameras/OrthographicCamera.js +1 -1
- package/src/cameras/PerspectiveCamera.js +1 -1
- package/src/cameras/StereoCamera.js +2 -2
- package/src/constants.js +11 -3
- package/src/core/BufferGeometry.js +10 -10
- package/src/core/EventDispatcher.js +1 -1
- package/src/core/InterleavedBuffer.js +1 -1
- package/src/core/InterleavedBufferAttribute.js +3 -2
- package/src/core/Object3D.js +3 -2
- package/src/core/Raycaster.js +2 -1
- package/src/core/RenderTarget.js +10 -1
- package/src/extras/Controls.js +5 -4
- package/src/extras/DataUtils.js +2 -1
- package/src/extras/Earcut.js +6 -0
- package/src/extras/ImageUtils.js +2 -2
- package/src/extras/PMREMGenerator.js +268 -55
- package/src/extras/TextureUtils.js +2 -1
- package/src/extras/core/Curve.js +2 -1
- package/src/extras/core/Interpolations.js +7 -1
- package/src/extras/core/ShapePath.js +4 -4
- package/src/extras/lib/earcut.js +8 -8
- package/src/geometries/BoxGeometry.js +1 -0
- package/src/geometries/CapsuleGeometry.js +1 -0
- package/src/geometries/CircleGeometry.js +1 -0
- package/src/geometries/ConeGeometry.js +1 -0
- package/src/geometries/CylinderGeometry.js +1 -0
- package/src/geometries/DodecahedronGeometry.js +1 -0
- package/src/geometries/ExtrudeGeometry.js +8 -6
- package/src/geometries/IcosahedronGeometry.js +1 -0
- package/src/geometries/LatheGeometry.js +1 -0
- package/src/geometries/OctahedronGeometry.js +1 -0
- package/src/geometries/PlaneGeometry.js +1 -0
- package/src/geometries/RingGeometry.js +1 -0
- package/src/geometries/ShapeGeometry.js +1 -0
- package/src/geometries/SphereGeometry.js +1 -0
- package/src/geometries/TetrahedronGeometry.js +1 -0
- package/src/geometries/TorusGeometry.js +1 -0
- package/src/geometries/TorusKnotGeometry.js +1 -0
- package/src/geometries/TubeGeometry.js +1 -0
- package/src/helpers/CameraHelper.js +1 -1
- package/src/lights/webgpu/ProjectorLight.js +1 -1
- package/src/loaders/AnimationLoader.js +2 -1
- package/src/loaders/AudioLoader.js +2 -1
- package/src/loaders/BufferGeometryLoader.js +2 -2
- package/src/loaders/Cache.js +2 -2
- package/src/loaders/DataTextureLoader.js +1 -1
- package/src/loaders/FileLoader.js +3 -2
- package/src/loaders/ImageBitmapLoader.js +5 -4
- package/src/loaders/ImageLoader.js +1 -1
- package/src/loaders/Loader.js +3 -3
- package/src/loaders/LoadingManager.js +25 -3
- package/src/loaders/MaterialLoader.js +3 -2
- package/src/loaders/ObjectLoader.js +13 -13
- package/src/loaders/TextureLoader.js +1 -1
- package/src/loaders/nodes/NodeLoader.js +3 -2
- package/src/materials/Material.js +16 -3
- package/src/materials/MeshBasicMaterial.js +1 -0
- package/src/materials/MeshDepthMaterial.js +1 -0
- package/src/materials/MeshDistanceMaterial.js +1 -1
- package/src/materials/MeshLambertMaterial.js +2 -1
- package/src/materials/MeshMatcapMaterial.js +22 -0
- package/src/materials/MeshNormalMaterial.js +1 -0
- package/src/materials/MeshPhongMaterial.js +2 -1
- package/src/materials/MeshPhysicalMaterial.js +2 -1
- package/src/materials/MeshStandardMaterial.js +8 -7
- package/src/materials/MeshToonMaterial.js +1 -0
- package/src/materials/PointsMaterial.js +1 -1
- package/src/materials/ShaderMaterial.js +2 -2
- package/src/materials/nodes/Line2NodeMaterial.js +2 -2
- package/src/materials/nodes/MeshSSSNodeMaterial.js +1 -1
- package/src/materials/nodes/NodeMaterial.js +62 -22
- package/src/materials/nodes/PointsNodeMaterial.js +81 -28
- package/src/materials/nodes/SpriteNodeMaterial.js +3 -15
- package/src/materials/nodes/manager/NodeMaterialObserver.js +3 -2
- package/src/math/Color.js +6 -5
- package/src/math/ColorManagement.js +9 -3
- package/src/math/Cylindrical.js +1 -1
- package/src/math/Euler.js +2 -1
- package/src/math/MathUtils.js +13 -11
- package/src/math/Matrix2.js +1 -1
- package/src/math/Matrix3.js +2 -2
- package/src/math/Matrix4.js +7 -7
- package/src/math/Plane.js +1 -1
- package/src/math/Quaternion.js +68 -66
- package/src/math/Spherical.js +1 -1
- package/src/nodes/Nodes.js +4 -1
- package/src/nodes/TSL.js +4 -1
- package/src/nodes/accessors/BufferNode.js +1 -1
- package/src/nodes/accessors/Camera.js +133 -7
- package/src/nodes/accessors/ClippingNode.js +6 -5
- package/src/nodes/accessors/CubeTextureNode.js +5 -4
- package/src/nodes/accessors/InstanceNode.js +25 -5
- package/src/nodes/accessors/Lights.js +10 -0
- package/src/nodes/accessors/Normal.js +5 -4
- package/src/nodes/accessors/Object3DNode.js +1 -1
- package/src/nodes/accessors/Position.js +18 -2
- package/src/nodes/accessors/ReferenceBaseNode.js +1 -1
- package/src/nodes/accessors/ReferenceNode.js +3 -2
- package/src/nodes/accessors/SceneNode.js +2 -1
- package/src/nodes/accessors/StorageBufferNode.js +2 -1
- package/src/nodes/accessors/StorageTextureNode.js +22 -0
- package/src/nodes/accessors/Texture3DNode.js +14 -1
- package/src/nodes/accessors/TextureNode.js +130 -44
- package/src/nodes/code/FunctionCallNode.js +24 -4
- package/src/nodes/code/FunctionNode.js +23 -0
- package/src/nodes/core/ArrayNode.js +1 -0
- package/src/nodes/core/AssignNode.js +4 -3
- package/src/nodes/core/AttributeNode.js +2 -1
- package/src/nodes/core/ContextNode.js +29 -10
- package/src/nodes/core/IndexNode.js +2 -2
- package/src/nodes/core/InputNode.js +2 -1
- package/src/nodes/core/InspectorNode.js +128 -0
- package/src/nodes/core/{CacheNode.js → IsolateNode.js} +40 -7
- package/src/nodes/core/Node.js +152 -31
- package/src/nodes/core/NodeBuilder.js +183 -35
- package/src/nodes/core/NodeFrame.js +21 -21
- package/src/nodes/core/NodeFunction.js +2 -1
- package/src/nodes/core/NodeParser.js +2 -1
- package/src/nodes/core/NodeUniform.js +1 -1
- package/src/nodes/core/NodeUtils.js +17 -91
- package/src/nodes/core/ParameterNode.js +31 -0
- package/src/nodes/core/PropertyNode.js +7 -0
- package/src/nodes/core/StackNode.js +43 -16
- package/src/nodes/core/StructNode.js +5 -5
- package/src/nodes/core/StructTypeNode.js +1 -0
- package/src/nodes/core/SubBuildNode.js +2 -2
- package/src/nodes/core/UniformNode.js +18 -10
- package/src/nodes/core/VarNode.js +70 -33
- package/src/nodes/core/VaryingNode.js +3 -2
- package/src/nodes/display/BlendModes.js +5 -4
- package/src/nodes/display/BumpMapNode.js +1 -1
- package/src/nodes/display/ColorAdjustment.js +1 -1
- package/src/nodes/display/FrontFacingNode.js +4 -8
- package/src/nodes/display/NormalMapNode.js +2 -1
- package/src/nodes/display/PassNode.js +52 -11
- package/src/nodes/display/RenderOutputNode.js +28 -2
- package/src/nodes/display/ScreenNode.js +44 -14
- package/src/nodes/display/ToneMappingNode.js +31 -4
- package/src/nodes/display/ToonOutlinePassNode.js +8 -0
- package/src/nodes/display/ViewportDepthTextureNode.js +16 -4
- package/src/nodes/display/ViewportSharedTextureNode.js +12 -0
- package/src/nodes/display/ViewportTextureNode.js +42 -12
- package/src/nodes/fog/Fog.js +3 -2
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +52 -0
- package/src/nodes/functions/BSDF/DFGApprox.js +60 -19
- package/src/nodes/functions/BasicLightingModel.js +2 -1
- package/src/nodes/functions/PhysicalLightingModel.js +3 -2
- package/src/nodes/functions/VolumetricLightingModel.js +5 -5
- package/src/nodes/geometry/RangeNode.js +40 -4
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +2 -1
- package/src/nodes/gpgpu/ComputeNode.js +17 -5
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +455 -0
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +2 -1
- package/src/nodes/lighting/EnvironmentNode.js +6 -6
- package/src/nodes/lighting/LightsNode.js +3 -4
- package/src/nodes/lighting/PointShadowNode.js +6 -0
- package/src/nodes/lighting/ShadowFilterNode.js +2 -0
- package/src/nodes/lighting/ShadowNode.js +75 -8
- package/src/nodes/math/BitcastNode.js +156 -0
- package/src/nodes/math/ConditionalNode.js +24 -7
- package/src/nodes/math/MathNode.js +25 -19
- package/src/nodes/math/OperatorNode.js +7 -5
- package/src/nodes/pmrem/PMREMUtils.js +117 -2
- package/src/nodes/shapes/Shapes.js +1 -1
- package/src/nodes/tsl/TSLBase.js +5 -2
- package/src/nodes/tsl/TSLCore.js +460 -159
- package/src/nodes/utils/DebugNode.js +2 -1
- package/src/nodes/utils/EventNode.js +36 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +37 -19
- package/src/nodes/utils/JoinNode.js +6 -3
- package/src/nodes/utils/LoopNode.js +20 -24
- package/src/nodes/utils/MemberNode.js +59 -7
- package/src/nodes/utils/PostProcessingUtils.js +28 -1
- package/src/nodes/utils/RTTNode.js +13 -3
- package/src/nodes/utils/ReflectorNode.js +58 -7
- package/src/nodes/utils/SampleNode.js +12 -2
- package/src/nodes/utils/SplitNode.js +11 -0
- package/src/nodes/utils/Timer.js +0 -47
- package/src/objects/BatchedMesh.js +2 -2
- package/src/objects/LOD.js +1 -1
- package/src/objects/Line.js +2 -1
- package/src/objects/LineSegments.js +2 -1
- package/src/objects/Skeleton.js +3 -2
- package/src/objects/SkinnedMesh.js +3 -1
- package/src/objects/Sprite.js +4 -3
- package/src/renderers/WebGLRenderer.js +48 -41
- package/src/renderers/common/Animation.js +13 -1
- package/src/renderers/common/Attributes.js +1 -1
- package/src/renderers/common/Backend.js +108 -27
- package/src/renderers/common/Background.js +2 -1
- package/src/renderers/common/Bindings.js +58 -2
- package/src/renderers/common/CanvasTarget.js +341 -0
- package/src/renderers/common/ChainMap.js +1 -1
- package/src/renderers/common/DataMap.js +1 -1
- package/src/renderers/common/Geometries.js +26 -0
- package/src/renderers/common/Info.js +4 -2
- package/src/renderers/common/InspectorBase.js +146 -0
- package/src/renderers/common/Pipelines.js +1 -1
- package/src/renderers/common/PostProcessing.js +6 -25
- package/src/renderers/common/QuadMesh.js +7 -1
- package/src/renderers/common/RenderContext.js +2 -2
- package/src/renderers/common/RenderList.js +7 -3
- package/src/renderers/common/RenderObject.js +16 -2
- package/src/renderers/common/RenderObjects.js +1 -1
- package/src/renderers/common/Renderer.js +473 -245
- package/src/renderers/common/RendererUtils.js +9 -0
- package/src/renderers/common/SampledTexture.js +9 -1
- package/src/renderers/common/Sampler.js +50 -12
- package/src/renderers/common/StorageTexture.js +9 -1
- package/src/renderers/common/Textures.js +121 -45
- package/src/renderers/common/TimestampQueryPool.js +65 -3
- package/src/renderers/common/UniformsGroup.js +2 -1
- package/src/renderers/common/XRManager.js +42 -22
- package/src/renderers/common/extras/PMREMGenerator.js +160 -65
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/NodeLibrary.js +9 -7
- package/src/renderers/common/nodes/NodeSampler.js +13 -1
- package/src/renderers/common/nodes/Nodes.js +38 -16
- package/src/renderers/shaders/DFGLUTData.js +64 -0
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -12
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +52 -18
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +7 -15
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +1 -1
- package/src/renderers/shaders/UniformsLib.js +1 -0
- package/src/renderers/shaders/UniformsUtils.js +25 -4
- package/src/renderers/webgl/WebGLCapabilities.js +2 -1
- package/src/renderers/webgl/WebGLExtensions.js +2 -25
- package/src/renderers/webgl/WebGLInfo.js +3 -1
- package/src/renderers/webgl/WebGLProgram.js +15 -14
- package/src/renderers/webgl/WebGLPrograms.js +2 -1
- package/src/renderers/webgl/WebGLShadowMap.js +3 -2
- package/src/renderers/webgl/WebGLState.js +15 -14
- package/src/renderers/webgl/WebGLTextures.js +19 -14
- package/src/renderers/webgl/WebGLUniformsGroups.js +5 -3
- package/src/renderers/webgl/WebGLUtils.js +3 -2
- package/src/renderers/webgl-fallback/WebGLBackend.js +199 -167
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +181 -25
- package/src/renderers/webgl-fallback/utils/WebGLConstants.js +2 -3
- package/src/renderers/webgl-fallback/utils/WebGLState.js +7 -6
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +169 -19
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +51 -22
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +3 -2
- package/src/renderers/webgpu/WebGPUBackend.js +153 -123
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +2 -1
- package/src/renderers/webgpu/WebGPURenderer.js +3 -2
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +142 -50
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +2 -1
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +5 -3
- package/src/renderers/webgpu/utils/WebGPUConstants.js +7 -2
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +53 -34
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +6 -8
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +260 -99
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +32 -9
- package/src/renderers/webgpu/utils/WebGPUUtils.js +22 -2
- package/src/renderers/webxr/WebXRManager.js +42 -26
- package/src/textures/ExternalTexture.js +15 -4
- package/src/textures/Source.js +3 -2
- package/src/textures/Texture.js +3 -2
- package/src/textures/VideoTexture.js +2 -3
- package/src/utils.js +67 -3
- package/examples/jsm/loaders/RGBMLoader.js +0 -1148
|
@@ -7,7 +7,7 @@ import { Material } from './Material.js';
|
|
|
7
7
|
* Can also be used to customize the shadow casting of an object by assigning
|
|
8
8
|
* an instance of `MeshDistanceMaterial` to {@link Object3D#customDistanceMaterial}.
|
|
9
9
|
* The following examples demonstrates this approach in order to ensure
|
|
10
|
-
* transparent parts of objects do
|
|
10
|
+
* transparent parts of objects do not cast shadows.
|
|
11
11
|
*
|
|
12
12
|
* @augments Material
|
|
13
13
|
*/
|
|
@@ -7,7 +7,7 @@ import { Euler } from '../math/Euler.js';
|
|
|
7
7
|
/**
|
|
8
8
|
* A material for non-shiny surfaces, without specular highlights.
|
|
9
9
|
*
|
|
10
|
-
* The material uses a non-physically based [Lambertian]
|
|
10
|
+
* The material uses a non-physically based [Lambertian](https://en.wikipedia.org/wiki/Lambertian_reflectance)
|
|
11
11
|
* model for calculating reflectance. This can simulate some surfaces (such
|
|
12
12
|
* as untreated wood or stone) well, but cannot simulate shiny surfaces with
|
|
13
13
|
* specular highlights (such as varnished wood). `MeshLambertMaterial` uses per-fragment
|
|
@@ -19,6 +19,7 @@ import { Euler } from '../math/Euler.js';
|
|
|
19
19
|
* {@link MeshPhysicalMaterial}, at the cost of some graphical accuracy.
|
|
20
20
|
*
|
|
21
21
|
* @augments Material
|
|
22
|
+
* @demo scenes/material-browser.html#MeshLambertMaterial
|
|
22
23
|
*/
|
|
23
24
|
class MeshLambertMaterial extends Material {
|
|
24
25
|
|
|
@@ -13,6 +13,7 @@ import { Color } from '../math/Color.js';
|
|
|
13
13
|
* shadows.
|
|
14
14
|
*
|
|
15
15
|
* @augments Material
|
|
16
|
+
* @demo scenes/material-browser.html#MeshMatcapMaterial
|
|
16
17
|
*/
|
|
17
18
|
class MeshMatcapMaterial extends Material {
|
|
18
19
|
|
|
@@ -164,6 +165,24 @@ class MeshMatcapMaterial extends Material {
|
|
|
164
165
|
*/
|
|
165
166
|
this.alphaMap = null;
|
|
166
167
|
|
|
168
|
+
/**
|
|
169
|
+
* Renders the geometry as a wireframe.
|
|
170
|
+
*
|
|
171
|
+
* @type {boolean}
|
|
172
|
+
* @default false
|
|
173
|
+
*/
|
|
174
|
+
this.wireframe = false;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Controls the thickness of the wireframe.
|
|
178
|
+
*
|
|
179
|
+
* Can only be used with {@link SVGRenderer}.
|
|
180
|
+
*
|
|
181
|
+
* @type {number}
|
|
182
|
+
* @default 1
|
|
183
|
+
*/
|
|
184
|
+
this.wireframeLinewidth = 1;
|
|
185
|
+
|
|
167
186
|
/**
|
|
168
187
|
* Whether the material is rendered with flat shading or not.
|
|
169
188
|
*
|
|
@@ -210,6 +229,9 @@ class MeshMatcapMaterial extends Material {
|
|
|
210
229
|
|
|
211
230
|
this.alphaMap = source.alphaMap;
|
|
212
231
|
|
|
232
|
+
this.wireframe = source.wireframe;
|
|
233
|
+
this.wireframeLinewidth = source.wireframeLinewidth;
|
|
234
|
+
|
|
213
235
|
this.flatShading = source.flatShading;
|
|
214
236
|
|
|
215
237
|
this.fog = source.fog;
|
|
@@ -7,7 +7,7 @@ import { Euler } from '../math/Euler.js';
|
|
|
7
7
|
/**
|
|
8
8
|
* A material for shiny surfaces with specular highlights.
|
|
9
9
|
*
|
|
10
|
-
* The material uses a non-physically based [Blinn-Phong]
|
|
10
|
+
* The material uses a non-physically based [Blinn-Phong](https://en.wikipedia.org/wiki/Blinn-Phong_shading_model)
|
|
11
11
|
* model for calculating reflectance. Unlike the Lambertian model used in the
|
|
12
12
|
* {@link MeshLambertMaterial} this can simulate shiny surfaces with specular
|
|
13
13
|
* highlights (such as varnished wood). `MeshPhongMaterial` uses per-fragment shading.
|
|
@@ -17,6 +17,7 @@ import { Euler } from '../math/Euler.js';
|
|
|
17
17
|
* some graphical accuracy.
|
|
18
18
|
*
|
|
19
19
|
* @augments Material
|
|
20
|
+
* @demo scenes/material-browser.html#MeshPhongMaterial
|
|
20
21
|
*/
|
|
21
22
|
class MeshPhongMaterial extends Material {
|
|
22
23
|
|
|
@@ -27,6 +27,7 @@ import { clamp } from '../math/MathUtils.js';
|
|
|
27
27
|
* best results, always specify an environment map when using this material.
|
|
28
28
|
*
|
|
29
29
|
* @augments MeshStandardMaterial
|
|
30
|
+
* @demo scenes/material-browser.html#MeshPhysicalMaterial
|
|
30
31
|
*/
|
|
31
32
|
class MeshPhysicalMaterial extends MeshStandardMaterial {
|
|
32
33
|
|
|
@@ -323,7 +324,7 @@ class MeshPhysicalMaterial extends MeshStandardMaterial {
|
|
|
323
324
|
}
|
|
324
325
|
|
|
325
326
|
/**
|
|
326
|
-
* The anisotropy strength.
|
|
327
|
+
* The anisotropy strength, from `0.0` to `1.0`.
|
|
327
328
|
*
|
|
328
329
|
* @type {number}
|
|
329
330
|
* @default 0
|
|
@@ -8,9 +8,9 @@ import { Euler } from '../math/Euler.js';
|
|
|
8
8
|
* A standard physically based material, using Metallic-Roughness workflow.
|
|
9
9
|
*
|
|
10
10
|
* Physically based rendering (PBR) has recently become the standard in many
|
|
11
|
-
* 3D applications, such as [Unity]
|
|
12
|
-
* [Unreal]
|
|
13
|
-
* [3D Studio Max]
|
|
11
|
+
* 3D applications, such as [Unity](https://blogs.unity3d.com/2014/10/29/physically-based-shading-in-unity-5-a-primer/),
|
|
12
|
+
* [Unreal](https://docs.unrealengine.com/latest/INT/Engine/Rendering/Materials/PhysicallyBased/) and
|
|
13
|
+
* [3D Studio Max](http://area.autodesk.com/blogs/the-3ds-max-blog/what039s-new-for-rendering-in-3ds-max-2017).
|
|
14
14
|
*
|
|
15
15
|
* This approach differs from older approaches in that instead of using
|
|
16
16
|
* approximations for the way in which light interacts with a surface, a
|
|
@@ -26,16 +26,17 @@ import { Euler } from '../math/Euler.js';
|
|
|
26
26
|
* Note that for best results you should always specify an environment map when using this material.
|
|
27
27
|
*
|
|
28
28
|
* For a non-technical introduction to the concept of PBR and how to set up a
|
|
29
|
-
* PBR material, check out these articles by the people at [marmoset]
|
|
29
|
+
* PBR material, check out these articles by the people at [marmoset](https://www.marmoset.co):
|
|
30
30
|
*
|
|
31
|
-
* - [Basic Theory of Physically Based Rendering]
|
|
32
|
-
* - [Physically Based Rendering and You Can Too]
|
|
31
|
+
* - [Basic Theory of Physically Based Rendering](https://www.marmoset.co/posts/basic-theory-of-physically-based-rendering/)
|
|
32
|
+
* - [Physically Based Rendering and You Can Too](https://www.marmoset.co/posts/physically-based-rendering-and-you-can-too/)
|
|
33
33
|
*
|
|
34
34
|
* Technical details of the approach used in three.js (and most other PBR systems) can be found is this
|
|
35
|
-
* [paper from Disney]
|
|
35
|
+
* [paper from Disney](https://media.disneyanimation.com/uploads/production/publication_asset/48/asset/s2012_pbs_disney_brdf_notes_v3.pdf)
|
|
36
36
|
* (pdf), by Brent Burley.
|
|
37
37
|
*
|
|
38
38
|
* @augments Material
|
|
39
|
+
* @demo scenes/material-browser.html#MeshStandardMaterial
|
|
39
40
|
*/
|
|
40
41
|
class MeshStandardMaterial extends Material {
|
|
41
42
|
|
|
@@ -88,7 +88,7 @@ class PointsMaterial extends Material {
|
|
|
88
88
|
/**
|
|
89
89
|
* Defines the size of the points in pixels.
|
|
90
90
|
*
|
|
91
|
-
* Might be capped if the value exceeds hardware dependent parameters like [gl.ALIASED_POINT_SIZE_RANGE]
|
|
91
|
+
* Might be capped if the value exceeds hardware dependent parameters like [gl.ALIASED_POINT_SIZE_RANGE](https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getParamete).
|
|
92
92
|
*
|
|
93
93
|
* @type {number}
|
|
94
94
|
* @default 1
|
|
@@ -17,7 +17,7 @@ import default_fragment from '../renderers/shaders/ShaderChunk/default_fragment.
|
|
|
17
17
|
* - You can use the directive `#pragma unroll_loop_start` and `#pragma unroll_loop_end`
|
|
18
18
|
* in order to unroll a `for` loop in GLSL by the shader preprocessor. The directive has
|
|
19
19
|
* to be placed right above the loop. The loop formatting has to correspond to a defined standard.
|
|
20
|
-
* - The loop has to be [normalized]
|
|
20
|
+
* - The loop has to be [normalized](https://en.wikipedia.org/wiki/Normalized_loop).
|
|
21
21
|
* - The loop variable has to be *i*.
|
|
22
22
|
* - The value `UNROLLED_LOOP_INDEX` will be replaced with the explicitly
|
|
23
23
|
* value of *i* for the given iteration and can be used in preprocessor
|
|
@@ -223,7 +223,7 @@ class ShaderMaterial extends Material {
|
|
|
223
223
|
};
|
|
224
224
|
|
|
225
225
|
/**
|
|
226
|
-
* If set, this calls [gl.bindAttribLocation]
|
|
226
|
+
* If set, this calls [gl.bindAttribLocation](https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/bindAttribLocation)
|
|
227
227
|
* to bind a generic vertex index to an attribute variable.
|
|
228
228
|
*
|
|
229
229
|
* @type {string|undefined}
|
|
@@ -378,7 +378,7 @@ class Line2NodeMaterial extends NodeMaterial {
|
|
|
378
378
|
|
|
379
379
|
if ( ! useDash ) {
|
|
380
380
|
|
|
381
|
-
if ( useAlphaToCoverage && renderer.
|
|
381
|
+
if ( useAlphaToCoverage && renderer.currentSamples > 0 ) {
|
|
382
382
|
|
|
383
383
|
const dnorm = norm.fwidth();
|
|
384
384
|
alpha.assign( smoothstep( dnorm.negate().add( 0.5 ), dnorm.add( 0.5 ), norm ).oneMinus() );
|
|
@@ -395,7 +395,7 @@ class Line2NodeMaterial extends NodeMaterial {
|
|
|
395
395
|
|
|
396
396
|
// round endcaps
|
|
397
397
|
|
|
398
|
-
if ( useAlphaToCoverage && renderer.
|
|
398
|
+
if ( useAlphaToCoverage && renderer.currentSamples > 0 ) {
|
|
399
399
|
|
|
400
400
|
const a = vUv.x;
|
|
401
401
|
const b = vUv.y.greaterThan( 0.0 ).select( vUv.y.sub( 1.0 ), vUv.y.add( 1.0 ) );
|
|
@@ -39,7 +39,7 @@ class SSSLightingModel extends PhysicalLightingModel {
|
|
|
39
39
|
/**
|
|
40
40
|
* Extends the default implementation with a SSS term.
|
|
41
41
|
*
|
|
42
|
-
* Reference: [Approximating Translucency for a Fast, Cheap and Convincing Subsurface Scattering Look]
|
|
42
|
+
* Reference: [Approximating Translucency for a Fast, Cheap and Convincing Subsurface Scattering Look](https://colinbarrebrisebois.com/2011/03/07/gdc-2011-approximating-translucency-for-a-fast-cheap-and-convincing-subsurface-scattering-look/)
|
|
43
43
|
*
|
|
44
44
|
* @param {Object} input - The input data.
|
|
45
45
|
* @param {NodeBuilder} builder - The current node builder.
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Material } from '../Material.js';
|
|
2
|
-
import { NormalBlending } from '../../constants.js';
|
|
3
2
|
|
|
4
|
-
import {
|
|
3
|
+
import { hashArray, hashString } from '../../nodes/core/NodeUtils.js';
|
|
5
4
|
import { output, diffuseColor, emissive, varyingProperty } from '../../nodes/core/PropertyNode.js';
|
|
6
5
|
import { materialAlphaTest, materialColor, materialOpacity, materialEmissive, materialNormal, materialLightMap, materialAO } from '../../nodes/accessors/MaterialNode.js';
|
|
7
6
|
import { modelViewProjection } from '../../nodes/accessors/ModelViewProjectionNode.js';
|
|
@@ -12,7 +11,7 @@ import { materialReference } from '../../nodes/accessors/MaterialReferenceNode.j
|
|
|
12
11
|
import { positionLocal, positionView } from '../../nodes/accessors/Position.js';
|
|
13
12
|
import { skinning } from '../../nodes/accessors/SkinningNode.js';
|
|
14
13
|
import { morphReference } from '../../nodes/accessors/MorphNode.js';
|
|
15
|
-
import { mix } from '../../nodes/math/MathNode.js';
|
|
14
|
+
import { fwidth, mix, smoothstep } from '../../nodes/math/MathNode.js';
|
|
16
15
|
import { float, vec3, vec4, bool } from '../../nodes/tsl/TSLBase.js';
|
|
17
16
|
import AONode from '../../nodes/lighting/AONode.js';
|
|
18
17
|
import { lightingContext } from '../../nodes/lighting/LightingContextNode.js';
|
|
@@ -26,6 +25,7 @@ import { modelViewMatrix } from '../../nodes/accessors/ModelNode.js';
|
|
|
26
25
|
import { vertexColor } from '../../nodes/accessors/VertexColorNode.js';
|
|
27
26
|
import { premultiplyAlpha } from '../../nodes/display/BlendModes.js';
|
|
28
27
|
import { subBuild } from '../../nodes/core/SubBuildNode.js';
|
|
28
|
+
import { warn } from '../../utils.js';
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* Base class for all node materials.
|
|
@@ -181,7 +181,7 @@ class NodeMaterial extends Material {
|
|
|
181
181
|
* and `alphaMap` properties. This node property allows to overwrite the default
|
|
182
182
|
* and define the opacity with a node instead.
|
|
183
183
|
*
|
|
184
|
-
* If you don't want to overwrite the
|
|
184
|
+
* If you don't want to overwrite the opacity but modify the existing
|
|
185
185
|
* value instead, use {@link materialOpacity}.
|
|
186
186
|
*
|
|
187
187
|
* @type {?Node<float>}
|
|
@@ -394,7 +394,7 @@ class NodeMaterial extends Material {
|
|
|
394
394
|
|
|
395
395
|
set: ( value ) => {
|
|
396
396
|
|
|
397
|
-
|
|
397
|
+
warn( 'NodeMaterial: ".shadowPositionNode" was renamed to ".receivedShadowPositionNode".' );
|
|
398
398
|
|
|
399
399
|
this.receivedShadowPositionNode = value;
|
|
400
400
|
|
|
@@ -404,6 +404,34 @@ class NodeMaterial extends Material {
|
|
|
404
404
|
|
|
405
405
|
}
|
|
406
406
|
|
|
407
|
+
/**
|
|
408
|
+
* Returns an array of child nodes for this material.
|
|
409
|
+
*
|
|
410
|
+
* @private
|
|
411
|
+
* @returns {Array<{property: string, childNode: Node}>}
|
|
412
|
+
*/
|
|
413
|
+
_getNodeChildren() {
|
|
414
|
+
|
|
415
|
+
const children = [];
|
|
416
|
+
|
|
417
|
+
for ( const property of Object.getOwnPropertyNames( this ) ) {
|
|
418
|
+
|
|
419
|
+
if ( property.startsWith( '_' ) === true ) continue;
|
|
420
|
+
|
|
421
|
+
const object = this[ property ];
|
|
422
|
+
|
|
423
|
+
if ( object && object.isNode === true ) {
|
|
424
|
+
|
|
425
|
+
children.push( { property, childNode: object } );
|
|
426
|
+
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
return children;
|
|
432
|
+
|
|
433
|
+
}
|
|
434
|
+
|
|
407
435
|
/**
|
|
408
436
|
* Allows to define a custom cache key that influence the material key computation
|
|
409
437
|
* for render objects.
|
|
@@ -412,7 +440,15 @@ class NodeMaterial extends Material {
|
|
|
412
440
|
*/
|
|
413
441
|
customProgramCacheKey() {
|
|
414
442
|
|
|
415
|
-
|
|
443
|
+
const values = [];
|
|
444
|
+
|
|
445
|
+
for ( const { property, childNode } of this._getNodeChildren() ) {
|
|
446
|
+
|
|
447
|
+
values.push( hashString( property.slice( 0, - 4 ) ), childNode.getCacheKey() );
|
|
448
|
+
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
return this.type + hashArray( values );
|
|
416
452
|
|
|
417
453
|
}
|
|
418
454
|
|
|
@@ -504,7 +540,7 @@ class NodeMaterial extends Material {
|
|
|
504
540
|
|
|
505
541
|
const outgoingLightNode = this.setupLighting( builder );
|
|
506
542
|
|
|
507
|
-
if ( clippingNode !== null ) builder.stack.
|
|
543
|
+
if ( clippingNode !== null ) builder.stack.addToStack( clippingNode );
|
|
508
544
|
|
|
509
545
|
// force unsigned floats - useful for RenderTargets
|
|
510
546
|
|
|
@@ -589,7 +625,7 @@ class NodeMaterial extends Material {
|
|
|
589
625
|
|
|
590
626
|
if ( unionPlanes.length > 0 || intersectionPlanes.length > 0 ) {
|
|
591
627
|
|
|
592
|
-
const samples = builder.renderer.
|
|
628
|
+
const samples = builder.renderer.currentSamples;
|
|
593
629
|
|
|
594
630
|
if ( this.alphaToCoverage && samples > 1 ) {
|
|
595
631
|
|
|
@@ -598,7 +634,7 @@ class NodeMaterial extends Material {
|
|
|
598
634
|
|
|
599
635
|
} else {
|
|
600
636
|
|
|
601
|
-
builder.stack.
|
|
637
|
+
builder.stack.addToStack( clipping() );
|
|
602
638
|
|
|
603
639
|
}
|
|
604
640
|
|
|
@@ -625,7 +661,7 @@ class NodeMaterial extends Material {
|
|
|
625
661
|
|
|
626
662
|
if ( candidateCount > 0 && candidateCount <= 8 && builder.isAvailable( 'clipDistance' ) ) {
|
|
627
663
|
|
|
628
|
-
builder.stack.
|
|
664
|
+
builder.stack.addToStack( hardwareClipping() );
|
|
629
665
|
|
|
630
666
|
this.hardwareClipping = true;
|
|
631
667
|
|
|
@@ -783,7 +819,9 @@ class NodeMaterial extends Material {
|
|
|
783
819
|
* @param {NodeBuilder} builder - The current node builder.
|
|
784
820
|
* @param {BufferGeometry} geometry - The geometry.
|
|
785
821
|
*/
|
|
786
|
-
setupDiffuseColor(
|
|
822
|
+
setupDiffuseColor( builder ) {
|
|
823
|
+
|
|
824
|
+
const { object, geometry } = builder;
|
|
787
825
|
|
|
788
826
|
// MASK
|
|
789
827
|
|
|
@@ -842,7 +880,16 @@ class NodeMaterial extends Material {
|
|
|
842
880
|
|
|
843
881
|
alphaTestNode = this.alphaTestNode !== null ? float( this.alphaTestNode ) : materialAlphaTest;
|
|
844
882
|
|
|
845
|
-
|
|
883
|
+
if ( this.alphaToCoverage === true ) {
|
|
884
|
+
|
|
885
|
+
diffuseColor.a = smoothstep( alphaTestNode, alphaTestNode.add( fwidth( diffuseColor.a ) ), diffuseColor.a );
|
|
886
|
+
diffuseColor.a.lessThanEqual( 0 ).discard();
|
|
887
|
+
|
|
888
|
+
} else {
|
|
889
|
+
|
|
890
|
+
diffuseColor.a.lessThanEqual( alphaTestNode ).discard();
|
|
891
|
+
|
|
892
|
+
}
|
|
846
893
|
|
|
847
894
|
}
|
|
848
895
|
|
|
@@ -856,16 +903,10 @@ class NodeMaterial extends Material {
|
|
|
856
903
|
|
|
857
904
|
// OPAQUE
|
|
858
905
|
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
if ( isOpaque ) {
|
|
906
|
+
if ( builder.isOpaque() ) {
|
|
862
907
|
|
|
863
908
|
diffuseColor.a.assign( 1.0 );
|
|
864
909
|
|
|
865
|
-
} else if ( alphaTestNode === null ) {
|
|
866
|
-
|
|
867
|
-
diffuseColor.a.lessThanEqual( 0 ).discard();
|
|
868
|
-
|
|
869
910
|
}
|
|
870
911
|
|
|
871
912
|
}
|
|
@@ -1183,11 +1224,9 @@ class NodeMaterial extends Material {
|
|
|
1183
1224
|
}
|
|
1184
1225
|
|
|
1185
1226
|
const data = Material.prototype.toJSON.call( this, meta );
|
|
1186
|
-
const nodeChildren = getNodeChildren( this );
|
|
1187
|
-
|
|
1188
1227
|
data.inputNodes = {};
|
|
1189
1228
|
|
|
1190
|
-
for ( const { property, childNode } of
|
|
1229
|
+
for ( const { property, childNode } of this._getNodeChildren() ) {
|
|
1191
1230
|
|
|
1192
1231
|
data.inputNodes[ property ] = childNode.toJSON( meta ).uuid;
|
|
1193
1232
|
|
|
@@ -1237,6 +1276,7 @@ class NodeMaterial extends Material {
|
|
|
1237
1276
|
|
|
1238
1277
|
this.lightsNode = source.lightsNode;
|
|
1239
1278
|
this.envNode = source.envNode;
|
|
1279
|
+
this.aoNode = source.aoNode;
|
|
1240
1280
|
|
|
1241
1281
|
this.colorNode = source.colorNode;
|
|
1242
1282
|
this.normalNode = source.normalNode;
|
|
@@ -1,18 +1,36 @@
|
|
|
1
1
|
import SpriteNodeMaterial from './SpriteNodeMaterial.js';
|
|
2
|
-
import {
|
|
2
|
+
import { viewportSize, screenDPR } from '../../nodes/display/ScreenNode.js';
|
|
3
3
|
import { positionGeometry, positionLocal, positionView } from '../../nodes/accessors/Position.js';
|
|
4
4
|
import { modelViewMatrix } from '../../nodes/accessors/ModelNode.js';
|
|
5
5
|
import { materialPointSize } from '../../nodes/accessors/MaterialNode.js';
|
|
6
6
|
import { rotate } from '../../nodes/utils/RotateNode.js';
|
|
7
|
-
import { float, vec2, vec3, vec4 } from '../../nodes/tsl/TSLBase.js';
|
|
7
|
+
import { float, uniform, vec2, vec3, vec4 } from '../../nodes/tsl/TSLBase.js';
|
|
8
8
|
|
|
9
9
|
import { PointsMaterial } from '../PointsMaterial.js';
|
|
10
|
+
import { Vector2 } from '../../math/Vector2.js';
|
|
10
11
|
|
|
11
12
|
const _defaultValues = /*@__PURE__*/ new PointsMaterial();
|
|
13
|
+
const _size = /*@__PURE__*/ new Vector2();
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* Node material version of {@link PointsMaterial}.
|
|
15
17
|
*
|
|
18
|
+
* This material can be used in two ways:
|
|
19
|
+
*
|
|
20
|
+
* - By rendering point primitives with {@link Points}. Since WebGPU only supports point primitives
|
|
21
|
+
* with a pixel size of `1`, it's not possible to define a size.
|
|
22
|
+
*
|
|
23
|
+
* ```js
|
|
24
|
+
* const pointCloud = new THREE.Points( geometry, new THREE.PointsNodeMaterial() );
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* - By rendering point primitives with {@link Sprites}. In this case, size is honored,
|
|
28
|
+
* see {@link PointsNodeMaterial#sizeNode}.
|
|
29
|
+
*
|
|
30
|
+
* ```js
|
|
31
|
+
* const instancedPoints = new THREE.Sprite( new THREE.PointsNodeMaterial( { positionNode: instancedBufferAttribute( positionAttribute ) } ) );
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
16
34
|
* @augments SpriteNodeMaterial
|
|
17
35
|
*/
|
|
18
36
|
class PointsNodeMaterial extends SpriteNodeMaterial {
|
|
@@ -68,68 +86,95 @@ class PointsNodeMaterial extends SpriteNodeMaterial {
|
|
|
68
86
|
|
|
69
87
|
}
|
|
70
88
|
|
|
71
|
-
|
|
89
|
+
setupVertexSprite( builder ) {
|
|
72
90
|
|
|
73
|
-
const
|
|
91
|
+
const { material, camera } = builder;
|
|
92
|
+
|
|
93
|
+
const { rotationNode, scaleNode, sizeNode, sizeAttenuation } = this;
|
|
94
|
+
|
|
95
|
+
let mvp = super.setupVertex( builder );
|
|
74
96
|
|
|
75
97
|
// skip further processing if the material is not a node material
|
|
76
98
|
|
|
77
|
-
if (
|
|
99
|
+
if ( material.isNodeMaterial !== true ) {
|
|
78
100
|
|
|
79
101
|
return mvp;
|
|
80
102
|
|
|
81
103
|
}
|
|
82
104
|
|
|
83
|
-
//
|
|
105
|
+
// point size
|
|
84
106
|
|
|
85
|
-
|
|
107
|
+
let pointSize = sizeNode !== null ? vec2( sizeNode ) : materialPointSize;
|
|
86
108
|
|
|
87
|
-
|
|
88
|
-
const aspect = viewport.z.div( viewport.w );
|
|
109
|
+
pointSize = pointSize.mul( screenDPR );
|
|
89
110
|
|
|
90
|
-
//
|
|
111
|
+
// size attenuation
|
|
91
112
|
|
|
92
|
-
if (
|
|
113
|
+
if ( camera.isPerspectiveCamera && sizeAttenuation === true ) {
|
|
93
114
|
|
|
94
|
-
|
|
115
|
+
// follow WebGLRenderer's implementation, and scale by half the canvas height in logical units
|
|
95
116
|
|
|
96
|
-
|
|
117
|
+
pointSize = pointSize.mul( scale.div( positionView.z.negate() ) );
|
|
97
118
|
|
|
98
119
|
}
|
|
99
120
|
|
|
100
|
-
//
|
|
101
|
-
|
|
102
|
-
let pointSize = sizeNode !== null ? vec2( sizeNode ) : materialPointSize;
|
|
121
|
+
// scale
|
|
103
122
|
|
|
104
|
-
if (
|
|
123
|
+
if ( scaleNode && scaleNode.isNode ) {
|
|
105
124
|
|
|
106
|
-
pointSize = pointSize.mul(
|
|
125
|
+
pointSize = pointSize.mul( vec2( scaleNode ) );
|
|
107
126
|
|
|
108
127
|
}
|
|
109
128
|
|
|
110
|
-
//
|
|
129
|
+
// compute offset
|
|
111
130
|
|
|
112
|
-
|
|
131
|
+
let offset = positionGeometry.xy;
|
|
113
132
|
|
|
114
|
-
|
|
133
|
+
// apply rotation
|
|
134
|
+
|
|
135
|
+
if ( rotationNode && rotationNode.isNode ) {
|
|
136
|
+
|
|
137
|
+
const rotation = float( rotationNode );
|
|
138
|
+
|
|
139
|
+
offset = rotate( offset, rotation );
|
|
115
140
|
|
|
116
141
|
}
|
|
117
142
|
|
|
118
|
-
|
|
143
|
+
// account for point size
|
|
144
|
+
|
|
145
|
+
offset = offset.mul( pointSize );
|
|
146
|
+
|
|
147
|
+
// scale by viewport size
|
|
148
|
+
|
|
149
|
+
offset = offset.div( viewportSize.div( 2 ) );
|
|
119
150
|
|
|
120
|
-
|
|
121
|
-
alignedPosition.y.assign( alignedPosition.y.mul( aspect ) );
|
|
151
|
+
// compensate for the perspective divide
|
|
122
152
|
|
|
123
|
-
|
|
124
|
-
alignedPosition.assign( alignedPosition.mul( mvp.w ) );
|
|
153
|
+
offset = offset.mul( mvp.w );
|
|
125
154
|
|
|
126
|
-
//
|
|
127
|
-
|
|
155
|
+
// add offset
|
|
156
|
+
|
|
157
|
+
mvp = mvp.add( vec4( offset, 0, 0 ) );
|
|
128
158
|
|
|
129
159
|
return mvp;
|
|
130
160
|
|
|
131
161
|
}
|
|
132
162
|
|
|
163
|
+
setupVertex( builder ) {
|
|
164
|
+
|
|
165
|
+
if ( builder.object.isPoints ) {
|
|
166
|
+
|
|
167
|
+
return super.setupVertex( builder );
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
} else {
|
|
171
|
+
|
|
172
|
+
return this.setupVertexSprite( builder );
|
|
173
|
+
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
}
|
|
177
|
+
|
|
133
178
|
/**
|
|
134
179
|
* Whether alpha to coverage should be used or not.
|
|
135
180
|
*
|
|
@@ -155,4 +200,12 @@ class PointsNodeMaterial extends SpriteNodeMaterial {
|
|
|
155
200
|
|
|
156
201
|
}
|
|
157
202
|
|
|
203
|
+
const scale = /*@__PURE__*/ uniform( 1 ).onFrameUpdate( function ( { renderer } ) {
|
|
204
|
+
|
|
205
|
+
const size = renderer.getSize( _size ); // logical units
|
|
206
|
+
|
|
207
|
+
this.value = 0.5 * size.y;
|
|
208
|
+
|
|
209
|
+
} );
|
|
210
|
+
|
|
158
211
|
export default PointsNodeMaterial;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import NodeMaterial from './NodeMaterial.js';
|
|
2
|
-
import { cameraProjectionMatrix } from '../../nodes/accessors/Camera.js';
|
|
3
2
|
import { materialRotation } from '../../nodes/accessors/MaterialNode.js';
|
|
4
3
|
import { modelViewMatrix, modelWorldMatrix } from '../../nodes/accessors/ModelNode.js';
|
|
5
4
|
import { positionGeometry } from '../../nodes/accessors/Position.js';
|
|
@@ -111,9 +110,7 @@ class SpriteNodeMaterial extends NodeMaterial {
|
|
|
111
110
|
|
|
112
111
|
const { object, camera } = builder;
|
|
113
112
|
|
|
114
|
-
const sizeAttenuation = this
|
|
115
|
-
|
|
116
|
-
const { positionNode, rotationNode, scaleNode } = this;
|
|
113
|
+
const { positionNode, rotationNode, scaleNode, sizeAttenuation } = this;
|
|
117
114
|
|
|
118
115
|
const mvPosition = modelViewMatrix.mul( vec3( positionNode || 0 ) );
|
|
119
116
|
|
|
@@ -125,18 +122,9 @@ class SpriteNodeMaterial extends NodeMaterial {
|
|
|
125
122
|
|
|
126
123
|
}
|
|
127
124
|
|
|
128
|
-
if ( sizeAttenuation === false ) {
|
|
129
|
-
|
|
130
|
-
if ( camera.isPerspectiveCamera ) {
|
|
131
|
-
|
|
132
|
-
scale = scale.mul( mvPosition.z.negate() );
|
|
133
|
-
|
|
134
|
-
} else {
|
|
135
|
-
|
|
136
|
-
const orthoScale = float( 2.0 ).div( cameraProjectionMatrix.element( 1 ).element( 1 ) );
|
|
137
|
-
scale = scale.mul( orthoScale.mul( 2 ) );
|
|
125
|
+
if ( camera.isPerspectiveCamera && sizeAttenuation === false ) {
|
|
138
126
|
|
|
139
|
-
|
|
127
|
+
scale = scale.mul( mvPosition.z.negate() );
|
|
140
128
|
|
|
141
129
|
}
|
|
142
130
|
|
|
@@ -465,13 +465,14 @@ class NodeMaterialObserver {
|
|
|
465
465
|
|
|
466
466
|
if ( renderObjectData.morphTargetInfluences[ i ] !== object.morphTargetInfluences[ i ] ) {
|
|
467
467
|
|
|
468
|
+
renderObjectData.morphTargetInfluences[ i ] = object.morphTargetInfluences[ i ];
|
|
468
469
|
morphChanged = true;
|
|
469
470
|
|
|
470
471
|
}
|
|
471
472
|
|
|
472
473
|
}
|
|
473
474
|
|
|
474
|
-
if ( morphChanged ) return
|
|
475
|
+
if ( morphChanged ) return false;
|
|
475
476
|
|
|
476
477
|
}
|
|
477
478
|
|
|
@@ -548,7 +549,7 @@ class NodeMaterialObserver {
|
|
|
548
549
|
*
|
|
549
550
|
* @param {LightsNode} lightsNode - The lights node.
|
|
550
551
|
* @param {number} renderId - The render ID.
|
|
551
|
-
* @return {Array} The lights for the given lights node and render ID.
|
|
552
|
+
* @return {Array<Object>} The lights for the given lights node and render ID.
|
|
552
553
|
*/
|
|
553
554
|
getLights( lightsNode, renderId ) {
|
|
554
555
|
|