super-three 0.141.0 → 0.144.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/build/three.cjs +1558 -1034
- package/build/three.js +1558 -1034
- package/build/three.min.js +1 -1
- package/build/three.module.js +2012 -1243
- package/examples/js/animation/MMDPhysics.js +1 -16
- package/examples/js/controls/ArcballControls.js +16 -3
- package/examples/js/controls/FirstPersonControls.js +0 -7
- package/examples/js/controls/FlyControls.js +0 -8
- package/examples/js/controls/OrbitControls.js +0 -4
- package/examples/js/controls/PointerLockControls.js +0 -8
- package/examples/js/controls/TrackballControls.js +0 -2
- package/examples/js/controls/TransformControls.js +20 -16
- package/examples/js/effects/AnaglyphEffect.js +2 -2
- package/examples/js/effects/OutlineEffect.js +4 -24
- package/examples/js/effects/ParallaxBarrierEffect.js +2 -2
- package/examples/js/effects/PeppersGhostEffect.js +2 -2
- package/examples/js/effects/StereoEffect.js +2 -2
- package/examples/js/environments/RoomEnvironment.js +22 -0
- package/examples/js/exporters/ColladaExporter.js +4 -13
- package/examples/js/exporters/DRACOExporter.js +0 -12
- package/examples/js/exporters/GLTFExporter.js +28 -29
- package/examples/js/exporters/OBJExporter.js +2 -23
- package/examples/js/exporters/PLYExporter.js +12 -24
- package/examples/js/exporters/STLExporter.js +0 -7
- package/examples/js/exporters/USDZExporter.js +6 -0
- package/examples/js/geometries/ConvexGeometry.js +1 -1
- package/examples/js/geometries/ParametricGeometry.js +1 -8
- package/examples/js/interactive/SelectionHelper.js +2 -0
- package/examples/js/libs/ktx-parse.umd.js +1 -0
- package/examples/js/libs/meshopt_decoder.js +98 -32
- package/examples/js/loaders/ColladaLoader.js +1 -0
- package/examples/js/loaders/DRACOLoader.js +2 -25
- package/examples/js/loaders/EXRLoader.js +2 -13
- package/examples/js/loaders/FBXLoader.js +10 -3
- package/examples/js/loaders/FontLoader.js +3 -16
- package/examples/js/loaders/GLTFLoader.js +52 -36
- package/examples/js/loaders/HDRCubeTextureLoader.js +0 -11
- package/examples/js/loaders/LDrawLoader.js +139 -74
- package/examples/js/loaders/OBJLoader.js +7 -13
- package/examples/js/loaders/PCDLoader.js +59 -14
- package/examples/js/loaders/PLYLoader.js +3 -3
- package/examples/js/loaders/SVGLoader.js +4 -3
- package/examples/js/loaders/TIFFLoader.js +31 -0
- package/examples/js/loaders/VRMLLoader.js +33 -24
- package/examples/js/loaders/VTKLoader.js +1 -1
- package/examples/js/loaders/lwo/LWO2Parser.js +8 -7
- package/examples/js/loaders/lwo/LWO3Parser.js +8 -7
- package/examples/js/materials/MeshGouraudMaterial.js +385 -0
- package/examples/js/math/ColorConverter.js +0 -50
- package/examples/js/misc/GPUComputationRenderer.js +23 -0
- package/examples/js/misc/Volume.js +198 -190
- package/examples/js/misc/VolumeSlice.js +90 -88
- package/examples/js/modifiers/SimplifyModifier.js +1 -1
- package/examples/js/objects/GroundProjectedEnv.js +193 -0
- package/examples/js/objects/Reflector.js +9 -2
- package/examples/js/objects/ReflectorForSSRPass.js +3 -4
- package/examples/js/objects/Refractor.js +10 -4
- package/examples/js/objects/ShadowMesh.js +5 -1
- package/examples/js/postprocessing/OutlinePass.js +5 -3
- package/examples/js/renderers/CSS2DRenderer.js +2 -2
- package/examples/js/renderers/CSS3DRenderer.js +2 -2
- package/examples/js/renderers/Projector.js +2 -23
- package/examples/js/shaders/LuminosityShader.js +1 -1
- package/examples/js/shaders/MMDToonShader.js +6 -2
- package/examples/js/shaders/ToneMapShader.js +1 -1
- package/examples/js/utils/BufferGeometryUtils.js +1 -1
- package/examples/js/utils/GeometryUtils.js +2 -18
- package/examples/js/utils/PackedPhongMaterial.js +1 -1
- package/examples/js/utils/SceneUtils.js +0 -16
- package/examples/jsm/animation/MMDPhysics.js +3 -22
- package/examples/jsm/controls/ArcballControls.js +17 -2
- package/examples/jsm/controls/FirstPersonControls.js +0 -7
- package/examples/jsm/controls/FlyControls.js +0 -7
- package/examples/jsm/controls/OrbitControls.js +0 -5
- package/examples/jsm/controls/PointerLockControls.js +0 -7
- package/examples/jsm/controls/TrackballControls.js +0 -3
- package/examples/jsm/controls/TransformControls.js +18 -16
- package/examples/jsm/effects/AnaglyphEffect.js +2 -2
- package/examples/jsm/effects/OutlineEffect.js +4 -25
- package/examples/jsm/effects/ParallaxBarrierEffect.js +2 -2
- package/examples/jsm/effects/PeppersGhostEffect.js +2 -2
- package/examples/jsm/effects/StereoEffect.js +2 -2
- package/examples/jsm/environments/RoomEnvironment.js +23 -0
- package/examples/jsm/exporters/ColladaExporter.js +4 -13
- package/examples/jsm/exporters/DRACOExporter.js +0 -13
- package/examples/jsm/exporters/GLTFExporter.js +29 -31
- package/examples/jsm/exporters/KTX2Exporter.js +29 -29
- package/examples/jsm/exporters/OBJExporter.js +0 -18
- package/examples/jsm/exporters/PLYExporter.js +14 -22
- package/examples/jsm/exporters/STLExporter.js +1 -9
- package/examples/jsm/exporters/USDZExporter.js +14 -3
- package/examples/jsm/geometries/ConvexGeometry.js +1 -1
- package/examples/jsm/geometries/ParametricGeometry.js +0 -6
- package/examples/jsm/interactive/HTMLMesh.js +9 -9
- package/examples/jsm/interactive/SelectionHelper.js +5 -3
- package/examples/jsm/libs/meshopt_decoder.module.js +97 -32
- package/examples/jsm/libs/utif.module.js +1579 -0
- package/examples/jsm/libs/zstddec.module.js +1 -0
- package/examples/jsm/loaders/ColladaLoader.js +1 -0
- package/examples/jsm/loaders/DRACOLoader.js +2 -28
- package/examples/jsm/loaders/EXRLoader.js +3 -13
- package/examples/jsm/loaders/FBXLoader.js +10 -3
- package/examples/jsm/loaders/FontLoader.js +3 -16
- package/examples/jsm/loaders/GLTFLoader.js +52 -36
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +0 -13
- package/examples/jsm/loaders/KTX2Loader.js +192 -30
- package/examples/jsm/loaders/LDrawLoader.js +135 -74
- package/examples/jsm/loaders/OBJLoader.js +6 -14
- package/examples/jsm/loaders/PCDLoader.js +59 -13
- package/examples/jsm/loaders/PLYLoader.js +3 -3
- package/examples/jsm/loaders/RGBELoader.js +1 -1
- package/examples/jsm/loaders/SVGLoader.js +4 -3
- package/examples/jsm/loaders/TIFFLoader.js +36 -0
- package/examples/jsm/loaders/USDZLoader.js +393 -0
- package/examples/jsm/loaders/VRMLLoader.js +23 -25
- package/examples/jsm/loaders/VTKLoader.js +1 -1
- package/examples/jsm/loaders/lwo/LWO2Parser.js +6 -8
- package/examples/jsm/loaders/lwo/LWO3Parser.js +6 -8
- package/examples/jsm/materials/MeshGouraudMaterial.js +423 -0
- package/examples/jsm/math/ColorConverter.js +1 -49
- package/examples/jsm/misc/GPUComputationRenderer.js +43 -0
- package/examples/jsm/misc/Volume.js +169 -171
- package/examples/jsm/misc/VolumeSlice.js +78 -80
- package/examples/jsm/modifiers/SimplifyModifier.js +1 -1
- package/examples/jsm/node-editor/accessors/MatcapUVEditor.js +1 -1
- package/examples/jsm/node-editor/accessors/NormalEditor.js +1 -1
- package/examples/jsm/node-editor/accessors/PositionEditor.js +1 -1
- package/examples/jsm/node-editor/accessors/UVEditor.js +1 -1
- package/examples/jsm/node-editor/display/BlendEditor.js +1 -1
- package/examples/jsm/node-editor/display/NormalMapEditor.js +1 -1
- package/examples/jsm/node-editor/inputs/ColorEditor.js +1 -1
- package/examples/jsm/node-editor/inputs/FloatEditor.js +1 -1
- package/examples/jsm/node-editor/inputs/SliderEditor.js +1 -1
- package/examples/jsm/node-editor/inputs/TextureEditor.js +1 -1
- package/examples/jsm/node-editor/inputs/Vector2Editor.js +1 -1
- package/examples/jsm/node-editor/inputs/Vector3Editor.js +1 -1
- package/examples/jsm/node-editor/inputs/Vector4Editor.js +1 -1
- package/examples/jsm/node-editor/materials/BasicMaterialEditor.js +1 -1
- package/examples/jsm/node-editor/materials/PointsMaterialEditor.js +1 -1
- package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +1 -1
- package/examples/jsm/node-editor/math/AngleEditor.js +1 -1
- package/examples/jsm/node-editor/math/DotEditor.js +1 -1
- package/examples/jsm/node-editor/math/InvertEditor.js +1 -1
- package/examples/jsm/node-editor/math/LimiterEditor.js +1 -1
- package/examples/jsm/node-editor/math/NormalizeEditor.js +1 -1
- package/examples/jsm/node-editor/math/OperatorEditor.js +1 -1
- package/examples/jsm/node-editor/math/PowerEditor.js +1 -1
- package/examples/jsm/node-editor/math/TrigonometryEditor.js +1 -1
- package/examples/jsm/node-editor/procedural/CheckerEditor.js +1 -1
- package/examples/jsm/node-editor/utils/JoinEditor.js +1 -1
- package/examples/jsm/node-editor/utils/OscillatorEditor.js +1 -1
- package/examples/jsm/node-editor/utils/PreviewEditor.js +3 -3
- package/examples/jsm/node-editor/utils/SplitEditor.js +1 -1
- package/examples/jsm/node-editor/utils/TimerEditor.js +1 -1
- package/examples/jsm/nodes/Nodes.js +43 -13
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +9 -5
- package/examples/jsm/nodes/accessors/NormalNode.js +4 -4
- package/examples/jsm/nodes/accessors/PositionNode.js +5 -5
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +31 -0
- package/examples/jsm/nodes/core/AttributeNode.js +3 -3
- package/examples/jsm/nodes/core/CodeNode.js +3 -3
- package/examples/jsm/nodes/core/FunctionCallNode.js +20 -5
- package/examples/jsm/nodes/core/FunctionNode.js +2 -2
- package/examples/jsm/nodes/core/Node.js +14 -12
- package/examples/jsm/nodes/core/NodeBuilder.js +12 -12
- package/examples/jsm/nodes/core/NodeUtils.js +23 -1
- package/examples/jsm/nodes/core/{NodeVary.js → NodeVarying.js} +3 -3
- package/examples/jsm/nodes/core/{VaryNode.js → VaryingNode.js} +7 -7
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +94 -0
- package/examples/jsm/nodes/geometry/RangeNode.js +109 -0
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +2 -0
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +8 -7
- package/examples/jsm/nodes/lighting/LightingContextNode.js +4 -4
- package/examples/jsm/nodes/loaders/NodeLoader.js +2 -2
- package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +31 -0
- package/examples/jsm/nodes/materials/Materials.js +13 -25
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +70 -0
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +4 -7
- package/examples/jsm/nodes/materials/NodeMaterial.js +2 -2
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +28 -17
- package/examples/jsm/nodes/materialx/Disclaimer.md +199 -0
- package/examples/jsm/nodes/materialx/functions/lib/mx_hsv.js +56 -0
- package/examples/jsm/nodes/materialx/functions/lib/mx_noise.js +607 -0
- package/examples/jsm/nodes/math/MathNode.js +2 -12
- package/examples/jsm/nodes/parsers/GLSLNodeFunction.js +21 -6
- package/examples/jsm/nodes/procedural/CheckerNode.js +2 -2
- package/examples/jsm/nodes/shadernode/ShaderNode.js +5 -5
- package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +8 -5
- package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +20 -6
- package/examples/jsm/nodes/utils/ConvertNode.js +8 -3
- package/examples/jsm/nodes/utils/JoinNode.js +7 -7
- package/examples/jsm/nodes/utils/MaxMipLevelNode.js +2 -1
- package/examples/jsm/nodes/utils/RotateUVNode.js +32 -0
- package/examples/jsm/nodes/utils/SplitNode.js +21 -5
- package/examples/jsm/nodes/utils/TimerNode.js +2 -2
- package/examples/jsm/objects/GroundProjectedEnv.js +186 -0
- package/examples/jsm/objects/Reflector.js +12 -5
- package/examples/jsm/objects/ReflectorForSSRPass.js +3 -5
- package/examples/jsm/objects/Refractor.js +12 -6
- package/examples/jsm/objects/ShadowMesh.js +8 -2
- package/examples/jsm/postprocessing/OutlinePass.js +5 -3
- package/examples/jsm/renderers/CSS2DRenderer.js +2 -2
- package/examples/jsm/renderers/CSS3DRenderer.js +2 -2
- package/examples/jsm/renderers/Projector.js +2 -24
- package/examples/jsm/renderers/webgl/nodes/SlotNode.js +9 -5
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +329 -218
- package/examples/jsm/renderers/webgl/nodes/WebGLNodes.js +7 -3
- package/examples/jsm/renderers/webgpu/WebGPUBackground.js +39 -3
- package/examples/jsm/renderers/webgpu/WebGPUComputePipelines.js +6 -0
- package/examples/jsm/renderers/webgpu/WebGPUGeometries.js +6 -0
- package/examples/jsm/renderers/webgpu/WebGPUObjects.js +1 -1
- package/examples/jsm/renderers/webgpu/WebGPURenderPipeline.js +17 -19
- package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +16 -14
- package/examples/jsm/renderers/webgpu/WebGPURenderStates.js +2 -2
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +66 -81
- package/examples/jsm/renderers/webgpu/WebGPUTextureUtils.js +5 -3
- package/examples/jsm/renderers/webgpu/WebGPUTextures.js +2 -2
- package/examples/jsm/renderers/webgpu/WebGPUUtils.js +81 -0
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +25 -30
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodes.js +1 -1
- package/examples/jsm/shaders/LuminosityShader.js +1 -1
- package/examples/jsm/shaders/MMDToonShader.js +2 -2
- package/examples/jsm/shaders/ToneMapShader.js +1 -1
- package/examples/jsm/utils/BufferGeometryUtils.js +2 -1
- package/examples/jsm/utils/GeometryUtils.js +17 -25
- package/examples/jsm/utils/PackedPhongMaterial.js +0 -1
- package/examples/jsm/utils/SceneUtils.js +1 -21
- package/examples/jsm/webxr/OculusHandPointerModel.js +6 -1
- package/examples/jsm/webxr/VRButton.js +1 -7
- package/package.json +18 -14
- package/src/Three.Legacy.js +262 -36
- package/src/Three.js +3 -2
- package/src/animation/AnimationAction.js +6 -5
- package/src/animation/AnimationClip.js +1 -1
- package/src/animation/AnimationMixer.js +1 -1
- package/src/animation/AnimationUtils.js +204 -199
- package/src/animation/KeyframeTrack.js +1 -1
- package/src/animation/PropertyBinding.js +24 -5
- package/src/cameras/CubeCamera.js +0 -7
- package/src/constants.js +2 -4
- package/src/core/BufferAttribute.js +81 -111
- package/src/core/BufferGeometry.js +3 -41
- package/src/core/InstancedBufferAttribute.js +0 -10
- package/src/core/InterleavedBuffer.js +1 -1
- package/src/core/InterleavedBufferAttribute.js +56 -7
- package/src/core/Object3D.js +22 -5
- package/src/core/Uniform.js +0 -7
- package/src/core/UniformsGroup.js +92 -0
- package/src/extras/DataUtils.js +104 -88
- package/src/extras/core/Path.js +1 -0
- package/src/extras/core/ShapePath.js +1 -4
- package/src/extras/curves/CatmullRomCurve3.js +4 -2
- package/src/geometries/BoxGeometry.js +1 -1
- package/src/geometries/CapsuleGeometry.js +1 -1
- package/src/geometries/CircleGeometry.js +1 -1
- package/src/geometries/ConeGeometry.js +1 -1
- package/src/geometries/CylinderGeometry.js +2 -1
- package/src/geometries/DodecahedronGeometry.js +1 -1
- package/src/geometries/EdgesGeometry.js +5 -4
- package/src/geometries/ExtrudeGeometry.js +2 -11
- package/src/geometries/IcosahedronGeometry.js +1 -1
- package/src/geometries/LatheGeometry.js +2 -2
- package/src/geometries/OctahedronGeometry.js +1 -1
- package/src/geometries/PlaneGeometry.js +2 -1
- package/src/geometries/PolyhedronGeometry.js +1 -1
- package/src/geometries/RingGeometry.js +1 -1
- package/src/geometries/ShapeGeometry.js +2 -1
- package/src/geometries/SphereGeometry.js +2 -1
- package/src/geometries/TetrahedronGeometry.js +1 -1
- package/src/geometries/TorusGeometry.js +2 -1
- package/src/geometries/TorusKnotGeometry.js +2 -1
- package/src/geometries/TubeGeometry.js +2 -1
- package/src/geometries/WireframeGeometry.js +1 -0
- package/src/helpers/CameraHelper.js +97 -38
- package/src/helpers/DirectionalLightHelper.js +1 -0
- package/src/helpers/HemisphereLightHelper.js +1 -0
- package/src/helpers/PlaneHelper.js +6 -9
- package/src/helpers/PolarGridHelper.js +18 -14
- package/src/helpers/SpotLightHelper.js +1 -0
- package/src/lights/SpotLight.js +2 -0
- package/src/loaders/FileLoader.js +12 -1
- package/src/loaders/LoadingManager.js +1 -1
- package/src/loaders/MaterialLoader.js +49 -7
- package/src/loaders/ObjectLoader.js +4 -41
- package/src/materials/Material.js +1 -33
- package/src/materials/Materials.js +0 -27
- package/src/materials/MeshLambertMaterial.js +28 -1
- package/src/materials/ShaderMaterial.js +3 -7
- package/src/math/Color.js +3 -13
- package/src/math/MathUtils.js +1 -7
- package/src/math/Matrix3.js +1 -7
- package/src/math/Matrix4.js +3 -27
- package/src/math/Quaternion.js +1 -21
- package/src/math/Vector2.js +4 -24
- package/src/math/Vector3.js +7 -46
- package/src/math/Vector4.js +4 -24
- package/src/renderers/WebGLRenderer.js +84 -8
- package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +12 -12
- package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +3 -5
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +6 -5
- package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +24 -24
- package/src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js +2 -1
- package/src/renderers/shaders/ShaderChunk/iridescence_fragment.glsl.js +113 -99
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +34 -12
- package/src/renderers/shaders/ShaderChunk/lights_lambert_fragment.glsl.js +5 -0
- package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +30 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +3 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +13 -1
- package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +2 -4
- package/src/renderers/shaders/ShaderChunk/output_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +18 -7
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +8 -3
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +9 -6
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +14 -10
- package/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +22 -50
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib.js +31 -31
- package/src/renderers/shaders/UniformsLib.js +12 -11
- package/src/renderers/shaders/UniformsUtils.js +14 -0
- package/src/renderers/webgl/WebGLBackground.js +2 -2
- package/src/renderers/webgl/WebGLLights.js +37 -13
- package/src/renderers/webgl/WebGLMorphtargets.js +0 -20
- package/src/renderers/webgl/WebGLProgram.js +6 -11
- package/src/renderers/webgl/WebGLPrograms.js +30 -26
- package/src/renderers/webgl/WebGLRenderLists.js +5 -4
- package/src/renderers/webgl/WebGLRenderStates.js +5 -4
- package/src/renderers/webgl/WebGLShaderCache.js +9 -6
- package/src/renderers/webgl/WebGLShadowMap.js +10 -15
- package/src/renderers/webgl/WebGLState.js +47 -0
- package/src/renderers/webgl/WebGLUniforms.js +4 -4
- package/src/renderers/webgl/WebGLUniformsGroups.js +372 -0
- package/src/renderers/webgl/WebGLUtils.js +2 -0
- package/src/renderers/webvr/WebVRManager.js +42 -9
- package/src/renderers/webvr/WebVRUtils.js +1 -1
- package/src/renderers/webxr/WebXRController.js +45 -37
- package/src/renderers/webxr/WebXRManager.js +58 -33
- package/src/scenes/Scene.js +16 -3
- package/src/textures/Source.js +1 -1
- package/src/utils.js +1 -1
- package/examples/js/controls/experimental/CameraControls.js +0 -1048
- package/examples/js/loaders/KTX2Loader.js +0 -558
- package/examples/jsm/controls/experimental/CameraControls.js +0 -1248
- package/examples/jsm/nodes/accessors/ReflectNode.js +0 -70
- package/examples/jsm/package.json +0 -3
- package/examples/jsm/renderers/webgl/nodes/WebGLPhysicalContextNode.js +0 -45
- package/src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl.js +0 -122
|
@@ -187,17 +187,17 @@ const ints = [ - 1, - 2 ];
|
|
|
187
187
|
const floats = [ 0.5, 1.5, 1 / 3, 1e-6, 1e6, Math.PI, Math.PI * 2, 1 / Math.PI, 2 / Math.PI, 1 / ( Math.PI * 2 ), Math.PI / 2 ];
|
|
188
188
|
|
|
189
189
|
const boolsCacheMap = new Map();
|
|
190
|
-
for (
|
|
190
|
+
for ( const bool of bools ) boolsCacheMap.set( bool, new ConstNode( bool ) );
|
|
191
191
|
|
|
192
192
|
const uintsCacheMap = new Map();
|
|
193
|
-
for (
|
|
193
|
+
for ( const uint of uints ) uintsCacheMap.set( uint, new ConstNode( uint, 'uint' ) );
|
|
194
194
|
|
|
195
195
|
const intsCacheMap = new Map( [ ...uintsCacheMap ].map( el => new ConstNode( el.value, 'int' ) ) );
|
|
196
|
-
for (
|
|
196
|
+
for ( const int of ints ) intsCacheMap.set( int, new ConstNode( int, 'int' ) );
|
|
197
197
|
|
|
198
198
|
const floatsCacheMap = new Map( [ ...intsCacheMap ].map( el => new ConstNode( el.value ) ) );
|
|
199
|
-
for (
|
|
200
|
-
for (
|
|
199
|
+
for ( const float of floats ) floatsCacheMap.set( float, new ConstNode( float ) );
|
|
200
|
+
for ( const float of floats ) floatsCacheMap.set( - float, new ConstNode( - float ) );
|
|
201
201
|
|
|
202
202
|
export const cacheMaps = { bool: boolsCacheMap, uint: uintsCacheMap, ints: intsCacheMap, float: floatsCacheMap };
|
|
203
203
|
|
|
@@ -11,7 +11,7 @@ import InstanceIndexNode from '../core/InstanceIndexNode.js';
|
|
|
11
11
|
import PropertyNode from '../core/PropertyNode.js';
|
|
12
12
|
import UniformNode from '../core/UniformNode.js';
|
|
13
13
|
import VarNode from '../core/VarNode.js';
|
|
14
|
-
import
|
|
14
|
+
import VaryingNode from '../core/VaryingNode.js';
|
|
15
15
|
|
|
16
16
|
// accessors
|
|
17
17
|
import BufferNode from '../accessors/BufferNode.js';
|
|
@@ -87,12 +87,12 @@ export const bmat4 = new ConvertType( 'bmat4' );
|
|
|
87
87
|
|
|
88
88
|
// @TODO: ArrayUniformNode
|
|
89
89
|
|
|
90
|
-
export const func = ( code ) => {
|
|
90
|
+
export const func = ( code, includes ) => {
|
|
91
91
|
|
|
92
|
-
const node = nodeObject( new FunctionNode( code ) );
|
|
92
|
+
const node = nodeObject( new FunctionNode( code, includes ) );
|
|
93
93
|
|
|
94
94
|
const call = node.call.bind( node );
|
|
95
|
-
node.call = ( params ) => nodeObject( call( params ) );
|
|
95
|
+
node.call = ( ...params ) => nodeObject( call( params.length > 1 || params[ 0 ]?.isNode === true ? nodeArray( params ) : nodeObjects( params[ 0 ] ) ) );
|
|
96
96
|
|
|
97
97
|
return node;
|
|
98
98
|
|
|
@@ -109,6 +109,8 @@ export const uniform = ( nodeOrType ) => {
|
|
|
109
109
|
|
|
110
110
|
};
|
|
111
111
|
|
|
112
|
+
export const fn = ( code, includes ) => func( code, includes ).call;
|
|
113
|
+
|
|
112
114
|
export const attribute = ( name, nodeType ) => nodeObject( new AttributeNode( name, nodeType ) );
|
|
113
115
|
export const property = ( name, nodeOrType ) => nodeObject( new PropertyNode( name, getConstNodeType( nodeOrType ) ) );
|
|
114
116
|
|
|
@@ -120,7 +122,7 @@ export const call = nodeProxy( FunctionCallNode );
|
|
|
120
122
|
export const instanceIndex = nodeImmutable( InstanceIndexNode );
|
|
121
123
|
export const label = nodeProxy( VarNode );
|
|
122
124
|
export const temp = label;
|
|
123
|
-
export const
|
|
125
|
+
export const varying = nodeProxy( VaryingNode );
|
|
124
126
|
|
|
125
127
|
// accesors
|
|
126
128
|
|
|
@@ -236,6 +238,7 @@ export const dFdy = nodeProxy( MathNode, MathNode.DFDY );
|
|
|
236
238
|
export const saturate = nodeProxy( MathNode, MathNode.SATURATE );
|
|
237
239
|
export const round = nodeProxy( MathNode, MathNode.ROUND );
|
|
238
240
|
|
|
241
|
+
export const atan2 = nodeProxy( MathNode, MathNode.ATAN2 );
|
|
239
242
|
export const min = nodeProxy( MathNode, MathNode.MIN );
|
|
240
243
|
export const max = nodeProxy( MathNode, MathNode.MAX );
|
|
241
244
|
export const mod = nodeProxy( MathNode, MathNode.MOD );
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// accessors
|
|
2
2
|
import CubeTextureNode from '../accessors/CubeTextureNode.js';
|
|
3
3
|
import InstanceNode from '../accessors/InstanceNode.js';
|
|
4
|
-
import
|
|
4
|
+
import ReflectVectorNode from '../accessors/ReflectVectorNode.js';
|
|
5
5
|
import SkinningNode from '../accessors/SkinningNode.js';
|
|
6
6
|
|
|
7
7
|
// display
|
|
8
|
+
import ColorAdjustmentNode from '../display/ColorAdjustmentNode.js';
|
|
8
9
|
import ColorSpaceNode from '../display/ColorSpaceNode.js';
|
|
9
10
|
import NormalMapNode from '../display/NormalMapNode.js';
|
|
10
11
|
import ToneMappingNode from '../display/ToneMappingNode.js';
|
|
@@ -18,9 +19,13 @@ import LightingContextNode from '../lighting/LightingContextNode.js';
|
|
|
18
19
|
import MatcapUVNode from '../utils/MatcapUVNode.js';
|
|
19
20
|
import MaxMipLevelNode from '../utils/MaxMipLevelNode.js';
|
|
20
21
|
import OscNode from '../utils/OscNode.js';
|
|
22
|
+
import RotateUVNode from '../utils/RotateUVNode.js';
|
|
21
23
|
import SpriteSheetUVNode from '../utils/SpriteSheetUVNode.js';
|
|
22
24
|
import TimerNode from '../utils/TimerNode.js';
|
|
23
25
|
|
|
26
|
+
// geometry
|
|
27
|
+
import RangeNode from '../geometry/RangeNode.js';
|
|
28
|
+
|
|
24
29
|
// procedural
|
|
25
30
|
import CheckerNode from '../procedural/CheckerNode.js';
|
|
26
31
|
|
|
@@ -61,13 +66,16 @@ export const cubeTexture = nodeProxy( CubeTextureNode );
|
|
|
61
66
|
|
|
62
67
|
export const instance = nodeProxy( InstanceNode );
|
|
63
68
|
|
|
64
|
-
export const reflectVector = nodeImmutable(
|
|
65
|
-
export const reflectCube = nodeImmutable( ReflectNode, ReflectNode.CUBE );
|
|
69
|
+
export const reflectVector = nodeImmutable( ReflectVectorNode );
|
|
66
70
|
|
|
67
71
|
export const skinning = nodeProxy( SkinningNode );
|
|
68
72
|
|
|
69
73
|
// display
|
|
70
74
|
|
|
75
|
+
export const saturation = nodeProxy( ColorAdjustmentNode, ColorAdjustmentNode.SATURATION );
|
|
76
|
+
export const vibrance = nodeProxy( ColorAdjustmentNode, ColorAdjustmentNode.VIBRANCE );
|
|
77
|
+
export const hue = nodeProxy( ColorAdjustmentNode, ColorAdjustmentNode.HUE );
|
|
78
|
+
|
|
71
79
|
export const colorSpace = ( node, encoding ) => nodeObject( new ColorSpaceNode( null, nodeObject( node ) ).fromEncoding( encoding ) );
|
|
72
80
|
export const normalMap = nodeProxy( NormalMapNode );
|
|
73
81
|
export const toneMapping = ( mapping, exposure, color ) => nodeObject( new ToneMappingNode( mapping, nodeObject( exposure ), nodeObject( color ) ) );
|
|
@@ -89,12 +97,18 @@ export const oscSquare = nodeProxy( OscNode, OscNode.SQUARE );
|
|
|
89
97
|
export const oscTriangle = nodeProxy( OscNode, OscNode.TRIANGLE );
|
|
90
98
|
export const oscSawtooth = nodeProxy( OscNode, OscNode.SAWTOOTH );
|
|
91
99
|
|
|
100
|
+
export const rotateUV = nodeProxy( RotateUVNode );
|
|
101
|
+
|
|
92
102
|
export const spritesheetUV = nodeProxy( SpriteSheetUVNode );
|
|
93
103
|
|
|
94
104
|
// @TODO: add supports to use node in timeScale
|
|
95
|
-
export const timerLocal = ( timeScale ) => nodeObject( new TimerNode( TimerNode.LOCAL, timeScale ) );
|
|
96
|
-
export const timerGlobal = ( timeScale ) => nodeObject( new TimerNode( TimerNode.GLOBAL, timeScale ) );
|
|
97
|
-
export const timerDelta = ( timeScale ) => nodeObject( new TimerNode( TimerNode.DELTA, timeScale ) );
|
|
105
|
+
export const timerLocal = ( timeScale, value = 0 ) => nodeObject( new TimerNode( TimerNode.LOCAL, timeScale, value ) );
|
|
106
|
+
export const timerGlobal = ( timeScale, value = 0 ) => nodeObject( new TimerNode( TimerNode.GLOBAL, timeScale, value ) );
|
|
107
|
+
export const timerDelta = ( timeScale, value = 0 ) => nodeObject( new TimerNode( TimerNode.DELTA, timeScale, value ) );
|
|
108
|
+
|
|
109
|
+
// geometry
|
|
110
|
+
|
|
111
|
+
export const range = ( min, max ) => nodeObject( new RangeNode( min, max ) );
|
|
98
112
|
|
|
99
113
|
// procedural
|
|
100
114
|
|
|
@@ -17,23 +17,28 @@ class ConvertNode extends Node {
|
|
|
17
17
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
generate( builder ) {
|
|
20
|
+
generate( builder, output ) {
|
|
21
21
|
|
|
22
22
|
const convertTo = this.convertTo;
|
|
23
23
|
const node = this.node;
|
|
24
|
+
const type = this.getNodeType( builder );
|
|
25
|
+
|
|
26
|
+
let snippet = null;
|
|
24
27
|
|
|
25
28
|
if ( builder.isReference( convertTo ) === false ) {
|
|
26
29
|
|
|
27
30
|
const nodeSnippet = node.build( builder, convertTo );
|
|
28
31
|
|
|
29
|
-
|
|
32
|
+
snippet = builder.format( nodeSnippet, type, convertTo );
|
|
30
33
|
|
|
31
34
|
} else {
|
|
32
35
|
|
|
33
|
-
|
|
36
|
+
snippet = node.build( builder, convertTo );
|
|
34
37
|
|
|
35
38
|
}
|
|
36
39
|
|
|
40
|
+
return builder.format( snippet, type, output );
|
|
41
|
+
|
|
37
42
|
}
|
|
38
43
|
|
|
39
44
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import TempNode from '../core/Node.js';
|
|
2
2
|
|
|
3
|
-
class JoinNode extends
|
|
3
|
+
class JoinNode extends TempNode {
|
|
4
4
|
|
|
5
5
|
constructor( nodes = [] ) {
|
|
6
6
|
|
|
@@ -16,16 +16,14 @@ class JoinNode extends Node {
|
|
|
16
16
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
generate( builder ) {
|
|
19
|
+
generate( builder, output ) {
|
|
20
20
|
|
|
21
21
|
const type = this.getNodeType( builder );
|
|
22
22
|
const nodes = this.nodes;
|
|
23
23
|
|
|
24
24
|
const snippetValues = [];
|
|
25
25
|
|
|
26
|
-
for (
|
|
27
|
-
|
|
28
|
-
const input = nodes[ i ];
|
|
26
|
+
for ( const input of nodes ) {
|
|
29
27
|
|
|
30
28
|
const inputSnippet = input.build( builder );
|
|
31
29
|
|
|
@@ -33,7 +31,9 @@ class JoinNode extends Node {
|
|
|
33
31
|
|
|
34
32
|
}
|
|
35
33
|
|
|
36
|
-
|
|
34
|
+
const snippet = `${ builder.getType( type ) }( ${ snippetValues.join( ', ' ) } )`;
|
|
35
|
+
|
|
36
|
+
return builder.format( snippet, type, output );
|
|
37
37
|
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -15,7 +15,8 @@ class MaxMipLevelNode extends UniformNode {
|
|
|
15
15
|
|
|
16
16
|
update() {
|
|
17
17
|
|
|
18
|
-
const
|
|
18
|
+
const images = this.texture.images;
|
|
19
|
+
const image = ( images && images.length > 0 ) ? ( images[ 0 ]?.image || images[ 0 ] ) : this.texture.image;
|
|
19
20
|
|
|
20
21
|
if ( image?.width !== undefined ) {
|
|
21
22
|
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import TempNode from '../core/TempNode.js';
|
|
2
|
+
import { vec2, add, sub, mul, cos, sin } from '../shadernode/ShaderNodeBaseElements.js';
|
|
3
|
+
|
|
4
|
+
class RotateUVNode extends TempNode {
|
|
5
|
+
|
|
6
|
+
constructor( uvNode, rotationNode, centerNode = vec2( .5 ) ) {
|
|
7
|
+
|
|
8
|
+
super( 'vec2' );
|
|
9
|
+
|
|
10
|
+
this.uvNode = uvNode;
|
|
11
|
+
this.rotationNode = rotationNode;
|
|
12
|
+
this.centerNode = centerNode;
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
construct() {
|
|
17
|
+
|
|
18
|
+
const { uvNode, rotationNode, centerNode } = this;
|
|
19
|
+
|
|
20
|
+
const cosAngle = cos( rotationNode );
|
|
21
|
+
const sinAngle = sin( rotationNode );
|
|
22
|
+
|
|
23
|
+
return vec2(
|
|
24
|
+
add( add( mul( cosAngle, sub( uvNode.x, centerNode.x ) ), mul( sinAngle, sub( uvNode.y, centerNode.y ) ) ), centerNode.x ),
|
|
25
|
+
add( sub( mul( cosAngle, sub( uvNode.y, centerNode.y ) ), mul( sinAngle, sub( uvNode.x, centerNode.x ) ) ), centerNode.y )
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default RotateUVNode;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import Node from '../core/Node.js';
|
|
2
2
|
import { vector } from '../core/NodeBuilder.js';
|
|
3
3
|
|
|
4
|
+
const vectorComponents = 'xyzw';
|
|
5
|
+
|
|
4
6
|
class SplitNode extends Node {
|
|
5
7
|
|
|
6
8
|
constructor( node, components = 'x' ) {
|
|
@@ -32,11 +34,13 @@ class SplitNode extends Node {
|
|
|
32
34
|
|
|
33
35
|
}
|
|
34
36
|
|
|
35
|
-
generate( builder ) {
|
|
37
|
+
generate( builder, output ) {
|
|
36
38
|
|
|
37
39
|
const node = this.node;
|
|
38
40
|
const nodeTypeLength = builder.getTypeLength( node.getNodeType( builder ) );
|
|
39
41
|
|
|
42
|
+
let snippet = null;
|
|
43
|
+
|
|
40
44
|
if ( nodeTypeLength > 1 ) {
|
|
41
45
|
|
|
42
46
|
let type = null;
|
|
@@ -45,7 +49,7 @@ class SplitNode extends Node {
|
|
|
45
49
|
|
|
46
50
|
if ( componentsLength >= nodeTypeLength ) {
|
|
47
51
|
|
|
48
|
-
//
|
|
52
|
+
// needed expand the input node
|
|
49
53
|
|
|
50
54
|
type = builder.getTypeFromLength( this.getVectorLength() );
|
|
51
55
|
|
|
@@ -53,16 +57,28 @@ class SplitNode extends Node {
|
|
|
53
57
|
|
|
54
58
|
const nodeSnippet = node.build( builder, type );
|
|
55
59
|
|
|
56
|
-
|
|
60
|
+
if ( this.components.length === nodeTypeLength && this.components === vectorComponents.slice( 0, this.components.length ) ) {
|
|
61
|
+
|
|
62
|
+
// unecessary swizzle
|
|
63
|
+
|
|
64
|
+
snippet = builder.format( nodeSnippet, type, output );
|
|
65
|
+
|
|
66
|
+
} else {
|
|
67
|
+
|
|
68
|
+
snippet = builder.format( `${nodeSnippet}.${this.components}`, this.getNodeType( builder ), output );
|
|
69
|
+
|
|
70
|
+
}
|
|
57
71
|
|
|
58
72
|
} else {
|
|
59
73
|
|
|
60
|
-
// ignore components if node
|
|
74
|
+
// ignore .components if .node returns float/integer
|
|
61
75
|
|
|
62
|
-
|
|
76
|
+
snippet = node.build( builder, output );
|
|
63
77
|
|
|
64
78
|
}
|
|
65
79
|
|
|
80
|
+
return snippet;
|
|
81
|
+
|
|
66
82
|
}
|
|
67
83
|
|
|
68
84
|
serialize( data ) {
|
|
@@ -7,9 +7,9 @@ class TimerNode extends UniformNode {
|
|
|
7
7
|
static GLOBAL = 'global';
|
|
8
8
|
static DELTA = 'delta';
|
|
9
9
|
|
|
10
|
-
constructor( scope = TimerNode.LOCAL, scale = 1 ) {
|
|
10
|
+
constructor( scope = TimerNode.LOCAL, scale = 1, value = 0 ) {
|
|
11
11
|
|
|
12
|
-
super(
|
|
12
|
+
super( value );
|
|
13
13
|
|
|
14
14
|
this.scope = scope;
|
|
15
15
|
this.scale = scale;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { Mesh, IcosahedronGeometry, ShaderMaterial, DoubleSide } from 'three';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Ground projected env map adapted from @react-three/drei.
|
|
5
|
+
* https://github.com/pmndrs/drei/blob/master/src/core/Environment.tsx
|
|
6
|
+
*/
|
|
7
|
+
export class GroundProjectedEnv extends Mesh {
|
|
8
|
+
|
|
9
|
+
constructor( texture, options ) {
|
|
10
|
+
|
|
11
|
+
const isCubeMap = texture.isCubeTexture;
|
|
12
|
+
const w =
|
|
13
|
+
( isCubeMap ? texture.image[ 0 ]?.width : texture.image.width ) ?? 1024;
|
|
14
|
+
const cubeSize = w / 4;
|
|
15
|
+
const _lodMax = Math.floor( Math.log2( cubeSize ) );
|
|
16
|
+
const _cubeSize = Math.pow( 2, _lodMax );
|
|
17
|
+
const width = 3 * Math.max( _cubeSize, 16 * 7 );
|
|
18
|
+
const height = 4 * _cubeSize;
|
|
19
|
+
|
|
20
|
+
const defines = [
|
|
21
|
+
isCubeMap ? '#define ENVMAP_TYPE_CUBE' : '',
|
|
22
|
+
`#define CUBEUV_TEXEL_WIDTH ${1.0 / width}`,
|
|
23
|
+
`#define CUBEUV_TEXEL_HEIGHT ${1.0 / height}`,
|
|
24
|
+
`#define CUBEUV_MAX_MIP ${_lodMax}.0`,
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
const vertexShader = /* glsl */ `
|
|
28
|
+
varying vec3 vWorldPosition;
|
|
29
|
+
|
|
30
|
+
void main()
|
|
31
|
+
{
|
|
32
|
+
|
|
33
|
+
vec4 worldPosition = ( modelMatrix * vec4( position, 1.0 ) );
|
|
34
|
+
vWorldPosition = worldPosition.xyz;
|
|
35
|
+
|
|
36
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
`;
|
|
40
|
+
const fragmentShader = defines.join( '\n' ) + /* glsl */ `
|
|
41
|
+
#define ENVMAP_TYPE_CUBE_UV
|
|
42
|
+
|
|
43
|
+
varying vec3 vWorldPosition;
|
|
44
|
+
|
|
45
|
+
uniform float radius;
|
|
46
|
+
uniform float height;
|
|
47
|
+
uniform float angle;
|
|
48
|
+
|
|
49
|
+
#ifdef ENVMAP_TYPE_CUBE
|
|
50
|
+
|
|
51
|
+
uniform samplerCube map;
|
|
52
|
+
|
|
53
|
+
#else
|
|
54
|
+
|
|
55
|
+
uniform sampler2D map;
|
|
56
|
+
|
|
57
|
+
#endif
|
|
58
|
+
|
|
59
|
+
// From: https://www.shadertoy.com/view/4tsBD7
|
|
60
|
+
float diskIntersectWithBackFaceCulling( vec3 ro, vec3 rd, vec3 c, vec3 n, float r )
|
|
61
|
+
{
|
|
62
|
+
|
|
63
|
+
float d = dot ( rd, n );
|
|
64
|
+
|
|
65
|
+
if( d > 0.0 ) { return 1e6; }
|
|
66
|
+
|
|
67
|
+
vec3 o = ro - c;
|
|
68
|
+
float t = - dot( n, o ) / d;
|
|
69
|
+
vec3 q = o + rd * t;
|
|
70
|
+
|
|
71
|
+
return ( dot( q, q ) < r * r ) ? t : 1e6;
|
|
72
|
+
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// From: https://www.iquilezles.org/www/articles/intersectors/intersectors.htm
|
|
76
|
+
float sphereIntersect( vec3 ro, vec3 rd, vec3 ce, float ra )
|
|
77
|
+
{
|
|
78
|
+
|
|
79
|
+
vec3 oc = ro - ce;
|
|
80
|
+
float b = dot( oc, rd );
|
|
81
|
+
float c = dot( oc, oc ) - ra * ra;
|
|
82
|
+
float h = b * b - c;
|
|
83
|
+
|
|
84
|
+
if( h < 0.0 ) { return -1.0; }
|
|
85
|
+
|
|
86
|
+
h = sqrt( h );
|
|
87
|
+
|
|
88
|
+
return - b + h;
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
vec3 project()
|
|
93
|
+
{
|
|
94
|
+
|
|
95
|
+
vec3 p = normalize( vWorldPosition );
|
|
96
|
+
vec3 camPos = cameraPosition;
|
|
97
|
+
camPos.y -= height;
|
|
98
|
+
|
|
99
|
+
float intersection = sphereIntersect( camPos, p, vec3( 0.0 ), radius );
|
|
100
|
+
if( intersection > 0.0 ) {
|
|
101
|
+
|
|
102
|
+
vec3 h = vec3( 0.0, - height, 0.0 );
|
|
103
|
+
float intersection2 = diskIntersectWithBackFaceCulling( camPos, p, h, vec3( 0.0, 1.0, 0.0 ), radius );
|
|
104
|
+
p = ( camPos + min( intersection, intersection2 ) * p ) / radius;
|
|
105
|
+
|
|
106
|
+
} else {
|
|
107
|
+
|
|
108
|
+
p = vec3( 0.0, 1.0, 0.0 );
|
|
109
|
+
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return p;
|
|
113
|
+
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
#include <common>
|
|
117
|
+
#include <cube_uv_reflection_fragment>
|
|
118
|
+
|
|
119
|
+
void main()
|
|
120
|
+
{
|
|
121
|
+
|
|
122
|
+
vec3 projectedWorldPosition = project();
|
|
123
|
+
|
|
124
|
+
#ifdef ENVMAP_TYPE_CUBE
|
|
125
|
+
|
|
126
|
+
vec3 outcolor = textureCube( map, projectedWorldPosition ).rgb;
|
|
127
|
+
|
|
128
|
+
#else
|
|
129
|
+
|
|
130
|
+
vec3 direction = normalize( projectedWorldPosition );
|
|
131
|
+
vec2 uv = equirectUv( direction );
|
|
132
|
+
vec3 outcolor = texture2D( map, uv ).rgb;
|
|
133
|
+
|
|
134
|
+
#endif
|
|
135
|
+
|
|
136
|
+
gl_FragColor = vec4( outcolor, 1.0 );
|
|
137
|
+
|
|
138
|
+
#include <tonemapping_fragment>
|
|
139
|
+
#include <encodings_fragment>
|
|
140
|
+
|
|
141
|
+
}
|
|
142
|
+
`;
|
|
143
|
+
|
|
144
|
+
const uniforms = {
|
|
145
|
+
map: { value: texture },
|
|
146
|
+
height: { value: options?.height || 15 },
|
|
147
|
+
radius: { value: options?.radius || 100 },
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const geometry = new IcosahedronGeometry( 1, 16 );
|
|
151
|
+
const material = new ShaderMaterial( {
|
|
152
|
+
uniforms,
|
|
153
|
+
fragmentShader,
|
|
154
|
+
vertexShader,
|
|
155
|
+
side: DoubleSide,
|
|
156
|
+
} );
|
|
157
|
+
|
|
158
|
+
super( geometry, material );
|
|
159
|
+
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
set radius( radius ) {
|
|
163
|
+
|
|
164
|
+
this.material.uniforms.radius.value = radius;
|
|
165
|
+
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
get radius() {
|
|
169
|
+
|
|
170
|
+
return this.material.uniforms.radius.value;
|
|
171
|
+
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
set height( height ) {
|
|
175
|
+
|
|
176
|
+
this.material.uniforms.height.value = height;
|
|
177
|
+
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
get height() {
|
|
181
|
+
|
|
182
|
+
return this.material.uniforms.height.value;
|
|
183
|
+
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
}
|
|
@@ -8,7 +8,10 @@ import {
|
|
|
8
8
|
UniformsUtils,
|
|
9
9
|
Vector3,
|
|
10
10
|
Vector4,
|
|
11
|
-
WebGLRenderTarget
|
|
11
|
+
WebGLRenderTarget,
|
|
12
|
+
HalfFloatType,
|
|
13
|
+
NoToneMapping,
|
|
14
|
+
LinearEncoding
|
|
12
15
|
} from 'three';
|
|
13
16
|
|
|
14
17
|
class Reflector extends Mesh {
|
|
@@ -48,7 +51,7 @@ class Reflector extends Mesh {
|
|
|
48
51
|
const textureMatrix = new Matrix4();
|
|
49
52
|
const virtualCamera = this.camera;
|
|
50
53
|
|
|
51
|
-
const renderTarget = new WebGLRenderTarget( textureWidth, textureHeight, { samples: multisample } );
|
|
54
|
+
const renderTarget = new WebGLRenderTarget( textureWidth, textureHeight, { samples: multisample, type: HalfFloatType } );
|
|
52
55
|
|
|
53
56
|
const material = new ShaderMaterial( {
|
|
54
57
|
uniforms: UniformsUtils.clone( shader.uniforms ),
|
|
@@ -137,18 +140,19 @@ class Reflector extends Mesh {
|
|
|
137
140
|
projectionMatrix.elements[ 14 ] = clipPlane.w;
|
|
138
141
|
|
|
139
142
|
// Render
|
|
140
|
-
|
|
141
|
-
renderTarget.texture.encoding = renderer.outputEncoding;
|
|
142
|
-
|
|
143
143
|
scope.visible = false;
|
|
144
144
|
|
|
145
145
|
const currentRenderTarget = renderer.getRenderTarget();
|
|
146
146
|
|
|
147
147
|
const currentXrEnabled = renderer.xr.enabled;
|
|
148
148
|
const currentShadowAutoUpdate = renderer.shadowMap.autoUpdate;
|
|
149
|
+
const currentOutputEncoding = renderer.outputEncoding;
|
|
150
|
+
const currentToneMapping = renderer.toneMapping;
|
|
149
151
|
|
|
150
152
|
renderer.xr.enabled = false; // Avoid camera modification
|
|
151
153
|
renderer.shadowMap.autoUpdate = false; // Avoid re-computing shadows
|
|
154
|
+
renderer.outputEncoding = LinearEncoding;
|
|
155
|
+
renderer.toneMapping = NoToneMapping;
|
|
152
156
|
|
|
153
157
|
renderer.setRenderTarget( renderTarget );
|
|
154
158
|
|
|
@@ -159,6 +163,8 @@ class Reflector extends Mesh {
|
|
|
159
163
|
|
|
160
164
|
renderer.xr.enabled = currentXrEnabled;
|
|
161
165
|
renderer.shadowMap.autoUpdate = currentShadowAutoUpdate;
|
|
166
|
+
renderer.outputEncoding = currentOutputEncoding;
|
|
167
|
+
renderer.toneMapping = currentToneMapping;
|
|
162
168
|
|
|
163
169
|
renderer.setRenderTarget( currentRenderTarget );
|
|
164
170
|
|
|
@@ -254,6 +260,7 @@ Reflector.ReflectorShader = {
|
|
|
254
260
|
vec4 base = texture2DProj( tDiffuse, vUv );
|
|
255
261
|
gl_FragColor = vec4( blendOverlay( base.rgb, color ), 1.0 );
|
|
256
262
|
|
|
263
|
+
#include <tonemapping_fragment>
|
|
257
264
|
#include <encodings_fragment>
|
|
258
265
|
|
|
259
266
|
}`
|
|
@@ -11,7 +11,8 @@ import {
|
|
|
11
11
|
DepthTexture,
|
|
12
12
|
UnsignedShortType,
|
|
13
13
|
NearestFilter,
|
|
14
|
-
Plane
|
|
14
|
+
Plane,
|
|
15
|
+
HalfFloatType
|
|
15
16
|
} from 'three';
|
|
16
17
|
|
|
17
18
|
class ReflectorForSSRPass extends Mesh {
|
|
@@ -104,6 +105,7 @@ class ReflectorForSSRPass extends Mesh {
|
|
|
104
105
|
|
|
105
106
|
const parameters = {
|
|
106
107
|
depthTexture: useDepthTexture ? depthTexture : null,
|
|
108
|
+
type: HalfFloatType
|
|
107
109
|
};
|
|
108
110
|
|
|
109
111
|
const renderTarget = new WebGLRenderTarget( textureWidth, textureHeight, parameters );
|
|
@@ -198,10 +200,6 @@ class ReflectorForSSRPass extends Mesh {
|
|
|
198
200
|
textureMatrix.multiply( virtualCamera.matrixWorldInverse );
|
|
199
201
|
textureMatrix.multiply( scope.matrixWorld );
|
|
200
202
|
|
|
201
|
-
// Render
|
|
202
|
-
|
|
203
|
-
renderTarget.texture.encoding = renderer.outputEncoding;
|
|
204
|
-
|
|
205
203
|
// scope.visible = false;
|
|
206
204
|
|
|
207
205
|
const currentRenderTarget = renderer.getRenderTarget();
|
|
@@ -9,7 +9,10 @@ import {
|
|
|
9
9
|
UniformsUtils,
|
|
10
10
|
Vector3,
|
|
11
11
|
Vector4,
|
|
12
|
-
WebGLRenderTarget
|
|
12
|
+
WebGLRenderTarget,
|
|
13
|
+
LinearEncoding,
|
|
14
|
+
NoToneMapping,
|
|
15
|
+
HalfFloatType
|
|
13
16
|
} from 'three';
|
|
14
17
|
|
|
15
18
|
class Refractor extends Mesh {
|
|
@@ -45,7 +48,7 @@ class Refractor extends Mesh {
|
|
|
45
48
|
|
|
46
49
|
// render target
|
|
47
50
|
|
|
48
|
-
const renderTarget = new WebGLRenderTarget( textureWidth, textureHeight, { samples: multisample } );
|
|
51
|
+
const renderTarget = new WebGLRenderTarget( textureWidth, textureHeight, { samples: multisample, type: HalfFloatType } );
|
|
49
52
|
|
|
50
53
|
// material
|
|
51
54
|
|
|
@@ -191,9 +194,13 @@ class Refractor extends Mesh {
|
|
|
191
194
|
const currentRenderTarget = renderer.getRenderTarget();
|
|
192
195
|
const currentXrEnabled = renderer.xr.enabled;
|
|
193
196
|
const currentShadowAutoUpdate = renderer.shadowMap.autoUpdate;
|
|
197
|
+
const currentOutputEncoding = renderer.outputEncoding;
|
|
198
|
+
const currentToneMapping = renderer.toneMapping;
|
|
194
199
|
|
|
195
200
|
renderer.xr.enabled = false; // avoid camera modification
|
|
196
201
|
renderer.shadowMap.autoUpdate = false; // avoid re-computing shadows
|
|
202
|
+
renderer.outputEncoding = LinearEncoding;
|
|
203
|
+
renderer.toneMapping = NoToneMapping;
|
|
197
204
|
|
|
198
205
|
renderer.setRenderTarget( renderTarget );
|
|
199
206
|
if ( renderer.autoClear === false ) renderer.clear();
|
|
@@ -201,6 +208,8 @@ class Refractor extends Mesh {
|
|
|
201
208
|
|
|
202
209
|
renderer.xr.enabled = currentXrEnabled;
|
|
203
210
|
renderer.shadowMap.autoUpdate = currentShadowAutoUpdate;
|
|
211
|
+
renderer.outputEncoding = currentOutputEncoding;
|
|
212
|
+
renderer.toneMapping = currentToneMapping;
|
|
204
213
|
renderer.setRenderTarget( currentRenderTarget );
|
|
205
214
|
|
|
206
215
|
// restore viewport
|
|
@@ -221,10 +230,6 @@ class Refractor extends Mesh {
|
|
|
221
230
|
|
|
222
231
|
this.onBeforeRender = function ( renderer, scene, camera ) {
|
|
223
232
|
|
|
224
|
-
// Render
|
|
225
|
-
|
|
226
|
-
renderTarget.texture.encoding = renderer.outputEncoding;
|
|
227
|
-
|
|
228
233
|
// ensure refractors are rendered only once per frame
|
|
229
234
|
|
|
230
235
|
if ( camera.userData.refractor === true ) return;
|
|
@@ -317,6 +322,7 @@ Refractor.RefractorShader = {
|
|
|
317
322
|
vec4 base = texture2DProj( tDiffuse, vUv );
|
|
318
323
|
gl_FragColor = vec4( blendOverlay( base.rgb, color ), 1.0 );
|
|
319
324
|
|
|
325
|
+
#include <tonemapping_fragment>
|
|
320
326
|
#include <encodings_fragment>
|
|
321
327
|
|
|
322
328
|
}`
|