@plastic-software/three 0.174.0 → 0.175.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/build/three.cjs +10655 -1446
- package/build/three.core.js +9626 -1094
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +834 -157
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +4 -2
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +2658 -1697
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +2654 -1709
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +1 -1
- package/examples/jsm/animation/AnimationClipCreator.js +57 -6
- package/examples/jsm/animation/CCDIKSolver.js +93 -39
- package/examples/jsm/capabilities/WebGL.js +28 -3
- package/examples/jsm/capabilities/WebGPU.js +16 -6
- package/examples/jsm/controls/ArcballControls.js +424 -154
- package/examples/jsm/controls/DragControls.js +93 -2
- package/examples/jsm/controls/FirstPersonControls.js +113 -4
- package/examples/jsm/controls/FlyControls.js +49 -2
- package/examples/jsm/controls/MapControls.js +42 -9
- package/examples/jsm/controls/OrbitControls.js +345 -42
- package/examples/jsm/controls/PointerLockControls.js +111 -9
- package/examples/jsm/controls/TrackballControls.js +159 -8
- package/examples/jsm/controls/TransformControls.js +252 -6
- package/examples/jsm/csm/CSM.js +226 -15
- package/examples/jsm/csm/CSMFrustum.js +52 -0
- package/examples/jsm/csm/CSMHelper.js +47 -0
- package/examples/jsm/csm/CSMShader.js +10 -1
- package/examples/jsm/csm/CSMShadowNode.js +156 -13
- package/examples/jsm/curves/CurveExtras.js +289 -31
- package/examples/jsm/curves/NURBSCurve.js +57 -14
- package/examples/jsm/curves/NURBSSurface.js +50 -6
- package/examples/jsm/curves/NURBSUtils.js +96 -112
- package/examples/jsm/curves/NURBSVolume.js +22 -4
- package/examples/jsm/effects/AnaglyphEffect.js +30 -0
- package/examples/jsm/effects/AsciiEffect.js +60 -15
- package/examples/jsm/effects/OutlineEffect.js +59 -111
- package/examples/jsm/effects/ParallaxBarrierEffect.js +28 -0
- package/examples/jsm/effects/PeppersGhostEffect.js +21 -2
- package/examples/jsm/effects/StereoEffect.js +29 -0
- package/examples/jsm/environments/DebugEnvironment.js +49 -0
- package/examples/jsm/environments/RoomEnvironment.js +23 -4
- package/examples/jsm/exporters/DRACOExporter.js +53 -13
- package/examples/jsm/exporters/EXRExporter.js +37 -8
- package/examples/jsm/exporters/GLTFExporter.js +171 -48
- package/examples/jsm/exporters/KTX2Exporter.js +20 -0
- package/examples/jsm/exporters/OBJExporter.js +18 -0
- package/examples/jsm/exporters/PLYExporter.js +39 -9
- package/examples/jsm/exporters/STLExporter.js +25 -5
- package/examples/jsm/exporters/USDZExporter.js +70 -3
- package/examples/jsm/geometries/BoxLineGeometry.js +22 -0
- package/examples/jsm/geometries/ConvexGeometry.js +18 -0
- package/examples/jsm/geometries/DecalGeometry.js +20 -9
- package/examples/jsm/geometries/ParametricFunctions.js +97 -0
- package/examples/jsm/geometries/ParametricGeometry.js +37 -5
- package/examples/jsm/geometries/RoundedBoxGeometry.js +21 -0
- package/examples/jsm/geometries/TeapotGeometry.js +22 -38
- package/examples/jsm/geometries/TextGeometry.js +44 -16
- package/examples/jsm/helpers/LightProbeHelper.js +35 -0
- package/examples/jsm/helpers/LightProbeHelperGPU.js +36 -0
- package/examples/jsm/helpers/OctreeHelper.js +35 -0
- package/examples/jsm/helpers/PositionalAudioHelper.js +59 -0
- package/examples/jsm/helpers/RectAreaLightHelper.js +35 -3
- package/examples/jsm/helpers/TextureHelper.js +27 -0
- package/examples/jsm/helpers/TextureHelperGPU.js +28 -0
- package/examples/jsm/helpers/VertexNormalsHelper.js +58 -2
- package/examples/jsm/helpers/VertexTangentsHelper.js +46 -2
- package/examples/jsm/helpers/ViewHelper.js +75 -1
- package/examples/jsm/interactive/HTMLMesh.js +25 -0
- package/examples/jsm/interactive/InteractiveGroup.js +65 -5
- package/examples/jsm/interactive/SelectionBox.js +74 -9
- package/examples/jsm/interactive/SelectionHelper.js +71 -29
- package/examples/jsm/libs/motion-controllers.module.js +1 -1
- package/examples/jsm/lighting/TiledLighting.js +23 -0
- package/examples/jsm/lights/LightProbeGenerator.js +26 -1
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +48 -13
- package/examples/jsm/lights/RectAreaLightUniformsLib.js +15 -0
- package/examples/jsm/lines/Line2.js +36 -0
- package/examples/jsm/lines/LineGeometry.js +52 -0
- package/examples/jsm/lines/LineMaterial.js +95 -0
- package/examples/jsm/lines/LineSegments2.js +51 -2
- package/examples/jsm/lines/LineSegmentsGeometry.js +62 -8
- package/examples/jsm/lines/Wireframe.js +38 -2
- package/examples/jsm/lines/WireframeGeometry2.js +24 -0
- package/examples/jsm/lines/webgpu/Line2.js +25 -1
- package/examples/jsm/lines/webgpu/LineSegments2.js +44 -6
- package/examples/jsm/lines/webgpu/Wireframe.js +30 -2
- package/examples/jsm/loaders/3DMLoader.js +71 -2
- package/examples/jsm/loaders/3MFLoader.js +41 -3
- package/examples/jsm/loaders/AMFLoader.js +31 -12
- package/examples/jsm/loaders/BVHLoader.js +57 -11
- package/examples/jsm/loaders/ColladaLoader.js +35 -0
- package/examples/jsm/loaders/DDSLoader.js +24 -0
- package/examples/jsm/loaders/DRACOLoader.js +73 -1
- package/examples/jsm/loaders/EXRLoader.js +40 -8
- package/examples/jsm/loaders/FBXLoader.js +42 -14
- package/examples/jsm/loaders/FontLoader.js +60 -2
- package/examples/jsm/loaders/GCodeLoader.js +33 -5
- package/examples/jsm/loaders/GLTFLoader.js +218 -5
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +48 -0
- package/examples/jsm/loaders/IESLoader.js +41 -0
- package/examples/jsm/loaders/KMZLoader.js +32 -0
- package/examples/jsm/loaders/KTX2Loader.js +86 -18
- package/examples/jsm/loaders/KTXLoader.js +26 -6
- package/examples/jsm/loaders/LDrawLoader.js +115 -5
- package/examples/jsm/loaders/LUT3dlLoader.js +46 -10
- package/examples/jsm/loaders/LUTCubeLoader.js +45 -9
- package/examples/jsm/loaders/LUTImageLoader.js +78 -38
- package/examples/jsm/loaders/LWOLoader.js +46 -7
- package/examples/jsm/loaders/LottieLoader.js +37 -0
- package/examples/jsm/loaders/MD2Loader.js +36 -1
- package/examples/jsm/loaders/MDDLoader.js +56 -12
- package/examples/jsm/loaders/MTLLoader.js +38 -33
- package/examples/jsm/loaders/MaterialXLoader.js +33 -0
- package/examples/jsm/loaders/NRRDLoader.js +36 -5
- package/examples/jsm/loaders/OBJLoader.js +48 -1
- package/examples/jsm/loaders/PCDLoader.js +47 -0
- package/examples/jsm/loaders/PDBLoader.js +40 -2
- package/examples/jsm/loaders/PLYLoader.js +62 -32
- package/examples/jsm/loaders/PVRLoader.js +23 -5
- package/examples/jsm/loaders/RGBELoader.js +38 -5
- package/examples/jsm/loaders/RGBMLoader.js +67 -1
- package/examples/jsm/loaders/STLLoader.js +47 -38
- package/examples/jsm/loaders/SVGLoader.js +113 -20
- package/examples/jsm/loaders/TDSLoader.js +81 -61
- package/examples/jsm/loaders/TGALoader.js +22 -0
- package/examples/jsm/loaders/TIFFLoader.js +22 -0
- package/examples/jsm/loaders/TTFLoader.js +36 -2
- package/examples/jsm/loaders/USDZLoader.js +34 -1
- package/examples/jsm/loaders/UltraHDRLoader.js +58 -12
- package/examples/jsm/loaders/VOXLoader.js +57 -0
- package/examples/jsm/loaders/VRMLLoader.js +32 -1
- package/examples/jsm/loaders/VTKLoader.js +38 -0
- package/examples/jsm/loaders/XYZLoader.js +35 -0
- package/examples/jsm/materials/LDrawConditionalLineMaterial.js +39 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +39 -0
- package/examples/jsm/materials/MeshPostProcessingMaterial.js +24 -2
- package/examples/jsm/math/Capsule.js +89 -14
- package/examples/jsm/math/ColorConverter.js +21 -0
- package/examples/jsm/math/ColorSpaces.js +53 -0
- package/examples/jsm/math/ConvexHull.js +514 -92
- package/examples/jsm/math/ImprovedNoise.js +14 -2
- package/examples/jsm/math/Lut.js +111 -0
- package/examples/jsm/math/MeshSurfaceSampler.js +76 -13
- package/examples/jsm/math/OBB.js +139 -46
- package/examples/jsm/math/Octree.js +132 -5
- package/examples/jsm/math/SimplexNoise.js +66 -42
- package/examples/jsm/misc/ConvexObjectBreaker.js +43 -25
- package/examples/jsm/misc/GPUComputationRenderer.js +92 -17
- package/examples/jsm/misc/Gyroscope.js +11 -0
- package/examples/jsm/misc/MD2Character.js +115 -2
- package/examples/jsm/misc/MD2CharacterComplex.js +170 -8
- package/examples/jsm/misc/MorphAnimMesh.js +43 -0
- package/examples/jsm/misc/MorphBlendMesh.js +102 -0
- package/examples/jsm/misc/ProgressiveLightMap.js +40 -15
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +33 -13
- package/examples/jsm/misc/RollerCoaster.js +52 -0
- package/examples/jsm/misc/Timer.js +79 -2
- package/examples/jsm/misc/TubePainter.js +53 -0
- package/examples/jsm/misc/Volume.js +108 -72
- package/examples/jsm/misc/VolumeSlice.js +88 -45
- package/examples/jsm/modifiers/CurveModifier.js +57 -34
- package/examples/jsm/modifiers/CurveModifierGPU.js +36 -17
- package/examples/jsm/modifiers/EdgeSplitModifier.js +18 -0
- package/examples/jsm/modifiers/SimplifyModifier.js +20 -8
- package/examples/jsm/modifiers/TessellateModifier.js +33 -2
- package/examples/jsm/objects/GroundedSkybox.js +23 -5
- package/examples/jsm/objects/Lensflare.js +91 -2
- package/examples/jsm/objects/LensflareMesh.js +53 -2
- package/examples/jsm/objects/MarchingCubes.js +88 -5
- package/examples/jsm/objects/Reflector.js +70 -0
- package/examples/jsm/objects/ReflectorForSSRPass.js +39 -0
- package/examples/jsm/objects/Refractor.js +61 -0
- package/examples/jsm/objects/ShadowMesh.js +53 -4
- package/examples/jsm/objects/Sky.js +26 -9
- package/examples/jsm/objects/SkyMesh.js +60 -9
- package/examples/jsm/objects/Water.js +44 -5
- package/examples/jsm/objects/Water2.js +42 -3
- package/examples/jsm/objects/Water2Mesh.js +38 -3
- package/examples/jsm/objects/WaterMesh.js +94 -7
- package/examples/jsm/physics/AmmoPhysics.js +47 -0
- package/examples/jsm/physics/JoltPhysics.js +48 -0
- package/examples/jsm/physics/RapierPhysics.js +56 -0
- package/examples/jsm/postprocessing/AfterimagePass.js +90 -38
- package/examples/jsm/postprocessing/BloomPass.js +125 -24
- package/examples/jsm/postprocessing/BokehPass.js +98 -22
- package/examples/jsm/postprocessing/ClearPass.js +53 -3
- package/examples/jsm/postprocessing/CubeTexturePass.js +81 -21
- package/examples/jsm/postprocessing/DotScreenPass.js +58 -10
- package/examples/jsm/postprocessing/EffectComposer.js +131 -0
- package/examples/jsm/postprocessing/FilmPass.js +53 -5
- package/examples/jsm/postprocessing/GTAOPass.js +191 -48
- package/examples/jsm/postprocessing/GlitchPass.js +84 -33
- package/examples/jsm/postprocessing/HalftonePass.js +64 -10
- package/examples/jsm/postprocessing/LUTPass.js +37 -8
- package/examples/jsm/postprocessing/MaskPass.js +90 -0
- package/examples/jsm/postprocessing/OutlinePass.js +266 -133
- package/examples/jsm/postprocessing/OutputPass.js +53 -14
- package/examples/jsm/postprocessing/Pass.js +98 -4
- package/examples/jsm/postprocessing/RenderPass.js +83 -0
- package/examples/jsm/postprocessing/RenderPixelatedPass.js +123 -45
- package/examples/jsm/postprocessing/RenderTransitionPass.js +119 -21
- package/examples/jsm/postprocessing/SAOPass.js +126 -53
- package/examples/jsm/postprocessing/SMAAPass.js +103 -71
- package/examples/jsm/postprocessing/SSAARenderPass.js +117 -35
- package/examples/jsm/postprocessing/SSAOPass.js +160 -47
- package/examples/jsm/postprocessing/SSRPass.js +230 -49
- package/examples/jsm/postprocessing/SavePass.js +68 -16
- package/examples/jsm/postprocessing/ShaderPass.js +64 -7
- package/examples/jsm/postprocessing/TAARenderPass.js +78 -24
- package/examples/jsm/postprocessing/TexturePass.js +71 -8
- package/examples/jsm/postprocessing/UnrealBloomPass.js +113 -37
- package/examples/jsm/renderers/CSS2DRenderer.js +77 -1
- package/examples/jsm/renderers/CSS3DRenderer.js +99 -3
- package/examples/jsm/renderers/Projector.js +18 -2
- package/examples/jsm/renderers/SVGRenderer.js +124 -0
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +9 -5
- package/examples/jsm/shaders/AfterimageShader.js +6 -4
- package/examples/jsm/shaders/BasicShader.js +6 -2
- package/examples/jsm/shaders/BleachBypassShader.js +8 -4
- package/examples/jsm/shaders/BlendShader.js +6 -2
- package/examples/jsm/shaders/BokehShader.js +7 -4
- package/examples/jsm/shaders/BokehShader2.js +7 -3
- package/examples/jsm/shaders/BrightnessContrastShader.js +8 -5
- package/examples/jsm/shaders/ColorCorrectionShader.js +6 -2
- package/examples/jsm/shaders/ColorifyShader.js +6 -2
- package/examples/jsm/shaders/ConvolutionShader.js +7 -39
- package/examples/jsm/shaders/CopyShader.js +6 -2
- package/examples/jsm/shaders/DOFMipMapShader.js +8 -4
- package/examples/jsm/shaders/DepthLimitedBlurShader.js +7 -1
- package/examples/jsm/shaders/DigitalGlitch.js +7 -7
- package/examples/jsm/shaders/DotScreenShader.js +6 -4
- package/examples/jsm/shaders/ExposureShader.js +6 -2
- package/examples/jsm/shaders/FXAAShader.js +15 -7
- package/examples/jsm/shaders/FilmShader.js +10 -0
- package/examples/jsm/shaders/FocusShader.js +6 -4
- package/examples/jsm/shaders/FreiChenShader.js +7 -3
- package/examples/jsm/shaders/GTAOShader.js +33 -39
- package/examples/jsm/shaders/GammaCorrectionShader.js +8 -2
- package/examples/jsm/shaders/GodRaysShader.js +14 -5
- package/examples/jsm/shaders/HalftoneShader.js +11 -5
- package/examples/jsm/shaders/HorizontalBlurShader.js +9 -3
- package/examples/jsm/shaders/HorizontalTiltShiftShader.js +6 -2
- package/examples/jsm/shaders/HueSaturationShader.js +7 -3
- package/examples/jsm/shaders/KaleidoShader.js +8 -4
- package/examples/jsm/shaders/LuminosityHighPassShader.js +6 -5
- package/examples/jsm/shaders/LuminosityShader.js +6 -3
- package/examples/jsm/shaders/MirrorShader.js +7 -4
- package/examples/jsm/shaders/NormalMapShader.js +5 -3
- package/examples/jsm/shaders/OutputShader.js +11 -0
- package/examples/jsm/shaders/PoissonDenoiseShader.js +21 -15
- package/examples/jsm/shaders/RGBShiftShader.js +5 -1
- package/examples/jsm/shaders/SAOShader.js +8 -2
- package/examples/jsm/shaders/SMAAShader.js +23 -1
- package/examples/jsm/shaders/SSAOShader.js +23 -5
- package/examples/jsm/shaders/SSRShader.js +25 -1
- package/examples/jsm/shaders/SepiaShader.js +6 -4
- package/examples/jsm/shaders/SobelOperatorShader.js +5 -2
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +10 -8
- package/examples/jsm/shaders/TechnicolorShader.js +7 -4
- package/examples/jsm/shaders/ToonShader.js +29 -7
- package/examples/jsm/shaders/TriangleBlurShader.js +6 -4
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +6 -3
- package/examples/jsm/shaders/VelocityShader.js +6 -2
- package/examples/jsm/shaders/VerticalBlurShader.js +6 -2
- package/examples/jsm/shaders/VerticalTiltShiftShader.js +5 -1
- package/examples/jsm/shaders/VignetteShader.js +6 -4
- package/examples/jsm/shaders/VolumeShader.js +7 -1
- package/examples/jsm/shaders/WaterRefractionShader.js +8 -0
- package/examples/jsm/textures/FlakesTexture.js +12 -0
- package/examples/jsm/transpiler/Transpiler.js +31 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +1 -1
- package/examples/jsm/tsl/display/BloomNode.js +1 -1
- package/examples/jsm/tsl/display/PixelationPassNode.js +4 -4
- package/examples/jsm/tsl/display/SSRNode.js +1 -1
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +29 -3
- package/examples/jsm/tsl/math/Bayer.js +14 -1
- package/examples/jsm/tsl/utils/Raymarching.js +4 -2
- package/examples/jsm/utils/BufferGeometryUtils.js +88 -29
- package/examples/jsm/utils/CameraUtils.js +10 -7
- package/examples/jsm/utils/GeometryCompressionUtils.js +20 -30
- package/examples/jsm/utils/GeometryUtils.js +12 -13
- package/examples/jsm/utils/LDrawUtils.js +11 -4
- package/examples/jsm/utils/SceneOptimizer.js +66 -20
- package/examples/jsm/utils/SceneUtils.js +50 -3
- package/examples/jsm/utils/ShadowMapViewer.js +47 -24
- package/examples/jsm/utils/ShadowMapViewerGPU.js +47 -24
- package/examples/jsm/utils/SkeletonUtils.js +45 -0
- package/examples/jsm/utils/SortUtils.js +14 -5
- package/examples/jsm/utils/UVsDebug.js +9 -4
- package/examples/jsm/utils/WebGLTextureUtils.js +13 -0
- package/examples/jsm/utils/WebGPUTextureUtils.js +14 -0
- package/examples/jsm/utils/WorkerPool.js +65 -2
- package/examples/jsm/webxr/ARButton.js +18 -0
- package/examples/jsm/webxr/OculusHandModel.js +83 -0
- package/examples/jsm/webxr/OculusHandPointerModel.js +125 -0
- package/examples/jsm/webxr/Text2D.js +11 -0
- package/examples/jsm/webxr/VRButton.js +30 -0
- package/examples/jsm/webxr/XRButton.js +22 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +87 -3
- package/examples/jsm/webxr/XREstimatedLight.js +33 -3
- package/examples/jsm/webxr/XRHandMeshModel.js +35 -0
- package/examples/jsm/webxr/XRHandModelFactory.js +92 -0
- package/examples/jsm/webxr/XRHandPrimitiveModel.js +42 -0
- package/examples/jsm/webxr/XRPlanes.js +17 -0
- package/package.json +1 -1
- package/src/Three.TSL.js +3 -1
- package/src/animation/AnimationAction.js +262 -30
- package/src/animation/AnimationClip.js +141 -2
- package/src/animation/AnimationMixer.js +99 -15
- package/src/animation/AnimationObjectGroup.js +41 -18
- package/src/animation/AnimationUtils.js +168 -18
- package/src/animation/KeyframeTrack.js +144 -10
- package/src/animation/PropertyBinding.js +77 -3
- package/src/animation/PropertyMixer.js +72 -5
- package/src/animation/tracks/BooleanKeyframeTrack.js +33 -6
- package/src/animation/tracks/ColorKeyframeTrack.js +26 -5
- package/src/animation/tracks/NumberKeyframeTrack.js +26 -2
- package/src/animation/tracks/QuaternionKeyframeTrack.js +30 -1
- package/src/animation/tracks/StringKeyframeTrack.js +33 -2
- package/src/animation/tracks/VectorKeyframeTrack.js +26 -2
- package/src/audio/AudioAnalyser.js +1 -1
- package/src/audio/AudioListener.js +2 -2
- package/src/audio/PositionalAudio.js +5 -5
- package/src/constants.js +1429 -5
- package/src/core/BufferAttribute.js +413 -3
- package/src/core/BufferGeometry.js +337 -1
- package/src/core/Clock.js +60 -0
- package/src/core/GLBufferAttribute.js +99 -0
- package/src/core/InstancedBufferAttribute.js +29 -0
- package/src/core/InstancedBufferGeometry.js +20 -0
- package/src/core/InstancedInterleavedBuffer.js +26 -0
- package/src/core/InterleavedBuffer.js +137 -3
- package/src/core/InterleavedBufferAttribute.js +197 -0
- package/src/core/Layers.js +71 -10
- package/src/core/Object3D.js +23 -0
- package/src/core/Raycaster.js +134 -1
- package/src/core/RenderTarget.js +166 -7
- package/src/core/RenderTarget3D.js +25 -0
- package/src/core/RenderTargetArray.js +18 -0
- package/src/core/Uniform.js +29 -0
- package/src/core/UniformsGroup.js +84 -2
- package/src/extras/Controls.js +16 -1
- package/src/extras/Earcut.js +3 -781
- package/src/extras/ImageUtils.js +3 -2
- package/src/extras/PMREMGenerator.js +22 -17
- package/src/extras/core/Curve.js +1 -1
- package/src/extras/core/Path.js +1 -1
- package/src/extras/lib/earcut.js +685 -0
- package/src/geometries/ConeGeometry.js +2 -2
- package/src/geometries/CylinderGeometry.js +2 -2
- package/src/geometries/ExtrudeGeometry.js +71 -39
- package/src/geometries/LatheGeometry.js +1 -1
- package/src/lights/LightShadow.js +1 -1
- package/src/lights/webgpu/IESSpotLight.js +1 -1
- package/src/loaders/AnimationLoader.js +31 -0
- package/src/loaders/AudioLoader.js +31 -0
- package/src/loaders/BufferGeometryLoader.js +34 -0
- package/src/loaders/Cache.js +45 -0
- package/src/loaders/CompressedTextureLoader.js +36 -3
- package/src/loaders/CubeTextureLoader.js +45 -0
- package/src/loaders/DataTextureLoader.js +44 -3
- package/src/loaders/FileLoader.js +57 -1
- package/src/loaders/ImageBitmapLoader.js +57 -0
- package/src/loaders/ImageLoader.js +30 -0
- package/src/loaders/Loader.js +4 -6
- package/src/loaders/LoaderUtils.js +18 -36
- package/src/loaders/LoadingManager.js +142 -0
- package/src/loaders/MaterialLoader.js +57 -0
- package/src/loaders/ObjectLoader.js +53 -0
- package/src/loaders/TextureLoader.js +33 -0
- package/src/loaders/nodes/NodeLoader.js +6 -2
- package/src/loaders/nodes/NodeMaterialLoader.js +1 -1
- package/src/loaders/nodes/NodeObjectLoader.js +3 -3
- package/src/materials/LineBasicMaterial.js +74 -1
- package/src/materials/LineDashedMaterial.js +52 -0
- package/src/materials/Material.js +18 -3
- package/src/materials/MeshBasicMaterial.js +165 -0
- package/src/materials/MeshDepthMaterial.js +93 -0
- package/src/materials/MeshDistanceMaterial.js +76 -0
- package/src/materials/MeshLambertMaterial.js +273 -0
- package/src/materials/MeshMatcapMaterial.js +142 -0
- package/src/materials/MeshNormalMaterial.js +113 -0
- package/src/materials/MeshPhongMaterial.js +288 -0
- package/src/materials/MeshPhysicalMaterial.js +292 -1
- package/src/materials/MeshStandardMaterial.js +297 -0
- package/src/materials/MeshToonMaterial.js +218 -0
- package/src/materials/PointsMaterial.js +89 -0
- package/src/materials/RawShaderMaterial.js +25 -0
- package/src/materials/ShaderMaterial.js +215 -6
- package/src/materials/ShadowMaterial.js +54 -0
- package/src/materials/SpriteMaterial.js +82 -0
- package/src/materials/nodes/Line2NodeMaterial.js +1 -1
- package/src/materials/nodes/LineBasicNodeMaterial.js +2 -2
- package/src/materials/nodes/LineDashedNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshBasicNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshLambertNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshNormalNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshPhongNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshSSSNodeMaterial.js +1 -1
- package/src/materials/nodes/MeshStandardNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshToonNodeMaterial.js +2 -2
- package/src/materials/nodes/NodeMaterial.js +7 -3
- package/src/materials/nodes/PointsNodeMaterial.js +1 -1
- package/src/materials/nodes/ShadowNodeMaterial.js +11 -2
- package/src/materials/nodes/SpriteNodeMaterial.js +1 -1
- package/src/materials/nodes/VolumeNodeMaterial.js +10 -1
- package/src/math/Color.js +1 -1
- package/src/math/MathUtils.js +223 -0
- package/src/nodes/Nodes.js +1 -0
- package/src/nodes/accessors/BatchNode.js +8 -8
- package/src/nodes/accessors/BuiltinNode.js +1 -1
- package/src/nodes/accessors/CubeTextureNode.js +1 -1
- package/src/nodes/accessors/InstanceNode.js +5 -5
- package/src/nodes/accessors/InstancedMeshNode.js +1 -1
- package/src/nodes/accessors/MorphNode.js +27 -23
- package/src/nodes/accessors/Normal.js +1 -1
- package/src/nodes/accessors/Object3DNode.js +12 -12
- package/src/nodes/accessors/ReferenceBaseNode.js +2 -2
- package/src/nodes/accessors/ReferenceNode.js +1 -1
- package/src/nodes/accessors/SkinningNode.js +46 -37
- package/src/nodes/accessors/StorageBufferNode.js +1 -1
- package/src/nodes/accessors/StorageTextureNode.js +3 -3
- package/src/nodes/accessors/Texture3DNode.js +1 -1
- package/src/nodes/accessors/TextureNode.js +25 -5
- package/src/nodes/accessors/TextureSizeNode.js +1 -1
- package/src/nodes/accessors/UniformArrayNode.js +2 -2
- package/src/nodes/code/CodeNode.js +4 -4
- package/src/nodes/code/ExpressionNode.js +4 -4
- package/src/nodes/code/FunctionCallNode.js +23 -3
- package/src/nodes/code/ScriptableNode.js +4 -4
- package/src/nodes/code/ScriptableValueNode.js +2 -2
- package/src/nodes/core/AssignNode.js +1 -1
- package/src/nodes/core/AttributeNode.js +1 -1
- package/src/nodes/core/BypassNode.js +1 -1
- package/src/nodes/core/CacheNode.js +1 -1
- package/src/nodes/core/ContextNode.js +1 -1
- package/src/nodes/core/InputNode.js +2 -2
- package/src/nodes/core/Node.js +14 -2
- package/src/nodes/core/NodeBuilder.js +86 -14
- package/src/nodes/core/StackNode.js +5 -5
- package/src/nodes/core/StructNode.js +1 -1
- package/src/nodes/core/StructTypeNode.js +2 -2
- package/src/nodes/core/VarNode.js +2 -8
- package/src/nodes/core/VaryingNode.js +3 -3
- package/src/nodes/display/BlendModes.js +4 -4
- package/src/nodes/display/BumpMapNode.js +1 -1
- package/src/nodes/display/NormalMapNode.js +1 -1
- package/src/nodes/display/PosterizeNode.js +1 -1
- package/src/nodes/display/ScreenNode.js +3 -3
- package/src/nodes/display/ViewportDepthNode.js +2 -2
- package/src/nodes/display/ViewportDepthTextureNode.js +2 -2
- package/src/nodes/display/ViewportSharedTextureNode.js +2 -2
- package/src/nodes/display/ViewportTextureNode.js +4 -4
- package/src/nodes/functions/ShadowMaskModel.js +4 -4
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +6 -6
- package/src/nodes/geometry/RangeNode.js +1 -1
- package/src/nodes/gpgpu/AtomicFunctionNode.js +16 -40
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -1
- package/src/nodes/gpgpu/ComputeNode.js +30 -2
- package/src/nodes/lighting/AnalyticLightNode.js +9 -1
- package/src/nodes/lighting/LightsNode.js +3 -3
- package/src/nodes/lighting/ShadowNode.js +1 -1
- package/src/nodes/math/ConditionalNode.js +20 -3
- package/src/nodes/math/MathNode.js +83 -78
- package/src/nodes/math/OperatorNode.js +171 -82
- package/src/nodes/pmrem/PMREMNode.js +4 -4
- package/src/nodes/pmrem/PMREMUtils.js +2 -2
- package/src/nodes/tsl/TSLBase.js +2 -1
- package/src/nodes/tsl/TSLCore.js +115 -12
- package/src/nodes/utils/ArrayElementNode.js +3 -1
- package/src/nodes/utils/CubeMapNode.js +3 -3
- package/src/nodes/utils/DebugNode.js +70 -0
- package/src/nodes/utils/EquirectUVNode.js +2 -2
- package/src/nodes/utils/JoinNode.js +27 -2
- package/src/nodes/utils/LoopNode.js +58 -28
- package/src/nodes/utils/MaxMipLevelNode.js +1 -1
- package/src/nodes/utils/ReflectorNode.js +2 -2
- package/src/nodes/utils/RemapNode.js +6 -6
- package/src/nodes/utils/RotateNode.js +1 -1
- package/src/nodes/utils/SpriteSheetUVNode.js +3 -3
- package/src/nodes/utils/StorageArrayElementNode.js +1 -1
- package/src/nodes/utils/TriplanarTexturesNode.js +3 -3
- package/src/objects/BatchedMesh.js +4 -4
- package/src/objects/InstancedMesh.js +2 -2
- package/src/objects/LOD.js +1 -1
- package/src/objects/Skeleton.js +1 -1
- package/src/renderers/WebGL3DRenderTarget.js +25 -0
- package/src/renderers/WebGLArrayRenderTarget.js +25 -0
- package/src/renderers/WebGLCubeRenderTarget.js +39 -1
- package/src/renderers/WebGLRenderTarget.js +19 -0
- package/src/renderers/WebGLRenderer.js +617 -79
- package/src/renderers/common/Animation.js +2 -2
- package/src/renderers/common/Attributes.js +2 -2
- package/src/renderers/common/Backend.js +12 -3
- package/src/renderers/common/Background.js +1 -0
- package/src/renderers/common/Color4.js +1 -1
- package/src/renderers/common/CubeRenderTarget.js +13 -0
- package/src/renderers/common/PostProcessing.js +2 -0
- package/src/renderers/common/QuadMesh.js +2 -0
- package/src/renderers/common/RenderList.js +2 -2
- package/src/renderers/common/RenderObject.js +1 -1
- package/src/renderers/common/RenderObjects.js +2 -2
- package/src/renderers/common/Renderer.js +52 -31
- package/src/renderers/common/XRManager.js +333 -10
- package/src/renderers/common/extras/PMREMGenerator.js +6 -0
- package/src/renderers/common/nodes/NodeBuilderState.js +3 -3
- package/src/renderers/shaders/UniformsLib.js +1 -4
- package/src/renderers/shaders/UniformsUtils.js +1 -3
- package/src/renderers/webgl/WebGLBackground.js +4 -2
- package/src/renderers/webgl/WebGLState.js +9 -9
- package/src/renderers/webgl-fallback/WebGLBackend.js +25 -26
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +3 -12
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +67 -19
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +1 -1
- package/src/renderers/webgpu/WebGPUBackend.js +128 -87
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +1 -11
- package/src/renderers/webgpu/WebGPURenderer.js +17 -11
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +4 -4
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +5 -3
- package/src/renderers/webgpu/utils/WebGPUConstants.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +1 -1
- package/src/renderers/webxr/WebXRController.js +87 -2
- package/src/renderers/webxr/WebXRDepthSensing.js +49 -0
- package/src/renderers/webxr/WebXRManager.js +173 -1
- package/src/scenes/Scene.js +2 -1
- package/src/textures/CanvasTexture.js +28 -0
- package/src/textures/CompressedArrayTexture.js +57 -0
- package/src/textures/CompressedCubeTexture.js +29 -0
- package/src/textures/CompressedTexture.js +64 -6
- package/src/textures/CubeTexture.js +52 -4
- package/src/textures/Data3DTexture.js +77 -0
- package/src/textures/DataArrayTexture.js +93 -0
- package/src/textures/DataTexture.js +65 -0
- package/src/textures/DepthTexture.js +59 -9
- package/src/textures/FramebufferTexture.js +62 -0
- package/src/textures/Source.js +69 -0
- package/src/textures/Texture.js +5 -5
- package/src/textures/VideoFrameTexture.js +43 -6
- package/src/textures/VideoTexture.js +49 -4
- package/examples/jsm/geometries/ParametricGeometries.js +0 -254
package/build/three.module.js
CHANGED
|
@@ -716,10 +716,7 @@ const ShaderChunk = {
|
|
|
716
716
|
sprite_frag: fragment$1
|
|
717
717
|
};
|
|
718
718
|
|
|
719
|
-
|
|
720
|
-
* Uniforms library for shared webgl shaders
|
|
721
|
-
*/
|
|
722
|
-
|
|
719
|
+
// Uniforms library for shared webgl shaders
|
|
723
720
|
const UniformsLib = {
|
|
724
721
|
|
|
725
722
|
common: {
|
|
@@ -748,7 +745,7 @@ const UniformsLib = {
|
|
|
748
745
|
|
|
749
746
|
envMap: { value: null },
|
|
750
747
|
envMapRotation: { value: /*@__PURE__*/ new Matrix3() },
|
|
751
|
-
flipEnvMap: { value: -1 },
|
|
748
|
+
flipEnvMap: { value: - 1 },
|
|
752
749
|
reflectivity: { value: 1.0 }, // basic, lambert, phong
|
|
753
750
|
ior: { value: 1.5 }, // physical
|
|
754
751
|
refractionRatio: { value: 0.98 }, // basic, lambert, phong
|
|
@@ -1169,7 +1166,7 @@ const ShaderLib = {
|
|
|
1169
1166
|
|
|
1170
1167
|
uniforms: {
|
|
1171
1168
|
envMap: { value: null },
|
|
1172
|
-
flipEnvMap: { value: -1 },
|
|
1169
|
+
flipEnvMap: { value: - 1 },
|
|
1173
1170
|
backgroundBlurriness: { value: 0 },
|
|
1174
1171
|
backgroundIntensity: { value: 1 },
|
|
1175
1172
|
backgroundRotation: { value: /*@__PURE__*/ new Matrix3() }
|
|
@@ -1184,7 +1181,7 @@ const ShaderLib = {
|
|
|
1184
1181
|
|
|
1185
1182
|
uniforms: {
|
|
1186
1183
|
tCube: { value: null },
|
|
1187
|
-
tFlip: { value: -1 },
|
|
1184
|
+
tFlip: { value: - 1 },
|
|
1188
1185
|
opacity: { value: 1.0 }
|
|
1189
1186
|
},
|
|
1190
1187
|
|
|
@@ -1387,7 +1384,8 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
|
|
|
1387
1384
|
side: BackSide,
|
|
1388
1385
|
depthTest: false,
|
|
1389
1386
|
depthWrite: false,
|
|
1390
|
-
fog: false
|
|
1387
|
+
fog: false,
|
|
1388
|
+
allowOverride: false
|
|
1391
1389
|
} )
|
|
1392
1390
|
);
|
|
1393
1391
|
|
|
@@ -1418,18 +1416,18 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
|
|
|
1418
1416
|
_e1$1.copy( scene.backgroundRotation );
|
|
1419
1417
|
|
|
1420
1418
|
// accommodate left-handed frame
|
|
1421
|
-
_e1$1.x *= -1; _e1$1.y *= -1; _e1$1.z *= -1;
|
|
1419
|
+
_e1$1.x *= - 1; _e1$1.y *= - 1; _e1$1.z *= - 1;
|
|
1422
1420
|
|
|
1423
1421
|
if ( background.isCubeTexture && background.isRenderTargetTexture === false ) {
|
|
1424
1422
|
|
|
1425
1423
|
// environment maps which are not cube render targets or PMREMs follow a different convention
|
|
1426
|
-
_e1$1.y *= -1;
|
|
1427
|
-
_e1$1.z *= -1;
|
|
1424
|
+
_e1$1.y *= - 1;
|
|
1425
|
+
_e1$1.z *= - 1;
|
|
1428
1426
|
|
|
1429
1427
|
}
|
|
1430
1428
|
|
|
1431
1429
|
boxMesh.material.uniforms.envMap.value = background;
|
|
1432
|
-
boxMesh.material.uniforms.flipEnvMap.value = ( background.isCubeTexture && background.isRenderTargetTexture === false ) ? -1 : 1;
|
|
1430
|
+
boxMesh.material.uniforms.flipEnvMap.value = ( background.isCubeTexture && background.isRenderTargetTexture === false ) ? - 1 : 1;
|
|
1433
1431
|
boxMesh.material.uniforms.backgroundBlurriness.value = scene.backgroundBlurriness;
|
|
1434
1432
|
boxMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;
|
|
1435
1433
|
boxMesh.material.uniforms.backgroundRotation.value.setFromMatrix4( _m1$1.makeRotationFromEuler( _e1$1 ) );
|
|
@@ -1466,7 +1464,8 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
|
|
|
1466
1464
|
side: FrontSide,
|
|
1467
1465
|
depthTest: false,
|
|
1468
1466
|
depthWrite: false,
|
|
1469
|
-
fog: false
|
|
1467
|
+
fog: false,
|
|
1468
|
+
allowOverride: false
|
|
1470
1469
|
} )
|
|
1471
1470
|
);
|
|
1472
1471
|
|
|
@@ -2693,9 +2692,9 @@ const _axisDirections = [
|
|
|
2693
2692
|
/*@__PURE__*/ new Vector3( INV_PHI, 0, PHI ),
|
|
2694
2693
|
/*@__PURE__*/ new Vector3( 0, PHI, - INV_PHI ),
|
|
2695
2694
|
/*@__PURE__*/ new Vector3( 0, PHI, INV_PHI ),
|
|
2696
|
-
/*@__PURE__*/ new Vector3( -1, 1, -1 ),
|
|
2697
|
-
/*@__PURE__*/ new Vector3( 1, 1, -1 ),
|
|
2698
|
-
/*@__PURE__*/ new Vector3( -1, 1, 1 ),
|
|
2695
|
+
/*@__PURE__*/ new Vector3( - 1, 1, - 1 ),
|
|
2696
|
+
/*@__PURE__*/ new Vector3( 1, 1, - 1 ),
|
|
2697
|
+
/*@__PURE__*/ new Vector3( - 1, 1, 1 ),
|
|
2699
2698
|
/*@__PURE__*/ new Vector3( 1, 1, 1 ) ];
|
|
2700
2699
|
|
|
2701
2700
|
const _origin = /*@__PURE__*/ new Vector3();
|
|
@@ -2711,12 +2710,16 @@ const _origin = /*@__PURE__*/ new Vector3();
|
|
|
2711
2710
|
* higher roughness levels. In this way we maintain resolution to smoothly
|
|
2712
2711
|
* interpolate diffuse lighting while limiting sampling computation.
|
|
2713
2712
|
*
|
|
2714
|
-
* Paper: Fast, Accurate Image-Based Lighting
|
|
2715
|
-
* https://drive.google.com/file/d/15y8r_UpKlU9SvV4ILb0C3qCPecS8pvLz/view
|
|
2713
|
+
* Paper: Fast, Accurate Image-Based Lighting:
|
|
2714
|
+
* {@link https://drive.google.com/file/d/15y8r_UpKlU9SvV4ILb0C3qCPecS8pvLz/view}
|
|
2716
2715
|
*/
|
|
2717
|
-
|
|
2718
2716
|
class PMREMGenerator {
|
|
2719
2717
|
|
|
2718
|
+
/**
|
|
2719
|
+
* Constructs a new PMREM generator.
|
|
2720
|
+
*
|
|
2721
|
+
* @param {WebGLRenderer} renderer - The renderer.
|
|
2722
|
+
*/
|
|
2720
2723
|
constructor( renderer ) {
|
|
2721
2724
|
|
|
2722
2725
|
this._renderer = renderer;
|
|
@@ -2742,12 +2745,14 @@ class PMREMGenerator {
|
|
|
2742
2745
|
* in radians to be applied to the scene before PMREM generation. Optional near
|
|
2743
2746
|
* and far planes ensure the scene is rendered in its entirety.
|
|
2744
2747
|
*
|
|
2745
|
-
* @param {Scene} scene
|
|
2746
|
-
* @param {number} sigma
|
|
2747
|
-
* @param {number} near
|
|
2748
|
-
* @param {number} far
|
|
2749
|
-
* @param {Object} [options={}]
|
|
2750
|
-
* @
|
|
2748
|
+
* @param {Scene} scene - The scene to be captured.
|
|
2749
|
+
* @param {number} [sigma=0] - The blur radius in radians.
|
|
2750
|
+
* @param {number} [near=0.1] - The near plane distance.
|
|
2751
|
+
* @param {number} [far=100] - The far plane distance.
|
|
2752
|
+
* @param {Object} [options={}] - The configuration options.
|
|
2753
|
+
* @param {number} [options.size=256] - The texture size of the PMREM.
|
|
2754
|
+
* @param {Vector3} [options.renderTarget=origin] - The position of the internal cube camera that renders the scene.
|
|
2755
|
+
* @return {WebGLRenderTarget} The resulting PMREM.
|
|
2751
2756
|
*/
|
|
2752
2757
|
fromScene( scene, sigma = 0, near = 0.1, far = 100, options = {} ) {
|
|
2753
2758
|
|
|
@@ -2787,11 +2792,10 @@ class PMREMGenerator {
|
|
|
2787
2792
|
* Generates a PMREM from an equirectangular texture, which can be either LDR
|
|
2788
2793
|
* or HDR. The ideal input image size is 1k (1024 x 512),
|
|
2789
2794
|
* as this matches best with the 256 x 256 cubemap output.
|
|
2790
|
-
* The smallest supported equirectangular image size is 64 x 32.
|
|
2791
2795
|
*
|
|
2792
|
-
* @param {Texture} equirectangular
|
|
2793
|
-
* @param {?WebGLRenderTarget} [renderTarget=null] -
|
|
2794
|
-
* @return {WebGLRenderTarget}
|
|
2796
|
+
* @param {Texture} equirectangular - The equirectangular texture to be converted.
|
|
2797
|
+
* @param {?WebGLRenderTarget} [renderTarget=null] - The render target to use.
|
|
2798
|
+
* @return {WebGLRenderTarget} The resulting PMREM.
|
|
2795
2799
|
*/
|
|
2796
2800
|
fromEquirectangular( equirectangular, renderTarget = null ) {
|
|
2797
2801
|
|
|
@@ -2803,11 +2807,10 @@ class PMREMGenerator {
|
|
|
2803
2807
|
* Generates a PMREM from an cubemap texture, which can be either LDR
|
|
2804
2808
|
* or HDR. The ideal input cube size is 256 x 256,
|
|
2805
2809
|
* as this matches best with the 256 x 256 cubemap output.
|
|
2806
|
-
* The smallest supported cube size is 16 x 16.
|
|
2807
2810
|
*
|
|
2808
|
-
* @param {Texture} cubemap
|
|
2809
|
-
* @param {
|
|
2810
|
-
* @return {WebGLRenderTarget}
|
|
2811
|
+
* @param {Texture} cubemap - The cubemap texture to be converted.
|
|
2812
|
+
* @param {?WebGLRenderTarget} [renderTarget=null] - The render target to use.
|
|
2813
|
+
* @return {WebGLRenderTarget} The resulting PMREM.
|
|
2811
2814
|
*/
|
|
2812
2815
|
fromCubemap( cubemap, renderTarget = null ) {
|
|
2813
2816
|
|
|
@@ -2970,8 +2973,8 @@ class PMREMGenerator {
|
|
|
2970
2973
|
const fov = 90;
|
|
2971
2974
|
const aspect = 1;
|
|
2972
2975
|
const cubeCamera = new PerspectiveCamera( fov, aspect, near, far );
|
|
2973
|
-
const upSign = [ 1, -1, 1, 1, 1, 1 ];
|
|
2974
|
-
const forwardSign = [ 1, 1, 1, -1, -1, -1 ];
|
|
2976
|
+
const upSign = [ 1, - 1, 1, 1, 1, 1 ];
|
|
2977
|
+
const forwardSign = [ 1, 1, 1, - 1, - 1, - 1 ];
|
|
2975
2978
|
const renderer = this._renderer;
|
|
2976
2979
|
|
|
2977
2980
|
const originalAutoClear = renderer.autoClear;
|
|
@@ -3074,7 +3077,7 @@ class PMREMGenerator {
|
|
|
3074
3077
|
|
|
3075
3078
|
}
|
|
3076
3079
|
|
|
3077
|
-
this._cubemapMaterial.uniforms.flipEnvMap.value = ( texture.isRenderTargetTexture === false ) ? -1 : 1;
|
|
3080
|
+
this._cubemapMaterial.uniforms.flipEnvMap.value = ( texture.isRenderTargetTexture === false ) ? - 1 : 1;
|
|
3078
3081
|
|
|
3079
3082
|
} else {
|
|
3080
3083
|
|
|
@@ -3130,6 +3133,7 @@ class PMREMGenerator {
|
|
|
3130
3133
|
* the poles) to approximate the orthogonally-separable blur. It is least
|
|
3131
3134
|
* accurate at the poles, but still does a decent job.
|
|
3132
3135
|
*
|
|
3136
|
+
* @private
|
|
3133
3137
|
* @param {WebGLRenderTarget} cubeUVRenderTarget
|
|
3134
3138
|
* @param {number} lodIn
|
|
3135
3139
|
* @param {number} lodOut
|
|
@@ -3293,7 +3297,7 @@ function _createPlanes( lodMax ) {
|
|
|
3293
3297
|
for ( let face = 0; face < cubeFaces; face ++ ) {
|
|
3294
3298
|
|
|
3295
3299
|
const x = ( face % 3 ) * 2 / 3 - 1;
|
|
3296
|
-
const y = face > 2 ? 0 : -1;
|
|
3300
|
+
const y = face > 2 ? 0 : - 1;
|
|
3297
3301
|
const coordinates = [
|
|
3298
3302
|
x, y, 0,
|
|
3299
3303
|
x + 2 / 3, y, 0,
|
|
@@ -3492,7 +3496,7 @@ function _getCubemapMaterial() {
|
|
|
3492
3496
|
|
|
3493
3497
|
uniforms: {
|
|
3494
3498
|
'envMap': { value: null },
|
|
3495
|
-
'flipEnvMap': { value: -1 }
|
|
3499
|
+
'flipEnvMap': { value: - 1 }
|
|
3496
3500
|
},
|
|
3497
3501
|
|
|
3498
3502
|
vertexShader: _getCommonVertexShader(),
|
|
@@ -7866,18 +7870,18 @@ function WebGLLights( extensions ) {
|
|
|
7866
7870
|
version: 0,
|
|
7867
7871
|
|
|
7868
7872
|
hash: {
|
|
7869
|
-
directionalLength: -1,
|
|
7870
|
-
pointLength: -1,
|
|
7871
|
-
spotLength: -1,
|
|
7872
|
-
rectAreaLength: -1,
|
|
7873
|
-
hemiLength: -1,
|
|
7874
|
-
|
|
7875
|
-
numDirectionalShadows: -1,
|
|
7876
|
-
numPointShadows: -1,
|
|
7877
|
-
numSpotShadows: -1,
|
|
7878
|
-
numSpotMaps: -1,
|
|
7879
|
-
|
|
7880
|
-
numLightProbes: -1
|
|
7873
|
+
directionalLength: - 1,
|
|
7874
|
+
pointLength: - 1,
|
|
7875
|
+
spotLength: - 1,
|
|
7876
|
+
rectAreaLength: - 1,
|
|
7877
|
+
hemiLength: - 1,
|
|
7878
|
+
|
|
7879
|
+
numDirectionalShadows: - 1,
|
|
7880
|
+
numPointShadows: - 1,
|
|
7881
|
+
numSpotShadows: - 1,
|
|
7882
|
+
numSpotMaps: - 1,
|
|
7883
|
+
|
|
7884
|
+
numLightProbes: - 1
|
|
7881
7885
|
},
|
|
7882
7886
|
|
|
7883
7887
|
ambient: [ 0, 0, 0 ],
|
|
@@ -8418,7 +8422,7 @@ function WebGLShadowMap( renderer, objects, capabilities ) {
|
|
|
8418
8422
|
fullScreenTri.setAttribute(
|
|
8419
8423
|
'position',
|
|
8420
8424
|
new BufferAttribute(
|
|
8421
|
-
new Float32Array( [ -1, -1, 0.5, 3, -1, 0.5, -1, 3, 0.5 ] ),
|
|
8425
|
+
new Float32Array( [ - 1, - 1, 0.5, 3, - 1, 0.5, - 1, 3, 0.5 ] ),
|
|
8422
8426
|
3
|
|
8423
8427
|
)
|
|
8424
8428
|
);
|
|
@@ -8851,7 +8855,7 @@ function WebGLState( gl, extensions ) {
|
|
|
8851
8855
|
locked = false;
|
|
8852
8856
|
|
|
8853
8857
|
currentColorMask = null;
|
|
8854
|
-
currentColorClear.set( -1, 0, 0, 0 ); // set to invalid state
|
|
8858
|
+
currentColorClear.set( - 1, 0, 0, 0 ); // set to invalid state
|
|
8855
8859
|
|
|
8856
8860
|
}
|
|
8857
8861
|
|
|
@@ -8862,17 +8866,17 @@ function WebGLState( gl, extensions ) {
|
|
|
8862
8866
|
function DepthBuffer() {
|
|
8863
8867
|
|
|
8864
8868
|
let locked = false;
|
|
8865
|
-
let reversed = false;
|
|
8866
8869
|
|
|
8870
|
+
let currentReversed = false;
|
|
8867
8871
|
let currentDepthMask = null;
|
|
8868
8872
|
let currentDepthFunc = null;
|
|
8869
8873
|
let currentDepthClear = null;
|
|
8870
8874
|
|
|
8871
8875
|
return {
|
|
8872
8876
|
|
|
8873
|
-
setReversed: function (
|
|
8877
|
+
setReversed: function ( reversed ) {
|
|
8874
8878
|
|
|
8875
|
-
if (
|
|
8879
|
+
if ( currentReversed !== reversed ) {
|
|
8876
8880
|
|
|
8877
8881
|
const ext = extensions.get( 'EXT_clip_control' );
|
|
8878
8882
|
|
|
@@ -8886,19 +8890,19 @@ function WebGLState( gl, extensions ) {
|
|
|
8886
8890
|
|
|
8887
8891
|
}
|
|
8888
8892
|
|
|
8893
|
+
currentReversed = reversed;
|
|
8894
|
+
|
|
8889
8895
|
const oldDepth = currentDepthClear;
|
|
8890
8896
|
currentDepthClear = null;
|
|
8891
8897
|
this.setClear( oldDepth );
|
|
8892
8898
|
|
|
8893
8899
|
}
|
|
8894
8900
|
|
|
8895
|
-
reversed = value;
|
|
8896
|
-
|
|
8897
8901
|
},
|
|
8898
8902
|
|
|
8899
8903
|
getReversed: function () {
|
|
8900
8904
|
|
|
8901
|
-
return
|
|
8905
|
+
return currentReversed;
|
|
8902
8906
|
|
|
8903
8907
|
},
|
|
8904
8908
|
|
|
@@ -8929,7 +8933,7 @@ function WebGLState( gl, extensions ) {
|
|
|
8929
8933
|
|
|
8930
8934
|
setFunc: function ( depthFunc ) {
|
|
8931
8935
|
|
|
8932
|
-
if (
|
|
8936
|
+
if ( currentReversed ) depthFunc = reversedFuncs[ depthFunc ];
|
|
8933
8937
|
|
|
8934
8938
|
if ( currentDepthFunc !== depthFunc ) {
|
|
8935
8939
|
|
|
@@ -8997,7 +9001,7 @@ function WebGLState( gl, extensions ) {
|
|
|
8997
9001
|
|
|
8998
9002
|
if ( currentDepthClear !== depth ) {
|
|
8999
9003
|
|
|
9000
|
-
if (
|
|
9004
|
+
if ( currentReversed ) {
|
|
9001
9005
|
|
|
9002
9006
|
depth = 1 - depth;
|
|
9003
9007
|
|
|
@@ -9017,7 +9021,7 @@ function WebGLState( gl, extensions ) {
|
|
|
9017
9021
|
currentDepthMask = null;
|
|
9018
9022
|
currentDepthFunc = null;
|
|
9019
9023
|
currentDepthClear = null;
|
|
9020
|
-
|
|
9024
|
+
currentReversed = false;
|
|
9021
9025
|
|
|
9022
9026
|
}
|
|
9023
9027
|
|
|
@@ -9180,12 +9184,12 @@ function WebGLState( gl, extensions ) {
|
|
|
9180
9184
|
let version = 0;
|
|
9181
9185
|
const glVersion = gl.getParameter( gl.VERSION );
|
|
9182
9186
|
|
|
9183
|
-
if ( glVersion.indexOf( 'WebGL' ) !== -1 ) {
|
|
9187
|
+
if ( glVersion.indexOf( 'WebGL' ) !== - 1 ) {
|
|
9184
9188
|
|
|
9185
9189
|
version = parseFloat( /^WebGL (\d)/.exec( glVersion )[ 1 ] );
|
|
9186
9190
|
lineWidthAvailable = ( version >= 1.0 );
|
|
9187
9191
|
|
|
9188
|
-
} else if ( glVersion.indexOf( 'OpenGL ES' ) !== -1 ) {
|
|
9192
|
+
} else if ( glVersion.indexOf( 'OpenGL ES' ) !== - 1 ) {
|
|
9189
9193
|
|
|
9190
9194
|
version = parseFloat( /^OpenGL ES (\d)/.exec( glVersion )[ 1 ] );
|
|
9191
9195
|
lineWidthAvailable = ( version >= 2.0 );
|
|
@@ -12527,18 +12531,53 @@ void main() {
|
|
|
12527
12531
|
|
|
12528
12532
|
}`;
|
|
12529
12533
|
|
|
12534
|
+
/**
|
|
12535
|
+
* A XR module that manages the access to the Depth Sensing API.
|
|
12536
|
+
*/
|
|
12530
12537
|
class WebXRDepthSensing {
|
|
12531
12538
|
|
|
12539
|
+
/**
|
|
12540
|
+
* Constructs a new depth sensing module.
|
|
12541
|
+
*/
|
|
12532
12542
|
constructor() {
|
|
12533
12543
|
|
|
12544
|
+
/**
|
|
12545
|
+
* A texture representing the depth of the user's environment.
|
|
12546
|
+
*
|
|
12547
|
+
* @type {?Texture}
|
|
12548
|
+
*/
|
|
12534
12549
|
this.texture = null;
|
|
12550
|
+
|
|
12551
|
+
/**
|
|
12552
|
+
* A plane mesh for visualizing the depth texture.
|
|
12553
|
+
*
|
|
12554
|
+
* @type {?Mesh}
|
|
12555
|
+
*/
|
|
12535
12556
|
this.mesh = null;
|
|
12536
12557
|
|
|
12558
|
+
/**
|
|
12559
|
+
* The depth near value.
|
|
12560
|
+
*
|
|
12561
|
+
* @type {number}
|
|
12562
|
+
*/
|
|
12537
12563
|
this.depthNear = 0;
|
|
12564
|
+
|
|
12565
|
+
/**
|
|
12566
|
+
* The depth near far.
|
|
12567
|
+
*
|
|
12568
|
+
* @type {number}
|
|
12569
|
+
*/
|
|
12538
12570
|
this.depthFar = 0;
|
|
12539
12571
|
|
|
12540
12572
|
}
|
|
12541
12573
|
|
|
12574
|
+
/**
|
|
12575
|
+
* Inits the depth sensing module
|
|
12576
|
+
*
|
|
12577
|
+
* @param {WebGLRenderer} renderer - The renderer.
|
|
12578
|
+
* @param {XRWebGLDepthInformation} depthData - The XR depth data.
|
|
12579
|
+
* @param {XRRenderState} renderState - The XR render state.
|
|
12580
|
+
*/
|
|
12542
12581
|
init( renderer, depthData, renderState ) {
|
|
12543
12582
|
|
|
12544
12583
|
if ( this.texture === null ) {
|
|
@@ -12561,6 +12600,12 @@ class WebXRDepthSensing {
|
|
|
12561
12600
|
|
|
12562
12601
|
}
|
|
12563
12602
|
|
|
12603
|
+
/**
|
|
12604
|
+
* Returns a plane mesh that visualizes the depth texture.
|
|
12605
|
+
*
|
|
12606
|
+
* @param {ArrayCamera} cameraXR - The XR camera.
|
|
12607
|
+
* @return {?Mesh} The plane mesh.
|
|
12608
|
+
*/
|
|
12564
12609
|
getMesh( cameraXR ) {
|
|
12565
12610
|
|
|
12566
12611
|
if ( this.texture !== null ) {
|
|
@@ -12588,6 +12633,9 @@ class WebXRDepthSensing {
|
|
|
12588
12633
|
|
|
12589
12634
|
}
|
|
12590
12635
|
|
|
12636
|
+
/**
|
|
12637
|
+
* Resets the module
|
|
12638
|
+
*/
|
|
12591
12639
|
reset() {
|
|
12592
12640
|
|
|
12593
12641
|
this.texture = null;
|
|
@@ -12595,6 +12643,11 @@ class WebXRDepthSensing {
|
|
|
12595
12643
|
|
|
12596
12644
|
}
|
|
12597
12645
|
|
|
12646
|
+
/**
|
|
12647
|
+
* Returns a texture representing the depth of the user's environment.
|
|
12648
|
+
*
|
|
12649
|
+
* @return {?Texture} The depth texture.
|
|
12650
|
+
*/
|
|
12598
12651
|
getDepthTexture() {
|
|
12599
12652
|
|
|
12600
12653
|
return this.texture;
|
|
@@ -12603,8 +12656,23 @@ class WebXRDepthSensing {
|
|
|
12603
12656
|
|
|
12604
12657
|
}
|
|
12605
12658
|
|
|
12659
|
+
/**
|
|
12660
|
+
* This class represents an abstraction of the WebXR Device API and is
|
|
12661
|
+
* internally used by {@link WebGLRenderer}. `WebXRManager` also provides a public
|
|
12662
|
+
* interface that allows users to enable/disable XR and perform XR related
|
|
12663
|
+
* tasks like for instance retrieving controllers.
|
|
12664
|
+
*
|
|
12665
|
+
* @augments EventDispatcher
|
|
12666
|
+
* @hideconstructor
|
|
12667
|
+
*/
|
|
12606
12668
|
class WebXRManager extends EventDispatcher {
|
|
12607
12669
|
|
|
12670
|
+
/**
|
|
12671
|
+
* Constructs a new WebGL renderer.
|
|
12672
|
+
*
|
|
12673
|
+
* @param {WebGLRenderer} renderer - The renderer.
|
|
12674
|
+
* @param {WebGL2RenderingContext} gl - The rendering context.
|
|
12675
|
+
*/
|
|
12608
12676
|
constructor( renderer, gl ) {
|
|
12609
12677
|
|
|
12610
12678
|
super();
|
|
@@ -12656,11 +12724,40 @@ class WebXRManager extends EventDispatcher {
|
|
|
12656
12724
|
|
|
12657
12725
|
//
|
|
12658
12726
|
|
|
12727
|
+
/**
|
|
12728
|
+
* Whether the manager's XR camera should be automatically updated or not.
|
|
12729
|
+
*
|
|
12730
|
+
* @type {boolean}
|
|
12731
|
+
* @default true
|
|
12732
|
+
*/
|
|
12659
12733
|
this.cameraAutoUpdate = true;
|
|
12734
|
+
|
|
12735
|
+
/**
|
|
12736
|
+
* This flag notifies the renderer to be ready for XR rendering. Set it to `true`
|
|
12737
|
+
* if you are going to use XR in your app.
|
|
12738
|
+
*
|
|
12739
|
+
* @type {boolean}
|
|
12740
|
+
* @default false
|
|
12741
|
+
*/
|
|
12660
12742
|
this.enabled = false;
|
|
12661
12743
|
|
|
12744
|
+
/**
|
|
12745
|
+
* Whether XR presentation is active or not.
|
|
12746
|
+
*
|
|
12747
|
+
* @type {boolean}
|
|
12748
|
+
* @readonly
|
|
12749
|
+
* @default false
|
|
12750
|
+
*/
|
|
12662
12751
|
this.isPresenting = false;
|
|
12663
12752
|
|
|
12753
|
+
/**
|
|
12754
|
+
* Returns a group representing the `target ray` space of the XR controller.
|
|
12755
|
+
* Use this space for visualizing 3D objects that support the user in pointing
|
|
12756
|
+
* tasks like UI interaction.
|
|
12757
|
+
*
|
|
12758
|
+
* @param {number} index - The index of the controller.
|
|
12759
|
+
* @return {Group} A group representing the `target ray` space.
|
|
12760
|
+
*/
|
|
12664
12761
|
this.getController = function ( index ) {
|
|
12665
12762
|
|
|
12666
12763
|
let controller = controllers[ index ];
|
|
@@ -12676,6 +12773,21 @@ class WebXRManager extends EventDispatcher {
|
|
|
12676
12773
|
|
|
12677
12774
|
};
|
|
12678
12775
|
|
|
12776
|
+
/**
|
|
12777
|
+
* Returns a group representing the `grip` space of the XR controller.
|
|
12778
|
+
* Use this space for visualizing 3D objects that support the user in pointing
|
|
12779
|
+
* tasks like UI interaction.
|
|
12780
|
+
*
|
|
12781
|
+
* Note: If you want to show something in the user's hand AND offer a
|
|
12782
|
+
* pointing ray at the same time, you'll want to attached the handheld object
|
|
12783
|
+
* to the group returned by `getControllerGrip()` and the ray to the
|
|
12784
|
+
* group returned by `getController()`. The idea is to have two
|
|
12785
|
+
* different groups in two different coordinate spaces for the same WebXR
|
|
12786
|
+
* controller.
|
|
12787
|
+
*
|
|
12788
|
+
* @param {number} index - The index of the controller.
|
|
12789
|
+
* @return {Group} A group representing the `grip` space.
|
|
12790
|
+
*/
|
|
12679
12791
|
this.getControllerGrip = function ( index ) {
|
|
12680
12792
|
|
|
12681
12793
|
let controller = controllers[ index ];
|
|
@@ -12691,6 +12803,14 @@ class WebXRManager extends EventDispatcher {
|
|
|
12691
12803
|
|
|
12692
12804
|
};
|
|
12693
12805
|
|
|
12806
|
+
/**
|
|
12807
|
+
* Returns a group representing the `hand` space of the XR controller.
|
|
12808
|
+
* Use this space for visualizing 3D objects that support the user in pointing
|
|
12809
|
+
* tasks like UI interaction.
|
|
12810
|
+
*
|
|
12811
|
+
* @param {number} index - The index of the controller.
|
|
12812
|
+
* @return {Group} A group representing the `hand` space.
|
|
12813
|
+
*/
|
|
12694
12814
|
this.getHand = function ( index ) {
|
|
12695
12815
|
|
|
12696
12816
|
let controller = controllers[ index ];
|
|
@@ -12712,7 +12832,7 @@ class WebXRManager extends EventDispatcher {
|
|
|
12712
12832
|
|
|
12713
12833
|
const controllerIndex = controllerInputSources.indexOf( event.inputSource );
|
|
12714
12834
|
|
|
12715
|
-
if ( controllerIndex === -1 ) {
|
|
12835
|
+
if ( controllerIndex === - 1 ) {
|
|
12716
12836
|
|
|
12717
12837
|
return;
|
|
12718
12838
|
|
|
@@ -12780,6 +12900,13 @@ class WebXRManager extends EventDispatcher {
|
|
|
12780
12900
|
|
|
12781
12901
|
}
|
|
12782
12902
|
|
|
12903
|
+
/**
|
|
12904
|
+
* Sets the framebuffer scale factor.
|
|
12905
|
+
*
|
|
12906
|
+
* This method can not be used during a XR session.
|
|
12907
|
+
*
|
|
12908
|
+
* @param {number} value - The framebuffer scale factor.
|
|
12909
|
+
*/
|
|
12783
12910
|
this.setFramebufferScaleFactor = function ( value ) {
|
|
12784
12911
|
|
|
12785
12912
|
framebufferScaleFactor = value;
|
|
@@ -12792,6 +12919,15 @@ class WebXRManager extends EventDispatcher {
|
|
|
12792
12919
|
|
|
12793
12920
|
};
|
|
12794
12921
|
|
|
12922
|
+
/**
|
|
12923
|
+
* Sets the reference space type. Can be used to configure a spatial relationship with the user's physical
|
|
12924
|
+
* environment. Depending on how the user moves in 3D space, setting an appropriate reference space can
|
|
12925
|
+
* improve tracking. Default is `local-floor`.
|
|
12926
|
+
*
|
|
12927
|
+
* This method can not be used during a XR session.
|
|
12928
|
+
*
|
|
12929
|
+
* @param {string} value - The reference space type.
|
|
12930
|
+
*/
|
|
12795
12931
|
this.setReferenceSpaceType = function ( value ) {
|
|
12796
12932
|
|
|
12797
12933
|
referenceSpaceType = value;
|
|
@@ -12804,42 +12940,81 @@ class WebXRManager extends EventDispatcher {
|
|
|
12804
12940
|
|
|
12805
12941
|
};
|
|
12806
12942
|
|
|
12943
|
+
/**
|
|
12944
|
+
* Returns the XR reference space.
|
|
12945
|
+
*
|
|
12946
|
+
* @return {XRReferenceSpace} The XR reference space.
|
|
12947
|
+
*/
|
|
12807
12948
|
this.getReferenceSpace = function () {
|
|
12808
12949
|
|
|
12809
12950
|
return customReferenceSpace || referenceSpace;
|
|
12810
12951
|
|
|
12811
12952
|
};
|
|
12812
12953
|
|
|
12954
|
+
/**
|
|
12955
|
+
* Sets a custom XR reference space.
|
|
12956
|
+
*
|
|
12957
|
+
* @param {XRReferenceSpace} space - The XR reference space.
|
|
12958
|
+
*/
|
|
12813
12959
|
this.setReferenceSpace = function ( space ) {
|
|
12814
12960
|
|
|
12815
12961
|
customReferenceSpace = space;
|
|
12816
12962
|
|
|
12817
12963
|
};
|
|
12818
12964
|
|
|
12965
|
+
/**
|
|
12966
|
+
* Returns the current base layer.
|
|
12967
|
+
*
|
|
12968
|
+
* @return {?(XRWebGLLayer|XRProjectionLayer)} The XR base layer.
|
|
12969
|
+
*/
|
|
12819
12970
|
this.getBaseLayer = function () {
|
|
12820
12971
|
|
|
12821
12972
|
return glProjLayer !== null ? glProjLayer : glBaseLayer;
|
|
12822
12973
|
|
|
12823
12974
|
};
|
|
12824
12975
|
|
|
12976
|
+
/**
|
|
12977
|
+
* Returns the current XR binding.
|
|
12978
|
+
*
|
|
12979
|
+
* @return {?XRWebGLBinding} The XR binding.
|
|
12980
|
+
*/
|
|
12825
12981
|
this.getBinding = function () {
|
|
12826
12982
|
|
|
12827
12983
|
return glBinding;
|
|
12828
12984
|
|
|
12829
12985
|
};
|
|
12830
12986
|
|
|
12987
|
+
/**
|
|
12988
|
+
* Returns the current XR frame.
|
|
12989
|
+
*
|
|
12990
|
+
* @return {?XRFrame} The XR frame. Returns `null` when used outside a XR session.
|
|
12991
|
+
*/
|
|
12831
12992
|
this.getFrame = function () {
|
|
12832
12993
|
|
|
12833
12994
|
return xrFrame;
|
|
12834
12995
|
|
|
12835
12996
|
};
|
|
12836
12997
|
|
|
12998
|
+
/**
|
|
12999
|
+
* Returns the current XR session.
|
|
13000
|
+
*
|
|
13001
|
+
* @return {?XRSession} The XR session. Returns `null` when used outside a XR session.
|
|
13002
|
+
*/
|
|
12837
13003
|
this.getSession = function () {
|
|
12838
13004
|
|
|
12839
13005
|
return session;
|
|
12840
13006
|
|
|
12841
13007
|
};
|
|
12842
13008
|
|
|
13009
|
+
/**
|
|
13010
|
+
* After a XR session has been requested usually with one of the `*Button` modules, it
|
|
13011
|
+
* is injected into the renderer with this method. This method triggers the start of
|
|
13012
|
+
* the actual XR rendering.
|
|
13013
|
+
*
|
|
13014
|
+
* @async
|
|
13015
|
+
* @param {XRSession} value - The XR session to set.
|
|
13016
|
+
* @return {Promise} A Promise that resolves when the session has been set.
|
|
13017
|
+
*/
|
|
12843
13018
|
this.setSession = async function ( value ) {
|
|
12844
13019
|
|
|
12845
13020
|
session = value;
|
|
@@ -12964,6 +13139,11 @@ class WebXRManager extends EventDispatcher {
|
|
|
12964
13139
|
|
|
12965
13140
|
};
|
|
12966
13141
|
|
|
13142
|
+
/**
|
|
13143
|
+
* Returns the environment blend mode from the current XR session.
|
|
13144
|
+
*
|
|
13145
|
+
* @return {'opaque'|'additive'|'alpha-blend'|undefined} The environment blend mode. Returns `undefined` when used outside of a XR session.
|
|
13146
|
+
*/
|
|
12967
13147
|
this.getEnvironmentBlendMode = function () {
|
|
12968
13148
|
|
|
12969
13149
|
if ( session !== null ) {
|
|
@@ -12974,6 +13154,11 @@ class WebXRManager extends EventDispatcher {
|
|
|
12974
13154
|
|
|
12975
13155
|
};
|
|
12976
13156
|
|
|
13157
|
+
/**
|
|
13158
|
+
* Returns the current depth texture computed via depth sensing.
|
|
13159
|
+
*
|
|
13160
|
+
* @return {?Texture} The depth texture.
|
|
13161
|
+
*/
|
|
12977
13162
|
this.getDepthTexture = function () {
|
|
12978
13163
|
|
|
12979
13164
|
return depthSensing.getDepthTexture();
|
|
@@ -13006,7 +13191,7 @@ class WebXRManager extends EventDispatcher {
|
|
|
13006
13191
|
|
|
13007
13192
|
let controllerIndex = controllerInputSources.indexOf( inputSource );
|
|
13008
13193
|
|
|
13009
|
-
if ( controllerIndex === -1 ) {
|
|
13194
|
+
if ( controllerIndex === - 1 ) {
|
|
13010
13195
|
|
|
13011
13196
|
// Assign input source a controller that currently has no input source
|
|
13012
13197
|
|
|
@@ -13030,7 +13215,7 @@ class WebXRManager extends EventDispatcher {
|
|
|
13030
13215
|
|
|
13031
13216
|
// If all controllers do currently receive input we ignore new ones
|
|
13032
13217
|
|
|
13033
|
-
if ( controllerIndex === -1 ) break;
|
|
13218
|
+
if ( controllerIndex === - 1 ) break;
|
|
13034
13219
|
|
|
13035
13220
|
}
|
|
13036
13221
|
|
|
@@ -13097,7 +13282,7 @@ class WebXRManager extends EventDispatcher {
|
|
|
13097
13282
|
camera.matrixWorldInverse.copy( camera.matrixWorld ).invert();
|
|
13098
13283
|
|
|
13099
13284
|
// Check if the projection uses an infinite far plane.
|
|
13100
|
-
if ( projL[ 10 ] === -1 ) {
|
|
13285
|
+
if ( projL[ 10 ] === - 1.0 ) {
|
|
13101
13286
|
|
|
13102
13287
|
// Use the projection matrix from the left eye.
|
|
13103
13288
|
// The camera offset is sufficient to include the view volumes
|
|
@@ -13140,6 +13325,15 @@ class WebXRManager extends EventDispatcher {
|
|
|
13140
13325
|
|
|
13141
13326
|
}
|
|
13142
13327
|
|
|
13328
|
+
/**
|
|
13329
|
+
* Updates the state of the XR camera. Use this method on app level if you
|
|
13330
|
+
* set cameraAutoUpdate` to `false`. The method requires the non-XR
|
|
13331
|
+
* camera of the scene as a parameter. The passed in camera's transformation
|
|
13332
|
+
* is automatically adjusted to the position of the XR camera when calling
|
|
13333
|
+
* this method.
|
|
13334
|
+
*
|
|
13335
|
+
* @param {Camera} camera - The camera.
|
|
13336
|
+
*/
|
|
13143
13337
|
this.updateCamera = function ( camera ) {
|
|
13144
13338
|
|
|
13145
13339
|
if ( session === null ) return;
|
|
@@ -13235,12 +13429,27 @@ class WebXRManager extends EventDispatcher {
|
|
|
13235
13429
|
|
|
13236
13430
|
}
|
|
13237
13431
|
|
|
13432
|
+
/**
|
|
13433
|
+
* Returns an instance of {@link ArrayCamera} which represents the XR camera
|
|
13434
|
+
* of the active XR session. For each view it holds a separate camera object.
|
|
13435
|
+
*
|
|
13436
|
+
* The camera's `fov` is currently not used and does not reflect the fov of
|
|
13437
|
+
* the XR camera. If you need the fov on app level, you have to compute in
|
|
13438
|
+
* manually from the XR camera's projection matrices.
|
|
13439
|
+
*
|
|
13440
|
+
* @return {ArrayCamera} The XR camera.
|
|
13441
|
+
*/
|
|
13238
13442
|
this.getCamera = function () {
|
|
13239
13443
|
|
|
13240
13444
|
return cameraXR;
|
|
13241
13445
|
|
|
13242
13446
|
};
|
|
13243
13447
|
|
|
13448
|
+
/**
|
|
13449
|
+
* Returns the amount of foveation used by the XR compositor for the projection layer.
|
|
13450
|
+
*
|
|
13451
|
+
* @return {number} The amount of foveation.
|
|
13452
|
+
*/
|
|
13244
13453
|
this.getFoveation = function () {
|
|
13245
13454
|
|
|
13246
13455
|
if ( glProjLayer === null && glBaseLayer === null ) {
|
|
@@ -13253,6 +13462,12 @@ class WebXRManager extends EventDispatcher {
|
|
|
13253
13462
|
|
|
13254
13463
|
};
|
|
13255
13464
|
|
|
13465
|
+
/**
|
|
13466
|
+
* Sets the foveation value.
|
|
13467
|
+
*
|
|
13468
|
+
* @param {number} value - A number in the range `[0,1]` where `0` means no foveation (full resolution)
|
|
13469
|
+
* and `1` means maximum foveation (the edges render at lower resolution).
|
|
13470
|
+
*/
|
|
13256
13471
|
this.setFoveation = function ( value ) {
|
|
13257
13472
|
|
|
13258
13473
|
// 0 = no foveation = full resolution
|
|
@@ -13274,12 +13489,22 @@ class WebXRManager extends EventDispatcher {
|
|
|
13274
13489
|
|
|
13275
13490
|
};
|
|
13276
13491
|
|
|
13492
|
+
/**
|
|
13493
|
+
* Returns `true` if depth sensing is supported.
|
|
13494
|
+
*
|
|
13495
|
+
* @return {boolean} Whether depth sensing is supported or not.
|
|
13496
|
+
*/
|
|
13277
13497
|
this.hasDepthSensing = function () {
|
|
13278
13498
|
|
|
13279
13499
|
return depthSensing.texture !== null;
|
|
13280
13500
|
|
|
13281
13501
|
};
|
|
13282
13502
|
|
|
13503
|
+
/**
|
|
13504
|
+
* Returns the depth sensing mesh.
|
|
13505
|
+
*
|
|
13506
|
+
* @return {Mesh} The depth sensing mesh.
|
|
13507
|
+
*/
|
|
13283
13508
|
this.getDepthSensingMesh = function () {
|
|
13284
13509
|
|
|
13285
13510
|
return depthSensing.getMesh( cameraXR );
|
|
@@ -13338,7 +13563,7 @@ class WebXRManager extends EventDispatcher {
|
|
|
13338
13563
|
renderer.setRenderTargetTextures(
|
|
13339
13564
|
newRenderTarget,
|
|
13340
13565
|
glSubImage.colorTexture,
|
|
13341
|
-
|
|
13566
|
+
glSubImage.depthStencilTexture );
|
|
13342
13567
|
|
|
13343
13568
|
renderer.setRenderTarget( newRenderTarget );
|
|
13344
13569
|
|
|
@@ -13598,7 +13823,7 @@ function WebGLMaterials( renderer, properties ) {
|
|
|
13598
13823
|
|
|
13599
13824
|
if ( material.side === BackSide ) {
|
|
13600
13825
|
|
|
13601
|
-
uniforms.bumpScale.value *= -1;
|
|
13826
|
+
uniforms.bumpScale.value *= - 1;
|
|
13602
13827
|
|
|
13603
13828
|
}
|
|
13604
13829
|
|
|
@@ -13665,19 +13890,19 @@ function WebGLMaterials( renderer, properties ) {
|
|
|
13665
13890
|
_e1.copy( envMapRotation );
|
|
13666
13891
|
|
|
13667
13892
|
// accommodate left-handed frame
|
|
13668
|
-
_e1.x *= -1; _e1.y *= -1; _e1.z *= -1;
|
|
13893
|
+
_e1.x *= - 1; _e1.y *= - 1; _e1.z *= - 1;
|
|
13669
13894
|
|
|
13670
13895
|
if ( envMap.isCubeTexture && envMap.isRenderTargetTexture === false ) {
|
|
13671
13896
|
|
|
13672
13897
|
// environment maps which are not cube render targets or PMREMs follow a different convention
|
|
13673
|
-
_e1.y *= -1;
|
|
13674
|
-
_e1.z *= -1;
|
|
13898
|
+
_e1.y *= - 1;
|
|
13899
|
+
_e1.z *= - 1;
|
|
13675
13900
|
|
|
13676
13901
|
}
|
|
13677
13902
|
|
|
13678
13903
|
uniforms.envMapRotation.value.setFromMatrix4( _m1.makeRotationFromEuler( _e1 ) );
|
|
13679
13904
|
|
|
13680
|
-
uniforms.flipEnvMap.value = ( envMap.isCubeTexture && envMap.isRenderTargetTexture === false ) ? -1 : 1;
|
|
13905
|
+
uniforms.flipEnvMap.value = ( envMap.isCubeTexture && envMap.isRenderTargetTexture === false ) ? - 1 : 1;
|
|
13681
13906
|
|
|
13682
13907
|
uniforms.reflectivity.value = material.reflectivity;
|
|
13683
13908
|
uniforms.ior.value = material.ior;
|
|
@@ -14100,7 +14325,7 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {
|
|
|
14100
14325
|
|
|
14101
14326
|
for ( let i = 0; i < maxBindingPoints; i ++ ) {
|
|
14102
14327
|
|
|
14103
|
-
if ( allocatedBindingPoints.indexOf( i ) === -1 ) {
|
|
14328
|
+
if ( allocatedBindingPoints.indexOf( i ) === - 1 ) {
|
|
14104
14329
|
|
|
14105
14330
|
allocatedBindingPoints.push( i );
|
|
14106
14331
|
return i;
|
|
@@ -14417,8 +14642,18 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {
|
|
|
14417
14642
|
|
|
14418
14643
|
}
|
|
14419
14644
|
|
|
14645
|
+
/**
|
|
14646
|
+
* This renderer uses WebGL 2 to display scenes.
|
|
14647
|
+
*
|
|
14648
|
+
* WebGL 1 is not supported since `r163`.
|
|
14649
|
+
*/
|
|
14420
14650
|
class WebGLRenderer {
|
|
14421
14651
|
|
|
14652
|
+
/**
|
|
14653
|
+
* Constructs a new WebGL renderer.
|
|
14654
|
+
*
|
|
14655
|
+
* @param {WebGLRenderer~Options} [parameters] - The configuration parameter.
|
|
14656
|
+
*/
|
|
14422
14657
|
constructor( parameters = {} ) {
|
|
14423
14658
|
|
|
14424
14659
|
const {
|
|
@@ -14435,6 +14670,13 @@ class WebGLRenderer {
|
|
|
14435
14670
|
reverseDepthBuffer = false,
|
|
14436
14671
|
} = parameters;
|
|
14437
14672
|
|
|
14673
|
+
/**
|
|
14674
|
+
* This flag can be used for type testing.
|
|
14675
|
+
*
|
|
14676
|
+
* @type {boolean}
|
|
14677
|
+
* @readonly
|
|
14678
|
+
* @default true
|
|
14679
|
+
*/
|
|
14438
14680
|
this.isWebGLRenderer = true;
|
|
14439
14681
|
|
|
14440
14682
|
let _alpha;
|
|
@@ -14469,13 +14711,36 @@ class WebGLRenderer {
|
|
|
14469
14711
|
|
|
14470
14712
|
// public properties
|
|
14471
14713
|
|
|
14714
|
+
/**
|
|
14715
|
+
* A canvas where the renderer draws its output.This is automatically created by the renderer
|
|
14716
|
+
* in the constructor (if not provided already); you just need to add it to your page like so:
|
|
14717
|
+
* ```js
|
|
14718
|
+
* document.body.appendChild( renderer.domElement );
|
|
14719
|
+
* ```
|
|
14720
|
+
*
|
|
14721
|
+
* @type {DOMElement}
|
|
14722
|
+
*/
|
|
14472
14723
|
this.domElement = canvas;
|
|
14473
14724
|
|
|
14474
|
-
|
|
14725
|
+
/**
|
|
14726
|
+
* A object with debug configuration settings.
|
|
14727
|
+
*
|
|
14728
|
+
* - `checkShaderErrors`: If it is `true`, defines whether material shader programs are
|
|
14729
|
+
* checked for errors during compilation and linkage process. It may be useful to disable
|
|
14730
|
+
* this check in production for performance gain. It is strongly recommended to keep these
|
|
14731
|
+
* checks enabled during development. If the shader does not compile and link - it will not
|
|
14732
|
+
* work and associated material will not render.
|
|
14733
|
+
* - `onShaderError(gl, program, glVertexShader,glFragmentShader)`: A callback function that
|
|
14734
|
+
* can be used for custom error reporting. The callback receives the WebGL context, an instance
|
|
14735
|
+
* of WebGLProgram as well two instances of WebGLShader representing the vertex and fragment shader.
|
|
14736
|
+
* Assigning a custom function disables the default error reporting.
|
|
14737
|
+
*
|
|
14738
|
+
* @type {Object}
|
|
14739
|
+
*/
|
|
14475
14740
|
this.debug = {
|
|
14476
14741
|
|
|
14477
14742
|
/**
|
|
14478
|
-
* Enables error checking and reporting when shader programs are being compiled
|
|
14743
|
+
* Enables error checking and reporting when shader programs are being compiled.
|
|
14479
14744
|
* @type {boolean}
|
|
14480
14745
|
*/
|
|
14481
14746
|
checkShaderErrors: true,
|
|
@@ -14488,29 +14753,105 @@ class WebGLRenderer {
|
|
|
14488
14753
|
|
|
14489
14754
|
// clearing
|
|
14490
14755
|
|
|
14756
|
+
/**
|
|
14757
|
+
* Whether the renderer should automatically clear its output before rendering a frame or not.
|
|
14758
|
+
*
|
|
14759
|
+
* @type {boolean}
|
|
14760
|
+
* @default true
|
|
14761
|
+
*/
|
|
14491
14762
|
this.autoClear = true;
|
|
14763
|
+
|
|
14764
|
+
/**
|
|
14765
|
+
* If {@link WebGLRenderer#autoClear} set to `true`, whether the renderer should clear
|
|
14766
|
+
* the color buffer or not.
|
|
14767
|
+
*
|
|
14768
|
+
* @type {boolean}
|
|
14769
|
+
* @default true
|
|
14770
|
+
*/
|
|
14492
14771
|
this.autoClearColor = true;
|
|
14772
|
+
|
|
14773
|
+
/**
|
|
14774
|
+
* If {@link WebGLRenderer#autoClear} set to `true`, whether the renderer should clear
|
|
14775
|
+
* the depth buffer or not.
|
|
14776
|
+
*
|
|
14777
|
+
* @type {boolean}
|
|
14778
|
+
* @default true
|
|
14779
|
+
*/
|
|
14493
14780
|
this.autoClearDepth = true;
|
|
14781
|
+
|
|
14782
|
+
/**
|
|
14783
|
+
* If {@link WebGLRenderer#autoClear} set to `true`, whether the renderer should clear
|
|
14784
|
+
* the stencil buffer or not.
|
|
14785
|
+
*
|
|
14786
|
+
* @type {boolean}
|
|
14787
|
+
* @default true
|
|
14788
|
+
*/
|
|
14494
14789
|
this.autoClearStencil = true;
|
|
14495
14790
|
|
|
14496
14791
|
// scene graph
|
|
14497
14792
|
|
|
14793
|
+
/**
|
|
14794
|
+
* Whether the renderer should sort objects or not.
|
|
14795
|
+
*
|
|
14796
|
+
* Note: Sorting is used to attempt to properly render objects that have some
|
|
14797
|
+
* degree of transparency. By definition, sorting objects may not work in all
|
|
14798
|
+
* cases. Depending on the needs of application, it may be necessary to turn
|
|
14799
|
+
* off sorting and use other methods to deal with transparency rendering e.g.
|
|
14800
|
+
* manually determining each object's rendering order.
|
|
14801
|
+
*
|
|
14802
|
+
* @type {boolean}
|
|
14803
|
+
* @default true
|
|
14804
|
+
*/
|
|
14498
14805
|
this.sortObjects = true;
|
|
14499
14806
|
|
|
14500
14807
|
// user-defined clipping
|
|
14501
14808
|
|
|
14809
|
+
/**
|
|
14810
|
+
* User-defined clipping planes specified in world space. These planes apply globally.
|
|
14811
|
+
* Points in space whose dot product with the plane is negative are cut away.
|
|
14812
|
+
*
|
|
14813
|
+
* @type {Array<Plane>}
|
|
14814
|
+
*/
|
|
14502
14815
|
this.clippingPlanes = [];
|
|
14503
|
-
this.localClippingEnabled = false;
|
|
14504
14816
|
|
|
14505
|
-
|
|
14506
|
-
|
|
14507
|
-
|
|
14817
|
+
/**
|
|
14818
|
+
* Whether the renderer respects object-level clipping planes or not.
|
|
14819
|
+
*
|
|
14820
|
+
* @type {boolean}
|
|
14821
|
+
* @default false
|
|
14822
|
+
*/
|
|
14823
|
+
this.localClippingEnabled = false;
|
|
14508
14824
|
|
|
14509
14825
|
// tone mapping
|
|
14510
14826
|
|
|
14827
|
+
/**
|
|
14828
|
+
* The tone mapping technique of the renderer.
|
|
14829
|
+
*
|
|
14830
|
+
* @type {(NoToneMapping|LinearToneMapping|ReinhardToneMapping|CineonToneMapping|ACESFilmicToneMapping|CustomToneMapping|AgXToneMapping|NeutralToneMapping)}
|
|
14831
|
+
* @default NoToneMapping
|
|
14832
|
+
*/
|
|
14511
14833
|
this.toneMapping = NoToneMapping;
|
|
14834
|
+
|
|
14835
|
+
/**
|
|
14836
|
+
* Exposure level of tone mapping.
|
|
14837
|
+
*
|
|
14838
|
+
* @type {number}
|
|
14839
|
+
* @default 1
|
|
14840
|
+
*/
|
|
14512
14841
|
this.toneMappingExposure = 1.0;
|
|
14513
14842
|
|
|
14843
|
+
// transmission
|
|
14844
|
+
|
|
14845
|
+
/**
|
|
14846
|
+
* The normalized resolution scale for the transmission render target, measured in percentage
|
|
14847
|
+
* of viewport dimensions. Lowering this value can result in significant performance improvements
|
|
14848
|
+
* when using {@link MeshPhysicalMaterial#transmission}.
|
|
14849
|
+
*
|
|
14850
|
+
* @type {number}
|
|
14851
|
+
* @default 1
|
|
14852
|
+
*/
|
|
14853
|
+
this.transmissionResolutionScale = 1.0;
|
|
14854
|
+
|
|
14514
14855
|
// internal properties
|
|
14515
14856
|
|
|
14516
14857
|
const _this = this;
|
|
@@ -14519,10 +14860,12 @@ class WebGLRenderer {
|
|
|
14519
14860
|
|
|
14520
14861
|
// internal state cache
|
|
14521
14862
|
|
|
14863
|
+
this._outputColorSpace = SRGBColorSpace;
|
|
14864
|
+
|
|
14522
14865
|
let _currentActiveCubeFace = 0;
|
|
14523
14866
|
let _currentActiveMipmapLevel = 0;
|
|
14524
14867
|
let _currentRenderTarget = null;
|
|
14525
|
-
let _currentMaterialId = -1;
|
|
14868
|
+
let _currentMaterialId = - 1;
|
|
14526
14869
|
|
|
14527
14870
|
let _currentCamera = null;
|
|
14528
14871
|
|
|
@@ -14555,9 +14898,6 @@ class WebGLRenderer {
|
|
|
14555
14898
|
let _clippingEnabled = false;
|
|
14556
14899
|
let _localClippingEnabled = false;
|
|
14557
14900
|
|
|
14558
|
-
// transmission render target scale
|
|
14559
|
-
this.transmissionResolutionScale = 1.0;
|
|
14560
|
-
|
|
14561
14901
|
// camera matrices cache
|
|
14562
14902
|
|
|
14563
14903
|
const _currentProjectionMatrix = new Matrix4();
|
|
@@ -14686,12 +15026,79 @@ class WebGLRenderer {
|
|
|
14686
15026
|
|
|
14687
15027
|
info.programs = programCache.programs;
|
|
14688
15028
|
|
|
15029
|
+
/**
|
|
15030
|
+
* Holds details about the capabilities of the current rendering context.
|
|
15031
|
+
*
|
|
15032
|
+
* @name WebGLRenderer#capabilities
|
|
15033
|
+
* @type {WebGLRenderer~Capabilities}
|
|
15034
|
+
*/
|
|
14689
15035
|
_this.capabilities = capabilities;
|
|
15036
|
+
|
|
15037
|
+
/**
|
|
15038
|
+
* Provides methods for retrieving and testing WebGL extensions.
|
|
15039
|
+
*
|
|
15040
|
+
* - `get(extensionName:string)`: Used to check whether a WebGL extension is supported
|
|
15041
|
+
* and return the extension object if available.
|
|
15042
|
+
* - `has(extensionName:string)`: returns `true` if the extension is supported.
|
|
15043
|
+
*
|
|
15044
|
+
* @name WebGLRenderer#extensions
|
|
15045
|
+
* @type {Object}
|
|
15046
|
+
*/
|
|
14690
15047
|
_this.extensions = extensions;
|
|
15048
|
+
|
|
15049
|
+
/**
|
|
15050
|
+
* Used to track properties of other objects like native WebGL objects.
|
|
15051
|
+
*
|
|
15052
|
+
* @name WebGLRenderer#properties
|
|
15053
|
+
* @type {Object}
|
|
15054
|
+
*/
|
|
14691
15055
|
_this.properties = properties;
|
|
15056
|
+
|
|
15057
|
+
/**
|
|
15058
|
+
* Manages the render lists of the renderer.
|
|
15059
|
+
*
|
|
15060
|
+
* @name WebGLRenderer#renderLists
|
|
15061
|
+
* @type {Object}
|
|
15062
|
+
*/
|
|
14692
15063
|
_this.renderLists = renderLists;
|
|
15064
|
+
|
|
15065
|
+
|
|
15066
|
+
|
|
15067
|
+
/**
|
|
15068
|
+
* Interface for managing shadows.
|
|
15069
|
+
*
|
|
15070
|
+
* @name WebGLRenderer#shadowMap
|
|
15071
|
+
* @type {WebGLRenderer~ShadowMap}
|
|
15072
|
+
*/
|
|
14693
15073
|
_this.shadowMap = shadowMap;
|
|
15074
|
+
|
|
15075
|
+
/**
|
|
15076
|
+
* Interface for managing the WebGL state.
|
|
15077
|
+
*
|
|
15078
|
+
* @name WebGLRenderer#state
|
|
15079
|
+
* @type {Object}
|
|
15080
|
+
*/
|
|
14694
15081
|
_this.state = state;
|
|
15082
|
+
|
|
15083
|
+
/**
|
|
15084
|
+
* Holds a series of statistical information about the GPU memory
|
|
15085
|
+
* and the rendering process. Useful for debugging and monitoring.
|
|
15086
|
+
*
|
|
15087
|
+
* By default these data are reset at each render call but when having
|
|
15088
|
+
* multiple render passes per frame (e.g. when using post processing) it can
|
|
15089
|
+
* be preferred to reset with a custom pattern. First, set `autoReset` to
|
|
15090
|
+
* `false`.
|
|
15091
|
+
* ```js
|
|
15092
|
+
* renderer.info.autoReset = false;
|
|
15093
|
+
* ```
|
|
15094
|
+
* Call `reset()` whenever you have finished to render a single frame.
|
|
15095
|
+
* ```js
|
|
15096
|
+
* renderer.info.reset();
|
|
15097
|
+
* ```
|
|
15098
|
+
*
|
|
15099
|
+
* @name WebGLRenderer#info
|
|
15100
|
+
* @type {WebGLRenderer~Info}
|
|
15101
|
+
*/
|
|
14695
15102
|
_this.info = info;
|
|
14696
15103
|
|
|
14697
15104
|
}
|
|
@@ -14702,22 +15109,38 @@ class WebGLRenderer {
|
|
|
14702
15109
|
|
|
14703
15110
|
const xr = new WebXRManager( _this, _gl );
|
|
14704
15111
|
|
|
15112
|
+
/**
|
|
15113
|
+
* A reference to the XR manager.
|
|
15114
|
+
*
|
|
15115
|
+
* @type {WebXRManager}
|
|
15116
|
+
*/
|
|
14705
15117
|
this.xr = xr;
|
|
14706
15118
|
|
|
14707
|
-
|
|
14708
|
-
|
|
15119
|
+
/**
|
|
15120
|
+
* Returns the rendering context.
|
|
15121
|
+
*
|
|
15122
|
+
* @return {WebGL2RenderingContext} The rendering context.
|
|
15123
|
+
*/
|
|
14709
15124
|
this.getContext = function () {
|
|
14710
15125
|
|
|
14711
15126
|
return _gl;
|
|
14712
15127
|
|
|
14713
15128
|
};
|
|
14714
15129
|
|
|
15130
|
+
/**
|
|
15131
|
+
* Returns the rendering context attributes.
|
|
15132
|
+
*
|
|
15133
|
+
* @return {WebGLContextAttributes} The rendering context attributes.
|
|
15134
|
+
*/
|
|
14715
15135
|
this.getContextAttributes = function () {
|
|
14716
15136
|
|
|
14717
15137
|
return _gl.getContextAttributes();
|
|
14718
15138
|
|
|
14719
15139
|
};
|
|
14720
15140
|
|
|
15141
|
+
/**
|
|
15142
|
+
* Simulates a loss of the WebGL context. This requires support for the `WEBGL_lose_context` extension.
|
|
15143
|
+
*/
|
|
14721
15144
|
this.forceContextLoss = function () {
|
|
14722
15145
|
|
|
14723
15146
|
const extension = extensions.get( 'WEBGL_lose_context' );
|
|
@@ -14725,6 +15148,9 @@ class WebGLRenderer {
|
|
|
14725
15148
|
|
|
14726
15149
|
};
|
|
14727
15150
|
|
|
15151
|
+
/**
|
|
15152
|
+
* Simulates a restore of the WebGL context. This requires support for the `WEBGL_lose_context` extension.
|
|
15153
|
+
*/
|
|
14728
15154
|
this.forceContextRestore = function () {
|
|
14729
15155
|
|
|
14730
15156
|
const extension = extensions.get( 'WEBGL_lose_context' );
|
|
@@ -14732,12 +15158,22 @@ class WebGLRenderer {
|
|
|
14732
15158
|
|
|
14733
15159
|
};
|
|
14734
15160
|
|
|
15161
|
+
/**
|
|
15162
|
+
* Returns the pixel ratio.
|
|
15163
|
+
*
|
|
15164
|
+
* @return {number} The pixel ratio.
|
|
15165
|
+
*/
|
|
14735
15166
|
this.getPixelRatio = function () {
|
|
14736
15167
|
|
|
14737
15168
|
return _pixelRatio;
|
|
14738
15169
|
|
|
14739
15170
|
};
|
|
14740
15171
|
|
|
15172
|
+
/**
|
|
15173
|
+
* Sets the given pixel ratio and resizes the canvas if necessary.
|
|
15174
|
+
*
|
|
15175
|
+
* @param {number} value - The pixel ratio.
|
|
15176
|
+
*/
|
|
14741
15177
|
this.setPixelRatio = function ( value ) {
|
|
14742
15178
|
|
|
14743
15179
|
if ( value === undefined ) return;
|
|
@@ -14748,12 +15184,27 @@ class WebGLRenderer {
|
|
|
14748
15184
|
|
|
14749
15185
|
};
|
|
14750
15186
|
|
|
15187
|
+
/**
|
|
15188
|
+
* Returns the renderer's size in logical pixels. This method does not honor the pixel ratio.
|
|
15189
|
+
*
|
|
15190
|
+
* @param {Vector2} target - The method writes the result in this target object.
|
|
15191
|
+
* @return {Vector2} The renderer's size in logical pixels.
|
|
15192
|
+
*/
|
|
14751
15193
|
this.getSize = function ( target ) {
|
|
14752
15194
|
|
|
14753
15195
|
return target.set( _width, _height );
|
|
14754
15196
|
|
|
14755
15197
|
};
|
|
14756
15198
|
|
|
15199
|
+
/**
|
|
15200
|
+
* Resizes the output canvas to (width, height) with device pixel ratio taken
|
|
15201
|
+
* into account, and also sets the viewport to fit that size, starting in (0,
|
|
15202
|
+
* 0). Setting `updateStyle` to false prevents any style changes to the output canvas.
|
|
15203
|
+
*
|
|
15204
|
+
* @param {number} width - The width in logical pixels.
|
|
15205
|
+
* @param {number} height - The height in logical pixels.
|
|
15206
|
+
* @param {boolean} [updateStyle=true] - Whether to update the `style` attribute of the canvas or not.
|
|
15207
|
+
*/
|
|
14757
15208
|
this.setSize = function ( width, height, updateStyle = true ) {
|
|
14758
15209
|
|
|
14759
15210
|
if ( xr.isPresenting ) {
|
|
@@ -14780,12 +15231,31 @@ class WebGLRenderer {
|
|
|
14780
15231
|
|
|
14781
15232
|
};
|
|
14782
15233
|
|
|
15234
|
+
/**
|
|
15235
|
+
* Returns the drawing buffer size in physical pixels. This method honors the pixel ratio.
|
|
15236
|
+
*
|
|
15237
|
+
* @param {Vector2} target - The method writes the result in this target object.
|
|
15238
|
+
* @return {Vector2} The drawing buffer size.
|
|
15239
|
+
*/
|
|
14783
15240
|
this.getDrawingBufferSize = function ( target ) {
|
|
14784
15241
|
|
|
14785
15242
|
return target.set( _width * _pixelRatio, _height * _pixelRatio ).floor();
|
|
14786
15243
|
|
|
14787
15244
|
};
|
|
14788
15245
|
|
|
15246
|
+
/**
|
|
15247
|
+
* This method allows to define the drawing buffer size by specifying
|
|
15248
|
+
* width, height and pixel ratio all at once. The size of the drawing
|
|
15249
|
+
* buffer is computed with this formula:
|
|
15250
|
+
* ```js
|
|
15251
|
+
* size.x = width * pixelRatio;
|
|
15252
|
+
* size.y = height * pixelRatio;
|
|
15253
|
+
* ```
|
|
15254
|
+
*
|
|
15255
|
+
* @param {number} width - The width in logical pixels.
|
|
15256
|
+
* @param {number} height - The height in logical pixels.
|
|
15257
|
+
* @param {number} pixelRatio - The pixel ratio.
|
|
15258
|
+
*/
|
|
14789
15259
|
this.setDrawingBufferSize = function ( width, height, pixelRatio ) {
|
|
14790
15260
|
|
|
14791
15261
|
_width = width;
|
|
@@ -14800,18 +15270,39 @@ class WebGLRenderer {
|
|
|
14800
15270
|
|
|
14801
15271
|
};
|
|
14802
15272
|
|
|
15273
|
+
/**
|
|
15274
|
+
* Returns the current viewport definition.
|
|
15275
|
+
*
|
|
15276
|
+
* @param {Vector2} target - The method writes the result in this target object.
|
|
15277
|
+
* @return {Vector2} The current viewport definition.
|
|
15278
|
+
*/
|
|
14803
15279
|
this.getCurrentViewport = function ( target ) {
|
|
14804
15280
|
|
|
14805
15281
|
return target.copy( _currentViewport );
|
|
14806
15282
|
|
|
14807
15283
|
};
|
|
14808
15284
|
|
|
15285
|
+
/**
|
|
15286
|
+
* Returns the viewport definition.
|
|
15287
|
+
*
|
|
15288
|
+
* @param {Vector4} target - The method writes the result in this target object.
|
|
15289
|
+
* @return {Vector4} The viewport definition.
|
|
15290
|
+
*/
|
|
14809
15291
|
this.getViewport = function ( target ) {
|
|
14810
15292
|
|
|
14811
15293
|
return target.copy( _viewport );
|
|
14812
15294
|
|
|
14813
15295
|
};
|
|
14814
15296
|
|
|
15297
|
+
/**
|
|
15298
|
+
* Sets the viewport to render from `(x, y)` to `(x + width, y + height)`.
|
|
15299
|
+
*
|
|
15300
|
+
* @param {number | Vector4} x - The horizontal coordinate for the lower left corner of the viewport origin in logical pixel unit.
|
|
15301
|
+
* Or alternatively a four-component vector specifying all the parameters of the viewport.
|
|
15302
|
+
* @param {number} y - The vertical coordinate for the lower left corner of the viewport origin in logical pixel unit.
|
|
15303
|
+
* @param {number} width - The width of the viewport in logical pixel unit.
|
|
15304
|
+
* @param {number} height - The height of the viewport in logical pixel unit.
|
|
15305
|
+
*/
|
|
14815
15306
|
this.setViewport = function ( x, y, width, height ) {
|
|
14816
15307
|
|
|
14817
15308
|
if ( x.isVector4 ) {
|
|
@@ -14828,12 +15319,27 @@ class WebGLRenderer {
|
|
|
14828
15319
|
|
|
14829
15320
|
};
|
|
14830
15321
|
|
|
15322
|
+
/**
|
|
15323
|
+
* Returns the scissor region.
|
|
15324
|
+
*
|
|
15325
|
+
* @param {Vector4} target - The method writes the result in this target object.
|
|
15326
|
+
* @return {Vector4} The scissor region.
|
|
15327
|
+
*/
|
|
14831
15328
|
this.getScissor = function ( target ) {
|
|
14832
15329
|
|
|
14833
15330
|
return target.copy( _scissor );
|
|
14834
15331
|
|
|
14835
15332
|
};
|
|
14836
15333
|
|
|
15334
|
+
/**
|
|
15335
|
+
* Sets the scissor region to render from `(x, y)` to `(x + width, y + height)`.
|
|
15336
|
+
*
|
|
15337
|
+
* @param {number | Vector4} x - The horizontal coordinate for the lower left corner of the scissor region origin in logical pixel unit.
|
|
15338
|
+
* Or alternatively a four-component vector specifying all the parameters of the scissor region.
|
|
15339
|
+
* @param {number} y - The vertical coordinate for the lower left corner of the scissor region origin in logical pixel unit.
|
|
15340
|
+
* @param {number} width - The width of the scissor region in logical pixel unit.
|
|
15341
|
+
* @param {number} height - The height of the scissor region in logical pixel unit.
|
|
15342
|
+
*/
|
|
14837
15343
|
this.setScissor = function ( x, y, width, height ) {
|
|
14838
15344
|
|
|
14839
15345
|
if ( x.isVector4 ) {
|
|
@@ -14850,24 +15356,48 @@ class WebGLRenderer {
|
|
|
14850
15356
|
|
|
14851
15357
|
};
|
|
14852
15358
|
|
|
15359
|
+
/**
|
|
15360
|
+
* Returns `true` if the scissor test is enabled.
|
|
15361
|
+
*
|
|
15362
|
+
* @return {boolean} Whether the scissor test is enabled or not.
|
|
15363
|
+
*/
|
|
14853
15364
|
this.getScissorTest = function () {
|
|
14854
15365
|
|
|
14855
15366
|
return _scissorTest;
|
|
14856
15367
|
|
|
14857
15368
|
};
|
|
14858
15369
|
|
|
15370
|
+
/**
|
|
15371
|
+
* Enable or disable the scissor test. When this is enabled, only the pixels
|
|
15372
|
+
* within the defined scissor area will be affected by further renderer
|
|
15373
|
+
* actions.
|
|
15374
|
+
*
|
|
15375
|
+
* @param {boolean} boolean - Whether the scissor test is enabled or not.
|
|
15376
|
+
*/
|
|
14859
15377
|
this.setScissorTest = function ( boolean ) {
|
|
14860
15378
|
|
|
14861
15379
|
state.setScissorTest( _scissorTest = boolean );
|
|
14862
15380
|
|
|
14863
15381
|
};
|
|
14864
15382
|
|
|
15383
|
+
/**
|
|
15384
|
+
* Sets a custom opaque sort function for the render lists. Pass `null`
|
|
15385
|
+
* to use the default `painterSortStable` function.
|
|
15386
|
+
*
|
|
15387
|
+
* @param {?Function} method - The opaque sort function.
|
|
15388
|
+
*/
|
|
14865
15389
|
this.setOpaqueSort = function ( method ) {
|
|
14866
15390
|
|
|
14867
15391
|
_opaqueSort = method;
|
|
14868
15392
|
|
|
14869
15393
|
};
|
|
14870
15394
|
|
|
15395
|
+
/**
|
|
15396
|
+
* Sets a custom transparent sort function for the render lists. Pass `null`
|
|
15397
|
+
* to use the default `reversePainterSortStable` function.
|
|
15398
|
+
*
|
|
15399
|
+
* @param {?Function} method - The opaque sort function.
|
|
15400
|
+
*/
|
|
14871
15401
|
this.setTransparentSort = function ( method ) {
|
|
14872
15402
|
|
|
14873
15403
|
_transparentSort = method;
|
|
@@ -14876,30 +15406,60 @@ class WebGLRenderer {
|
|
|
14876
15406
|
|
|
14877
15407
|
// Clearing
|
|
14878
15408
|
|
|
15409
|
+
/**
|
|
15410
|
+
* Returns the clear color.
|
|
15411
|
+
*
|
|
15412
|
+
* @param {Color} target - The method writes the result in this target object.
|
|
15413
|
+
* @return {Color} The clear color.
|
|
15414
|
+
*/
|
|
14879
15415
|
this.getClearColor = function ( target ) {
|
|
14880
15416
|
|
|
14881
15417
|
return target.copy( background.getClearColor() );
|
|
14882
15418
|
|
|
14883
15419
|
};
|
|
14884
15420
|
|
|
15421
|
+
/**
|
|
15422
|
+
* Sets the clear color and alpha.
|
|
15423
|
+
*
|
|
15424
|
+
* @param {Color} color - The clear color.
|
|
15425
|
+
* @param {number} [alpha=1] - The clear alpha.
|
|
15426
|
+
*/
|
|
14885
15427
|
this.setClearColor = function () {
|
|
14886
15428
|
|
|
14887
15429
|
background.setClearColor( ...arguments );
|
|
14888
15430
|
|
|
14889
15431
|
};
|
|
14890
15432
|
|
|
15433
|
+
/**
|
|
15434
|
+
* Returns the clear alpha. Ranges within `[0,1]`.
|
|
15435
|
+
*
|
|
15436
|
+
* @return {number} The clear alpha.
|
|
15437
|
+
*/
|
|
14891
15438
|
this.getClearAlpha = function () {
|
|
14892
15439
|
|
|
14893
15440
|
return background.getClearAlpha();
|
|
14894
15441
|
|
|
14895
15442
|
};
|
|
14896
15443
|
|
|
15444
|
+
/**
|
|
15445
|
+
* Sets the clear alpha.
|
|
15446
|
+
*
|
|
15447
|
+
* @param {number} alpha - The clear alpha.
|
|
15448
|
+
*/
|
|
14897
15449
|
this.setClearAlpha = function () {
|
|
14898
15450
|
|
|
14899
15451
|
background.setClearAlpha( ...arguments );
|
|
14900
15452
|
|
|
14901
15453
|
};
|
|
14902
15454
|
|
|
15455
|
+
/**
|
|
15456
|
+
* Tells the renderer to clear its color, depth or stencil drawing buffer(s).
|
|
15457
|
+
* This method initializes the buffers to the current clear color values.
|
|
15458
|
+
*
|
|
15459
|
+
* @param {boolean} [color=true] - Whether the color buffer should be cleared or not.
|
|
15460
|
+
* @param {boolean} [depth=true] - Whether the depth buffer should be cleared or not.
|
|
15461
|
+
* @param {boolean} [stencil=true] - Whether the stencil buffer should be cleared or not.
|
|
15462
|
+
*/
|
|
14903
15463
|
this.clear = function ( color = true, depth = true, stencil = true ) {
|
|
14904
15464
|
|
|
14905
15465
|
let bits = 0;
|
|
@@ -14978,26 +15538,37 @@ class WebGLRenderer {
|
|
|
14978
15538
|
|
|
14979
15539
|
};
|
|
14980
15540
|
|
|
15541
|
+
/**
|
|
15542
|
+
* Clears the color buffer. Equivalent to calling `renderer.clear( true, false, false )`.
|
|
15543
|
+
*/
|
|
14981
15544
|
this.clearColor = function () {
|
|
14982
15545
|
|
|
14983
15546
|
this.clear( true, false, false );
|
|
14984
15547
|
|
|
14985
15548
|
};
|
|
14986
15549
|
|
|
15550
|
+
/**
|
|
15551
|
+
* Clears the depth buffer. Equivalent to calling `renderer.clear( false, true, false )`.
|
|
15552
|
+
*/
|
|
14987
15553
|
this.clearDepth = function () {
|
|
14988
15554
|
|
|
14989
15555
|
this.clear( false, true, false );
|
|
14990
15556
|
|
|
14991
15557
|
};
|
|
14992
15558
|
|
|
15559
|
+
/**
|
|
15560
|
+
* Clears the stencil buffer. Equivalent to calling `renderer.clear( false, false, true )`.
|
|
15561
|
+
*/
|
|
14993
15562
|
this.clearStencil = function () {
|
|
14994
15563
|
|
|
14995
15564
|
this.clear( false, false, true );
|
|
14996
15565
|
|
|
14997
15566
|
};
|
|
14998
15567
|
|
|
14999
|
-
|
|
15000
|
-
|
|
15568
|
+
/**
|
|
15569
|
+
* Frees the GPU-related resources allocated by this instance. Call this
|
|
15570
|
+
* method whenever this instance is no longer used in your app.
|
|
15571
|
+
*/
|
|
15001
15572
|
this.dispose = function () {
|
|
15002
15573
|
|
|
15003
15574
|
canvas.removeEventListener( 'webglcontextlost', onContextLost, false );
|
|
@@ -15303,6 +15874,18 @@ class WebGLRenderer {
|
|
|
15303
15874
|
|
|
15304
15875
|
}
|
|
15305
15876
|
|
|
15877
|
+
/**
|
|
15878
|
+
* Compiles all materials in the scene with the camera. This is useful to precompile shaders
|
|
15879
|
+
* before the first rendering. If you want to add a 3D object to an existing scene, use the third
|
|
15880
|
+
* optional parameter for applying the target scene.
|
|
15881
|
+
*
|
|
15882
|
+
* Note that the (target) scene's lighting and environment must be configured before calling this method.
|
|
15883
|
+
*
|
|
15884
|
+
* @param {Object3D} scene - The scene or another type of 3D object to precompile.
|
|
15885
|
+
* @param {Camera} camera - The camera.
|
|
15886
|
+
* @param {?Scene} [targetScene=null] - The target scene.
|
|
15887
|
+
* @return {?Set} The precompiled materials.
|
|
15888
|
+
*/
|
|
15306
15889
|
this.compile = function ( scene, camera, targetScene = null ) {
|
|
15307
15890
|
|
|
15308
15891
|
if ( targetScene === null ) targetScene = scene;
|
|
@@ -15398,6 +15981,18 @@ class WebGLRenderer {
|
|
|
15398
15981
|
|
|
15399
15982
|
// compileAsync
|
|
15400
15983
|
|
|
15984
|
+
/**
|
|
15985
|
+
* Asynchronous version of {@link WebGLRenderer#compile}.
|
|
15986
|
+
*
|
|
15987
|
+
* This method makes use of the `KHR_parallel_shader_compile` WebGL extension. Hence,
|
|
15988
|
+
* it is recommended to use this version of `compile()` whenever possible.
|
|
15989
|
+
*
|
|
15990
|
+
* @async
|
|
15991
|
+
* @param {Object3D} scene - The scene or another type of 3D object to precompile.
|
|
15992
|
+
* @param {Camera} camera - The camera.
|
|
15993
|
+
* @param {?Scene} [targetScene=null] - The target scene.
|
|
15994
|
+
* @return {Promise} A Promise that resolves when the given scene can be rendered without unnecessary stalling due to shader compilation.
|
|
15995
|
+
*/
|
|
15401
15996
|
this.compileAsync = function ( scene, camera, targetScene = null ) {
|
|
15402
15997
|
|
|
15403
15998
|
const materials = this.compile( scene, camera, targetScene );
|
|
@@ -15499,6 +16094,20 @@ class WebGLRenderer {
|
|
|
15499
16094
|
|
|
15500
16095
|
// Rendering
|
|
15501
16096
|
|
|
16097
|
+
/**
|
|
16098
|
+
* Renders the given scene (or other type of 3D object) using the given camera.
|
|
16099
|
+
*
|
|
16100
|
+
* The render is done to a previously specified render target set by calling {@link WebGLRenderer#setRenderTarget}
|
|
16101
|
+
* or to the canvas as usual.
|
|
16102
|
+
*
|
|
16103
|
+
* By default render buffers are cleared before rendering but you can prevent
|
|
16104
|
+
* this by setting the property `autoClear` to `false`. If you want to prevent
|
|
16105
|
+
* only certain buffers being cleared you can `autoClearColor`, `autoClearDepth`
|
|
16106
|
+
* or `autoClearStencil` to `false`. To force a clear, use {@link WebGLRenderer#clear}.
|
|
16107
|
+
*
|
|
16108
|
+
* @param {Object3D} scene - The scene to render.
|
|
16109
|
+
* @param {Camera} camera - The camera.
|
|
16110
|
+
*/
|
|
15502
16111
|
this.render = function ( scene, camera ) {
|
|
15503
16112
|
|
|
15504
16113
|
if ( camera !== undefined && camera.isCamera !== true ) {
|
|
@@ -15654,7 +16263,7 @@ class WebGLRenderer {
|
|
|
15654
16263
|
// _gl.finish();
|
|
15655
16264
|
|
|
15656
16265
|
bindingStates.resetDefaultState();
|
|
15657
|
-
_currentMaterialId = -1;
|
|
16266
|
+
_currentMaterialId = - 1;
|
|
15658
16267
|
_currentCamera = null;
|
|
15659
16268
|
|
|
15660
16269
|
renderStateStack.pop();
|
|
@@ -15957,8 +16566,14 @@ class WebGLRenderer {
|
|
|
15957
16566
|
|
|
15958
16567
|
const object = renderItem.object;
|
|
15959
16568
|
const geometry = renderItem.geometry;
|
|
15960
|
-
const material = overrideMaterial === null ? renderItem.material : overrideMaterial;
|
|
15961
16569
|
const group = renderItem.group;
|
|
16570
|
+
let material = renderItem.material;
|
|
16571
|
+
|
|
16572
|
+
if ( material.allowOverride === true && overrideMaterial !== null ) {
|
|
16573
|
+
|
|
16574
|
+
material = overrideMaterial;
|
|
16575
|
+
|
|
16576
|
+
}
|
|
15962
16577
|
|
|
15963
16578
|
if ( object.layers.test( camera.layers ) ) {
|
|
15964
16579
|
|
|
@@ -16486,7 +17101,7 @@ class WebGLRenderer {
|
|
|
16486
17101
|
|
|
16487
17102
|
m_uniforms.envMap.value = envMap;
|
|
16488
17103
|
|
|
16489
|
-
m_uniforms.flipEnvMap.value = ( envMap.isCubeTexture && envMap.isRenderTargetTexture === false ) ? -1 : 1;
|
|
17104
|
+
m_uniforms.flipEnvMap.value = ( envMap.isCubeTexture && envMap.isRenderTargetTexture === false ) ? - 1 : 1;
|
|
16490
17105
|
|
|
16491
17106
|
}
|
|
16492
17107
|
|
|
@@ -16595,18 +17210,34 @@ class WebGLRenderer {
|
|
|
16595
17210
|
|
|
16596
17211
|
}
|
|
16597
17212
|
|
|
17213
|
+
/**
|
|
17214
|
+
* Returns the active cube face.
|
|
17215
|
+
*
|
|
17216
|
+
* @return {number} The active cube face.
|
|
17217
|
+
*/
|
|
16598
17218
|
this.getActiveCubeFace = function () {
|
|
16599
17219
|
|
|
16600
17220
|
return _currentActiveCubeFace;
|
|
16601
17221
|
|
|
16602
17222
|
};
|
|
16603
17223
|
|
|
17224
|
+
/**
|
|
17225
|
+
* Returns the active mipmap level.
|
|
17226
|
+
*
|
|
17227
|
+
* @return {number} The active mipmap level.
|
|
17228
|
+
*/
|
|
16604
17229
|
this.getActiveMipmapLevel = function () {
|
|
16605
17230
|
|
|
16606
17231
|
return _currentActiveMipmapLevel;
|
|
16607
17232
|
|
|
16608
17233
|
};
|
|
16609
17234
|
|
|
17235
|
+
/**
|
|
17236
|
+
* Returns the active render target.
|
|
17237
|
+
*
|
|
17238
|
+
* @return {?WebGLRenderTarget} The active render target. Returns `null` if no render target
|
|
17239
|
+
* is currently set.
|
|
17240
|
+
*/
|
|
16610
17241
|
this.getRenderTarget = function () {
|
|
16611
17242
|
|
|
16612
17243
|
return _currentRenderTarget;
|
|
@@ -16615,26 +17246,21 @@ class WebGLRenderer {
|
|
|
16615
17246
|
|
|
16616
17247
|
this.setRenderTargetTextures = function ( renderTarget, colorTexture, depthTexture ) {
|
|
16617
17248
|
|
|
16618
|
-
properties.get( renderTarget.texture ).__webglTexture = colorTexture;
|
|
16619
|
-
properties.get( renderTarget.depthTexture ).__webglTexture = depthTexture;
|
|
16620
|
-
|
|
16621
17249
|
const renderTargetProperties = properties.get( renderTarget );
|
|
16622
|
-
renderTargetProperties.__hasExternalTextures = true;
|
|
16623
|
-
|
|
16624
|
-
renderTargetProperties.__autoAllocateDepthBuffer = depthTexture === undefined;
|
|
16625
17250
|
|
|
16626
|
-
|
|
17251
|
+
renderTargetProperties.__autoAllocateDepthBuffer = renderTarget.resolveDepthBuffer === false;
|
|
17252
|
+
if ( renderTargetProperties.__autoAllocateDepthBuffer === false ) {
|
|
16627
17253
|
|
|
16628
17254
|
// The multisample_render_to_texture extension doesn't work properly if there
|
|
16629
17255
|
// are midframe flushes and an external depth buffer. Disable use of the extension.
|
|
16630
|
-
|
|
17256
|
+
renderTargetProperties.__useRenderToTexture = false;
|
|
16631
17257
|
|
|
16632
|
-
|
|
16633
|
-
renderTargetProperties.__useRenderToTexture = false;
|
|
17258
|
+
}
|
|
16634
17259
|
|
|
16635
|
-
|
|
17260
|
+
properties.get( renderTarget.texture ).__webglTexture = colorTexture;
|
|
17261
|
+
properties.get( renderTarget.depthTexture ).__webglTexture = renderTargetProperties.__autoAllocateDepthBuffer ? undefined : depthTexture;
|
|
16636
17262
|
|
|
16637
|
-
|
|
17263
|
+
renderTargetProperties.__hasExternalTextures = true;
|
|
16638
17264
|
|
|
16639
17265
|
};
|
|
16640
17266
|
|
|
@@ -16647,6 +17273,16 @@ class WebGLRenderer {
|
|
|
16647
17273
|
};
|
|
16648
17274
|
|
|
16649
17275
|
const _scratchFrameBuffer = _gl.createFramebuffer();
|
|
17276
|
+
|
|
17277
|
+
/**
|
|
17278
|
+
* Sets the active rendertarget.
|
|
17279
|
+
*
|
|
17280
|
+
* @param {?WebGLRenderTarget} renderTarget - The render target to set. When `null` is given,
|
|
17281
|
+
* the canvas is set as the active render target instead.
|
|
17282
|
+
* @param {number} [activeCubeFace=0] - The active cube face when using a cube render target.
|
|
17283
|
+
* Indicates the z layer to render in to when using 3D or array render targets.
|
|
17284
|
+
* @param {number} [activeMipmapLevel=0] - The active mipmap level.
|
|
17285
|
+
*/
|
|
16650
17286
|
this.setRenderTarget = function ( renderTarget, activeCubeFace = 0, activeMipmapLevel = 0 ) {
|
|
16651
17287
|
|
|
16652
17288
|
_currentRenderTarget = renderTarget;
|
|
@@ -16795,10 +17431,21 @@ class WebGLRenderer {
|
|
|
16795
17431
|
|
|
16796
17432
|
}
|
|
16797
17433
|
|
|
16798
|
-
_currentMaterialId = -1; // reset current material to ensure correct uniform bindings
|
|
17434
|
+
_currentMaterialId = - 1; // reset current material to ensure correct uniform bindings
|
|
16799
17435
|
|
|
16800
17436
|
};
|
|
16801
17437
|
|
|
17438
|
+
/**
|
|
17439
|
+
* Reads the pixel data from the given render target into the given buffer.
|
|
17440
|
+
*
|
|
17441
|
+
* @param {WebGLRenderTarget} renderTarget - The render target to read from.
|
|
17442
|
+
* @param {number} x - The `x` coordinate of the copy region's origin.
|
|
17443
|
+
* @param {number} y - The `y` coordinate of the copy region's origin.
|
|
17444
|
+
* @param {number} width - The width of the copy region.
|
|
17445
|
+
* @param {number} height - The height of the copy region.
|
|
17446
|
+
* @param {TypedArray} buffer - The result buffer.
|
|
17447
|
+
* @param {number} [activeCubeFaceIndex] - The active cube face index.
|
|
17448
|
+
*/
|
|
16802
17449
|
this.readRenderTargetPixels = function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex ) {
|
|
16803
17450
|
|
|
16804
17451
|
if ( ! ( renderTarget && renderTarget.isWebGLRenderTarget ) ) {
|
|
@@ -16861,6 +17508,21 @@ class WebGLRenderer {
|
|
|
16861
17508
|
|
|
16862
17509
|
};
|
|
16863
17510
|
|
|
17511
|
+
/**
|
|
17512
|
+
* Asynchronous, non-blocking version of {@link WebGLRenderer#readRenderTargetPixels}.
|
|
17513
|
+
*
|
|
17514
|
+
* It is recommended to use this version of `readRenderTargetPixels()` whenever possible.
|
|
17515
|
+
*
|
|
17516
|
+
* @async
|
|
17517
|
+
* @param {WebGLRenderTarget} renderTarget - The render target to read from.
|
|
17518
|
+
* @param {number} x - The `x` coordinate of the copy region's origin.
|
|
17519
|
+
* @param {number} y - The `y` coordinate of the copy region's origin.
|
|
17520
|
+
* @param {number} width - The width of the copy region.
|
|
17521
|
+
* @param {number} height - The height of the copy region.
|
|
17522
|
+
* @param {TypedArray} buffer - The result buffer.
|
|
17523
|
+
* @param {number} [activeCubeFaceIndex] - The active cube face index.
|
|
17524
|
+
* @return {Promise<TypedArray>} A Promise that resolves when the read has been finished. The resolve provides the read data as a typed array.
|
|
17525
|
+
*/
|
|
16864
17526
|
this.readRenderTargetPixelsAsync = async function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex ) {
|
|
16865
17527
|
|
|
16866
17528
|
if ( ! ( renderTarget && renderTarget.isWebGLRenderTarget ) ) {
|
|
@@ -16878,27 +17540,27 @@ class WebGLRenderer {
|
|
|
16878
17540
|
|
|
16879
17541
|
if ( framebuffer ) {
|
|
16880
17542
|
|
|
16881
|
-
|
|
16882
|
-
|
|
16883
|
-
const textureType = texture.type;
|
|
17543
|
+
// the following if statement ensures valid read requests (no out-of-bounds pixels, see #8604)
|
|
17544
|
+
if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
|
|
16884
17545
|
|
|
16885
|
-
|
|
17546
|
+
// set the active frame buffer to the one we want to read
|
|
17547
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
16886
17548
|
|
|
16887
|
-
|
|
17549
|
+
const texture = renderTarget.texture;
|
|
17550
|
+
const textureFormat = texture.format;
|
|
17551
|
+
const textureType = texture.type;
|
|
16888
17552
|
|
|
16889
|
-
|
|
17553
|
+
if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
|
|
16890
17554
|
|
|
16891
|
-
|
|
17555
|
+
throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.' );
|
|
16892
17556
|
|
|
16893
|
-
|
|
17557
|
+
}
|
|
16894
17558
|
|
|
16895
|
-
|
|
17559
|
+
if ( ! capabilities.textureTypeReadable( textureType ) ) {
|
|
16896
17560
|
|
|
16897
|
-
|
|
16898
|
-
if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
|
|
17561
|
+
throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.' );
|
|
16899
17562
|
|
|
16900
|
-
|
|
16901
|
-
state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
17563
|
+
}
|
|
16902
17564
|
|
|
16903
17565
|
const glBuffer = _gl.createBuffer();
|
|
16904
17566
|
_gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
|
|
@@ -16934,19 +17596,15 @@ class WebGLRenderer {
|
|
|
16934
17596
|
|
|
16935
17597
|
};
|
|
16936
17598
|
|
|
17599
|
+
/**
|
|
17600
|
+
* Copies pixels from the current bound framebuffer into the given texture.
|
|
17601
|
+
*
|
|
17602
|
+
* @param {FramebufferTexture} texture - The texture.
|
|
17603
|
+
* @param {Vector2} position - The start position of the copy operation.
|
|
17604
|
+
* @param {number} [level=0] - The mip level. The default represents the base mip.
|
|
17605
|
+
*/
|
|
16937
17606
|
this.copyFramebufferToTexture = function ( texture, position = null, level = 0 ) {
|
|
16938
17607
|
|
|
16939
|
-
// support previous signature with position first
|
|
16940
|
-
if ( texture.isTexture !== true ) {
|
|
16941
|
-
|
|
16942
|
-
// @deprecated, r165
|
|
16943
|
-
warnOnce( 'WebGLRenderer: copyFramebufferToTexture function signature has changed.' );
|
|
16944
|
-
|
|
16945
|
-
position = arguments[ 0 ] || null;
|
|
16946
|
-
texture = arguments[ 1 ];
|
|
16947
|
-
|
|
16948
|
-
}
|
|
16949
|
-
|
|
16950
17608
|
const levelScale = Math.pow( 2, - level );
|
|
16951
17609
|
const width = Math.floor( texture.image.width * levelScale );
|
|
16952
17610
|
const height = Math.floor( texture.image.height * levelScale );
|
|
@@ -16964,21 +17622,21 @@ class WebGLRenderer {
|
|
|
16964
17622
|
|
|
16965
17623
|
const _srcFramebuffer = _gl.createFramebuffer();
|
|
16966
17624
|
const _dstFramebuffer = _gl.createFramebuffer();
|
|
16967
|
-
this.copyTextureToTexture = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, srcLevel = 0, dstLevel = null ) {
|
|
16968
|
-
|
|
16969
|
-
// support previous signature with dstPosition first
|
|
16970
|
-
if ( srcTexture.isTexture !== true ) {
|
|
16971
|
-
|
|
16972
|
-
// @deprecated, r165
|
|
16973
|
-
warnOnce( 'WebGLRenderer: copyTextureToTexture function signature has changed.' );
|
|
16974
17625
|
|
|
16975
|
-
|
|
16976
|
-
|
|
16977
|
-
|
|
16978
|
-
|
|
16979
|
-
|
|
16980
|
-
|
|
16981
|
-
|
|
17626
|
+
/**
|
|
17627
|
+
* Copies data of the given source texture into a destination texture.
|
|
17628
|
+
*
|
|
17629
|
+
* When using render target textures as `srcTexture` and `dstTexture`, you must make sure both render targets are initialized
|
|
17630
|
+
* {@link WebGLRenderer#initRenderTarget}.
|
|
17631
|
+
*
|
|
17632
|
+
* @param {Texture} srcTexture - The source texture.
|
|
17633
|
+
* @param {Texture} dstTexture - The destination texture.
|
|
17634
|
+
* @param {Box2|Box3} [srcRegion=null] - A bounding box which describes the source region. Can be two or three-dimensional.
|
|
17635
|
+
* @param {Vector2|Vector3} [dstPosition=null] - A vector that represents the origin of the destination region. Can be two or three-dimensional.
|
|
17636
|
+
* @param {number} srcLevel - The source mipmap level to copy.
|
|
17637
|
+
* @param {number} dstLevel - The destination mipmap level.
|
|
17638
|
+
*/
|
|
17639
|
+
this.copyTextureToTexture = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, srcLevel = 0, dstLevel = null ) {
|
|
16982
17640
|
|
|
16983
17641
|
// support the previous signature with just a single dst mipmap level
|
|
16984
17642
|
if ( dstLevel === null ) {
|
|
@@ -17232,20 +17890,6 @@ class WebGLRenderer {
|
|
|
17232
17890
|
|
|
17233
17891
|
this.copyTextureToTexture3D = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) {
|
|
17234
17892
|
|
|
17235
|
-
// support previous signature with source box first
|
|
17236
|
-
if ( srcTexture.isTexture !== true ) {
|
|
17237
|
-
|
|
17238
|
-
// @deprecated, r165
|
|
17239
|
-
warnOnce( 'WebGLRenderer: copyTextureToTexture3D function signature has changed.' );
|
|
17240
|
-
|
|
17241
|
-
srcRegion = arguments[ 0 ] || null;
|
|
17242
|
-
dstPosition = arguments[ 1 ] || null;
|
|
17243
|
-
srcTexture = arguments[ 2 ];
|
|
17244
|
-
dstTexture = arguments[ 3 ];
|
|
17245
|
-
level = arguments[ 4 ] || 0;
|
|
17246
|
-
|
|
17247
|
-
}
|
|
17248
|
-
|
|
17249
17893
|
// @deprecated, r170
|
|
17250
17894
|
warnOnce( 'WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.' );
|
|
17251
17895
|
|
|
@@ -17253,6 +17897,13 @@ class WebGLRenderer {
|
|
|
17253
17897
|
|
|
17254
17898
|
};
|
|
17255
17899
|
|
|
17900
|
+
/**
|
|
17901
|
+
* Initializes the given WebGLRenderTarget memory. Useful for initializing a render target so data
|
|
17902
|
+
* can be copied into it using {@link WebGLRenderer#copyTextureToTexture} before it has been
|
|
17903
|
+
* rendered to.
|
|
17904
|
+
*
|
|
17905
|
+
* @param {WebGLRenderTarget} target - The render target.
|
|
17906
|
+
*/
|
|
17256
17907
|
this.initRenderTarget = function ( target ) {
|
|
17257
17908
|
|
|
17258
17909
|
if ( properties.get( target ).__webglFramebuffer === undefined ) {
|
|
@@ -17263,6 +17914,12 @@ class WebGLRenderer {
|
|
|
17263
17914
|
|
|
17264
17915
|
};
|
|
17265
17916
|
|
|
17917
|
+
/**
|
|
17918
|
+
* Initializes the given texture. Useful for preloading a texture rather than waiting until first
|
|
17919
|
+
* render (which can cause noticeable lags due to decode and GPU upload overhead).
|
|
17920
|
+
*
|
|
17921
|
+
* @param {Texture} texture - The texture.
|
|
17922
|
+
*/
|
|
17266
17923
|
this.initTexture = function ( texture ) {
|
|
17267
17924
|
|
|
17268
17925
|
if ( texture.isCubeTexture ) {
|
|
@@ -17287,6 +17944,11 @@ class WebGLRenderer {
|
|
|
17287
17944
|
|
|
17288
17945
|
};
|
|
17289
17946
|
|
|
17947
|
+
/**
|
|
17948
|
+
* Can be used to reset the internal WebGL state. This method is mostly
|
|
17949
|
+
* relevant for applications which share a single WebGL context across
|
|
17950
|
+
* multiple WebGL libraries.
|
|
17951
|
+
*/
|
|
17290
17952
|
this.resetState = function () {
|
|
17291
17953
|
|
|
17292
17954
|
_currentActiveCubeFace = 0;
|
|
@@ -17306,12 +17968,27 @@ class WebGLRenderer {
|
|
|
17306
17968
|
|
|
17307
17969
|
}
|
|
17308
17970
|
|
|
17971
|
+
/**
|
|
17972
|
+
* Defines the coordinate system of the renderer.
|
|
17973
|
+
*
|
|
17974
|
+
* In `WebGLRenderer`, the value is always `WebGLCoordinateSystem`.
|
|
17975
|
+
*
|
|
17976
|
+
* @type {WebGLCoordinateSystem|WebGPUCoordinateSystem}
|
|
17977
|
+
* @default WebGLCoordinateSystem
|
|
17978
|
+
* @readonly
|
|
17979
|
+
*/
|
|
17309
17980
|
get coordinateSystem() {
|
|
17310
17981
|
|
|
17311
17982
|
return WebGLCoordinateSystem;
|
|
17312
17983
|
|
|
17313
17984
|
}
|
|
17314
17985
|
|
|
17986
|
+
/**
|
|
17987
|
+
* Defines the output color space of the renderer.
|
|
17988
|
+
*
|
|
17989
|
+
* @type {SRGBColorSpace|LinearSRGBColorSpace}
|
|
17990
|
+
* @default SRGBColorSpace
|
|
17991
|
+
*/
|
|
17315
17992
|
get outputColorSpace() {
|
|
17316
17993
|
|
|
17317
17994
|
return this._outputColorSpace;
|
|
@@ -17323,7 +18000,7 @@ class WebGLRenderer {
|
|
|
17323
18000
|
this._outputColorSpace = colorSpace;
|
|
17324
18001
|
|
|
17325
18002
|
const gl = this.getContext();
|
|
17326
|
-
gl.
|
|
18003
|
+
gl.drawingBufferColorSpace = ColorManagement._getDrawingBufferColorSpace( colorSpace );
|
|
17327
18004
|
gl.unpackColorSpace = ColorManagement._getUnpackColorSpace();
|
|
17328
18005
|
|
|
17329
18006
|
}
|