@plastic-software/three 0.181.3 → 0.183.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 +3 -4
- package/build/three.cjs +11330 -10017
- package/build/three.core.js +10011 -9493
- package/build/three.core.min.js +2 -2
- package/build/three.module.js +1414 -631
- package/build/three.module.min.js +2 -2
- package/build/three.tsl.js +21 -13
- package/build/three.tsl.min.js +2 -2
- package/build/three.webgpu.js +8007 -5427
- package/build/three.webgpu.min.js +2 -2
- package/build/three.webgpu.nodes.js +8005 -5426
- package/build/three.webgpu.nodes.min.js +2 -2
- package/examples/jsm/Addons.js +0 -3
- package/examples/jsm/animation/CCDIKSolver.js +2 -2
- package/examples/jsm/controls/ArcballControls.js +3 -3
- package/examples/jsm/controls/MapControls.js +55 -1
- package/examples/jsm/controls/OrbitControls.js +109 -6
- package/examples/jsm/controls/TrackballControls.js +6 -6
- package/examples/jsm/csm/CSM.js +2 -1
- package/examples/jsm/effects/AnaglyphEffect.js +102 -7
- package/examples/jsm/environments/ColorEnvironment.js +59 -0
- package/examples/jsm/environments/RoomEnvironment.js +3 -0
- package/examples/jsm/exporters/EXRExporter.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +131 -4
- package/examples/jsm/exporters/USDZExporter.js +22 -3
- package/examples/jsm/geometries/DecalGeometry.js +1 -1
- package/examples/jsm/helpers/AnimationPathHelper.js +302 -0
- package/examples/jsm/helpers/LightProbeHelperGPU.js +1 -1
- package/examples/jsm/helpers/TextureHelperGPU.js +1 -1
- package/examples/jsm/helpers/ViewHelper.js +67 -8
- package/examples/jsm/inspector/Inspector.js +74 -14
- package/examples/jsm/inspector/RendererInspector.js +12 -2
- package/examples/jsm/inspector/tabs/Console.js +41 -7
- package/examples/jsm/inspector/tabs/Parameters.js +18 -2
- package/examples/jsm/inspector/tabs/Performance.js +2 -2
- package/examples/jsm/inspector/tabs/Viewer.js +4 -4
- package/examples/jsm/inspector/ui/Profiler.js +1836 -31
- package/examples/jsm/inspector/ui/Style.js +973 -14
- package/examples/jsm/inspector/ui/Tab.js +188 -1
- package/examples/jsm/inspector/ui/Values.js +17 -1
- package/examples/jsm/libs/meshopt_decoder.module.js +6 -5
- package/examples/jsm/lines/LineMaterial.js +6 -0
- package/examples/jsm/loaders/3DMLoader.js +5 -4
- package/examples/jsm/loaders/3MFLoader.js +2 -2
- package/examples/jsm/loaders/AMFLoader.js +2 -2
- package/examples/jsm/loaders/ColladaLoader.js +24 -4026
- package/examples/jsm/loaders/DRACOLoader.js +5 -5
- package/examples/jsm/loaders/EXRLoader.js +5 -5
- package/examples/jsm/loaders/FBXLoader.js +2 -4
- package/examples/jsm/loaders/GCodeLoader.js +34 -8
- package/examples/jsm/loaders/GLTFLoader.js +122 -171
- package/examples/jsm/loaders/HDRLoader.js +0 -1
- package/examples/jsm/loaders/KMZLoader.js +5 -5
- package/examples/jsm/loaders/KTX2Loader.js +19 -3
- package/examples/jsm/loaders/LDrawLoader.js +2 -3
- package/examples/jsm/loaders/LWOLoader.js +7 -39
- package/examples/jsm/loaders/NRRDLoader.js +2 -2
- package/examples/jsm/loaders/PCDLoader.js +4 -2
- package/examples/jsm/loaders/SVGLoader.js +1 -1
- package/examples/jsm/loaders/TDSLoader.js +0 -2
- package/examples/jsm/loaders/TGALoader.js +0 -2
- package/examples/jsm/loaders/USDLoader.js +100 -40
- package/examples/jsm/loaders/UltraHDRLoader.js +285 -160
- package/examples/jsm/loaders/VOXLoader.js +660 -117
- package/examples/jsm/loaders/VRMLLoader.js +79 -2
- package/examples/jsm/loaders/VTKLoader.js +37 -24
- package/examples/jsm/loaders/collada/ColladaComposer.js +2950 -0
- package/examples/jsm/loaders/collada/ColladaParser.js +1962 -0
- package/examples/jsm/loaders/usd/USDAParser.js +447 -366
- package/examples/jsm/loaders/usd/USDCParser.js +1841 -6
- package/examples/jsm/loaders/usd/USDComposer.js +4041 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +2 -2
- package/examples/jsm/materials/WoodNodeMaterial.js +11 -11
- package/examples/jsm/math/Octree.js +131 -1
- package/examples/jsm/misc/Volume.js +0 -1
- package/examples/jsm/misc/VolumeSlice.js +0 -1
- package/examples/jsm/objects/LensflareMesh.js +1 -1
- package/examples/jsm/objects/Sky.js +76 -4
- package/examples/jsm/objects/SkyMesh.js +127 -10
- package/examples/jsm/objects/Water.js +4 -3
- package/examples/jsm/objects/Water2.js +5 -3
- package/examples/jsm/objects/WaterMesh.js +5 -7
- package/examples/jsm/physics/AmmoPhysics.js +12 -7
- package/examples/jsm/physics/JoltPhysics.js +10 -6
- package/examples/jsm/physics/RapierPhysics.js +9 -5
- package/examples/jsm/postprocessing/EffectComposer.js +7 -5
- package/examples/jsm/postprocessing/OutputPass.js +9 -0
- package/examples/jsm/postprocessing/RenderPass.js +10 -0
- package/examples/jsm/postprocessing/RenderTransitionPass.js +1 -1
- package/examples/jsm/postprocessing/UnrealBloomPass.js +48 -18
- package/examples/jsm/renderers/CSS3DRenderer.js +1 -1
- package/examples/jsm/renderers/Projector.js +268 -30
- package/examples/jsm/renderers/SVGRenderer.js +193 -60
- package/examples/jsm/shaders/GTAOShader.js +19 -6
- package/examples/jsm/shaders/HalftoneShader.js +12 -1
- package/examples/jsm/shaders/PoissonDenoiseShader.js +6 -2
- package/examples/jsm/shaders/SAOShader.js +17 -4
- package/examples/jsm/shaders/SSAOShader.js +11 -1
- package/examples/jsm/shaders/SSRShader.js +6 -5
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +2 -4
- package/examples/jsm/shaders/VignetteShader.js +1 -1
- package/examples/jsm/transpiler/AST.js +44 -0
- package/examples/jsm/transpiler/GLSLDecoder.js +61 -4
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -0
- package/examples/jsm/transpiler/TSLEncoder.js +46 -3
- package/examples/jsm/transpiler/TranspilerUtils.js +3 -3
- package/examples/jsm/transpiler/WGSLEncoder.js +27 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +1 -1
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +458 -16
- package/examples/jsm/tsl/display/AnamorphicNode.js +1 -1
- package/examples/jsm/tsl/display/BilateralBlurNode.js +364 -0
- package/examples/jsm/tsl/display/BloomNode.js +16 -6
- package/examples/jsm/tsl/display/CRT.js +150 -0
- package/examples/jsm/tsl/display/DenoiseNode.js +1 -1
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +1 -1
- package/examples/jsm/tsl/display/DotScreenNode.js +1 -1
- package/examples/jsm/tsl/display/FXAANode.js +2 -2
- package/examples/jsm/tsl/display/GTAONode.js +5 -4
- package/examples/jsm/tsl/display/GaussianBlurNode.js +11 -2
- package/examples/jsm/tsl/display/GodraysNode.js +624 -0
- package/examples/jsm/tsl/display/LensflareNode.js +1 -1
- package/examples/jsm/tsl/display/Lut3DNode.js +1 -1
- package/examples/jsm/tsl/display/OutlineNode.js +3 -3
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +2 -2
- package/examples/jsm/tsl/display/PixelationPassNode.js +7 -6
- package/examples/jsm/tsl/display/RGBShiftNode.js +2 -2
- package/examples/jsm/tsl/display/RetroPassNode.js +263 -0
- package/examples/jsm/tsl/display/SMAANode.js +2 -2
- package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
- package/examples/jsm/tsl/display/SSGINode.js +8 -20
- package/examples/jsm/tsl/display/SSRNode.js +8 -8
- package/examples/jsm/tsl/display/SSSNode.js +6 -4
- package/examples/jsm/tsl/display/Shape.js +29 -0
- package/examples/jsm/tsl/display/SobelOperatorNode.js +2 -2
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +8 -1
- package/examples/jsm/tsl/display/StereoPassNode.js +1 -2
- package/examples/jsm/tsl/display/TRAANode.js +273 -125
- package/examples/jsm/tsl/display/TransitionNode.js +1 -1
- package/examples/jsm/tsl/display/depthAwareBlend.js +80 -0
- package/examples/jsm/tsl/display/radialBlur.js +68 -0
- package/examples/jsm/tsl/math/Bayer.js +40 -1
- package/examples/jsm/utils/LDrawUtils.js +1 -1
- package/examples/jsm/utils/ShadowMapViewer.js +24 -10
- package/examples/jsm/utils/ShadowMapViewerGPU.js +1 -1
- package/examples/jsm/utils/WebGPUTextureUtils.js +1 -1
- package/package.json +20 -26
- package/src/Three.Core.js +2 -1
- package/src/Three.TSL.js +19 -11
- package/src/Three.WebGPU.Nodes.js +2 -0
- package/src/Three.WebGPU.js +3 -0
- package/src/Three.js +1 -0
- package/src/animation/AnimationAction.js +1 -1
- package/src/animation/AnimationClip.js +1 -1
- package/src/animation/AnimationMixer.js +6 -0
- package/src/animation/AnimationUtils.js +1 -12
- package/src/animation/KeyframeTrack.js +47 -8
- package/src/animation/PropertyMixer.js +4 -4
- package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
- package/src/animation/tracks/ColorKeyframeTrack.js +1 -1
- package/src/animation/tracks/NumberKeyframeTrack.js +1 -1
- package/src/animation/tracks/QuaternionKeyframeTrack.js +1 -1
- package/src/animation/tracks/StringKeyframeTrack.js +1 -1
- package/src/animation/tracks/VectorKeyframeTrack.js +1 -1
- package/src/audio/Audio.js +1 -1
- package/src/audio/AudioListener.js +5 -3
- package/src/cameras/Camera.js +32 -2
- package/src/cameras/CubeCamera.js +20 -0
- package/src/constants.js +90 -5
- package/src/core/BufferGeometry.js +14 -2
- package/src/core/Clock.js +7 -0
- package/src/core/Object3D.js +56 -4
- package/src/core/Raycaster.js +2 -2
- package/src/core/RenderTarget.js +3 -4
- package/src/extras/PMREMGenerator.js +7 -18
- package/src/extras/TextureUtils.js +5 -1
- package/src/geometries/ExtrudeGeometry.js +2 -2
- package/src/geometries/PolyhedronGeometry.js +1 -1
- package/src/geometries/TorusGeometry.js +8 -3
- package/src/helpers/CameraHelper.js +3 -0
- package/src/helpers/DirectionalLightHelper.js +4 -1
- package/src/helpers/HemisphereLightHelper.js +3 -0
- package/src/helpers/PointLightHelper.js +1 -25
- package/src/helpers/SpotLightHelper.js +3 -0
- package/src/lights/DirectionalLight.js +13 -0
- package/src/lights/HemisphereLight.js +10 -0
- package/src/lights/Light.js +1 -11
- package/src/lights/LightProbe.js +0 -15
- package/src/lights/LightShadow.js +15 -6
- package/src/lights/PointLight.js +15 -0
- package/src/lights/PointLightShadow.js +0 -86
- package/src/lights/SpotLight.js +22 -1
- package/src/lights/webgpu/IESSpotLight.js +2 -1
- package/src/loaders/Cache.js +28 -0
- package/src/loaders/FileLoader.js +1 -1
- package/src/loaders/ImageBitmapLoader.js +8 -3
- package/src/loaders/Loader.js +6 -0
- package/src/loaders/MaterialLoader.js +2 -1
- package/src/loaders/ObjectLoader.js +21 -2
- package/src/loaders/nodes/NodeLoader.js +2 -2
- package/src/materials/Material.js +2 -0
- package/src/materials/MeshLambertMaterial.js +9 -0
- package/src/materials/MeshPhongMaterial.js +9 -0
- package/src/materials/ShaderMaterial.js +20 -1
- package/src/materials/nodes/Line2NodeMaterial.js +7 -7
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +5 -2
- package/src/materials/nodes/MeshStandardNodeMaterial.js +5 -4
- package/src/materials/nodes/NodeMaterial.js +72 -25
- package/src/materials/nodes/manager/NodeMaterialObserver.js +10 -4
- package/src/math/Line3.js +3 -5
- package/src/math/MathUtils.js +10 -10
- package/src/math/Matrix4.js +74 -65
- package/src/math/Quaternion.js +3 -29
- package/src/math/Sphere.js +1 -1
- package/src/math/Vector3.js +3 -5
- package/src/math/interpolants/BezierInterpolant.js +108 -0
- package/src/nodes/Nodes.js +87 -68
- package/src/nodes/TSL.js +6 -6
- package/src/nodes/accessors/Arrays.js +1 -1
- package/src/nodes/accessors/BatchNode.js +10 -10
- package/src/nodes/accessors/Bitangent.js +5 -5
- package/src/nodes/accessors/BufferAttributeNode.js +98 -12
- package/src/nodes/accessors/BufferNode.js +29 -2
- package/src/nodes/accessors/Camera.js +149 -28
- package/src/nodes/accessors/ClippingNode.js +4 -4
- package/src/nodes/accessors/CubeTextureNode.js +20 -1
- package/src/nodes/accessors/InstanceNode.js +148 -43
- package/src/nodes/accessors/MaterialNode.js +9 -1
- package/src/nodes/accessors/MaterialReferenceNode.js +1 -2
- package/src/nodes/accessors/ModelNode.js +1 -1
- package/src/nodes/accessors/Normal.js +11 -11
- package/src/nodes/accessors/Position.js +34 -2
- package/src/nodes/accessors/ReferenceBaseNode.js +4 -4
- package/src/nodes/accessors/ReferenceNode.js +4 -4
- package/src/nodes/accessors/RendererReferenceNode.js +1 -2
- package/src/nodes/accessors/SceneProperties.js +53 -0
- package/src/nodes/accessors/SkinningNode.js +27 -26
- package/src/nodes/accessors/StorageBufferNode.js +4 -21
- package/src/nodes/accessors/StorageTextureNode.js +37 -1
- package/src/nodes/accessors/Tangent.js +4 -14
- package/src/nodes/accessors/Texture3DNode.js +32 -35
- package/src/nodes/accessors/TextureNode.js +58 -22
- package/src/nodes/accessors/UniformArrayNode.js +4 -2
- package/src/nodes/accessors/UserDataNode.js +1 -2
- package/src/nodes/accessors/VertexColorNode.js +1 -2
- package/src/nodes/code/FunctionNode.js +1 -2
- package/src/nodes/core/ArrayNode.js +20 -1
- package/src/nodes/core/AssignNode.js +2 -2
- package/src/nodes/core/AttributeNode.js +2 -2
- package/src/nodes/core/ContextNode.js +103 -4
- package/src/nodes/core/MRTNode.js +48 -2
- package/src/nodes/core/Node.js +29 -3
- package/src/nodes/core/NodeBuilder.js +170 -53
- package/src/nodes/core/NodeError.js +28 -0
- package/src/nodes/core/NodeFrame.js +12 -4
- package/src/nodes/core/NodeUtils.js +10 -8
- package/src/nodes/core/OutputStructNode.js +12 -10
- package/src/nodes/core/ParameterNode.js +3 -3
- package/src/nodes/core/PropertyNode.js +19 -3
- package/src/nodes/core/StackNode.js +65 -16
- package/src/nodes/core/StackTrace.js +139 -0
- package/src/nodes/core/StructNode.js +16 -2
- package/src/nodes/core/StructTypeNode.js +11 -17
- package/src/nodes/core/SubBuildNode.js +1 -1
- package/src/nodes/core/UniformNode.js +21 -5
- package/src/nodes/core/VarNode.js +47 -22
- package/src/nodes/core/VaryingNode.js +1 -18
- package/src/nodes/display/BlendModes.js +0 -64
- package/src/nodes/display/ColorAdjustment.js +17 -0
- package/src/nodes/display/ColorSpaceNode.js +3 -3
- package/src/nodes/display/NormalMapNode.js +39 -4
- package/src/nodes/display/PassNode.js +98 -9
- package/src/nodes/display/RenderOutputNode.js +3 -3
- package/src/nodes/display/ScreenNode.js +3 -1
- package/src/nodes/display/ToneMappingNode.js +1 -1
- package/src/nodes/display/ToonOutlinePassNode.js +2 -2
- package/src/nodes/display/ViewportDepthNode.js +52 -4
- package/src/nodes/display/ViewportTextureNode.js +21 -4
- package/src/nodes/fog/Fog.js +18 -35
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +3 -3
- package/src/nodes/functions/BSDF/DFGLUT.js +56 -0
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +1 -1
- package/src/nodes/functions/PhysicalLightingModel.js +126 -45
- package/src/nodes/geometry/RangeNode.js +4 -2
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -2
- package/src/nodes/gpgpu/ComputeNode.js +5 -4
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +1 -1
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +4 -4
- package/src/nodes/lighting/AnalyticLightNode.js +53 -0
- package/src/nodes/lighting/EnvironmentNode.js +28 -3
- package/src/nodes/lighting/LightsNode.js +2 -2
- package/src/nodes/lighting/PointShadowNode.js +162 -149
- package/src/nodes/lighting/ShadowFilterNode.js +53 -65
- package/src/nodes/lighting/ShadowNode.js +97 -41
- package/src/nodes/math/BitcountNode.js +433 -0
- package/src/nodes/math/ConditionalNode.js +2 -2
- package/src/nodes/math/MathNode.js +3 -40
- package/src/nodes/math/OperatorNode.js +2 -1
- package/src/nodes/math/PackFloatNode.js +98 -0
- package/src/nodes/math/UnpackFloatNode.js +96 -0
- package/src/nodes/pmrem/PMREMNode.js +1 -1
- package/src/nodes/pmrem/PMREMUtils.js +9 -15
- package/src/nodes/tsl/TSLCore.js +17 -14
- package/src/nodes/utils/ArrayElementNode.js +13 -0
- package/src/nodes/utils/DebugNode.js +11 -11
- package/src/nodes/utils/EventNode.js +1 -2
- package/src/nodes/utils/JoinNode.js +2 -2
- package/src/nodes/utils/LoopNode.js +1 -1
- package/src/nodes/utils/MemberNode.js +1 -1
- package/src/nodes/utils/Packing.js +13 -1
- package/src/nodes/utils/PostProcessingUtils.js +33 -1
- package/src/nodes/utils/RTTNode.js +1 -1
- package/src/nodes/utils/ReflectorNode.js +3 -4
- package/src/nodes/utils/SampleNode.js +1 -1
- package/src/nodes/utils/SpriteSheetUV.js +35 -0
- package/src/nodes/utils/UVUtils.js +28 -0
- package/src/objects/BatchedMesh.js +27 -14
- package/src/objects/InstancedMesh.js +11 -0
- package/src/objects/Line.js +1 -1
- package/src/objects/Mesh.js +1 -1
- package/src/objects/Points.js +1 -1
- package/src/objects/Skeleton.js +9 -0
- package/src/renderers/WebGLRenderer.js +178 -92
- package/src/renderers/common/Backend.js +29 -0
- package/src/renderers/common/Background.js +24 -11
- package/src/renderers/common/BindGroup.js +1 -9
- package/src/renderers/common/Binding.js +11 -0
- package/src/renderers/common/Bindings.js +27 -12
- package/src/renderers/common/BlendMode.js +143 -0
- package/src/renderers/common/Buffer.js +40 -0
- package/src/renderers/common/BundleGroup.js +1 -1
- package/src/renderers/common/ChainMap.js +30 -6
- package/src/renderers/common/CubeRenderTarget.js +50 -6
- package/src/renderers/common/Geometries.js +29 -3
- package/src/renderers/common/Lighting.js +5 -21
- package/src/renderers/common/Pipelines.js +4 -4
- package/src/renderers/common/PostProcessing.js +8 -206
- package/src/renderers/common/RenderBundles.js +2 -1
- package/src/renderers/common/RenderContext.js +16 -0
- package/src/renderers/common/RenderContexts.js +33 -49
- package/src/renderers/common/RenderLists.js +2 -1
- package/src/renderers/common/RenderObject.js +15 -3
- package/src/renderers/common/RenderObjectPipeline.js +40 -0
- package/src/renderers/common/RenderObjects.js +18 -2
- package/src/renderers/common/RenderPipeline.js +203 -17
- package/src/renderers/common/Renderer.js +257 -72
- package/src/renderers/common/Sampler.js +4 -4
- package/src/renderers/common/StorageBuffer.js +13 -1
- package/src/renderers/common/Textures.js +17 -1
- package/src/renderers/common/TimestampQueryPool.js +5 -3
- package/src/renderers/common/Uniform.js +8 -0
- package/src/renderers/common/UniformsGroup.js +61 -0
- package/src/renderers/common/XRManager.js +3 -2
- package/src/renderers/common/extras/PMREMGenerator.js +2 -8
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/{Nodes.js → NodeManager.js} +18 -6
- package/src/renderers/common/nodes/NodeStorageBuffer.js +13 -2
- package/src/renderers/common/nodes/NodeUniformBuffer.js +52 -0
- package/src/renderers/shaders/DFGLUTData.js +19 -34
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +8 -10
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +7 -11
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +5 -2
- package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +6 -2
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +8 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +112 -51
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +20 -4
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +225 -186
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk.js +3 -3
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +3 -0
- package/src/renderers/shaders/ShaderLib/{distanceRGBA.glsl.js → distance.glsl.js} +1 -2
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -9
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/vsm.glsl.js +4 -6
- package/src/renderers/shaders/ShaderLib.js +7 -5
- package/src/renderers/shaders/UniformsLib.js +0 -3
- package/src/renderers/webgl/WebGLBackground.js +2 -2
- package/src/renderers/webgl/WebGLBindingStates.js +99 -27
- package/src/renderers/webgl/WebGLCapabilities.js +3 -4
- package/src/renderers/webgl/WebGLEnvironments.js +228 -0
- package/src/renderers/webgl/WebGLGeometries.js +10 -7
- package/src/renderers/webgl/WebGLLights.js +18 -1
- package/src/renderers/webgl/WebGLMaterials.js +12 -0
- package/src/renderers/webgl/WebGLObjects.js +3 -1
- package/src/renderers/webgl/WebGLOutput.js +267 -0
- package/src/renderers/webgl/WebGLProgram.js +45 -109
- package/src/renderers/webgl/WebGLPrograms.js +45 -49
- package/src/renderers/webgl/WebGLRenderLists.js +15 -0
- package/src/renderers/webgl/WebGLShadowMap.js +188 -24
- package/src/renderers/webgl/WebGLState.js +32 -37
- package/src/renderers/webgl/WebGLTextures.js +89 -28
- package/src/renderers/webgl/WebGLUniforms.js +40 -3
- package/src/renderers/webgl/WebGLUtils.js +6 -2
- package/src/renderers/webgl-fallback/WebGLBackend.js +148 -18
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +156 -35
- package/src/renderers/webgl-fallback/utils/WebGLState.js +181 -5
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +5 -3
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +9 -9
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +6 -2
- package/src/renderers/webgpu/WebGPUBackend.js +119 -13
- package/src/renderers/webgpu/WebGPURenderer.js +2 -1
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +322 -68
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +4 -17
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +357 -200
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -0
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +61 -23
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +152 -200
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +65 -42
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +7 -7
- package/src/renderers/webgpu/utils/WebGPUUtils.js +17 -11
- package/src/renderers/webxr/WebXRManager.js +2 -2
- package/src/textures/CubeDepthTexture.js +76 -0
- package/src/textures/Source.js +1 -1
- package/src/textures/Texture.js +3 -3
- package/src/utils.js +258 -3
- package/examples/jsm/materials/MeshGouraudMaterial.js +0 -434
- package/examples/jsm/materials/MeshPostProcessingMaterial.js +0 -167
- package/examples/jsm/shaders/GodRaysShader.js +0 -333
- package/src/nodes/accessors/SceneNode.js +0 -145
- package/src/nodes/code/ScriptableNode.js +0 -726
- package/src/nodes/code/ScriptableValueNode.js +0 -253
- package/src/nodes/display/PosterizeNode.js +0 -65
- package/src/nodes/functions/BSDF/DFGApprox.js +0 -71
- package/src/nodes/utils/SpriteSheetUVNode.js +0 -90
- package/src/renderers/webgl/WebGLCubeMaps.js +0 -99
- package/src/renderers/webgl/WebGLCubeUVMaps.js +0 -134
|
@@ -1,12 +1,284 @@
|
|
|
1
|
-
import { Matrix3, NodeMaterial } from 'three/webgpu';
|
|
2
|
-
import { clamp,
|
|
1
|
+
import { Matrix3, NodeMaterial, Vector3 } from 'three/webgpu';
|
|
2
|
+
import { clamp, Fn, vec4, uv, uniform, max } from 'three/tsl';
|
|
3
3
|
import StereoCompositePassNode from './StereoCompositePassNode.js';
|
|
4
|
+
import { frameCorners } from '../../utils/CameraUtils.js';
|
|
5
|
+
|
|
6
|
+
const _eyeL = /*@__PURE__*/ new Vector3();
|
|
7
|
+
const _eyeR = /*@__PURE__*/ new Vector3();
|
|
8
|
+
const _screenBottomLeft = /*@__PURE__*/ new Vector3();
|
|
9
|
+
const _screenBottomRight = /*@__PURE__*/ new Vector3();
|
|
10
|
+
const _screenTopLeft = /*@__PURE__*/ new Vector3();
|
|
11
|
+
const _right = /*@__PURE__*/ new Vector3();
|
|
12
|
+
const _up = /*@__PURE__*/ new Vector3();
|
|
13
|
+
const _forward = /*@__PURE__*/ new Vector3();
|
|
14
|
+
const _screenCenter = /*@__PURE__*/ new Vector3();
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Anaglyph algorithm types.
|
|
18
|
+
* @readonly
|
|
19
|
+
* @enum {string}
|
|
20
|
+
*/
|
|
21
|
+
const AnaglyphAlgorithm = {
|
|
22
|
+
TRUE: 'true',
|
|
23
|
+
GREY: 'grey',
|
|
24
|
+
COLOUR: 'colour',
|
|
25
|
+
HALF_COLOUR: 'halfColour',
|
|
26
|
+
DUBOIS: 'dubois',
|
|
27
|
+
OPTIMISED: 'optimised',
|
|
28
|
+
COMPROMISE: 'compromise'
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Anaglyph color modes.
|
|
33
|
+
* @readonly
|
|
34
|
+
* @enum {string}
|
|
35
|
+
*/
|
|
36
|
+
const AnaglyphColorMode = {
|
|
37
|
+
RED_CYAN: 'redCyan',
|
|
38
|
+
MAGENTA_CYAN: 'magentaCyan',
|
|
39
|
+
MAGENTA_GREEN: 'magentaGreen'
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Standard luminance coefficients (ITU-R BT.601).
|
|
44
|
+
* @private
|
|
45
|
+
*/
|
|
46
|
+
const LUMINANCE = { R: 0.299, G: 0.587, B: 0.114 };
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Creates an anaglyph matrix pair from left and right channel specifications.
|
|
50
|
+
* This provides a more intuitive way to define how source RGB channels map to output RGB channels.
|
|
51
|
+
*
|
|
52
|
+
* Each specification object has keys 'r', 'g', 'b' for output channels.
|
|
53
|
+
* Each output channel value is [rCoef, gCoef, bCoef] defining how much of each input channel contributes.
|
|
54
|
+
*
|
|
55
|
+
* @private
|
|
56
|
+
* @param {Object} leftSpec - Specification for left eye contribution
|
|
57
|
+
* @param {Object} rightSpec - Specification for right eye contribution
|
|
58
|
+
* @returns {{left: number[], right: number[]}} Column-major arrays for Matrix3
|
|
59
|
+
*/
|
|
60
|
+
function createMatrixPair( leftSpec, rightSpec ) {
|
|
61
|
+
|
|
62
|
+
// Convert row-major specification to column-major array for Matrix3
|
|
63
|
+
// Matrix3.fromArray expects [col0row0, col0row1, col0row2, col1row0, col1row1, col1row2, col2row0, col2row1, col2row2]
|
|
64
|
+
// Which represents:
|
|
65
|
+
// | col0row0 col1row0 col2row0 | | m[0] m[3] m[6] |
|
|
66
|
+
// | col0row1 col1row1 col2row1 | = | m[1] m[4] m[7] |
|
|
67
|
+
// | col0row2 col1row2 col2row2 | | m[2] m[5] m[8] |
|
|
68
|
+
|
|
69
|
+
function specToColumnMajor( spec ) {
|
|
70
|
+
|
|
71
|
+
const r = spec.r || [ 0, 0, 0 ]; // Output red channel coefficients [fromR, fromG, fromB]
|
|
72
|
+
const g = spec.g || [ 0, 0, 0 ]; // Output green channel coefficients
|
|
73
|
+
const b = spec.b || [ 0, 0, 0 ]; // Output blue channel coefficients
|
|
74
|
+
|
|
75
|
+
// Row-major matrix would be:
|
|
76
|
+
// | r[0] r[1] r[2] | (how input RGB maps to output R)
|
|
77
|
+
// | g[0] g[1] g[2] | (how input RGB maps to output G)
|
|
78
|
+
// | b[0] b[1] b[2] | (how input RGB maps to output B)
|
|
79
|
+
|
|
80
|
+
// Column-major for Matrix3:
|
|
81
|
+
return [
|
|
82
|
+
r[ 0 ], g[ 0 ], b[ 0 ], // Column 0: coefficients for input R
|
|
83
|
+
r[ 1 ], g[ 1 ], b[ 1 ], // Column 1: coefficients for input G
|
|
84
|
+
r[ 2 ], g[ 2 ], b[ 2 ] // Column 2: coefficients for input B
|
|
85
|
+
];
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
left: specToColumnMajor( leftSpec ),
|
|
91
|
+
right: specToColumnMajor( rightSpec )
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
}
|
|
4
95
|
|
|
5
96
|
/**
|
|
6
|
-
*
|
|
97
|
+
* Shorthand for luminance coefficients.
|
|
98
|
+
* @private
|
|
99
|
+
*/
|
|
100
|
+
const LUM = [ LUMINANCE.R, LUMINANCE.G, LUMINANCE.B ];
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Conversion matrices for different anaglyph algorithms.
|
|
104
|
+
* Based on research from "Introducing a New Anaglyph Method: Compromise Anaglyph" by Jure Ahtik
|
|
105
|
+
* and various other sources.
|
|
106
|
+
*
|
|
107
|
+
* Matrices are defined using createMatrixPair for clarity:
|
|
108
|
+
* - Each spec object defines how input RGB maps to output RGB
|
|
109
|
+
* - Keys 'r', 'g', 'b' represent output channels
|
|
110
|
+
* - Values are [rCoef, gCoef, bCoef] for input channel contribution
|
|
111
|
+
*
|
|
112
|
+
* @private
|
|
113
|
+
*/
|
|
114
|
+
const ANAGLYPH_MATRICES = {
|
|
115
|
+
|
|
116
|
+
// True Anaglyph - Red channel from left, luminance to cyan channel for right
|
|
117
|
+
// Paper: Left=[R,0,0], Right=[0,0,Lum]
|
|
118
|
+
[ AnaglyphAlgorithm.TRUE ]: {
|
|
119
|
+
[ AnaglyphColorMode.RED_CYAN ]: createMatrixPair(
|
|
120
|
+
{ r: [ 1, 0, 0 ] }, // Left: R -> outR
|
|
121
|
+
{ g: LUM, b: LUM } // Right: Lum -> outG, Lum -> outB
|
|
122
|
+
),
|
|
123
|
+
[ AnaglyphColorMode.MAGENTA_CYAN ]: createMatrixPair(
|
|
124
|
+
{ r: [ 1, 0, 0 ], b: [ 0, 0, 0.5 ] }, // Left: R -> outR, partial B -> outB
|
|
125
|
+
{ g: LUM, b: [ 0, 0, 0.5 ] } // Right: Lum -> outG, partial B
|
|
126
|
+
),
|
|
127
|
+
[ AnaglyphColorMode.MAGENTA_GREEN ]: createMatrixPair(
|
|
128
|
+
{ r: [ 1, 0, 0 ], b: LUM }, // Left: R -> outR, Lum -> outB
|
|
129
|
+
{ g: LUM } // Right: Lum -> outG
|
|
130
|
+
)
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
// Grey Anaglyph - Luminance-based, no color, minimal ghosting
|
|
134
|
+
// Paper: Left=[Lum,0,0], Right=[0,0,Lum]
|
|
135
|
+
[ AnaglyphAlgorithm.GREY ]: {
|
|
136
|
+
[ AnaglyphColorMode.RED_CYAN ]: createMatrixPair(
|
|
137
|
+
{ r: LUM }, // Left: Lum -> outR
|
|
138
|
+
{ g: LUM, b: LUM } // Right: Lum -> outG, Lum -> outB
|
|
139
|
+
),
|
|
140
|
+
[ AnaglyphColorMode.MAGENTA_CYAN ]: createMatrixPair(
|
|
141
|
+
{ r: LUM, b: [ 0.15, 0.29, 0.06 ] }, // Left: Lum -> outR, half-Lum -> outB
|
|
142
|
+
{ g: LUM, b: [ 0.15, 0.29, 0.06 ] } // Right: Lum -> outG, half-Lum -> outB
|
|
143
|
+
),
|
|
144
|
+
[ AnaglyphColorMode.MAGENTA_GREEN ]: createMatrixPair(
|
|
145
|
+
{ r: LUM, b: LUM }, // Left: Lum -> outR, Lum -> outB
|
|
146
|
+
{ g: LUM } // Right: Lum -> outG
|
|
147
|
+
)
|
|
148
|
+
},
|
|
149
|
+
|
|
150
|
+
// Colour Anaglyph - Full color, high retinal rivalry
|
|
151
|
+
// Paper: Left=[R,0,0], Right=[0,G,B]
|
|
152
|
+
[ AnaglyphAlgorithm.COLOUR ]: {
|
|
153
|
+
[ AnaglyphColorMode.RED_CYAN ]: createMatrixPair(
|
|
154
|
+
{ r: [ 1, 0, 0 ] }, // Left: R -> outR
|
|
155
|
+
{ g: [ 0, 1, 0 ], b: [ 0, 0, 1 ] } // Right: G -> outG, B -> outB
|
|
156
|
+
),
|
|
157
|
+
[ AnaglyphColorMode.MAGENTA_CYAN ]: createMatrixPair(
|
|
158
|
+
{ r: [ 1, 0, 0 ], b: [ 0, 0, 0.5 ] }, // Left: R -> outR, partial B -> outB
|
|
159
|
+
{ g: [ 0, 1, 0 ], b: [ 0, 0, 0.5 ] } // Right: G -> outG, partial B -> outB
|
|
160
|
+
),
|
|
161
|
+
[ AnaglyphColorMode.MAGENTA_GREEN ]: createMatrixPair(
|
|
162
|
+
{ r: [ 1, 0, 0 ], b: [ 0, 0, 1 ] }, // Left: R -> outR, B -> outB
|
|
163
|
+
{ g: [ 0, 1, 0 ] } // Right: G -> outG
|
|
164
|
+
)
|
|
165
|
+
},
|
|
166
|
+
|
|
167
|
+
// Half-Colour Anaglyph - Luminance for left red, full color for right cyan
|
|
168
|
+
// Paper: Left=[Lum,0,0], Right=[0,G,B]
|
|
169
|
+
[ AnaglyphAlgorithm.HALF_COLOUR ]: {
|
|
170
|
+
[ AnaglyphColorMode.RED_CYAN ]: createMatrixPair(
|
|
171
|
+
{ r: LUM }, // Left: Lum -> outR
|
|
172
|
+
{ g: [ 0, 1, 0 ], b: [ 0, 0, 1 ] } // Right: G -> outG, B -> outB
|
|
173
|
+
),
|
|
174
|
+
[ AnaglyphColorMode.MAGENTA_CYAN ]: createMatrixPair(
|
|
175
|
+
{ r: LUM, b: [ 0.15, 0.29, 0.06 ] }, // Left: Lum -> outR, half-Lum -> outB
|
|
176
|
+
{ g: [ 0, 1, 0 ], b: [ 0.15, 0.29, 0.06 ] } // Right: G -> outG, half-Lum -> outB
|
|
177
|
+
),
|
|
178
|
+
[ AnaglyphColorMode.MAGENTA_GREEN ]: createMatrixPair(
|
|
179
|
+
{ r: LUM, b: LUM }, // Left: Lum -> outR, Lum -> outB
|
|
180
|
+
{ g: [ 0, 1, 0 ] } // Right: G -> outG
|
|
181
|
+
)
|
|
182
|
+
},
|
|
183
|
+
|
|
184
|
+
// Dubois Anaglyph - Least-squares optimized for specific glasses
|
|
185
|
+
// From https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.7.6968&rep=rep1&type=pdf
|
|
186
|
+
[ AnaglyphAlgorithm.DUBOIS ]: {
|
|
187
|
+
[ AnaglyphColorMode.RED_CYAN ]: createMatrixPair(
|
|
188
|
+
{
|
|
189
|
+
r: [ 0.4561, 0.500484, 0.176381 ],
|
|
190
|
+
g: [ - 0.0400822, - 0.0378246, - 0.0157589 ],
|
|
191
|
+
b: [ - 0.0152161, - 0.0205971, - 0.00546856 ]
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
r: [ - 0.0434706, - 0.0879388, - 0.00155529 ],
|
|
195
|
+
g: [ 0.378476, 0.73364, - 0.0184503 ],
|
|
196
|
+
b: [ - 0.0721527, - 0.112961, 1.2264 ]
|
|
197
|
+
}
|
|
198
|
+
),
|
|
199
|
+
[ AnaglyphColorMode.MAGENTA_CYAN ]: createMatrixPair(
|
|
200
|
+
{
|
|
201
|
+
r: [ 0.4561, 0.500484, 0.176381 ],
|
|
202
|
+
g: [ - 0.0400822, - 0.0378246, - 0.0157589 ],
|
|
203
|
+
b: [ 0.088, 0.088, - 0.003 ]
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
r: [ - 0.0434706, - 0.0879388, - 0.00155529 ],
|
|
207
|
+
g: [ 0.378476, 0.73364, - 0.0184503 ],
|
|
208
|
+
b: [ 0.088, 0.088, 0.613 ]
|
|
209
|
+
}
|
|
210
|
+
),
|
|
211
|
+
[ AnaglyphColorMode.MAGENTA_GREEN ]: createMatrixPair(
|
|
212
|
+
{
|
|
213
|
+
r: [ 0.4561, 0.500484, 0.176381 ],
|
|
214
|
+
b: [ - 0.0434706, - 0.0879388, - 0.00155529 ]
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
g: [ 0.378476 + 0.4561, 0.73364 + 0.500484, - 0.0184503 + 0.176381 ]
|
|
218
|
+
}
|
|
219
|
+
)
|
|
220
|
+
},
|
|
221
|
+
|
|
222
|
+
// Optimised Anaglyph - Improved color with reduced retinal rivalry
|
|
223
|
+
// Paper: Left=[0,0.7G+0.3B,0,0], Right=[0,G,B]
|
|
224
|
+
[ AnaglyphAlgorithm.OPTIMISED ]: {
|
|
225
|
+
[ AnaglyphColorMode.RED_CYAN ]: createMatrixPair(
|
|
226
|
+
{ r: [ 0, 0.7, 0.3 ] }, // Left: 0.7G+0.3B -> outR
|
|
227
|
+
{ g: [ 0, 1, 0 ], b: [ 0, 0, 1 ] } // Right: G -> outG, B -> outB
|
|
228
|
+
),
|
|
229
|
+
[ AnaglyphColorMode.MAGENTA_CYAN ]: createMatrixPair(
|
|
230
|
+
{ r: [ 0, 0.7, 0.3 ], b: [ 0, 0, 0.5 ] }, // Left: 0.7G+0.3B -> outR, partial B
|
|
231
|
+
{ g: [ 0, 1, 0 ], b: [ 0, 0, 0.5 ] } // Right: G -> outG, partial B
|
|
232
|
+
),
|
|
233
|
+
[ AnaglyphColorMode.MAGENTA_GREEN ]: createMatrixPair(
|
|
234
|
+
{ r: [ 0, 0.7, 0.3 ], b: [ 0, 0, 1 ] }, // Left: 0.7G+0.3B -> outR, B -> outB
|
|
235
|
+
{ g: [ 0, 1, 0 ] } // Right: G -> outG
|
|
236
|
+
)
|
|
237
|
+
},
|
|
238
|
+
|
|
239
|
+
// Compromise Anaglyph - Best balance of color and stereo effect
|
|
240
|
+
// From Ahtik, J., "Techniques of Rendering Anaglyphs for Use in Art"
|
|
241
|
+
// Paper matrix [8]: Left=[0.439R+0.447G+0.148B, 0, 0], Right=[0, 0.095R+0.934G+0.005B, 0.018R+0.028G+1.057B]
|
|
242
|
+
[ AnaglyphAlgorithm.COMPROMISE ]: {
|
|
243
|
+
[ AnaglyphColorMode.RED_CYAN ]: createMatrixPair(
|
|
244
|
+
{ r: [ 0.439, 0.447, 0.148 ] }, // Left: weighted RGB -> outR
|
|
245
|
+
{
|
|
246
|
+
g: [ 0.095, 0.934, 0.005 ], // Right: weighted RGB -> outG
|
|
247
|
+
b: [ 0.018, 0.028, 1.057 ] // Right: weighted RGB -> outB
|
|
248
|
+
}
|
|
249
|
+
),
|
|
250
|
+
[ AnaglyphColorMode.MAGENTA_CYAN ]: createMatrixPair(
|
|
251
|
+
{
|
|
252
|
+
r: [ 0.439, 0.447, 0.148 ],
|
|
253
|
+
b: [ 0.009, 0.014, 0.074 ] // Partial blue from left
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
g: [ 0.095, 0.934, 0.005 ],
|
|
257
|
+
b: [ 0.009, 0.014, 0.528 ] // Partial blue from right
|
|
258
|
+
}
|
|
259
|
+
),
|
|
260
|
+
[ AnaglyphColorMode.MAGENTA_GREEN ]: createMatrixPair(
|
|
261
|
+
{
|
|
262
|
+
r: [ 0.439, 0.447, 0.148 ],
|
|
263
|
+
b: [ 0.018, 0.028, 1.057 ]
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
g: [ 0.095 + 0.439, 0.934 + 0.447, 0.005 + 0.148 ]
|
|
267
|
+
}
|
|
268
|
+
)
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* A render pass node that creates an anaglyph effect using physically-correct
|
|
274
|
+
* off-axis stereo projection.
|
|
275
|
+
*
|
|
276
|
+
* This implementation uses CameraUtils.frameCorners() to align stereo
|
|
277
|
+
* camera frustums to a virtual screen plane, providing accurate depth
|
|
278
|
+
* perception with zero parallax at the plane distance.
|
|
7
279
|
*
|
|
8
280
|
* @augments StereoCompositePassNode
|
|
9
|
-
* @three_import import { anaglyphPass } from 'three/addons/tsl/display/AnaglyphPassNode.js';
|
|
281
|
+
* @three_import import { anaglyphPass, AnaglyphAlgorithm, AnaglyphColorMode } from 'three/addons/tsl/display/AnaglyphPassNode.js';
|
|
10
282
|
*/
|
|
11
283
|
class AnaglyphPassNode extends StereoCompositePassNode {
|
|
12
284
|
|
|
@@ -35,29 +307,197 @@ class AnaglyphPassNode extends StereoCompositePassNode {
|
|
|
35
307
|
*/
|
|
36
308
|
this.isAnaglyphPassNode = true;
|
|
37
309
|
|
|
38
|
-
|
|
310
|
+
/**
|
|
311
|
+
* The interpupillary distance (eye separation) in world units.
|
|
312
|
+
* Typical human IPD is 0.064 meters (64mm).
|
|
313
|
+
*
|
|
314
|
+
* @type {number}
|
|
315
|
+
* @default 0.064
|
|
316
|
+
*/
|
|
317
|
+
this.eyeSep = 0.064;
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* The distance in world units from the viewer to the virtual
|
|
321
|
+
* screen plane where zero parallax (screen depth) occurs.
|
|
322
|
+
* Objects at this distance appear at the screen surface.
|
|
323
|
+
* Objects closer appear in front of the screen (negative parallax).
|
|
324
|
+
* Objects further appear behind the screen (positive parallax).
|
|
325
|
+
*
|
|
326
|
+
* The screen dimensions are derived from the camera's FOV and aspect ratio
|
|
327
|
+
* at this distance, ensuring the stereo view matches the camera's field of view.
|
|
328
|
+
*
|
|
329
|
+
* @type {number}
|
|
330
|
+
* @default 0.5
|
|
331
|
+
*/
|
|
332
|
+
this.planeDistance = 0.5;
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* The current anaglyph algorithm.
|
|
336
|
+
*
|
|
337
|
+
* @private
|
|
338
|
+
* @type {string}
|
|
339
|
+
* @default 'dubois'
|
|
340
|
+
*/
|
|
341
|
+
this._algorithm = AnaglyphAlgorithm.DUBOIS;
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* The current color mode.
|
|
345
|
+
*
|
|
346
|
+
* @private
|
|
347
|
+
* @type {string}
|
|
348
|
+
* @default 'redCyan'
|
|
349
|
+
*/
|
|
350
|
+
this._colorMode = AnaglyphColorMode.RED_CYAN;
|
|
39
351
|
|
|
40
352
|
/**
|
|
41
353
|
* Color matrix node for the left eye.
|
|
42
354
|
*
|
|
355
|
+
* @private
|
|
43
356
|
* @type {UniformNode<mat3>}
|
|
44
357
|
*/
|
|
45
|
-
this._colorMatrixLeft = uniform( new Matrix3()
|
|
46
|
-
0.456100, - 0.0400822, - 0.0152161,
|
|
47
|
-
0.500484, - 0.0378246, - 0.0205971,
|
|
48
|
-
0.176381, - 0.0157589, - 0.00546856
|
|
49
|
-
] ) );
|
|
358
|
+
this._colorMatrixLeft = uniform( new Matrix3() );
|
|
50
359
|
|
|
51
360
|
/**
|
|
52
361
|
* Color matrix node for the right eye.
|
|
53
362
|
*
|
|
363
|
+
* @private
|
|
54
364
|
* @type {UniformNode<mat3>}
|
|
55
365
|
*/
|
|
56
|
-
this._colorMatrixRight = uniform( new Matrix3()
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
366
|
+
this._colorMatrixRight = uniform( new Matrix3() );
|
|
367
|
+
|
|
368
|
+
// Initialize with default matrices
|
|
369
|
+
this._updateMatrices();
|
|
370
|
+
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Gets the current anaglyph algorithm.
|
|
375
|
+
*
|
|
376
|
+
* @type {string}
|
|
377
|
+
*/
|
|
378
|
+
get algorithm() {
|
|
379
|
+
|
|
380
|
+
return this._algorithm;
|
|
381
|
+
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Sets the anaglyph algorithm.
|
|
386
|
+
*
|
|
387
|
+
* @type {string}
|
|
388
|
+
*/
|
|
389
|
+
set algorithm( value ) {
|
|
390
|
+
|
|
391
|
+
if ( this._algorithm !== value ) {
|
|
392
|
+
|
|
393
|
+
this._algorithm = value;
|
|
394
|
+
this._updateMatrices();
|
|
395
|
+
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Gets the current color mode.
|
|
402
|
+
*
|
|
403
|
+
* @type {string}
|
|
404
|
+
*/
|
|
405
|
+
get colorMode() {
|
|
406
|
+
|
|
407
|
+
return this._colorMode;
|
|
408
|
+
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Sets the color mode.
|
|
413
|
+
*
|
|
414
|
+
* @type {string}
|
|
415
|
+
*/
|
|
416
|
+
set colorMode( value ) {
|
|
417
|
+
|
|
418
|
+
if ( this._colorMode !== value ) {
|
|
419
|
+
|
|
420
|
+
this._colorMode = value;
|
|
421
|
+
this._updateMatrices();
|
|
422
|
+
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Updates the color matrices based on current algorithm and color mode.
|
|
429
|
+
*
|
|
430
|
+
* @private
|
|
431
|
+
*/
|
|
432
|
+
_updateMatrices() {
|
|
433
|
+
|
|
434
|
+
const matrices = ANAGLYPH_MATRICES[ this._algorithm ][ this._colorMode ];
|
|
435
|
+
|
|
436
|
+
this._colorMatrixLeft.value.fromArray( matrices.left );
|
|
437
|
+
this._colorMatrixRight.value.fromArray( matrices.right );
|
|
438
|
+
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Updates the internal stereo camera using frameCorners for
|
|
443
|
+
* physically-correct off-axis projection.
|
|
444
|
+
*
|
|
445
|
+
* @param {number} coordinateSystem - The current coordinate system.
|
|
446
|
+
*/
|
|
447
|
+
updateStereoCamera( coordinateSystem ) {
|
|
448
|
+
|
|
449
|
+
const { stereo, camera } = this;
|
|
450
|
+
|
|
451
|
+
stereo.cameraL.coordinateSystem = coordinateSystem;
|
|
452
|
+
stereo.cameraR.coordinateSystem = coordinateSystem;
|
|
453
|
+
|
|
454
|
+
// Get the camera's local coordinate axes from its world matrix
|
|
455
|
+
camera.matrixWorld.extractBasis( _right, _up, _forward );
|
|
456
|
+
_right.normalize();
|
|
457
|
+
_up.normalize();
|
|
458
|
+
_forward.normalize();
|
|
459
|
+
|
|
460
|
+
// Calculate eye positions
|
|
461
|
+
const halfSep = this.eyeSep / 2;
|
|
462
|
+
_eyeL.copy( camera.position ).addScaledVector( _right, - halfSep );
|
|
463
|
+
_eyeR.copy( camera.position ).addScaledVector( _right, halfSep );
|
|
464
|
+
|
|
465
|
+
// Calculate screen center (at planeDistance in front of the camera center)
|
|
466
|
+
_screenCenter.copy( camera.position ).addScaledVector( _forward, - this.planeDistance );
|
|
467
|
+
|
|
468
|
+
// Calculate screen dimensions from camera FOV and aspect ratio
|
|
469
|
+
const DEG2RAD = Math.PI / 180;
|
|
470
|
+
const halfHeight = this.planeDistance * Math.tan( DEG2RAD * camera.fov / 2 );
|
|
471
|
+
const halfWidth = halfHeight * camera.aspect;
|
|
472
|
+
|
|
473
|
+
// Calculate screen corners
|
|
474
|
+
_screenBottomLeft.copy( _screenCenter )
|
|
475
|
+
.addScaledVector( _right, - halfWidth )
|
|
476
|
+
.addScaledVector( _up, - halfHeight );
|
|
477
|
+
|
|
478
|
+
_screenBottomRight.copy( _screenCenter )
|
|
479
|
+
.addScaledVector( _right, halfWidth )
|
|
480
|
+
.addScaledVector( _up, - halfHeight );
|
|
481
|
+
|
|
482
|
+
_screenTopLeft.copy( _screenCenter )
|
|
483
|
+
.addScaledVector( _right, - halfWidth )
|
|
484
|
+
.addScaledVector( _up, halfHeight );
|
|
485
|
+
|
|
486
|
+
// Set up left eye camera
|
|
487
|
+
stereo.cameraL.position.copy( _eyeL );
|
|
488
|
+
stereo.cameraL.near = camera.near;
|
|
489
|
+
stereo.cameraL.far = camera.far;
|
|
490
|
+
frameCorners( stereo.cameraL, _screenBottomLeft, _screenBottomRight, _screenTopLeft, true );
|
|
491
|
+
stereo.cameraL.matrixWorld.compose( stereo.cameraL.position, stereo.cameraL.quaternion, stereo.cameraL.scale );
|
|
492
|
+
stereo.cameraL.matrixWorldInverse.copy( stereo.cameraL.matrixWorld ).invert();
|
|
493
|
+
|
|
494
|
+
// Set up right eye camera
|
|
495
|
+
stereo.cameraR.position.copy( _eyeR );
|
|
496
|
+
stereo.cameraR.near = camera.near;
|
|
497
|
+
stereo.cameraR.far = camera.far;
|
|
498
|
+
frameCorners( stereo.cameraR, _screenBottomLeft, _screenBottomRight, _screenTopLeft, true );
|
|
499
|
+
stereo.cameraR.matrixWorld.compose( stereo.cameraR.position, stereo.cameraR.quaternion, stereo.cameraR.scale );
|
|
500
|
+
stereo.cameraR.matrixWorldInverse.copy( stereo.cameraR.matrixWorld ).invert();
|
|
61
501
|
|
|
62
502
|
}
|
|
63
503
|
|
|
@@ -95,6 +535,8 @@ class AnaglyphPassNode extends StereoCompositePassNode {
|
|
|
95
535
|
|
|
96
536
|
export default AnaglyphPassNode;
|
|
97
537
|
|
|
538
|
+
export { AnaglyphAlgorithm, AnaglyphColorMode };
|
|
539
|
+
|
|
98
540
|
/**
|
|
99
541
|
* TSL function for creating an anaglyph pass node.
|
|
100
542
|
*
|
|
@@ -104,4 +546,4 @@ export default AnaglyphPassNode;
|
|
|
104
546
|
* @param {Camera} camera - The camera to render the scene with.
|
|
105
547
|
* @returns {AnaglyphPassNode}
|
|
106
548
|
*/
|
|
107
|
-
export const anaglyphPass = ( scene, camera ) =>
|
|
549
|
+
export const anaglyphPass = ( scene, camera ) => new AnaglyphPassNode( scene, camera );
|
|
@@ -277,6 +277,6 @@ class AnamorphicNode extends TempNode {
|
|
|
277
277
|
* @param {number} [samples=32] - More samples result in larger flares and a more expensive runtime behavior.
|
|
278
278
|
* @returns {AnamorphicNode}
|
|
279
279
|
*/
|
|
280
|
-
export const anamorphic = ( node, threshold = .9, scale = 3, samples = 32 ) =>
|
|
280
|
+
export const anamorphic = ( node, threshold = .9, scale = 3, samples = 32 ) => new AnamorphicNode( convertToTexture( node ), nodeObject( threshold ), nodeObject( scale ), samples );
|
|
281
281
|
|
|
282
282
|
export default AnamorphicNode;
|