@needle-tools/three 0.146.10 → 0.153.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/build/three.cjs +40124 -20919
- package/build/three.js +40120 -20914
- package/build/three.min.js +8 -6
- package/build/three.module.js +7298 -6003
- package/build/three.module.min.js +7 -0
- package/examples/jsm/animation/AnimationClipCreator.js +5 -3
- package/examples/jsm/cameras/CinematicCamera.js +1 -2
- package/examples/jsm/capabilities/WebGPU.js +17 -5
- package/examples/jsm/controls/ArcballControls.js +1828 -1821
- package/examples/jsm/controls/MapControls.js +28 -0
- package/examples/jsm/controls/OrbitControls.js +26 -53
- package/examples/jsm/controls/PointerLockControls.js +70 -65
- package/examples/jsm/controls/TrackballControls.js +18 -4
- package/examples/jsm/controls/TransformControls.js +0 -1
- package/examples/jsm/csm/CSM.js +11 -5
- package/examples/jsm/csm/CSMShader.js +7 -6
- package/examples/jsm/effects/AnaglyphEffect.js +6 -20
- package/examples/jsm/effects/AsciiEffect.js +3 -6
- package/examples/jsm/effects/OutlineEffect.js +1 -15
- package/examples/jsm/effects/ParallaxBarrierEffect.js +3 -0
- package/examples/jsm/exporters/DRACOExporter.js +53 -11
- package/examples/jsm/exporters/EXRExporter.js +3 -9
- package/examples/jsm/exporters/GLTFExporter.js +561 -154
- package/examples/jsm/exporters/KTX2Exporter.js +34 -23
- package/examples/jsm/exporters/MMDExporter.js +1 -1
- package/examples/jsm/exporters/PLYExporter.js +8 -1
- package/examples/jsm/exporters/STLExporter.js +8 -4
- package/examples/jsm/exporters/USDZExporter.js +305 -792
- package/examples/jsm/geometries/ConvexGeometry.js +0 -6
- package/examples/jsm/geometries/ParametricGeometry.js +10 -0
- package/examples/jsm/helpers/OctreeHelper.js +1 -0
- package/examples/jsm/helpers/ViewHelper.js +71 -57
- package/examples/jsm/interactive/HTMLMesh.js +16 -3
- package/examples/jsm/interactive/InteractiveGroup.js +1 -1
- package/examples/{js → jsm}/libs/basis/README.md +4 -4
- package/examples/jsm/libs/draco/draco_decoder.js +34 -0
- package/examples/jsm/libs/draco/draco_decoder.wasm +0 -0
- package/examples/jsm/libs/draco/draco_wasm_wrapper.js +117 -0
- package/examples/jsm/libs/draco/gltf/draco_decoder.js +33 -0
- package/examples/jsm/libs/draco/gltf/draco_decoder.wasm +0 -0
- package/examples/jsm/libs/draco/gltf/draco_wasm_wrapper.js +116 -0
- package/examples/jsm/libs/lil-gui.module.min.js +2 -2
- package/examples/jsm/libs/tween.module.js +803 -0
- package/examples/jsm/lights/IESSpotLight.js +25 -0
- package/examples/jsm/lights/LightProbeGenerator.js +11 -9
- package/examples/jsm/lines/LineSegments2.js +16 -10
- package/examples/jsm/loaders/3DMLoader.js +8 -5
- package/examples/jsm/loaders/3MFLoader.js +12 -11
- package/examples/jsm/loaders/AMFLoader.js +2 -3
- package/examples/jsm/loaders/BVHLoader.js +2 -2
- package/examples/jsm/loaders/ColladaLoader.js +15 -16
- package/examples/jsm/loaders/DRACOLoader.js +69 -18
- package/examples/jsm/loaders/EXRLoader.js +23 -24
- package/examples/jsm/loaders/FBXLoader.js +34 -50
- package/examples/jsm/loaders/GCodeLoader.js +1 -2
- package/examples/jsm/loaders/GLTFLoader.js +417 -895
- package/examples/jsm/loaders/GLTFLoaderAnimationPointer.js +684 -0
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +4 -4
- package/examples/jsm/loaders/IESLoader.js +337 -0
- package/examples/jsm/loaders/KMZLoader.js +4 -4
- package/examples/jsm/loaders/KTX2Loader.js +145 -69
- package/examples/jsm/loaders/LDrawLoader.js +20 -18
- package/examples/jsm/loaders/LWOLoader.js +12 -29
- package/examples/jsm/loaders/LottieLoader.js +3 -1
- package/examples/jsm/loaders/MMDLoader.js +49 -18
- package/examples/jsm/loaders/MTLLoader.js +2 -2
- package/examples/jsm/loaders/MaterialXLoader.js +9 -3
- package/examples/jsm/loaders/NRRDLoader.js +33 -5
- package/examples/jsm/loaders/OBJLoader.js +1 -1
- package/examples/jsm/loaders/PCDLoader.js +26 -12
- package/examples/jsm/loaders/PDBLoader.js +7 -2
- package/examples/jsm/loaders/PLYLoader.js +254 -109
- package/examples/jsm/loaders/RGBELoader.js +3 -3
- package/examples/jsm/loaders/STLLoader.js +9 -5
- package/examples/jsm/loaders/SVGLoader.js +36 -27
- package/examples/jsm/loaders/TTFLoader.js +1 -8
- package/examples/jsm/loaders/TiltLoader.js +13 -7
- package/examples/jsm/loaders/USDZLoader.js +6 -6
- package/examples/jsm/loaders/VOXLoader.js +8 -2
- package/examples/jsm/loaders/VRMLLoader.js +44 -16
- package/examples/jsm/loaders/VTKLoader.js +19 -10
- package/examples/jsm/loaders/XYZLoader.js +9 -3
- package/examples/jsm/loaders/lwo/IFFParser.js +19 -19
- package/examples/jsm/materials/MeshGouraudMaterial.js +0 -3
- package/examples/jsm/math/ConvexHull.js +3 -3
- package/examples/jsm/math/Lut.js +5 -4
- package/examples/jsm/math/MeshSurfaceSampler.js +7 -9
- package/examples/jsm/math/Octree.js +1 -1
- package/examples/jsm/misc/ConvexObjectBreaker.js +2 -8
- package/examples/jsm/misc/GPUComputationRenderer.js +6 -5
- package/examples/jsm/misc/MD2Character.js +2 -2
- package/examples/jsm/misc/MD2CharacterComplex.js +2 -2
- package/examples/jsm/misc/ProgressiveLightMap.js +12 -10
- package/examples/jsm/misc/RollerCoaster.js +7 -1
- package/examples/jsm/misc/Volume.js +20 -5
- package/examples/jsm/misc/VolumeSlice.js +3 -1
- package/examples/jsm/modifiers/CurveModifier.js +1 -0
- package/examples/jsm/modifiers/TessellateModifier.js +19 -19
- package/examples/jsm/nodes/Nodes.js +144 -335
- package/examples/jsm/nodes/accessors/BitangentNode.js +43 -16
- package/examples/jsm/nodes/accessors/BufferAttributeNode.js +86 -0
- package/examples/jsm/nodes/accessors/BufferNode.js +6 -0
- package/examples/jsm/nodes/accessors/CameraNode.js +12 -2
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +27 -33
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +58 -0
- package/examples/jsm/nodes/accessors/InstanceNode.js +41 -26
- package/examples/jsm/nodes/accessors/MaterialNode.js +155 -38
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +16 -0
- package/examples/jsm/nodes/accessors/ModelNode.js +11 -0
- package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +13 -14
- package/examples/jsm/nodes/accessors/NormalNode.js +35 -19
- package/examples/jsm/nodes/accessors/Object3DNode.js +32 -12
- package/examples/jsm/nodes/accessors/PointUVNode.js +6 -1
- package/examples/jsm/nodes/accessors/PositionNode.js +38 -23
- package/examples/jsm/nodes/accessors/ReferenceNode.js +21 -14
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +11 -7
- package/examples/jsm/nodes/accessors/SkinningNode.js +43 -40
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +6 -0
- package/examples/jsm/nodes/accessors/TangentNode.js +28 -20
- package/examples/jsm/nodes/accessors/TextureNode.js +80 -12
- package/examples/jsm/nodes/accessors/UVNode.js +6 -0
- package/examples/jsm/nodes/accessors/UserDataNode.js +6 -0
- package/examples/jsm/nodes/code/CodeNode.js +75 -0
- package/examples/jsm/nodes/code/ExpressionNode.js +37 -0
- package/examples/jsm/nodes/{core → code}/FunctionCallNode.js +15 -1
- package/examples/jsm/nodes/{core → code}/FunctionNode.js +8 -7
- package/examples/jsm/nodes/code/ScriptableNode.js +488 -0
- package/examples/jsm/nodes/code/ScriptableValueNode.js +167 -0
- package/examples/jsm/nodes/core/ArrayUniformNode.js +3 -0
- package/examples/jsm/nodes/core/AttributeNode.js +17 -9
- package/examples/jsm/nodes/core/BypassNode.js +9 -2
- package/examples/jsm/nodes/core/CacheNode.js +46 -0
- package/examples/jsm/nodes/core/ConstNode.js +3 -0
- package/examples/jsm/nodes/core/ContextNode.js +8 -1
- package/examples/jsm/nodes/core/InputNode.js +26 -5
- package/examples/jsm/nodes/core/InstanceIndexNode.js +26 -2
- package/examples/jsm/nodes/core/LightingModel.js +16 -0
- package/examples/jsm/nodes/core/Node.js +129 -35
- package/examples/jsm/nodes/core/NodeAttribute.js +2 -1
- package/examples/jsm/nodes/core/NodeBuilder.js +271 -121
- package/examples/jsm/nodes/core/NodeCache.js +26 -0
- package/examples/jsm/nodes/core/NodeFrame.js +56 -5
- package/examples/jsm/nodes/core/NodeUtils.js +115 -28
- package/examples/jsm/nodes/core/PropertyNode.js +19 -2
- package/examples/jsm/nodes/core/StackNode.js +99 -0
- package/examples/jsm/nodes/core/TempNode.js +11 -3
- package/examples/jsm/nodes/core/UniformNode.js +16 -1
- package/examples/jsm/nodes/core/VarNode.js +21 -29
- package/examples/jsm/nodes/core/VaryingNode.js +15 -2
- package/examples/jsm/nodes/core/constants.js +6 -0
- package/examples/jsm/nodes/display/BlendModeNode.js +25 -11
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +30 -14
- package/examples/jsm/nodes/display/ColorSpaceNode.js +39 -27
- package/examples/jsm/nodes/display/FrontFacingNode.js +7 -1
- package/examples/jsm/nodes/display/NormalMapNode.js +31 -18
- package/examples/jsm/nodes/display/PosterizeNode.js +10 -3
- package/examples/jsm/nodes/display/ToneMappingNode.js +101 -11
- package/examples/jsm/nodes/display/ViewportNode.js +27 -18
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +30 -0
- package/examples/jsm/nodes/display/ViewportTextureNode.js +67 -0
- package/examples/jsm/nodes/fog/FogExp2Node.js +35 -0
- package/examples/jsm/nodes/fog/FogNode.js +12 -6
- package/examples/jsm/nodes/fog/FogRangeNode.js +12 -5
- package/examples/jsm/nodes/functions/BSDF/BRDF_BlinnPhong.js +30 -0
- package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +10 -13
- package/examples/jsm/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +8 -6
- package/examples/jsm/nodes/functions/BSDF/D_GGX.js +4 -4
- package/examples/jsm/nodes/functions/BSDF/F_Schlick.js +3 -3
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +7 -5
- package/examples/jsm/nodes/functions/PhongLightingModel.js +28 -0
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +35 -36
- package/examples/jsm/nodes/functions/material/getGeometryRoughness.js +4 -3
- package/examples/jsm/nodes/functions/material/getRoughness.js +4 -4
- package/examples/jsm/nodes/geometry/RangeNode.js +50 -55
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +9 -2
- package/examples/jsm/nodes/lighting/AONode.js +5 -3
- package/examples/jsm/nodes/lighting/AmbientLightNode.js +27 -0
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +114 -5
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +43 -0
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +121 -35
- package/examples/jsm/nodes/lighting/HemisphereLightNode.js +15 -10
- package/examples/jsm/nodes/lighting/IESSpotLightNode.js +39 -0
- package/examples/jsm/nodes/lighting/LightNode.js +57 -0
- package/examples/jsm/nodes/lighting/LightUtils.js +17 -0
- package/examples/jsm/nodes/lighting/LightingContextNode.js +30 -8
- package/examples/jsm/nodes/lighting/LightingNode.js +3 -1
- package/examples/jsm/nodes/lighting/LightsNode.js +18 -10
- package/examples/jsm/nodes/lighting/PointLightNode.js +71 -0
- package/examples/jsm/nodes/lighting/SpotLightNode.js +92 -0
- package/examples/jsm/nodes/loaders/NodeLoader.js +5 -4
- package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +4 -20
- package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +6 -9
- package/examples/jsm/nodes/materials/Materials.js +11 -55
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +5 -11
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +48 -0
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +74 -0
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +6 -6
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +21 -96
- package/examples/jsm/nodes/materials/NodeMaterial.js +284 -62
- package/examples/jsm/nodes/materials/PointsNodeMaterial.js +7 -1
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +29 -25
- package/examples/jsm/nodes/materialx/MaterialXNodes.js +31 -22
- package/examples/jsm/nodes/materialx/lib/mx_hsv.js +1 -1
- package/examples/jsm/nodes/materialx/lib/mx_noise.js +2 -1
- package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +2 -1
- package/examples/jsm/nodes/math/CondNode.js +43 -17
- package/examples/jsm/nodes/math/MathNode.js +178 -73
- package/examples/jsm/nodes/math/OperatorNode.js +52 -2
- package/examples/jsm/nodes/procedural/CheckerNode.js +14 -6
- package/examples/jsm/nodes/shadernode/ShaderNode.js +186 -63
- package/examples/jsm/nodes/utils/ArrayElementNode.js +4 -2
- package/examples/jsm/nodes/utils/ConvertNode.js +19 -1
- package/examples/jsm/nodes/utils/DiscardNode.js +26 -0
- package/examples/jsm/nodes/utils/EquirectUVNode.js +10 -4
- package/examples/jsm/nodes/utils/JoinNode.js +4 -1
- package/examples/jsm/nodes/utils/LoopNode.js +186 -0
- package/examples/jsm/nodes/utils/MatcapUVNode.js +11 -4
- package/examples/jsm/nodes/utils/MaxMipLevelNode.js +18 -5
- package/examples/jsm/nodes/utils/OscNode.js +21 -14
- package/examples/jsm/nodes/utils/PackingNode.js +55 -0
- package/examples/jsm/nodes/utils/RemapNode.js +13 -5
- package/examples/jsm/nodes/utils/RotateUVNode.js +18 -7
- package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +37 -0
- package/examples/jsm/nodes/utils/SplitNode.js +7 -5
- package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +15 -30
- package/examples/jsm/nodes/utils/TimerNode.js +16 -6
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +21 -10
- package/examples/jsm/objects/GroundProjectedSkybox.js +172 -0
- package/examples/jsm/objects/Lensflare.js +3 -4
- package/examples/jsm/objects/MarchingCubes.js +5 -1
- package/examples/jsm/objects/Reflector.js +7 -4
- package/examples/jsm/objects/Refractor.js +4 -4
- package/examples/jsm/objects/ShadowMesh.js +3 -3
- package/examples/jsm/objects/Water.js +2 -1
- package/examples/jsm/physics/AmmoPhysics.js +27 -28
- package/examples/jsm/physics/RapierPhysics.js +199 -0
- package/examples/jsm/postprocessing/AfterimagePass.js +3 -2
- package/examples/jsm/postprocessing/BloomPass.js +7 -4
- package/examples/jsm/postprocessing/BokehPass.js +3 -8
- package/examples/jsm/postprocessing/DotScreenPass.js +1 -2
- package/examples/jsm/postprocessing/EffectComposer.js +5 -95
- package/examples/jsm/postprocessing/FilmPass.js +1 -2
- package/examples/jsm/postprocessing/GlitchPass.js +0 -2
- package/examples/jsm/postprocessing/HalftonePass.js +0 -6
- package/examples/jsm/postprocessing/OutlinePass.js +7 -7
- package/examples/jsm/postprocessing/OutputPass.js +72 -0
- package/examples/jsm/postprocessing/Pass.js +2 -0
- package/examples/jsm/postprocessing/RenderPixelatedPass.js +4 -3
- package/examples/jsm/postprocessing/SAOPass.js +4 -26
- package/examples/jsm/postprocessing/SMAAPass.js +5 -8
- package/examples/jsm/postprocessing/SSAARenderPass.js +15 -6
- package/examples/jsm/postprocessing/SSAOPass.js +4 -14
- package/examples/jsm/postprocessing/SSRPass.js +3 -7
- package/examples/jsm/postprocessing/SavePass.js +2 -3
- package/examples/jsm/postprocessing/ShaderPass.js +1 -0
- package/examples/jsm/postprocessing/TAARenderPass.js +3 -2
- package/examples/jsm/postprocessing/TexturePass.js +0 -2
- package/examples/jsm/postprocessing/UnrealBloomPass.js +4 -11
- package/examples/jsm/renderers/CSS2DRenderer.js +6 -1
- package/examples/jsm/renderers/CSS3DRenderer.js +27 -5
- package/examples/jsm/renderers/{webgpu/WebGPUAnimation.js → common/Animation.js} +4 -4
- package/examples/jsm/renderers/common/Attributes.js +75 -0
- package/examples/jsm/renderers/common/Backend.js +160 -0
- package/examples/jsm/renderers/common/Background.js +133 -0
- package/examples/jsm/renderers/common/Binding.js +11 -0
- package/examples/jsm/renderers/common/Bindings.js +169 -0
- package/examples/jsm/renderers/common/Buffer.js +38 -0
- package/examples/jsm/renderers/{webgpu/WebGPUBufferUtils.js → common/BufferUtils.js} +2 -2
- package/examples/jsm/renderers/common/ChainMap.js +89 -0
- package/examples/jsm/renderers/common/ComputePipeline.js +17 -0
- package/examples/jsm/renderers/common/Constants.js +14 -0
- package/examples/jsm/renderers/common/CubeRenderTarget.js +65 -0
- package/examples/jsm/renderers/common/DataMap.js +54 -0
- package/examples/jsm/renderers/common/Geometries.js +215 -0
- package/examples/jsm/renderers/{webgpu/WebGPUInfo.js → common/Info.js} +2 -3
- package/examples/jsm/renderers/common/Pipeline.js +13 -0
- package/examples/jsm/renderers/common/Pipelines.js +309 -0
- package/examples/jsm/renderers/common/ProgrammableStage.js +18 -0
- package/examples/jsm/renderers/common/RenderContext.js +37 -0
- package/examples/jsm/renderers/common/RenderContexts.js +38 -0
- package/examples/jsm/renderers/{webgpu/WebGPURenderLists.js → common/RenderList.js} +26 -47
- package/examples/jsm/renderers/common/RenderLists.js +38 -0
- package/examples/jsm/renderers/common/RenderObject.js +95 -0
- package/examples/jsm/renderers/common/RenderObjects.js +92 -0
- package/examples/jsm/renderers/common/RenderPipeline.js +16 -0
- package/examples/jsm/renderers/common/RenderTarget.js +15 -0
- package/examples/jsm/renderers/common/Renderer.js +822 -0
- package/examples/jsm/renderers/common/SampledTexture.js +80 -0
- package/examples/jsm/renderers/common/Sampler.js +18 -0
- package/examples/jsm/renderers/common/StorageBuffer.js +17 -0
- package/examples/jsm/renderers/common/Textures.js +206 -0
- package/examples/jsm/renderers/{webgpu/WebGPUUniform.js → common/Uniform.js} +13 -9
- package/examples/jsm/renderers/common/UniformBuffer.js +15 -0
- package/examples/jsm/renderers/{webgpu/WebGPUUniformsGroup.js → common/UniformsGroup.js} +13 -13
- package/examples/jsm/renderers/common/nodes/NodeRender.js +302 -0
- package/examples/jsm/renderers/{webgpu/nodes/WebGPUNodeSampledTexture.js → common/nodes/NodeSampledTexture.js} +4 -4
- package/examples/jsm/renderers/{webgpu/nodes/WebGPUNodeSampler.js → common/nodes/NodeSampler.js} +3 -3
- package/examples/jsm/renderers/{webgpu/nodes/WebGPUNodeUniform.js → common/nodes/NodeUniform.js} +1 -1
- package/examples/jsm/renderers/common/nodes/Nodes.js +319 -0
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +35 -31
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +765 -0
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +15 -987
- package/examples/jsm/renderers/webgpu/nodes/{WebGPUNodeBuilder.js → WGSLNodeBuilder.js} +117 -90
- package/examples/jsm/{nodes/parsers → renderers/webgpu/nodes}/WGSLNodeFunction.js +2 -2
- package/examples/jsm/{nodes/parsers → renderers/webgpu/nodes}/WGSLNodeParser.js +1 -1
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +251 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +145 -0
- package/examples/jsm/renderers/webgpu/{constants.js → utils/WebGPUConstants.js} +73 -12
- package/examples/jsm/renderers/webgpu/{WebGPURenderPipeline.js → utils/WebGPUPipelineUtils.js} +135 -285
- package/examples/jsm/renderers/webgpu/{WebGPUTextureUtils.js → utils/WebGPUTextureMipmapUtils.js} +5 -25
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +855 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +88 -0
- package/examples/jsm/shaders/BleachBypassShader.js +2 -0
- package/examples/jsm/shaders/BokehShader2.js +3 -0
- package/examples/jsm/shaders/ColorifyShader.js +2 -0
- package/examples/jsm/shaders/ConvolutionShader.js +2 -0
- package/examples/jsm/shaders/CopyShader.js +2 -0
- package/examples/jsm/shaders/DotScreenShader.js +2 -0
- package/examples/jsm/shaders/ExposureShader.js +44 -0
- package/examples/jsm/shaders/FilmShader.js +2 -0
- package/examples/jsm/shaders/GammaCorrectionShader.js +2 -0
- package/examples/jsm/shaders/HorizontalBlurShader.js +2 -0
- package/examples/jsm/shaders/MMDToonShader.js +15 -4
- package/examples/jsm/shaders/OutputShader.js +61 -0
- package/examples/jsm/shaders/RGBShiftShader.js +4 -2
- package/examples/jsm/shaders/SepiaShader.js +2 -0
- package/examples/jsm/shaders/ToonShader.js +13 -5
- package/examples/jsm/shaders/VelocityShader.js +1 -1
- package/examples/jsm/shaders/VerticalBlurShader.js +2 -0
- package/examples/jsm/shaders/VignetteShader.js +2 -0
- package/examples/jsm/shaders/WaterRefractionShader.js +5 -2
- package/examples/jsm/utils/BufferGeometryUtils.js +54 -36
- package/examples/jsm/utils/LDrawUtils.js +4 -4
- package/examples/jsm/utils/PackedPhongMaterial.js +5 -78
- package/examples/jsm/utils/SceneUtils.js +8 -4
- package/examples/jsm/utils/SkeletonUtils.js +27 -210
- package/examples/jsm/utils/TextureUtils.js +41 -40
- package/examples/jsm/webxr/VRButton.js +1 -2
- package/examples/jsm/webxr/XRButton.js +198 -0
- package/examples/jsm/webxr/XRHandPrimitiveModel.js +1 -0
- package/examples/jsm/webxr/XRPlanes.js +100 -0
- package/package.json +34 -87
- package/src/Three.Legacy.js +19 -110
- package/src/Three.js +4 -3
- package/src/animation/AnimationUtils.js +13 -1
- package/src/audio/Audio.js +7 -2
- package/src/audio/PositionalAudio.js +8 -0
- package/src/cameras/Camera.js +5 -0
- package/src/cameras/CubeCamera.js +76 -13
- package/src/cameras/OrthographicCamera.js +1 -1
- package/src/cameras/PerspectiveCamera.js +1 -1
- package/src/constants.js +22 -2
- package/src/core/BufferAttribute.js +150 -9
- package/src/core/BufferGeometry.js +4 -10
- package/src/core/GLBufferAttribute.js +2 -0
- package/src/core/InterleavedBufferAttribute.js +5 -5
- package/src/core/Object3D.js +37 -8
- package/src/extras/DataUtils.js +7 -1
- package/src/extras/ImageUtils.js +2 -2
- package/src/extras/PMREMGenerator.js +5 -5
- package/src/extras/core/Curve.js +1 -1
- package/src/extras/curves/LineCurve.js +6 -4
- package/src/extras/curves/LineCurve3.js +13 -0
- package/src/geometries/BoxGeometry.js +10 -0
- package/src/geometries/CircleGeometry.js +11 -1
- package/src/geometries/ConeGeometry.js +1 -1
- package/src/geometries/CylinderGeometry.js +11 -1
- package/src/geometries/EdgesGeometry.js +10 -0
- package/src/geometries/ExtrudeGeometry.js +11 -1
- package/src/geometries/LatheGeometry.js +10 -0
- package/src/geometries/PlaneGeometry.js +10 -0
- package/src/geometries/PolyhedronGeometry.js +11 -1
- package/src/geometries/RingGeometry.js +11 -1
- package/src/geometries/ShapeGeometry.js +11 -1
- package/src/geometries/SphereGeometry.js +12 -2
- package/src/geometries/TorusGeometry.js +11 -1
- package/src/geometries/TorusKnotGeometry.js +10 -0
- package/src/geometries/TubeGeometry.js +10 -0
- package/src/geometries/WireframeGeometry.js +10 -0
- package/src/helpers/Box3Helper.js +1 -2
- package/src/lights/DirectionalLight.js +1 -1
- package/src/lights/HemisphereLight.js +1 -1
- package/src/lights/SpotLight.js +1 -1
- package/src/loaders/AudioLoader.js +14 -8
- package/src/loaders/CubeTextureLoader.js +2 -0
- package/src/loaders/DataTextureLoader.js +5 -1
- package/src/loaders/MaterialLoader.js +8 -0
- package/src/loaders/ObjectLoader.js +10 -2
- package/src/materials/LineBasicMaterial.js +4 -0
- package/src/materials/Material.js +16 -4
- package/src/materials/MeshDistanceMaterial.js +0 -9
- package/src/materials/MeshPhysicalMaterial.js +32 -6
- package/src/materials/ShaderMaterial.js +6 -1
- package/src/math/Box2.js +3 -2
- package/src/math/Box3.js +49 -64
- package/src/math/Color.js +88 -66
- package/src/math/ColorManagement.js +75 -16
- package/src/math/Euler.js +2 -11
- package/src/math/Frustum.js +29 -5
- package/src/math/MathUtils.js +43 -1
- package/src/math/Matrix3.js +26 -6
- package/src/math/Matrix4.js +74 -19
- package/src/math/Plane.js +2 -2
- package/src/math/Quaternion.js +6 -0
- package/src/math/Ray.js +7 -7
- package/src/math/Triangle.js +37 -7
- package/src/math/Vector2.js +16 -0
- package/src/math/Vector3.js +10 -0
- package/src/math/interpolants/CubicInterpolant.js +1 -2
- package/src/objects/InstancedMesh.js +82 -1
- package/src/objects/Mesh.js +108 -76
- package/src/objects/Skeleton.js +1 -1
- package/src/objects/SkinnedMesh.js +123 -8
- package/src/objects/Sprite.js +1 -1
- package/src/renderers/WebGLCubeRenderTarget.js +12 -3
- package/src/renderers/WebGLMultipleRenderTargets.js +4 -2
- package/src/renderers/WebGLRenderTarget.js +14 -2
- package/src/renderers/WebGLRenderer.js +1433 -1236
- package/src/renderers/shaders/ShaderChunk/alphamap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +0 -271
- package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +5 -5
- package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_maps.glsl.js +2 -10
- package/src/renderers/shaders/ShaderChunk/clearcoat_pars_fragment.glsl.js +5 -5
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +32 -0
- package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/displacementmap_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +26 -3
- package/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +3 -3
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +10 -2
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +11 -11
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +39 -13
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +306 -10
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +2 -10
- package/src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js +9 -1
- package/src/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl.js +10 -2
- package/src/renderers/shaders/ShaderChunk/metalnessmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +32 -10
- package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +5 -13
- package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +7 -7
- package/src/renderers/shaders/ShaderChunk/output_fragment.glsl.js +1 -2
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +11 -5
- package/src/renderers/shaders/ShaderChunk/roughnessmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +4 -11
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +39 -34
- package/src/renderers/shaders/ShaderChunk/specularmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +5 -5
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +101 -16
- package/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js +113 -1
- package/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js +134 -6
- package/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js +116 -1
- package/src/renderers/shaders/ShaderChunk.js +0 -6
- package/src/renderers/shaders/ShaderLib/background.glsl.js +0 -8
- package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +5 -0
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +1 -4
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +0 -3
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +3 -3
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +0 -3
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +16 -12
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +0 -3
- package/src/renderers/shaders/ShaderLib/points.glsl.js +13 -0
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +5 -0
- package/src/renderers/shaders/ShaderLib.js +18 -4
- package/src/renderers/shaders/UniformsLib.js +27 -15
- package/src/renderers/shaders/UniformsUtils.js +12 -3
- package/src/renderers/webgl/WebGLBackground.js +23 -12
- package/src/renderers/webgl/WebGLBindingStates.js +13 -5
- package/src/renderers/webgl/WebGLCapabilities.js +1 -2
- package/src/renderers/webgl/WebGLClipping.js +7 -3
- package/src/renderers/webgl/WebGLGeometries.js +12 -0
- package/src/renderers/webgl/WebGLInfo.js +0 -1
- package/src/renderers/webgl/WebGLLights.js +2 -2
- package/src/renderers/webgl/WebGLMaterials.js +123 -234
- package/src/renderers/webgl/WebGLMorphtargets.js +1 -1
- package/src/renderers/webgl/WebGLProgram.js +130 -48
- package/src/renderers/webgl/WebGLPrograms.js +210 -130
- package/src/renderers/webgl/WebGLRenderStates.js +2 -2
- package/src/renderers/webgl/WebGLShadowMap.js +40 -27
- package/src/renderers/webgl/WebGLState.js +23 -9
- package/src/renderers/webgl/WebGLTextures.js +39 -19
- package/src/renderers/webgl/WebGLUniformsGroups.js +74 -33
- package/src/renderers/webgl/WebGLUtils.js +41 -29
- package/src/renderers/webxr/WebXRController.js +3 -0
- package/src/renderers/webxr/WebXRManager.js +89 -141
- package/src/scenes/Scene.js +4 -6
- package/src/textures/CompressedTexture.js +2 -2
- package/src/textures/CubeTexture.js +2 -2
- package/src/textures/DataTexture.js +2 -2
- package/src/textures/DepthTexture.js +22 -0
- package/src/textures/FramebufferTexture.js +1 -3
- package/src/textures/Source.js +4 -0
- package/src/textures/Texture.js +43 -13
- package/src/utils.js +13 -1
- package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff +0 -0
- package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff2 +0 -0
- package/examples/fonts/open-sans/open-sans.css +0 -9
- package/examples/fonts/tabler-icons/fonts/tabler-icons.eot +0 -0
- package/examples/fonts/tabler-icons/fonts/tabler-icons.svg +0 -3966
- package/examples/fonts/tabler-icons/fonts/tabler-icons.ttf +0 -0
- package/examples/fonts/tabler-icons/fonts/tabler-icons.woff +0 -0
- package/examples/fonts/tabler-icons/fonts/tabler-icons.woff2 +0 -0
- package/examples/fonts/tabler-icons/tabler-icons.min.css +0 -4
- package/examples/js/animation/AnimationClipCreator.js +0 -89
- package/examples/js/animation/CCDIKSolver.js +0 -416
- package/examples/js/animation/MMDAnimationHelper.js +0 -1046
- package/examples/js/animation/MMDPhysics.js +0 -1174
- package/examples/js/cameras/CinematicCamera.js +0 -168
- package/examples/js/controls/ArcballControls.js +0 -2770
- package/examples/js/controls/DragControls.js +0 -205
- package/examples/js/controls/FirstPersonControls.js +0 -312
- package/examples/js/controls/FlyControls.js +0 -321
- package/examples/js/controls/OrbitControls.js +0 -1065
- package/examples/js/controls/PointerLockControls.js +0 -144
- package/examples/js/controls/TrackballControls.js +0 -729
- package/examples/js/controls/TransformControls.js +0 -1301
- package/examples/js/csm/CSM.js +0 -347
- package/examples/js/csm/CSMFrustum.js +0 -127
- package/examples/js/csm/CSMHelper.js +0 -165
- package/examples/js/csm/CSMShader.js +0 -253
- package/examples/js/curves/CurveExtras.js +0 -348
- package/examples/js/curves/NURBSCurve.js +0 -63
- package/examples/js/curves/NURBSSurface.js +0 -48
- package/examples/js/curves/NURBSUtils.js +0 -439
- package/examples/js/effects/AnaglyphEffect.js +0 -86
- package/examples/js/effects/AsciiEffect.js +0 -260
- package/examples/js/effects/OutlineEffect.js +0 -450
- package/examples/js/effects/ParallaxBarrierEffect.js +0 -62
- package/examples/js/effects/PeppersGhostEffect.js +0 -139
- package/examples/js/effects/StereoEffect.js +0 -46
- package/examples/js/environments/DebugEnvironment.js +0 -53
- package/examples/js/environments/RoomEnvironment.js +0 -124
- package/examples/js/exporters/ColladaExporter.js +0 -487
- package/examples/js/exporters/DRACOExporter.js +0 -212
- package/examples/js/exporters/EXRExporter.js +0 -455
- package/examples/js/exporters/GLTFExporter.js +0 -2425
- package/examples/js/exporters/MMDExporter.js +0 -187
- package/examples/js/exporters/OBJExporter.js +0 -260
- package/examples/js/exporters/PLYExporter.js +0 -427
- package/examples/js/exporters/STLExporter.js +0 -188
- package/examples/js/exporters/USDZExporter.js +0 -608
- package/examples/js/geometries/BoxLineGeometry.js +0 -59
- package/examples/js/geometries/ConvexGeometry.js +0 -53
- package/examples/js/geometries/DecalGeometry.js +0 -324
- package/examples/js/geometries/LightningStrike.js +0 -861
- package/examples/js/geometries/ParametricGeometries.js +0 -216
- package/examples/js/geometries/ParametricGeometry.js +0 -121
- package/examples/js/geometries/RoundedBoxGeometry.js +0 -142
- package/examples/js/geometries/TeapotGeometry.js +0 -335
- package/examples/js/geometries/TextGeometry.js +0 -53
- package/examples/js/helpers/LightProbeHelper.js +0 -48
- package/examples/js/helpers/OctreeHelper.js +0 -76
- package/examples/js/helpers/PositionalAudioHelper.js +0 -91
- package/examples/js/helpers/RectAreaLightHelper.js +0 -73
- package/examples/js/helpers/VertexNormalsHelper.js +0 -74
- package/examples/js/helpers/VertexTangentsHelper.js +0 -68
- package/examples/js/helpers/ViewHelper.js +0 -281
- package/examples/js/interactive/HTMLMesh.js +0 -497
- package/examples/js/interactive/InteractiveGroup.js +0 -95
- package/examples/js/interactive/SelectionBox.js +0 -195
- package/examples/js/interactive/SelectionHelper.js +0 -83
- package/examples/js/libs/chevrotain.min.js +0 -3
- package/examples/js/libs/draco/draco_decoder.js +0 -52
- package/examples/js/libs/draco/draco_decoder.wasm +0 -0
- package/examples/js/libs/draco/draco_wasm_wrapper.js +0 -104
- package/examples/js/libs/draco/gltf/draco_decoder.js +0 -48
- package/examples/js/libs/draco/gltf/draco_decoder.wasm +0 -0
- package/examples/js/libs/draco/gltf/draco_wasm_wrapper.js +0 -104
- package/examples/js/libs/fflate.min.js +0 -7
- package/examples/js/libs/ktx-parse.umd.js +0 -1
- package/examples/js/libs/meshopt_decoder.js +0 -188
- package/examples/js/libs/opentype.min.js +0 -1
- package/examples/js/libs/stats.min.js +0 -5
- package/examples/js/lights/LightProbeGenerator.js +0 -221
- package/examples/js/lights/RectAreaLightUniformsLib.js +0 -60
- package/examples/js/lines/Line2.js +0 -19
- package/examples/js/lines/LineGeometry.js +0 -69
- package/examples/js/lines/LineMaterial.js +0 -635
- package/examples/js/lines/LineSegments2.js +0 -311
- package/examples/js/lines/LineSegmentsGeometry.js +0 -198
- package/examples/js/lines/Wireframe.js +0 -47
- package/examples/js/lines/WireframeGeometry2.js +0 -20
- package/examples/js/loaders/3DMLoader.js +0 -1273
- package/examples/js/loaders/3MFLoader.js +0 -1306
- package/examples/js/loaders/AMFLoader.js +0 -504
- package/examples/js/loaders/BVHLoader.js +0 -395
- package/examples/js/loaders/BasisTextureLoader.js +0 -706
- package/examples/js/loaders/ColladaLoader.js +0 -3663
- package/examples/js/loaders/DDSLoader.js +0 -244
- package/examples/js/loaders/DRACOLoader.js +0 -511
- package/examples/js/loaders/EXRLoader.js +0 -2039
- package/examples/js/loaders/FBXLoader.js +0 -3680
- package/examples/js/loaders/FontLoader.js +0 -160
- package/examples/js/loaders/GCodeLoader.js +0 -255
- package/examples/js/loaders/GLTFLoader.js +0 -4108
- package/examples/js/loaders/HDRCubeTextureLoader.js +0 -87
- package/examples/js/loaders/KMZLoader.js +0 -121
- package/examples/js/loaders/KTXLoader.js +0 -159
- package/examples/js/loaders/LDrawLoader.js +0 -2263
- package/examples/js/loaders/LUT3dlLoader.js +0 -135
- package/examples/js/loaders/LUTCubeLoader.js +0 -132
- package/examples/js/loaders/LWOLoader.js +0 -901
- package/examples/js/loaders/LogLuvLoader.js +0 -715
- package/examples/js/loaders/LottieLoader.js +0 -62
- package/examples/js/loaders/MD2Loader.js +0 -248
- package/examples/js/loaders/MDDLoader.js +0 -91
- package/examples/js/loaders/MMDLoader.js +0 -1915
- package/examples/js/loaders/MTLLoader.js +0 -472
- package/examples/js/loaders/MaterialXLoader.js +0 -392
- package/examples/js/loaders/NRRDLoader.js +0 -609
- package/examples/js/loaders/OBJLoader.js +0 -789
- package/examples/js/loaders/PCDLoader.js +0 -413
- package/examples/js/loaders/PDBLoader.js +0 -317
- package/examples/js/loaders/PLYLoader.js +0 -532
- package/examples/js/loaders/PRWMLoader.js +0 -249
- package/examples/js/loaders/PVRLoader.js +0 -218
- package/examples/js/loaders/RGBELoader.js +0 -442
- package/examples/js/loaders/RGBMLoader.js +0 -1354
- package/examples/js/loaders/STLLoader.js +0 -364
- package/examples/js/loaders/SVGLoader.js +0 -2783
- package/examples/js/loaders/TDSLoader.js +0 -992
- package/examples/js/loaders/TGALoader.js +0 -484
- package/examples/js/loaders/TIFFLoader.js +0 -30
- package/examples/js/loaders/TTFLoader.js +0 -203
- package/examples/js/loaders/TiltLoader.js +0 -459
- package/examples/js/loaders/VOXLoader.js +0 -240
- package/examples/js/loaders/VRMLLoader.js +0 -3140
- package/examples/js/loaders/VTKLoader.js +0 -1078
- package/examples/js/loaders/XYZLoader.js +0 -89
- package/examples/js/loaders/lwo/IFFParser.js +0 -1067
- package/examples/js/loaders/lwo/LWO2Parser.js +0 -397
- package/examples/js/loaders/lwo/LWO3Parser.js +0 -360
- package/examples/js/materials/MeshGouraudMaterial.js +0 -387
- package/examples/js/math/Capsule.js +0 -103
- package/examples/js/math/ColorConverter.js +0 -33
- package/examples/js/math/ConvexHull.js +0 -1154
- package/examples/js/math/ImprovedNoise.js +0 -66
- package/examples/js/math/Lut.js +0 -164
- package/examples/js/math/MeshSurfaceSampler.js +0 -171
- package/examples/js/math/OBB.js +0 -382
- package/examples/js/math/Octree.js +0 -410
- package/examples/js/math/SimplexNoise.js +0 -445
- package/examples/js/misc/ConvexObjectBreaker.js +0 -474
- package/examples/js/misc/GPUComputationRenderer.js +0 -393
- package/examples/js/misc/Gyroscope.js +0 -56
- package/examples/js/misc/MD2Character.js +0 -235
- package/examples/js/misc/MD2CharacterComplex.js +0 -513
- package/examples/js/misc/MorphAnimMesh.js +0 -63
- package/examples/js/misc/MorphBlendMesh.js +0 -265
- package/examples/js/misc/ProgressiveLightMap.js +0 -335
- package/examples/js/misc/RollerCoaster.js +0 -430
- package/examples/js/misc/TubePainter.js +0 -167
- package/examples/js/misc/Volume.js +0 -437
- package/examples/js/misc/VolumeSlice.js +0 -214
- package/examples/js/modifiers/CurveModifier.js +0 -309
- package/examples/js/modifiers/EdgeSplitModifier.js +0 -228
- package/examples/js/modifiers/SimplifyModifier.js +0 -465
- package/examples/js/modifiers/TessellateModifier.js +0 -276
- package/examples/js/objects/GroundProjectedEnv.js +0 -181
- package/examples/js/objects/Lensflare.js +0 -356
- package/examples/js/objects/LightningStorm.js +0 -206
- package/examples/js/objects/MarchingCubes.js +0 -759
- package/examples/js/objects/Reflector.js +0 -216
- package/examples/js/objects/ReflectorForSSRPass.js +0 -315
- package/examples/js/objects/Refractor.js +0 -283
- package/examples/js/objects/ShadowMesh.js +0 -59
- package/examples/js/objects/Sky.js +0 -218
- package/examples/js/objects/Water.js +0 -292
- package/examples/js/objects/Water2.js +0 -307
- package/examples/js/physics/AmmoPhysics.js +0 -259
- package/examples/js/physics/OimoPhysics.js +0 -217
- package/examples/js/postprocessing/AdaptiveToneMappingPass.js +0 -335
- package/examples/js/postprocessing/AfterimagePass.js +0 -77
- package/examples/js/postprocessing/BloomPass.js +0 -135
- package/examples/js/postprocessing/BokehPass.js +0 -120
- package/examples/js/postprocessing/ClearPass.js +0 -39
- package/examples/js/postprocessing/CubeTexturePass.js +0 -60
- package/examples/js/postprocessing/DotScreenPass.js +0 -51
- package/examples/js/postprocessing/EffectComposer.js +0 -272
- package/examples/js/postprocessing/FilmPass.js +0 -52
- package/examples/js/postprocessing/GlitchPass.js +0 -104
- package/examples/js/postprocessing/HalftonePass.js +0 -75
- package/examples/js/postprocessing/LUTPass.js +0 -171
- package/examples/js/postprocessing/MaskPass.js +0 -95
- package/examples/js/postprocessing/OutlinePass.js +0 -598
- package/examples/js/postprocessing/Pass.js +0 -72
- package/examples/js/postprocessing/RenderPass.js +0 -70
- package/examples/js/postprocessing/SAOPass.js +0 -374
- package/examples/js/postprocessing/SMAAPass.js +0 -170
- package/examples/js/postprocessing/SSAARenderPass.js +0 -156
- package/examples/js/postprocessing/SSAOPass.js +0 -365
- package/examples/js/postprocessing/SSRPass.js +0 -567
- package/examples/js/postprocessing/SavePass.js +0 -59
- package/examples/js/postprocessing/ShaderPass.js +0 -64
- package/examples/js/postprocessing/TAARenderPass.js +0 -130
- package/examples/js/postprocessing/TexturePass.js +0 -49
- package/examples/js/postprocessing/UnrealBloomPass.js +0 -375
- package/examples/js/renderers/CSS2DRenderer.js +0 -178
- package/examples/js/renderers/CSS3DRenderer.js +0 -237
- package/examples/js/renderers/Projector.js +0 -818
- package/examples/js/renderers/SVGRenderer.js +0 -491
- package/examples/js/shaders/ACESFilmicToneMappingShader.js +0 -89
- package/examples/js/shaders/AfterimageShader.js +0 -60
- package/examples/js/shaders/BasicShader.js +0 -27
- package/examples/js/shaders/BleachBypassShader.js +0 -62
- package/examples/js/shaders/BlendShader.js +0 -54
- package/examples/js/shaders/BokehShader.js +0 -156
- package/examples/js/shaders/BokehShader2.js +0 -419
- package/examples/js/shaders/BrightnessContrastShader.js +0 -58
- package/examples/js/shaders/ColorCorrectionShader.js +0 -52
- package/examples/js/shaders/ColorifyShader.js +0 -47
- package/examples/js/shaders/ConvolutionShader.js +0 -92
- package/examples/js/shaders/CopyShader.js +0 -45
- package/examples/js/shaders/DOFMipMapShader.js +0 -60
- package/examples/js/shaders/DepthLimitedBlurShader.js +0 -173
- package/examples/js/shaders/DigitalGlitch.js +0 -127
- package/examples/js/shaders/DotScreenShader.js +0 -72
- package/examples/js/shaders/FXAAShader.js +0 -284
- package/examples/js/shaders/FilmShader.js +0 -110
- package/examples/js/shaders/FocusShader.js +0 -95
- package/examples/js/shaders/FreiChenShader.js +0 -93
- package/examples/js/shaders/GammaCorrectionShader.js +0 -41
- package/examples/js/shaders/GodRaysShader.js +0 -284
- package/examples/js/shaders/HalftoneShader.js +0 -336
- package/examples/js/shaders/HorizontalBlurShader.js +0 -59
- package/examples/js/shaders/HorizontalTiltShiftShader.js +0 -65
- package/examples/js/shaders/HueSaturationShader.js +0 -69
- package/examples/js/shaders/KaleidoShader.js +0 -60
- package/examples/js/shaders/LuminosityHighPassShader.js +0 -67
- package/examples/js/shaders/LuminosityShader.js +0 -46
- package/examples/js/shaders/MMDToonShader.js +0 -96
- package/examples/js/shaders/MirrorShader.js +0 -56
- package/examples/js/shaders/NormalMapShader.js +0 -55
- package/examples/js/shaders/RGBShiftShader.js +0 -56
- package/examples/js/shaders/SAOShader.js +0 -209
- package/examples/js/shaders/SMAAShader.js +0 -454
- package/examples/js/shaders/SSAOShader.js +0 -295
- package/examples/js/shaders/SSRShader.js +0 -381
- package/examples/js/shaders/SepiaShader.js +0 -52
- package/examples/js/shaders/SobelOperatorShader.js +0 -88
- package/examples/js/shaders/SubsurfaceScatteringShader.js +0 -49
- package/examples/js/shaders/TechnicolorShader.js +0 -43
- package/examples/js/shaders/ToneMapShader.js +0 -84
- package/examples/js/shaders/ToonShader.js +0 -335
- package/examples/js/shaders/TriangleBlurShader.js +0 -70
- package/examples/js/shaders/UnpackDepthRGBAShader.js +0 -47
- package/examples/js/shaders/VelocityShader.js +0 -126
- package/examples/js/shaders/VerticalBlurShader.js +0 -59
- package/examples/js/shaders/VerticalTiltShiftShader.js +0 -65
- package/examples/js/shaders/VignetteShader.js +0 -53
- package/examples/js/shaders/VolumeShader.js +0 -296
- package/examples/js/shaders/WaterRefractionShader.js +0 -84
- package/examples/js/textures/FlakesTexture.js +0 -40
- package/examples/js/utils/BufferGeometryUtils.js +0 -1160
- package/examples/js/utils/CameraUtils.js +0 -71
- package/examples/js/utils/GPUStatsPanel.js +0 -125
- package/examples/js/utils/GeometryCompressionUtils.js +0 -549
- package/examples/js/utils/GeometryUtils.js +0 -168
- package/examples/js/utils/LDrawUtils.js +0 -179
- package/examples/js/utils/PackedPhongMaterial.js +0 -109
- package/examples/js/utils/SceneUtils.js +0 -214
- package/examples/js/utils/ShadowMapViewer.js +0 -183
- package/examples/js/utils/SkeletonUtils.js +0 -493
- package/examples/js/utils/UVsDebug.js +0 -143
- package/examples/js/utils/WorkerPool.js +0 -105
- package/examples/jsm/exporters/ColladaExporter.js +0 -713
- package/examples/jsm/geometries/LightningStrike.js +0 -1017
- package/examples/jsm/libs/OimoPhysics/OimoPhysics.js +0 -37071
- package/examples/jsm/libs/OimoPhysics/index.js +0 -43
- package/examples/jsm/libs/flow.module.js +0 -4552
- package/examples/jsm/libs/tween.module.min.js +0 -3
- package/examples/jsm/loaders/BasisTextureLoader.js +0 -790
- package/examples/jsm/loaders/IFCLoader.js +0 -2431
- package/examples/jsm/loaders/PRWMLoader.js +0 -299
- package/examples/jsm/loaders/ifc/web-ifc-api.js +0 -47504
- package/examples/jsm/loaders/ifc/web-ifc.wasm +0 -0
- package/examples/jsm/node-editor/NodeEditor.js +0 -857
- package/examples/jsm/node-editor/accessors/MatcapUVEditor.js +0 -14
- package/examples/jsm/node-editor/accessors/NormalEditor.js +0 -30
- package/examples/jsm/node-editor/accessors/PositionEditor.js +0 -30
- package/examples/jsm/node-editor/accessors/UVEditor.js +0 -25
- package/examples/jsm/node-editor/core/BaseNode.js +0 -96
- package/examples/jsm/node-editor/core/DataFile.js +0 -59
- package/examples/jsm/node-editor/core/FileEditor.js +0 -20
- package/examples/jsm/node-editor/core/FileURLEditor.js +0 -29
- package/examples/jsm/node-editor/display/BlendEditor.js +0 -44
- package/examples/jsm/node-editor/display/NormalMapEditor.js +0 -49
- package/examples/jsm/node-editor/examples/animate-uv.json +0 -1
- package/examples/jsm/node-editor/examples/fake-top-light.json +0 -1
- package/examples/jsm/node-editor/examples/matcap.json +0 -1
- package/examples/jsm/node-editor/examples/oscillator-color.json +0 -1
- package/examples/jsm/node-editor/examples/rim.json +0 -1
- package/examples/jsm/node-editor/inputs/ColorEditor.js +0 -96
- package/examples/jsm/node-editor/inputs/FloatEditor.js +0 -23
- package/examples/jsm/node-editor/inputs/SliderEditor.js +0 -67
- package/examples/jsm/node-editor/inputs/TextureEditor.js +0 -155
- package/examples/jsm/node-editor/inputs/Vector2Editor.js +0 -28
- package/examples/jsm/node-editor/inputs/Vector3Editor.js +0 -30
- package/examples/jsm/node-editor/inputs/Vector4Editor.js +0 -37
- package/examples/jsm/node-editor/materials/BasicMaterialEditor.js +0 -84
- package/examples/jsm/node-editor/materials/PointsMaterialEditor.js +0 -102
- package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +0 -118
- package/examples/jsm/node-editor/math/AngleEditor.js +0 -40
- package/examples/jsm/node-editor/math/DotEditor.js +0 -35
- package/examples/jsm/node-editor/math/InvertEditor.js +0 -39
- package/examples/jsm/node-editor/math/LimiterEditor.js +0 -62
- package/examples/jsm/node-editor/math/NormalizeEditor.js +0 -28
- package/examples/jsm/node-editor/math/OperatorEditor.js +0 -63
- package/examples/jsm/node-editor/math/PowerEditor.js +0 -44
- package/examples/jsm/node-editor/math/TrigonometryEditor.js +0 -45
- package/examples/jsm/node-editor/procedural/CheckerEditor.js +0 -27
- package/examples/jsm/node-editor/scene/MeshEditor.js +0 -102
- package/examples/jsm/node-editor/scene/Object3DEditor.js +0 -160
- package/examples/jsm/node-editor/scene/PointsEditor.js +0 -99
- package/examples/jsm/node-editor/utils/JoinEditor.js +0 -58
- package/examples/jsm/node-editor/utils/OscillatorEditor.js +0 -43
- package/examples/jsm/node-editor/utils/PreviewEditor.js +0 -170
- package/examples/jsm/node-editor/utils/SplitEditor.js +0 -39
- package/examples/jsm/node-editor/utils/TimerEditor.js +0 -58
- package/examples/jsm/nodes/core/CodeNode.js +0 -50
- package/examples/jsm/nodes/core/ExpressionNode.js +0 -32
- package/examples/jsm/nodes/functions/light/getDistanceAttenuation.js +0 -22
- package/examples/jsm/nodes/lighting/PunctualLightNode.js +0 -68
- package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +0 -301
- package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +0 -149
- package/examples/jsm/objects/GroundProjectedEnv.js +0 -186
- package/examples/jsm/objects/LightningStorm.js +0 -245
- package/examples/jsm/physics/OimoPhysics.js +0 -231
- package/examples/jsm/postprocessing/AdaptiveToneMappingPass.js +0 -369
- package/examples/jsm/renderers/webgpu/WebGPUAttributes.js +0 -187
- package/examples/jsm/renderers/webgpu/WebGPUBackground.js +0 -173
- package/examples/jsm/renderers/webgpu/WebGPUBinding.js +0 -22
- package/examples/jsm/renderers/webgpu/WebGPUBindings.js +0 -255
- package/examples/jsm/renderers/webgpu/WebGPUBuffer.js +0 -43
- package/examples/jsm/renderers/webgpu/WebGPUComputePipelines.js +0 -78
- package/examples/jsm/renderers/webgpu/WebGPUGeometries.js +0 -82
- package/examples/jsm/renderers/webgpu/WebGPUObjects.js +0 -36
- package/examples/jsm/renderers/webgpu/WebGPUProgrammableStage.js +0 -22
- package/examples/jsm/renderers/webgpu/WebGPUProperties.js +0 -38
- package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +0 -296
- package/examples/jsm/renderers/webgpu/WebGPURenderStates.js +0 -66
- package/examples/jsm/renderers/webgpu/WebGPUSampledTexture.js +0 -73
- package/examples/jsm/renderers/webgpu/WebGPUSampler.js +0 -29
- package/examples/jsm/renderers/webgpu/WebGPUStorageBuffer.js +0 -20
- package/examples/jsm/renderers/webgpu/WebGPUTextureRenderer.js +0 -40
- package/examples/jsm/renderers/webgpu/WebGPUTextures.js +0 -794
- package/examples/jsm/renderers/webgpu/WebGPUUniformBuffer.js +0 -18
- package/examples/jsm/renderers/webgpu/WebGPUUtils.js +0 -81
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodes.js +0 -83
- package/examples/jsm/shaders/ToneMapShader.js +0 -73
- package/src/renderers/shaders/ShaderChunk/uv2_pars_fragment.glsl.js +0 -7
- package/src/renderers/shaders/ShaderChunk/uv2_pars_vertex.glsl.js +0 -10
- package/src/renderers/shaders/ShaderChunk/uv2_vertex.glsl.js +0 -7
- /package/examples/{js → jsm}/libs/ammo.wasm.js +0 -0
- /package/examples/{js → jsm}/libs/ammo.wasm.wasm +0 -0
- /package/examples/{js → jsm}/libs/basis/basis_transcoder.js +0 -0
- /package/examples/{js → jsm}/libs/basis/basis_transcoder.wasm +0 -0
- /package/examples/{js → jsm}/libs/draco/README.md +0 -0
- /package/examples/{js → jsm}/libs/draco/draco_encoder.js +0 -0
- /package/examples/{js → jsm}/libs/draco/gltf/draco_encoder.js +0 -0
|
@@ -1,22 +1,35 @@
|
|
|
1
1
|
import {
|
|
2
2
|
REVISION,
|
|
3
3
|
BackSide,
|
|
4
|
-
DoubleSide,
|
|
5
4
|
FrontSide,
|
|
5
|
+
DoubleSide,
|
|
6
6
|
RGBAFormat,
|
|
7
7
|
HalfFloatType,
|
|
8
8
|
FloatType,
|
|
9
9
|
UnsignedByteType,
|
|
10
|
-
LinearEncoding,
|
|
11
10
|
NoToneMapping,
|
|
12
|
-
LinearMipmapLinearFilter
|
|
11
|
+
LinearMipmapLinearFilter,
|
|
12
|
+
SRGBColorSpace,
|
|
13
|
+
LinearSRGBColorSpace,
|
|
14
|
+
sRGBEncoding,
|
|
15
|
+
LinearEncoding,
|
|
16
|
+
RGBAIntegerFormat,
|
|
17
|
+
RGIntegerFormat,
|
|
18
|
+
RedIntegerFormat,
|
|
19
|
+
UnsignedIntType,
|
|
20
|
+
UnsignedShortType,
|
|
21
|
+
UnsignedInt248Type,
|
|
22
|
+
UnsignedShort4444Type,
|
|
23
|
+
UnsignedShort5551Type,
|
|
24
|
+
WebGLCoordinateSystem
|
|
13
25
|
} from '../constants.js';
|
|
14
|
-
import {
|
|
26
|
+
import { Color } from '../math/Color.js';
|
|
15
27
|
import { Frustum } from '../math/Frustum.js';
|
|
16
28
|
import { Matrix4 } from '../math/Matrix4.js';
|
|
17
29
|
import { Vector2 } from '../math/Vector2.js';
|
|
18
30
|
import { Vector3 } from '../math/Vector3.js';
|
|
19
31
|
import { Vector4 } from '../math/Vector4.js';
|
|
32
|
+
import { floorPowerOfTwo } from '../math/MathUtils.js';
|
|
20
33
|
import { WebGLAnimation } from './webgl/WebGLAnimation.js';
|
|
21
34
|
import { WebGLAttributes } from './webgl/WebGLAttributes.js';
|
|
22
35
|
import { WebGLBackground } from './webgl/WebGLBackground.js';
|
|
@@ -55,1135 +68,1229 @@ function createCanvasElement() {
|
|
|
55
68
|
|
|
56
69
|
}
|
|
57
70
|
|
|
58
|
-
|
|
71
|
+
class WebGLRenderer {
|
|
59
72
|
|
|
60
|
-
|
|
73
|
+
constructor( parameters = {} ) {
|
|
61
74
|
|
|
62
|
-
|
|
63
|
-
|
|
75
|
+
const {
|
|
76
|
+
canvas = createCanvasElement(),
|
|
77
|
+
context = null,
|
|
78
|
+
depth = true,
|
|
79
|
+
stencil = true,
|
|
80
|
+
alpha = false,
|
|
81
|
+
antialias = false,
|
|
82
|
+
premultipliedAlpha = true,
|
|
83
|
+
preserveDrawingBuffer = false,
|
|
84
|
+
powerPreference = 'default',
|
|
85
|
+
failIfMajorPerformanceCaveat = false,
|
|
86
|
+
} = parameters;
|
|
64
87
|
|
|
65
|
-
|
|
66
|
-
_stencil = parameters.stencil !== undefined ? parameters.stencil : true,
|
|
67
|
-
_antialias = parameters.antialias !== undefined ? parameters.antialias : false,
|
|
68
|
-
_premultipliedAlpha = parameters.premultipliedAlpha !== undefined ? parameters.premultipliedAlpha : true,
|
|
69
|
-
_preserveDrawingBuffer = parameters.preserveDrawingBuffer !== undefined ? parameters.preserveDrawingBuffer : false,
|
|
70
|
-
_powerPreference = parameters.powerPreference !== undefined ? parameters.powerPreference : 'default',
|
|
71
|
-
_failIfMajorPerformanceCaveat = parameters.failIfMajorPerformanceCaveat !== undefined ? parameters.failIfMajorPerformanceCaveat : false;
|
|
88
|
+
this.isWebGLRenderer = true;
|
|
72
89
|
|
|
73
|
-
|
|
90
|
+
let _alpha;
|
|
74
91
|
|
|
75
|
-
|
|
92
|
+
if ( context !== null ) {
|
|
76
93
|
|
|
77
|
-
|
|
94
|
+
_alpha = context.getContextAttributes().alpha;
|
|
78
95
|
|
|
79
|
-
|
|
96
|
+
} else {
|
|
80
97
|
|
|
81
|
-
|
|
98
|
+
_alpha = alpha;
|
|
82
99
|
|
|
83
|
-
|
|
100
|
+
}
|
|
84
101
|
|
|
85
|
-
|
|
86
|
-
|
|
102
|
+
const uintClearColor = new Uint32Array( 4 );
|
|
103
|
+
const intClearColor = new Int32Array( 4 );
|
|
87
104
|
|
|
88
|
-
|
|
89
|
-
|
|
105
|
+
let currentRenderList = null;
|
|
106
|
+
let currentRenderState = null;
|
|
90
107
|
|
|
91
|
-
|
|
92
|
-
|
|
108
|
+
// render() can be called from within a callback triggered by another render.
|
|
109
|
+
// We track this so that the nested render call gets its list and state isolated from the parent render call.
|
|
93
110
|
|
|
94
|
-
|
|
111
|
+
const renderListStack = [];
|
|
112
|
+
const renderStateStack = [];
|
|
95
113
|
|
|
96
|
-
|
|
114
|
+
// public properties
|
|
97
115
|
|
|
98
|
-
|
|
99
|
-
this.debug = {
|
|
116
|
+
this.domElement = canvas;
|
|
100
117
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
* @type {boolean}
|
|
104
|
-
*/
|
|
105
|
-
checkShaderErrors: true
|
|
106
|
-
};
|
|
118
|
+
// Debug configuration container
|
|
119
|
+
this.debug = {
|
|
107
120
|
|
|
108
|
-
|
|
121
|
+
/**
|
|
122
|
+
* Enables error checking and reporting when shader programs are being compiled
|
|
123
|
+
* @type {boolean}
|
|
124
|
+
*/
|
|
125
|
+
checkShaderErrors: true,
|
|
126
|
+
/**
|
|
127
|
+
* Callback for custom error reporting.
|
|
128
|
+
* @type {?Function}
|
|
129
|
+
*/
|
|
130
|
+
onShaderError: null
|
|
131
|
+
};
|
|
109
132
|
|
|
110
|
-
|
|
111
|
-
this.autoClearColor = true;
|
|
112
|
-
this.autoClearDepth = true;
|
|
113
|
-
this.autoClearStencil = true;
|
|
133
|
+
// clearing
|
|
114
134
|
|
|
115
|
-
|
|
135
|
+
this.autoClear = true;
|
|
136
|
+
this.autoClearColor = true;
|
|
137
|
+
this.autoClearDepth = true;
|
|
138
|
+
this.autoClearStencil = true;
|
|
116
139
|
|
|
117
|
-
|
|
140
|
+
// scene graph
|
|
118
141
|
|
|
119
|
-
|
|
142
|
+
this.sortObjects = true;
|
|
120
143
|
|
|
121
|
-
|
|
122
|
-
this.localClippingEnabled = false;
|
|
144
|
+
// user-defined clipping
|
|
123
145
|
|
|
124
|
-
|
|
146
|
+
this.clippingPlanes = [];
|
|
147
|
+
this.localClippingEnabled = false;
|
|
125
148
|
|
|
126
|
-
|
|
149
|
+
// physically based shading
|
|
127
150
|
|
|
128
|
-
|
|
151
|
+
this.outputColorSpace = SRGBColorSpace;
|
|
129
152
|
|
|
130
|
-
|
|
153
|
+
// physical lights
|
|
131
154
|
|
|
132
|
-
|
|
155
|
+
this.useLegacyLights = true;
|
|
133
156
|
|
|
134
|
-
|
|
135
|
-
this.toneMappingExposure = 1.0;
|
|
157
|
+
// tone mapping
|
|
136
158
|
|
|
137
|
-
|
|
159
|
+
this.toneMapping = NoToneMapping;
|
|
160
|
+
this.toneMappingExposure = 1.0;
|
|
138
161
|
|
|
139
|
-
|
|
162
|
+
// internal properties
|
|
140
163
|
|
|
141
|
-
|
|
164
|
+
const _this = this;
|
|
142
165
|
|
|
143
|
-
|
|
166
|
+
let _isContextLost = false;
|
|
144
167
|
|
|
145
|
-
|
|
146
|
-
let _currentActiveMipmapLevel = 0;
|
|
147
|
-
let _currentRenderTarget = null;
|
|
148
|
-
let _currentMaterialId = - 1;
|
|
168
|
+
// internal state cache
|
|
149
169
|
|
|
150
|
-
|
|
170
|
+
let _currentActiveCubeFace = 0;
|
|
171
|
+
let _currentActiveMipmapLevel = 0;
|
|
172
|
+
let _currentRenderTarget = null;
|
|
173
|
+
let _currentMaterialId = - 1;
|
|
151
174
|
|
|
152
|
-
|
|
153
|
-
const _currentScissor = new Vector4();
|
|
154
|
-
let _currentScissorTest = null;
|
|
175
|
+
let _currentCamera = null;
|
|
155
176
|
|
|
156
|
-
|
|
177
|
+
const _currentViewport = new Vector4();
|
|
178
|
+
const _currentScissor = new Vector4();
|
|
179
|
+
let _currentScissorTest = null;
|
|
157
180
|
|
|
158
|
-
|
|
159
|
-
|
|
181
|
+
const _currentClearColor = new Color( 0x000000 );
|
|
182
|
+
let _currentClearAlpha = 0;
|
|
160
183
|
|
|
161
|
-
|
|
162
|
-
let _opaqueSort = null;
|
|
163
|
-
let _transparentSort = null;
|
|
184
|
+
//
|
|
164
185
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
let _scissorTest = false;
|
|
186
|
+
let _width = canvas.width;
|
|
187
|
+
let _height = canvas.height;
|
|
168
188
|
|
|
169
|
-
|
|
189
|
+
let _pixelRatio = 1;
|
|
190
|
+
let _opaqueSort = null;
|
|
191
|
+
let _transparentSort = null;
|
|
170
192
|
|
|
171
|
-
|
|
193
|
+
const _viewport = new Vector4( 0, 0, _width, _height );
|
|
194
|
+
const _scissor = new Vector4( 0, 0, _width, _height );
|
|
195
|
+
let _scissorTest = false;
|
|
172
196
|
|
|
173
|
-
|
|
197
|
+
// frustum
|
|
174
198
|
|
|
175
|
-
|
|
176
|
-
let _localClippingEnabled = false;
|
|
199
|
+
const _frustum = new Frustum();
|
|
177
200
|
|
|
178
|
-
|
|
201
|
+
// clipping
|
|
179
202
|
|
|
180
|
-
|
|
203
|
+
let _clippingEnabled = false;
|
|
204
|
+
let _localClippingEnabled = false;
|
|
181
205
|
|
|
182
|
-
|
|
206
|
+
// transmission
|
|
183
207
|
|
|
184
|
-
|
|
208
|
+
let _transmissionRenderTarget = null;
|
|
185
209
|
|
|
186
|
-
|
|
187
|
-
const _vector3 = new Vector3();
|
|
210
|
+
// camera matrices cache
|
|
188
211
|
|
|
189
|
-
|
|
212
|
+
const _projScreenMatrix = new Matrix4();
|
|
190
213
|
|
|
191
|
-
|
|
214
|
+
const _vector2 = new Vector2();
|
|
215
|
+
const _vector3 = new Vector3();
|
|
192
216
|
|
|
193
|
-
|
|
217
|
+
const _emptyScene = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: true };
|
|
194
218
|
|
|
195
|
-
|
|
219
|
+
function getTargetPixelRatio() {
|
|
196
220
|
|
|
197
|
-
|
|
221
|
+
return _currentRenderTarget === null ? _pixelRatio : 1;
|
|
198
222
|
|
|
199
|
-
|
|
223
|
+
}
|
|
200
224
|
|
|
201
|
-
|
|
225
|
+
// initialize
|
|
202
226
|
|
|
203
|
-
|
|
227
|
+
let _gl = context;
|
|
204
228
|
|
|
205
|
-
|
|
206
|
-
const context = _canvas.getContext( contextName, contextAttributes );
|
|
207
|
-
if ( context !== null ) return context;
|
|
229
|
+
function getContext( contextNames, contextAttributes ) {
|
|
208
230
|
|
|
209
|
-
|
|
231
|
+
for ( let i = 0; i < contextNames.length; i ++ ) {
|
|
210
232
|
|
|
211
|
-
|
|
233
|
+
const contextName = contextNames[ i ];
|
|
234
|
+
const context = canvas.getContext( contextName, contextAttributes );
|
|
235
|
+
if ( context !== null ) return context;
|
|
212
236
|
|
|
213
|
-
|
|
237
|
+
}
|
|
214
238
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
const contextAttributes = {
|
|
218
|
-
alpha: true,
|
|
219
|
-
depth: _depth,
|
|
220
|
-
stencil: _stencil,
|
|
221
|
-
antialias: _antialias,
|
|
222
|
-
premultipliedAlpha: _premultipliedAlpha,
|
|
223
|
-
preserveDrawingBuffer: _preserveDrawingBuffer,
|
|
224
|
-
powerPreference: _powerPreference,
|
|
225
|
-
failIfMajorPerformanceCaveat: _failIfMajorPerformanceCaveat
|
|
226
|
-
};
|
|
239
|
+
return null;
|
|
227
240
|
|
|
228
|
-
|
|
229
|
-
if ( 'setAttribute' in _canvas ) _canvas.setAttribute( 'data-engine', `three.js r${REVISION}` );
|
|
241
|
+
}
|
|
230
242
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
243
|
+
try {
|
|
244
|
+
|
|
245
|
+
const contextAttributes = {
|
|
246
|
+
alpha: true,
|
|
247
|
+
depth,
|
|
248
|
+
stencil,
|
|
249
|
+
antialias,
|
|
250
|
+
premultipliedAlpha,
|
|
251
|
+
preserveDrawingBuffer,
|
|
252
|
+
powerPreference,
|
|
253
|
+
failIfMajorPerformanceCaveat,
|
|
254
|
+
};
|
|
235
255
|
|
|
236
|
-
|
|
256
|
+
// OffscreenCanvas does not have setAttribute, see #22811
|
|
257
|
+
if ( 'setAttribute' in canvas ) canvas.setAttribute( 'data-engine', `three.js r${REVISION}` );
|
|
237
258
|
|
|
238
|
-
|
|
259
|
+
// event listeners must be registered before WebGL context is created, see #12753
|
|
260
|
+
canvas.addEventListener( 'webglcontextlost', onContextLost, false );
|
|
261
|
+
canvas.addEventListener( 'webglcontextrestored', onContextRestore, false );
|
|
262
|
+
canvas.addEventListener( 'webglcontextcreationerror', onContextCreationError, false );
|
|
239
263
|
|
|
240
|
-
if (
|
|
264
|
+
if ( _gl === null ) {
|
|
241
265
|
|
|
242
|
-
contextNames
|
|
266
|
+
const contextNames = [ 'webgl2', 'webgl', 'experimental-webgl' ];
|
|
243
267
|
|
|
244
|
-
|
|
268
|
+
if ( _this.isWebGL1Renderer === true ) {
|
|
245
269
|
|
|
246
|
-
|
|
270
|
+
contextNames.shift();
|
|
247
271
|
|
|
248
|
-
|
|
272
|
+
}
|
|
249
273
|
|
|
250
|
-
|
|
274
|
+
_gl = getContext( contextNames, contextAttributes );
|
|
251
275
|
|
|
252
|
-
|
|
276
|
+
if ( _gl === null ) {
|
|
253
277
|
|
|
254
|
-
|
|
278
|
+
if ( getContext( contextNames ) ) {
|
|
279
|
+
|
|
280
|
+
throw new Error( 'Error creating WebGL context with your selected attributes.' );
|
|
281
|
+
|
|
282
|
+
} else {
|
|
255
283
|
|
|
256
|
-
|
|
284
|
+
throw new Error( 'Error creating WebGL context.' );
|
|
285
|
+
|
|
286
|
+
}
|
|
257
287
|
|
|
258
288
|
}
|
|
259
289
|
|
|
260
290
|
}
|
|
261
291
|
|
|
262
|
-
|
|
292
|
+
if ( _gl instanceof WebGLRenderingContext ) { // @deprecated, r153
|
|
263
293
|
|
|
264
|
-
|
|
294
|
+
console.warn( 'THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163.' );
|
|
265
295
|
|
|
266
|
-
|
|
296
|
+
}
|
|
267
297
|
|
|
268
|
-
|
|
298
|
+
// Some experimental-webgl implementations do not have getShaderPrecisionFormat
|
|
269
299
|
|
|
270
|
-
|
|
300
|
+
if ( _gl.getShaderPrecisionFormat === undefined ) {
|
|
271
301
|
|
|
272
|
-
|
|
302
|
+
_gl.getShaderPrecisionFormat = function () {
|
|
303
|
+
|
|
304
|
+
return { 'rangeMin': 1, 'rangeMax': 1, 'precision': 1 };
|
|
305
|
+
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
} catch ( error ) {
|
|
311
|
+
|
|
312
|
+
console.error( 'THREE.WebGLRenderer: ' + error.message );
|
|
313
|
+
throw error;
|
|
273
314
|
|
|
274
315
|
}
|
|
275
316
|
|
|
276
|
-
|
|
317
|
+
let extensions, capabilities, state, info;
|
|
318
|
+
let properties, textures, cubemaps, cubeuvmaps, attributes, geometries, objects;
|
|
319
|
+
let programCache, materials, renderLists, renderStates, clipping, shadowMap;
|
|
277
320
|
|
|
278
|
-
|
|
279
|
-
throw error;
|
|
321
|
+
let background, morphtargets, bufferRenderer, indexedBufferRenderer;
|
|
280
322
|
|
|
281
|
-
|
|
323
|
+
let utils, bindingStates, uniformsGroups;
|
|
282
324
|
|
|
283
|
-
|
|
284
|
-
let properties, textures, cubemaps, cubeuvmaps, attributes, geometries, objects;
|
|
285
|
-
let programCache, materials, renderLists, renderStates, clipping, shadowMap;
|
|
325
|
+
function initGLContext() {
|
|
286
326
|
|
|
287
|
-
|
|
327
|
+
extensions = new WebGLExtensions( _gl );
|
|
288
328
|
|
|
289
|
-
|
|
329
|
+
capabilities = new WebGLCapabilities( _gl, extensions, parameters );
|
|
290
330
|
|
|
291
|
-
|
|
331
|
+
extensions.init( capabilities );
|
|
292
332
|
|
|
293
|
-
|
|
333
|
+
utils = new WebGLUtils( _gl, extensions, capabilities );
|
|
294
334
|
|
|
295
|
-
|
|
335
|
+
state = new WebGLState( _gl, extensions, capabilities );
|
|
296
336
|
|
|
297
|
-
|
|
337
|
+
info = new WebGLInfo( _gl );
|
|
338
|
+
properties = new WebGLProperties();
|
|
339
|
+
textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info );
|
|
340
|
+
cubemaps = new WebGLCubeMaps( _this );
|
|
341
|
+
cubeuvmaps = new WebGLCubeUVMaps( _this );
|
|
342
|
+
attributes = new WebGLAttributes( _gl, capabilities );
|
|
343
|
+
bindingStates = new WebGLBindingStates( _gl, extensions, attributes, capabilities );
|
|
344
|
+
geometries = new WebGLGeometries( _gl, attributes, info, bindingStates );
|
|
345
|
+
objects = new WebGLObjects( _gl, geometries, attributes, info );
|
|
346
|
+
morphtargets = new WebGLMorphtargets( _gl, capabilities, textures );
|
|
347
|
+
clipping = new WebGLClipping( properties );
|
|
348
|
+
programCache = new WebGLPrograms( _this, cubemaps, cubeuvmaps, extensions, capabilities, bindingStates, clipping );
|
|
349
|
+
materials = new WebGLMaterials( _this, properties );
|
|
350
|
+
renderLists = new WebGLRenderLists();
|
|
351
|
+
renderStates = new WebGLRenderStates( extensions, capabilities );
|
|
352
|
+
background = new WebGLBackground( _this, cubemaps, cubeuvmaps, state, objects, _alpha, premultipliedAlpha );
|
|
353
|
+
shadowMap = new WebGLShadowMap( _this, objects, capabilities );
|
|
354
|
+
uniformsGroups = new WebGLUniformsGroups( _gl, info, capabilities, state );
|
|
298
355
|
|
|
299
|
-
|
|
356
|
+
bufferRenderer = new WebGLBufferRenderer( _gl, extensions, info, capabilities );
|
|
357
|
+
indexedBufferRenderer = new WebGLIndexedBufferRenderer( _gl, extensions, info, capabilities );
|
|
300
358
|
|
|
301
|
-
|
|
359
|
+
info.programs = programCache.programs;
|
|
302
360
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
geometries = new WebGLGeometries( _gl, attributes, info, bindingStates );
|
|
311
|
-
objects = new WebGLObjects( _gl, geometries, attributes, info );
|
|
312
|
-
morphtargets = new WebGLMorphtargets( _gl, capabilities, textures );
|
|
313
|
-
clipping = new WebGLClipping( properties );
|
|
314
|
-
programCache = new WebGLPrograms( _this, cubemaps, cubeuvmaps, extensions, capabilities, bindingStates, clipping );
|
|
315
|
-
materials = new WebGLMaterials( _this, properties );
|
|
316
|
-
renderLists = new WebGLRenderLists();
|
|
317
|
-
renderStates = new WebGLRenderStates( extensions, capabilities );
|
|
318
|
-
background = new WebGLBackground( _this, cubemaps, cubeuvmaps, state, objects, _alpha, _premultipliedAlpha );
|
|
319
|
-
shadowMap = new WebGLShadowMap( _this, objects, capabilities );
|
|
320
|
-
uniformsGroups = new WebGLUniformsGroups( _gl, info, capabilities, state );
|
|
361
|
+
_this.capabilities = capabilities;
|
|
362
|
+
_this.extensions = extensions;
|
|
363
|
+
_this.properties = properties;
|
|
364
|
+
_this.renderLists = renderLists;
|
|
365
|
+
_this.shadowMap = shadowMap;
|
|
366
|
+
_this.state = state;
|
|
367
|
+
_this.info = info;
|
|
321
368
|
|
|
322
|
-
|
|
323
|
-
indexedBufferRenderer = new WebGLIndexedBufferRenderer( _gl, extensions, info, capabilities );
|
|
369
|
+
}
|
|
324
370
|
|
|
325
|
-
|
|
371
|
+
initGLContext();
|
|
326
372
|
|
|
327
|
-
|
|
328
|
-
_this.extensions = extensions;
|
|
329
|
-
_this.properties = properties;
|
|
330
|
-
_this.renderLists = renderLists;
|
|
331
|
-
_this.shadowMap = shadowMap;
|
|
332
|
-
_this.state = state;
|
|
333
|
-
_this.info = info;
|
|
373
|
+
// xr
|
|
334
374
|
|
|
335
|
-
|
|
375
|
+
const xr = new WebXRManager( _this, _gl );
|
|
336
376
|
|
|
337
|
-
|
|
377
|
+
this.xr = xr;
|
|
338
378
|
|
|
339
|
-
|
|
379
|
+
// API
|
|
340
380
|
|
|
341
|
-
|
|
381
|
+
this.getContext = function () {
|
|
342
382
|
|
|
343
|
-
|
|
383
|
+
return _gl;
|
|
344
384
|
|
|
345
|
-
|
|
385
|
+
};
|
|
346
386
|
|
|
347
|
-
|
|
387
|
+
this.getContextAttributes = function () {
|
|
348
388
|
|
|
349
|
-
|
|
389
|
+
return _gl.getContextAttributes();
|
|
350
390
|
|
|
351
|
-
|
|
391
|
+
};
|
|
352
392
|
|
|
353
|
-
|
|
393
|
+
this.forceContextLoss = function () {
|
|
354
394
|
|
|
355
|
-
|
|
395
|
+
const extension = extensions.get( 'WEBGL_lose_context' );
|
|
396
|
+
if ( extension ) extension.loseContext();
|
|
356
397
|
|
|
357
|
-
|
|
398
|
+
};
|
|
358
399
|
|
|
359
|
-
|
|
400
|
+
this.forceContextRestore = function () {
|
|
360
401
|
|
|
361
|
-
|
|
362
|
-
|
|
402
|
+
const extension = extensions.get( 'WEBGL_lose_context' );
|
|
403
|
+
if ( extension ) extension.restoreContext();
|
|
363
404
|
|
|
364
|
-
|
|
405
|
+
};
|
|
365
406
|
|
|
366
|
-
|
|
407
|
+
this.getPixelRatio = function () {
|
|
367
408
|
|
|
368
|
-
|
|
369
|
-
if ( extension ) extension.restoreContext();
|
|
409
|
+
return _pixelRatio;
|
|
370
410
|
|
|
371
|
-
|
|
411
|
+
};
|
|
372
412
|
|
|
373
|
-
|
|
413
|
+
this.setPixelRatio = function ( value ) {
|
|
374
414
|
|
|
375
|
-
|
|
415
|
+
if ( value === undefined ) return;
|
|
376
416
|
|
|
377
|
-
|
|
417
|
+
_pixelRatio = value;
|
|
378
418
|
|
|
379
|
-
|
|
419
|
+
this.setSize( _width, _height, false );
|
|
380
420
|
|
|
381
|
-
|
|
421
|
+
};
|
|
382
422
|
|
|
383
|
-
|
|
423
|
+
this.getSize = function ( target ) {
|
|
384
424
|
|
|
385
|
-
|
|
425
|
+
return target.set( _width, _height );
|
|
386
426
|
|
|
387
|
-
|
|
427
|
+
};
|
|
388
428
|
|
|
389
|
-
|
|
429
|
+
this.setSize = function ( width, height, updateStyle = true ) {
|
|
390
430
|
|
|
391
|
-
|
|
431
|
+
if ( xr.isPresenting ) {
|
|
392
432
|
|
|
393
|
-
|
|
433
|
+
console.warn( 'THREE.WebGLRenderer: Can\'t change size while VR device is presenting.' );
|
|
434
|
+
return;
|
|
394
435
|
|
|
395
|
-
|
|
436
|
+
}
|
|
396
437
|
|
|
397
|
-
|
|
438
|
+
_width = width;
|
|
439
|
+
_height = height;
|
|
398
440
|
|
|
399
|
-
|
|
400
|
-
|
|
441
|
+
canvas.width = Math.floor( width * _pixelRatio );
|
|
442
|
+
canvas.height = Math.floor( height * _pixelRatio );
|
|
401
443
|
|
|
402
|
-
|
|
444
|
+
if ( updateStyle === true ) {
|
|
403
445
|
|
|
404
|
-
|
|
405
|
-
|
|
446
|
+
canvas.style.width = width + 'px';
|
|
447
|
+
canvas.style.height = height + 'px';
|
|
406
448
|
|
|
407
|
-
|
|
408
|
-
_canvas.height = Math.floor( height * _pixelRatio );
|
|
449
|
+
}
|
|
409
450
|
|
|
410
|
-
|
|
451
|
+
this.setViewport( 0, 0, width, height );
|
|
411
452
|
|
|
412
|
-
|
|
413
|
-
_canvas.style.height = height + 'px';
|
|
453
|
+
};
|
|
414
454
|
|
|
415
|
-
|
|
455
|
+
this.getDrawingBufferSize = function ( target ) {
|
|
416
456
|
|
|
417
|
-
|
|
457
|
+
return target.set( _width * _pixelRatio, _height * _pixelRatio ).floor();
|
|
418
458
|
|
|
419
|
-
|
|
459
|
+
};
|
|
420
460
|
|
|
421
|
-
|
|
461
|
+
this.setDrawingBufferSize = function ( width, height, pixelRatio ) {
|
|
422
462
|
|
|
423
|
-
|
|
463
|
+
_width = width;
|
|
464
|
+
_height = height;
|
|
424
465
|
|
|
425
|
-
|
|
466
|
+
_pixelRatio = pixelRatio;
|
|
426
467
|
|
|
427
|
-
|
|
468
|
+
canvas.width = Math.floor( width * pixelRatio );
|
|
469
|
+
canvas.height = Math.floor( height * pixelRatio );
|
|
428
470
|
|
|
429
|
-
|
|
430
|
-
_height = height;
|
|
471
|
+
this.setViewport( 0, 0, width, height );
|
|
431
472
|
|
|
432
|
-
|
|
473
|
+
};
|
|
433
474
|
|
|
434
|
-
|
|
435
|
-
_canvas.height = Math.floor( height * pixelRatio );
|
|
475
|
+
this.getCurrentViewport = function ( target ) {
|
|
436
476
|
|
|
437
|
-
|
|
477
|
+
return target.copy( _currentViewport );
|
|
438
478
|
|
|
439
|
-
|
|
479
|
+
};
|
|
440
480
|
|
|
441
|
-
|
|
481
|
+
this.getViewport = function ( target ) {
|
|
442
482
|
|
|
443
|
-
|
|
483
|
+
return target.copy( _viewport );
|
|
444
484
|
|
|
445
|
-
|
|
485
|
+
};
|
|
446
486
|
|
|
447
|
-
|
|
487
|
+
this.setViewport = function ( x, y, width, height ) {
|
|
448
488
|
|
|
449
|
-
|
|
489
|
+
if ( x.isVector4 ) {
|
|
450
490
|
|
|
451
|
-
|
|
491
|
+
_viewport.set( x.x, x.y, x.z, x.w );
|
|
452
492
|
|
|
453
|
-
|
|
493
|
+
} else {
|
|
454
494
|
|
|
455
|
-
|
|
495
|
+
_viewport.set( x, y, width, height );
|
|
456
496
|
|
|
457
|
-
|
|
497
|
+
}
|
|
458
498
|
|
|
459
|
-
|
|
499
|
+
state.viewport( _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).floor() );
|
|
460
500
|
|
|
461
|
-
|
|
501
|
+
};
|
|
462
502
|
|
|
463
|
-
|
|
503
|
+
this.getScissor = function ( target ) {
|
|
504
|
+
|
|
505
|
+
return target.copy( _scissor );
|
|
464
506
|
|
|
465
|
-
|
|
507
|
+
};
|
|
466
508
|
|
|
467
|
-
|
|
509
|
+
this.setScissor = function ( x, y, width, height ) {
|
|
468
510
|
|
|
469
|
-
|
|
511
|
+
if ( x.isVector4 ) {
|
|
470
512
|
|
|
471
|
-
|
|
513
|
+
_scissor.set( x.x, x.y, x.z, x.w );
|
|
472
514
|
|
|
473
|
-
|
|
515
|
+
} else {
|
|
474
516
|
|
|
475
|
-
|
|
517
|
+
_scissor.set( x, y, width, height );
|
|
476
518
|
|
|
477
|
-
|
|
519
|
+
}
|
|
478
520
|
|
|
479
|
-
|
|
521
|
+
state.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).floor() );
|
|
480
522
|
|
|
481
|
-
}
|
|
523
|
+
};
|
|
482
524
|
|
|
483
|
-
|
|
525
|
+
this.getScissorTest = function () {
|
|
484
526
|
|
|
485
|
-
|
|
527
|
+
return _scissorTest;
|
|
486
528
|
|
|
487
|
-
|
|
529
|
+
};
|
|
488
530
|
|
|
489
|
-
|
|
531
|
+
this.setScissorTest = function ( boolean ) {
|
|
490
532
|
|
|
491
|
-
|
|
533
|
+
state.setScissorTest( _scissorTest = boolean );
|
|
492
534
|
|
|
493
|
-
|
|
535
|
+
};
|
|
494
536
|
|
|
495
|
-
|
|
537
|
+
this.setOpaqueSort = function ( method ) {
|
|
496
538
|
|
|
497
|
-
|
|
539
|
+
_opaqueSort = method;
|
|
498
540
|
|
|
499
|
-
|
|
541
|
+
};
|
|
500
542
|
|
|
501
|
-
|
|
543
|
+
this.setTransparentSort = function ( method ) {
|
|
502
544
|
|
|
503
|
-
|
|
545
|
+
_transparentSort = method;
|
|
504
546
|
|
|
505
|
-
|
|
547
|
+
};
|
|
506
548
|
|
|
507
|
-
|
|
549
|
+
// Clearing
|
|
508
550
|
|
|
509
|
-
|
|
551
|
+
this.getClearColor = function ( target ) {
|
|
510
552
|
|
|
511
|
-
|
|
553
|
+
return target.copy( background.getClearColor() );
|
|
512
554
|
|
|
513
|
-
|
|
555
|
+
};
|
|
514
556
|
|
|
515
|
-
|
|
557
|
+
this.setClearColor = function () {
|
|
516
558
|
|
|
517
|
-
|
|
559
|
+
background.setClearColor.apply( background, arguments );
|
|
518
560
|
|
|
519
|
-
|
|
561
|
+
};
|
|
520
562
|
|
|
521
|
-
|
|
563
|
+
this.getClearAlpha = function () {
|
|
522
564
|
|
|
523
|
-
|
|
565
|
+
return background.getClearAlpha();
|
|
524
566
|
|
|
525
|
-
|
|
567
|
+
};
|
|
526
568
|
|
|
527
|
-
|
|
569
|
+
this.setClearAlpha = function () {
|
|
528
570
|
|
|
529
|
-
|
|
571
|
+
background.setClearAlpha.apply( background, arguments );
|
|
530
572
|
|
|
531
|
-
|
|
573
|
+
};
|
|
532
574
|
|
|
533
|
-
|
|
575
|
+
this.clear = function ( color = true, depth = true, stencil = true ) {
|
|
534
576
|
|
|
535
|
-
|
|
577
|
+
let bits = 0;
|
|
536
578
|
|
|
537
|
-
|
|
579
|
+
if ( color ) {
|
|
538
580
|
|
|
539
|
-
|
|
581
|
+
// check if we're trying to clear an integer target
|
|
582
|
+
let isIntegerFormat = false;
|
|
583
|
+
if ( _currentRenderTarget !== null ) {
|
|
540
584
|
|
|
541
|
-
|
|
585
|
+
const targetFormat = _currentRenderTarget.texture.format;
|
|
586
|
+
isIntegerFormat = targetFormat === RGBAIntegerFormat ||
|
|
587
|
+
targetFormat === RGIntegerFormat ||
|
|
588
|
+
targetFormat === RedIntegerFormat;
|
|
542
589
|
|
|
543
|
-
|
|
590
|
+
}
|
|
544
591
|
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
592
|
+
// use the appropriate clear functions to clear the target if it's a signed
|
|
593
|
+
// or unsigned integer target
|
|
594
|
+
if ( isIntegerFormat ) {
|
|
548
595
|
|
|
549
|
-
|
|
596
|
+
const targetType = _currentRenderTarget.texture.type;
|
|
597
|
+
const isUnsignedType = targetType === UnsignedByteType ||
|
|
598
|
+
targetType === UnsignedIntType ||
|
|
599
|
+
targetType === UnsignedShortType ||
|
|
600
|
+
targetType === UnsignedInt248Type ||
|
|
601
|
+
targetType === UnsignedShort4444Type ||
|
|
602
|
+
targetType === UnsignedShort5551Type;
|
|
550
603
|
|
|
551
|
-
|
|
604
|
+
const clearColor = background.getClearColor();
|
|
605
|
+
const a = background.getClearAlpha();
|
|
606
|
+
const r = clearColor.r;
|
|
607
|
+
const g = clearColor.g;
|
|
608
|
+
const b = clearColor.b;
|
|
552
609
|
|
|
553
|
-
|
|
610
|
+
const __webglFramebuffer = properties.get( _currentRenderTarget ).__webglFramebuffer;
|
|
554
611
|
|
|
555
|
-
|
|
612
|
+
if ( isUnsignedType ) {
|
|
556
613
|
|
|
557
|
-
|
|
614
|
+
uintClearColor[ 0 ] = r;
|
|
615
|
+
uintClearColor[ 1 ] = g;
|
|
616
|
+
uintClearColor[ 2 ] = b;
|
|
617
|
+
uintClearColor[ 3 ] = a;
|
|
618
|
+
_gl.clearBufferuiv( _gl.COLOR, __webglFramebuffer, uintClearColor );
|
|
558
619
|
|
|
559
|
-
|
|
620
|
+
} else {
|
|
560
621
|
|
|
561
|
-
|
|
622
|
+
intClearColor[ 0 ] = r;
|
|
623
|
+
intClearColor[ 1 ] = g;
|
|
624
|
+
intClearColor[ 2 ] = b;
|
|
625
|
+
intClearColor[ 3 ] = a;
|
|
626
|
+
_gl.clearBufferiv( _gl.COLOR, __webglFramebuffer, intClearColor );
|
|
562
627
|
|
|
563
|
-
|
|
628
|
+
}
|
|
564
629
|
|
|
565
|
-
|
|
630
|
+
} else {
|
|
566
631
|
|
|
567
|
-
|
|
632
|
+
bits |= _gl.COLOR_BUFFER_BIT;
|
|
568
633
|
|
|
569
|
-
|
|
634
|
+
}
|
|
570
635
|
|
|
571
|
-
|
|
636
|
+
}
|
|
572
637
|
|
|
573
|
-
|
|
638
|
+
if ( depth ) bits |= _gl.DEPTH_BUFFER_BIT;
|
|
639
|
+
if ( stencil ) bits |= _gl.STENCIL_BUFFER_BIT;
|
|
574
640
|
|
|
575
|
-
|
|
576
|
-
_canvas.removeEventListener( 'webglcontextrestored', onContextRestore, false );
|
|
577
|
-
_canvas.removeEventListener( 'webglcontextcreationerror', onContextCreationError, false );
|
|
641
|
+
_gl.clear( bits );
|
|
578
642
|
|
|
579
|
-
|
|
580
|
-
renderStates.dispose();
|
|
581
|
-
properties.dispose();
|
|
582
|
-
cubemaps.dispose();
|
|
583
|
-
cubeuvmaps.dispose();
|
|
584
|
-
objects.dispose();
|
|
585
|
-
bindingStates.dispose();
|
|
586
|
-
uniformsGroups.dispose();
|
|
587
|
-
programCache.dispose();
|
|
643
|
+
};
|
|
588
644
|
|
|
589
|
-
|
|
645
|
+
this.clearColor = function () {
|
|
590
646
|
|
|
591
|
-
|
|
592
|
-
xr.removeEventListener( 'sessionend', onXRSessionEnd );
|
|
647
|
+
this.clear( true, false, false );
|
|
593
648
|
|
|
594
|
-
|
|
649
|
+
};
|
|
595
650
|
|
|
596
|
-
|
|
597
|
-
_transmissionRenderTarget = null;
|
|
651
|
+
this.clearDepth = function () {
|
|
598
652
|
|
|
599
|
-
|
|
653
|
+
this.clear( false, true, false );
|
|
600
654
|
|
|
601
|
-
|
|
655
|
+
};
|
|
602
656
|
|
|
603
|
-
|
|
657
|
+
this.clearStencil = function () {
|
|
604
658
|
|
|
605
|
-
|
|
659
|
+
this.clear( false, false, true );
|
|
606
660
|
|
|
607
|
-
|
|
661
|
+
};
|
|
608
662
|
|
|
609
|
-
|
|
663
|
+
//
|
|
610
664
|
|
|
611
|
-
|
|
665
|
+
this.dispose = function () {
|
|
612
666
|
|
|
613
|
-
|
|
667
|
+
canvas.removeEventListener( 'webglcontextlost', onContextLost, false );
|
|
668
|
+
canvas.removeEventListener( 'webglcontextrestored', onContextRestore, false );
|
|
669
|
+
canvas.removeEventListener( 'webglcontextcreationerror', onContextCreationError, false );
|
|
614
670
|
|
|
615
|
-
|
|
671
|
+
renderLists.dispose();
|
|
672
|
+
renderStates.dispose();
|
|
673
|
+
properties.dispose();
|
|
674
|
+
cubemaps.dispose();
|
|
675
|
+
cubeuvmaps.dispose();
|
|
676
|
+
objects.dispose();
|
|
677
|
+
bindingStates.dispose();
|
|
678
|
+
uniformsGroups.dispose();
|
|
679
|
+
programCache.dispose();
|
|
616
680
|
|
|
617
|
-
|
|
681
|
+
xr.dispose();
|
|
618
682
|
|
|
619
|
-
|
|
683
|
+
xr.removeEventListener( 'sessionstart', onXRSessionStart );
|
|
684
|
+
xr.removeEventListener( 'sessionend', onXRSessionEnd );
|
|
620
685
|
|
|
621
|
-
|
|
686
|
+
if ( _transmissionRenderTarget ) {
|
|
622
687
|
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
const shadowMapAutoUpdate = shadowMap.autoUpdate;
|
|
626
|
-
const shadowMapNeedsUpdate = shadowMap.needsUpdate;
|
|
627
|
-
const shadowMapType = shadowMap.type;
|
|
688
|
+
_transmissionRenderTarget.dispose();
|
|
689
|
+
_transmissionRenderTarget = null;
|
|
628
690
|
|
|
629
|
-
|
|
691
|
+
}
|
|
630
692
|
|
|
631
|
-
|
|
632
|
-
shadowMap.enabled = shadowMapEnabled;
|
|
633
|
-
shadowMap.autoUpdate = shadowMapAutoUpdate;
|
|
634
|
-
shadowMap.needsUpdate = shadowMapNeedsUpdate;
|
|
635
|
-
shadowMap.type = shadowMapType;
|
|
693
|
+
animation.stop();
|
|
636
694
|
|
|
637
|
-
|
|
695
|
+
};
|
|
638
696
|
|
|
639
|
-
|
|
697
|
+
// Events
|
|
640
698
|
|
|
641
|
-
|
|
699
|
+
function onContextLost( event ) {
|
|
642
700
|
|
|
643
|
-
|
|
701
|
+
event.preventDefault();
|
|
644
702
|
|
|
645
|
-
|
|
703
|
+
console.log( 'THREE.WebGLRenderer: Context Lost.' );
|
|
646
704
|
|
|
647
|
-
|
|
705
|
+
_isContextLost = true;
|
|
648
706
|
|
|
649
|
-
|
|
707
|
+
}
|
|
650
708
|
|
|
651
|
-
|
|
709
|
+
function onContextRestore( /* event */ ) {
|
|
652
710
|
|
|
653
|
-
|
|
711
|
+
console.log( 'THREE.WebGLRenderer: Context Restored.' );
|
|
654
712
|
|
|
655
|
-
|
|
713
|
+
_isContextLost = false;
|
|
656
714
|
|
|
657
|
-
|
|
715
|
+
const infoAutoReset = info.autoReset;
|
|
716
|
+
const shadowMapEnabled = shadowMap.enabled;
|
|
717
|
+
const shadowMapAutoUpdate = shadowMap.autoUpdate;
|
|
718
|
+
const shadowMapNeedsUpdate = shadowMap.needsUpdate;
|
|
719
|
+
const shadowMapType = shadowMap.type;
|
|
658
720
|
|
|
659
|
-
|
|
721
|
+
initGLContext();
|
|
660
722
|
|
|
661
|
-
|
|
723
|
+
info.autoReset = infoAutoReset;
|
|
724
|
+
shadowMap.enabled = shadowMapEnabled;
|
|
725
|
+
shadowMap.autoUpdate = shadowMapAutoUpdate;
|
|
726
|
+
shadowMap.needsUpdate = shadowMapNeedsUpdate;
|
|
727
|
+
shadowMap.type = shadowMapType;
|
|
662
728
|
|
|
663
|
-
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
function onContextCreationError( event ) {
|
|
664
732
|
|
|
733
|
+
console.error( 'THREE.WebGLRenderer: A WebGL context could not be created. Reason: ', event.statusMessage );
|
|
665
734
|
|
|
666
|
-
|
|
735
|
+
}
|
|
667
736
|
|
|
668
|
-
|
|
737
|
+
function onMaterialDispose( event ) {
|
|
669
738
|
|
|
670
|
-
|
|
739
|
+
const material = event.target;
|
|
671
740
|
|
|
672
|
-
|
|
741
|
+
material.removeEventListener( 'dispose', onMaterialDispose );
|
|
673
742
|
|
|
674
|
-
|
|
743
|
+
deallocateMaterial( material );
|
|
675
744
|
|
|
676
|
-
|
|
745
|
+
}
|
|
677
746
|
|
|
678
|
-
|
|
747
|
+
// Buffer deallocation
|
|
679
748
|
|
|
680
|
-
|
|
749
|
+
function deallocateMaterial( material ) {
|
|
681
750
|
|
|
682
|
-
|
|
751
|
+
releaseMaterialProgramReferences( material );
|
|
752
|
+
|
|
753
|
+
properties.remove( material );
|
|
683
754
|
|
|
684
755
|
}
|
|
685
756
|
|
|
686
|
-
}
|
|
687
757
|
|
|
688
|
-
|
|
758
|
+
function releaseMaterialProgramReferences( material ) {
|
|
689
759
|
|
|
690
|
-
|
|
760
|
+
const programs = properties.get( material ).programs;
|
|
691
761
|
|
|
692
|
-
|
|
762
|
+
if ( programs !== undefined ) {
|
|
693
763
|
|
|
694
|
-
|
|
764
|
+
programs.forEach( function ( program ) {
|
|
695
765
|
|
|
696
|
-
|
|
766
|
+
programCache.releaseProgram( program );
|
|
697
767
|
|
|
698
|
-
|
|
768
|
+
} );
|
|
699
769
|
|
|
700
|
-
|
|
770
|
+
if ( material.isShaderMaterial ) {
|
|
701
771
|
|
|
702
|
-
|
|
703
|
-
let rangeFactor = 1;
|
|
772
|
+
programCache.releaseShaderCache( material );
|
|
704
773
|
|
|
705
|
-
|
|
774
|
+
}
|
|
706
775
|
|
|
707
|
-
|
|
708
|
-
rangeFactor = 2;
|
|
776
|
+
}
|
|
709
777
|
|
|
710
778
|
}
|
|
711
779
|
|
|
712
|
-
//
|
|
780
|
+
// Buffer rendering
|
|
713
781
|
|
|
714
|
-
|
|
715
|
-
const position = geometry.attributes.position;
|
|
782
|
+
this.renderBufferDirect = function ( camera, scene, geometry, material, object, group ) {
|
|
716
783
|
|
|
717
|
-
|
|
718
|
-
let drawEnd = ( drawRange.start + drawRange.count ) * rangeFactor;
|
|
784
|
+
if ( scene === null ) scene = _emptyScene; // renderBufferDirect second parameter used to be fog (could be null)
|
|
719
785
|
|
|
720
|
-
|
|
786
|
+
const frontFaceCW = ( object.isMesh && object.matrixWorld.determinant() < 0 );
|
|
721
787
|
|
|
722
|
-
|
|
723
|
-
drawEnd = Math.min( drawEnd, ( group.start + group.count ) * rangeFactor );
|
|
788
|
+
const program = setProgram( camera, scene, geometry, material, object );
|
|
724
789
|
|
|
725
|
-
|
|
790
|
+
state.setMaterial( material, frontFaceCW );
|
|
726
791
|
|
|
727
|
-
|
|
792
|
+
//
|
|
728
793
|
|
|
729
|
-
|
|
730
|
-
|
|
794
|
+
let index = geometry.index;
|
|
795
|
+
let rangeFactor = 1;
|
|
731
796
|
|
|
732
|
-
|
|
797
|
+
if ( material.wireframe === true ) {
|
|
733
798
|
|
|
734
|
-
|
|
735
|
-
|
|
799
|
+
index = geometries.getWireframeAttribute( geometry );
|
|
800
|
+
rangeFactor = 2;
|
|
736
801
|
|
|
737
|
-
|
|
802
|
+
}
|
|
738
803
|
|
|
739
|
-
|
|
804
|
+
//
|
|
740
805
|
|
|
741
|
-
|
|
806
|
+
const drawRange = geometry.drawRange;
|
|
807
|
+
const position = geometry.attributes.position;
|
|
742
808
|
|
|
743
|
-
|
|
809
|
+
let drawStart = drawRange.start * rangeFactor;
|
|
810
|
+
let drawEnd = ( drawRange.start + drawRange.count ) * rangeFactor;
|
|
744
811
|
|
|
745
|
-
|
|
812
|
+
if ( group !== null ) {
|
|
746
813
|
|
|
747
|
-
|
|
748
|
-
|
|
814
|
+
drawStart = Math.max( drawStart, group.start * rangeFactor );
|
|
815
|
+
drawEnd = Math.min( drawEnd, ( group.start + group.count ) * rangeFactor );
|
|
749
816
|
|
|
750
|
-
|
|
817
|
+
}
|
|
751
818
|
|
|
752
|
-
|
|
819
|
+
if ( index !== null ) {
|
|
753
820
|
|
|
754
|
-
|
|
755
|
-
|
|
821
|
+
drawStart = Math.max( drawStart, 0 );
|
|
822
|
+
drawEnd = Math.min( drawEnd, index.count );
|
|
756
823
|
|
|
757
|
-
|
|
824
|
+
} else if ( position !== undefined && position !== null ) {
|
|
758
825
|
|
|
759
|
-
|
|
826
|
+
drawStart = Math.max( drawStart, 0 );
|
|
827
|
+
drawEnd = Math.min( drawEnd, position.count );
|
|
760
828
|
|
|
761
|
-
|
|
829
|
+
}
|
|
762
830
|
|
|
763
|
-
|
|
831
|
+
const drawCount = drawEnd - drawStart;
|
|
764
832
|
|
|
765
|
-
|
|
766
|
-
renderer.setMode( _gl.LINES );
|
|
833
|
+
if ( drawCount < 0 || drawCount === Infinity ) return;
|
|
767
834
|
|
|
768
|
-
|
|
835
|
+
//
|
|
769
836
|
|
|
770
|
-
|
|
837
|
+
bindingStates.setup( object, material, program, geometry, index );
|
|
771
838
|
|
|
772
|
-
|
|
839
|
+
let attribute;
|
|
840
|
+
let renderer = bufferRenderer;
|
|
773
841
|
|
|
774
|
-
|
|
842
|
+
if ( index !== null ) {
|
|
775
843
|
|
|
776
|
-
|
|
844
|
+
attribute = attributes.get( index );
|
|
777
845
|
|
|
778
|
-
|
|
846
|
+
renderer = indexedBufferRenderer;
|
|
847
|
+
renderer.setIndex( attribute );
|
|
779
848
|
|
|
780
|
-
|
|
849
|
+
}
|
|
781
850
|
|
|
782
|
-
|
|
851
|
+
//
|
|
783
852
|
|
|
784
|
-
|
|
853
|
+
if ( object.isMesh ) {
|
|
785
854
|
|
|
786
|
-
|
|
855
|
+
if ( material.wireframe === true ) {
|
|
787
856
|
|
|
788
|
-
|
|
857
|
+
state.setLineWidth( material.wireframeLinewidth * getTargetPixelRatio() );
|
|
858
|
+
renderer.setMode( _gl.LINES );
|
|
789
859
|
|
|
790
|
-
|
|
860
|
+
} else {
|
|
791
861
|
|
|
792
|
-
|
|
862
|
+
renderer.setMode( _gl.TRIANGLES );
|
|
793
863
|
|
|
794
|
-
|
|
864
|
+
}
|
|
795
865
|
|
|
796
|
-
|
|
866
|
+
} else if ( object.isLine ) {
|
|
797
867
|
|
|
798
|
-
|
|
868
|
+
let lineWidth = material.linewidth;
|
|
799
869
|
|
|
800
|
-
|
|
870
|
+
if ( lineWidth === undefined ) lineWidth = 1; // Not using Line*Material
|
|
801
871
|
|
|
802
|
-
|
|
872
|
+
state.setLineWidth( lineWidth * getTargetPixelRatio() );
|
|
803
873
|
|
|
804
|
-
|
|
874
|
+
if ( object.isLineSegments ) {
|
|
805
875
|
|
|
806
|
-
|
|
876
|
+
renderer.setMode( _gl.LINES );
|
|
807
877
|
|
|
808
|
-
|
|
878
|
+
} else if ( object.isLineLoop ) {
|
|
809
879
|
|
|
810
|
-
|
|
880
|
+
renderer.setMode( _gl.LINE_LOOP );
|
|
811
881
|
|
|
812
|
-
|
|
813
|
-
const instanceCount = Math.min( geometry.instanceCount, maxInstanceCount );
|
|
882
|
+
} else {
|
|
814
883
|
|
|
815
|
-
|
|
884
|
+
renderer.setMode( _gl.LINE_STRIP );
|
|
816
885
|
|
|
817
|
-
|
|
886
|
+
}
|
|
818
887
|
|
|
819
|
-
|
|
888
|
+
} else if ( object.isPoints ) {
|
|
820
889
|
|
|
821
|
-
|
|
890
|
+
renderer.setMode( _gl.POINTS );
|
|
822
891
|
|
|
823
|
-
|
|
892
|
+
} else if ( object.isSprite ) {
|
|
824
893
|
|
|
825
|
-
|
|
894
|
+
renderer.setMode( _gl.TRIANGLES );
|
|
826
895
|
|
|
827
|
-
|
|
896
|
+
}
|
|
828
897
|
|
|
829
|
-
|
|
898
|
+
if ( object.isInstancedMesh ) {
|
|
830
899
|
|
|
831
|
-
|
|
900
|
+
renderer.renderInstances( drawStart, drawCount, object.count );
|
|
832
901
|
|
|
833
|
-
|
|
834
|
-
material.needsUpdate = true;
|
|
835
|
-
getProgram( material, scene, object );
|
|
902
|
+
} else if ( geometry.isInstancedBufferGeometry ) {
|
|
836
903
|
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
getProgram( material, scene, object );
|
|
904
|
+
const maxInstanceCount = geometry._maxInstanceCount !== undefined ? geometry._maxInstanceCount : Infinity;
|
|
905
|
+
const instanceCount = Math.min( geometry.instanceCount, maxInstanceCount );
|
|
840
906
|
|
|
841
|
-
|
|
907
|
+
renderer.renderInstances( drawStart, drawCount, instanceCount );
|
|
842
908
|
|
|
843
909
|
} else {
|
|
844
910
|
|
|
845
|
-
|
|
911
|
+
renderer.render( drawStart, drawCount );
|
|
846
912
|
|
|
847
913
|
}
|
|
848
914
|
|
|
849
|
-
}
|
|
915
|
+
};
|
|
916
|
+
|
|
917
|
+
// Compile
|
|
850
918
|
|
|
851
|
-
|
|
852
|
-
currentRenderState.init();
|
|
919
|
+
this.compile = function ( scene, camera ) {
|
|
853
920
|
|
|
854
|
-
|
|
921
|
+
function prepare( material, scene, object ) {
|
|
855
922
|
|
|
856
|
-
|
|
923
|
+
if ( material.transparent === true && material.side === DoubleSide && material.forceSinglePass === false ) {
|
|
857
924
|
|
|
858
|
-
|
|
925
|
+
material.side = BackSide;
|
|
926
|
+
material.needsUpdate = true;
|
|
927
|
+
getProgram( material, scene, object );
|
|
859
928
|
|
|
860
|
-
|
|
929
|
+
material.side = FrontSide;
|
|
930
|
+
material.needsUpdate = true;
|
|
931
|
+
getProgram( material, scene, object );
|
|
861
932
|
|
|
862
|
-
|
|
933
|
+
material.side = DoubleSide;
|
|
934
|
+
|
|
935
|
+
} else {
|
|
863
936
|
|
|
864
|
-
|
|
937
|
+
getProgram( material, scene, object );
|
|
865
938
|
|
|
866
939
|
}
|
|
867
940
|
|
|
868
941
|
}
|
|
869
942
|
|
|
870
|
-
|
|
943
|
+
currentRenderState = renderStates.get( scene );
|
|
944
|
+
currentRenderState.init();
|
|
871
945
|
|
|
872
|
-
|
|
946
|
+
renderStateStack.push( currentRenderState );
|
|
873
947
|
|
|
874
|
-
|
|
948
|
+
scene.traverseVisible( function ( object ) {
|
|
875
949
|
|
|
876
|
-
|
|
950
|
+
if ( object.isLight && object.layers.test( camera.layers ) ) {
|
|
877
951
|
|
|
878
|
-
|
|
952
|
+
currentRenderState.pushLight( object );
|
|
879
953
|
|
|
880
|
-
|
|
954
|
+
if ( object.castShadow ) {
|
|
881
955
|
|
|
882
|
-
|
|
956
|
+
currentRenderState.pushShadow( object );
|
|
883
957
|
|
|
884
|
-
|
|
958
|
+
}
|
|
885
959
|
|
|
886
|
-
|
|
960
|
+
}
|
|
887
961
|
|
|
888
|
-
|
|
962
|
+
} );
|
|
889
963
|
|
|
890
|
-
|
|
964
|
+
currentRenderState.setupLights( _this.useLegacyLights );
|
|
891
965
|
|
|
892
|
-
|
|
966
|
+
scene.traverse( function ( object ) {
|
|
893
967
|
|
|
894
|
-
|
|
968
|
+
const material = object.material;
|
|
895
969
|
|
|
896
|
-
|
|
970
|
+
if ( material ) {
|
|
897
971
|
|
|
898
|
-
|
|
972
|
+
if ( Array.isArray( material ) ) {
|
|
899
973
|
|
|
900
|
-
|
|
901
|
-
currentRenderState = null;
|
|
974
|
+
for ( let i = 0; i < material.length; i ++ ) {
|
|
902
975
|
|
|
903
|
-
|
|
976
|
+
const material2 = material[ i ];
|
|
904
977
|
|
|
905
|
-
|
|
978
|
+
prepare( material2, scene, object );
|
|
906
979
|
|
|
907
|
-
|
|
980
|
+
}
|
|
908
981
|
|
|
909
|
-
|
|
982
|
+
} else {
|
|
910
983
|
|
|
911
|
-
|
|
984
|
+
prepare( material, scene, object );
|
|
912
985
|
|
|
913
|
-
|
|
986
|
+
}
|
|
914
987
|
|
|
915
|
-
|
|
988
|
+
}
|
|
916
989
|
|
|
917
|
-
|
|
990
|
+
} );
|
|
918
991
|
|
|
919
|
-
|
|
992
|
+
renderStateStack.pop();
|
|
993
|
+
currentRenderState = null;
|
|
920
994
|
|
|
921
|
-
|
|
995
|
+
};
|
|
922
996
|
|
|
923
|
-
|
|
997
|
+
// Animation Loop
|
|
924
998
|
|
|
925
|
-
|
|
999
|
+
let onAnimationFrameCallback = null;
|
|
926
1000
|
|
|
927
|
-
|
|
928
|
-
animation.setAnimationLoop( onAnimationFrame );
|
|
1001
|
+
function onAnimationFrame( time ) {
|
|
929
1002
|
|
|
930
|
-
|
|
1003
|
+
if ( onAnimationFrameCallback ) onAnimationFrameCallback( time );
|
|
931
1004
|
|
|
932
|
-
|
|
1005
|
+
}
|
|
933
1006
|
|
|
934
|
-
|
|
935
|
-
xr.setAnimationLoop( callback );
|
|
1007
|
+
function onXRSessionStart() {
|
|
936
1008
|
|
|
937
|
-
|
|
1009
|
+
animation.stop();
|
|
938
1010
|
|
|
939
|
-
|
|
1011
|
+
}
|
|
940
1012
|
|
|
941
|
-
|
|
942
|
-
xr.addEventListener( 'sessionend', onXRSessionEnd );
|
|
1013
|
+
function onXRSessionEnd() {
|
|
943
1014
|
|
|
944
|
-
|
|
1015
|
+
animation.start();
|
|
945
1016
|
|
|
946
|
-
|
|
1017
|
+
}
|
|
947
1018
|
|
|
948
|
-
|
|
1019
|
+
const animation = new WebGLAnimation();
|
|
1020
|
+
animation.setAnimationLoop( onAnimationFrame );
|
|
949
1021
|
|
|
950
|
-
|
|
951
|
-
return;
|
|
1022
|
+
if ( typeof self !== 'undefined' ) animation.setContext( self );
|
|
952
1023
|
|
|
953
|
-
|
|
1024
|
+
this.setAnimationLoop = function ( callback ) {
|
|
954
1025
|
|
|
955
|
-
|
|
1026
|
+
onAnimationFrameCallback = callback;
|
|
1027
|
+
xr.setAnimationLoop( callback );
|
|
956
1028
|
|
|
957
|
-
|
|
1029
|
+
( callback === null ) ? animation.stop() : animation.start();
|
|
958
1030
|
|
|
959
|
-
|
|
1031
|
+
};
|
|
960
1032
|
|
|
961
|
-
|
|
1033
|
+
xr.addEventListener( 'sessionstart', onXRSessionStart );
|
|
1034
|
+
xr.addEventListener( 'sessionend', onXRSessionEnd );
|
|
962
1035
|
|
|
963
|
-
|
|
1036
|
+
// Rendering
|
|
964
1037
|
|
|
965
|
-
|
|
1038
|
+
this.render = function ( scene, camera ) {
|
|
966
1039
|
|
|
967
|
-
if (
|
|
1040
|
+
if ( camera !== undefined && camera.isCamera !== true ) {
|
|
968
1041
|
|
|
969
|
-
|
|
1042
|
+
console.error( 'THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.' );
|
|
1043
|
+
return;
|
|
970
1044
|
|
|
971
|
-
|
|
1045
|
+
}
|
|
972
1046
|
|
|
973
|
-
|
|
974
|
-
if ( scene.isScene === true ) scene.onBeforeRender( _this, scene, camera, _currentRenderTarget );
|
|
1047
|
+
if ( _isContextLost === true ) return;
|
|
975
1048
|
|
|
976
|
-
|
|
977
|
-
currentRenderState.init();
|
|
1049
|
+
// update scene graph
|
|
978
1050
|
|
|
979
|
-
|
|
1051
|
+
if ( scene.matrixWorldAutoUpdate === true ) scene.updateMatrixWorld();
|
|
980
1052
|
|
|
981
|
-
|
|
982
|
-
_frustum.setFromProjectionMatrix( _projScreenMatrix );
|
|
1053
|
+
// update camera matrices and frustum
|
|
983
1054
|
|
|
984
|
-
|
|
985
|
-
_clippingEnabled = clipping.init( this.clippingPlanes, _localClippingEnabled, camera );
|
|
1055
|
+
if ( camera.parent === null && camera.matrixWorldAutoUpdate === true ) camera.updateMatrixWorld();
|
|
986
1056
|
|
|
987
|
-
|
|
988
|
-
currentRenderList.init();
|
|
1057
|
+
if ( xr.enabled === true && xr.isPresenting === true ) {
|
|
989
1058
|
|
|
990
|
-
|
|
1059
|
+
camera = xr.updateCameraXR( camera ); // use XR camera for rendering
|
|
991
1060
|
|
|
992
|
-
|
|
1061
|
+
}
|
|
993
1062
|
|
|
994
|
-
|
|
1063
|
+
//
|
|
1064
|
+
if ( scene.isScene === true ) scene.onBeforeRender( _this, scene, camera, _currentRenderTarget );
|
|
995
1065
|
|
|
996
|
-
|
|
1066
|
+
currentRenderState = renderStates.get( scene, renderStateStack.length );
|
|
1067
|
+
currentRenderState.init();
|
|
997
1068
|
|
|
998
|
-
|
|
1069
|
+
renderStateStack.push( currentRenderState );
|
|
999
1070
|
|
|
1000
|
-
|
|
1071
|
+
_projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
|
|
1072
|
+
_frustum.setFromProjectionMatrix( _projScreenMatrix );
|
|
1001
1073
|
|
|
1002
|
-
|
|
1074
|
+
_localClippingEnabled = this.localClippingEnabled;
|
|
1075
|
+
_clippingEnabled = clipping.init( this.clippingPlanes, _localClippingEnabled );
|
|
1003
1076
|
|
|
1004
|
-
|
|
1077
|
+
currentRenderList = renderLists.get( scene, renderListStack.length );
|
|
1078
|
+
currentRenderList.init();
|
|
1005
1079
|
|
|
1006
|
-
|
|
1080
|
+
renderListStack.push( currentRenderList );
|
|
1007
1081
|
|
|
1008
|
-
|
|
1082
|
+
projectObject( scene, camera, 0, _this.sortObjects );
|
|
1009
1083
|
|
|
1010
|
-
|
|
1084
|
+
currentRenderList.finish();
|
|
1011
1085
|
|
|
1012
|
-
|
|
1086
|
+
if ( _this.sortObjects === true ) {
|
|
1013
1087
|
|
|
1014
|
-
|
|
1088
|
+
currentRenderList.sort( _opaqueSort, _transparentSort );
|
|
1015
1089
|
|
|
1016
|
-
|
|
1090
|
+
}
|
|
1017
1091
|
|
|
1018
|
-
|
|
1092
|
+
//
|
|
1019
1093
|
|
|
1020
|
-
|
|
1094
|
+
if ( _clippingEnabled === true ) clipping.beginShadows();
|
|
1021
1095
|
|
|
1022
|
-
|
|
1096
|
+
const shadowsArray = currentRenderState.state.shadowsArray;
|
|
1023
1097
|
|
|
1024
|
-
|
|
1098
|
+
shadowMap.render( shadowsArray, scene, camera );
|
|
1025
1099
|
|
|
1026
|
-
|
|
1100
|
+
if ( _clippingEnabled === true ) clipping.endShadows();
|
|
1027
1101
|
|
|
1028
|
-
|
|
1102
|
+
//
|
|
1029
1103
|
|
|
1030
|
-
|
|
1104
|
+
if ( this.info.autoReset === true ) this.info.reset();
|
|
1031
1105
|
|
|
1032
|
-
|
|
1106
|
+
this.info.render.frame ++;
|
|
1033
1107
|
|
|
1034
|
-
|
|
1108
|
+
//
|
|
1035
1109
|
|
|
1036
|
-
|
|
1110
|
+
background.render( currentRenderList, scene );
|
|
1037
1111
|
|
|
1038
|
-
|
|
1112
|
+
// render scene
|
|
1039
1113
|
|
|
1040
|
-
|
|
1114
|
+
currentRenderState.setupLights( _this.useLegacyLights );
|
|
1041
1115
|
|
|
1042
|
-
|
|
1116
|
+
if ( camera.isArrayCamera ) {
|
|
1043
1117
|
|
|
1044
|
-
|
|
1118
|
+
const cameras = camera.cameras;
|
|
1045
1119
|
|
|
1046
|
-
|
|
1120
|
+
for ( let i = 0, l = cameras.length; i < l; i ++ ) {
|
|
1047
1121
|
|
|
1048
|
-
|
|
1122
|
+
const camera2 = cameras[ i ];
|
|
1049
1123
|
|
|
1050
|
-
|
|
1124
|
+
renderScene( currentRenderList, scene, camera2, camera2.viewport );
|
|
1051
1125
|
|
|
1052
|
-
|
|
1126
|
+
}
|
|
1053
1127
|
|
|
1054
|
-
|
|
1128
|
+
} else {
|
|
1055
1129
|
|
|
1056
|
-
|
|
1130
|
+
renderScene( currentRenderList, scene, camera );
|
|
1057
1131
|
|
|
1058
|
-
|
|
1132
|
+
}
|
|
1059
1133
|
|
|
1060
|
-
|
|
1134
|
+
//
|
|
1061
1135
|
|
|
1062
|
-
|
|
1063
|
-
_currentMaterialId = - 1;
|
|
1064
|
-
_currentCamera = null;
|
|
1136
|
+
if ( _currentRenderTarget !== null ) {
|
|
1065
1137
|
|
|
1066
|
-
|
|
1138
|
+
// resolve multisample renderbuffers to a single-sample texture if necessary
|
|
1067
1139
|
|
|
1068
|
-
|
|
1140
|
+
textures.updateMultisampleRenderTarget( _currentRenderTarget );
|
|
1069
1141
|
|
|
1070
|
-
|
|
1142
|
+
// Generate mipmap if we're using any kind of mipmap filtering
|
|
1071
1143
|
|
|
1072
|
-
|
|
1144
|
+
textures.updateRenderTargetMipmap( _currentRenderTarget );
|
|
1073
1145
|
|
|
1074
|
-
|
|
1146
|
+
}
|
|
1075
1147
|
|
|
1076
|
-
|
|
1148
|
+
//
|
|
1077
1149
|
|
|
1078
|
-
|
|
1150
|
+
if ( scene.isScene === true ) scene.onAfterRender( _this, scene, camera );
|
|
1079
1151
|
|
|
1080
|
-
|
|
1152
|
+
// _gl.finish();
|
|
1081
1153
|
|
|
1082
|
-
|
|
1154
|
+
bindingStates.resetDefaultState();
|
|
1155
|
+
_currentMaterialId = - 1;
|
|
1156
|
+
_currentCamera = null;
|
|
1083
1157
|
|
|
1084
|
-
|
|
1158
|
+
renderStateStack.pop();
|
|
1085
1159
|
|
|
1086
|
-
|
|
1160
|
+
if ( renderStateStack.length > 0 ) {
|
|
1087
1161
|
|
|
1088
|
-
|
|
1162
|
+
currentRenderState = renderStateStack[ renderStateStack.length - 1 ];
|
|
1089
1163
|
|
|
1090
|
-
|
|
1164
|
+
} else {
|
|
1091
1165
|
|
|
1092
|
-
|
|
1166
|
+
currentRenderState = null;
|
|
1093
1167
|
|
|
1094
|
-
|
|
1168
|
+
}
|
|
1095
1169
|
|
|
1096
|
-
|
|
1170
|
+
renderListStack.pop();
|
|
1097
1171
|
|
|
1098
|
-
|
|
1172
|
+
if ( renderListStack.length > 0 ) {
|
|
1099
1173
|
|
|
1100
|
-
|
|
1174
|
+
currentRenderList = renderListStack[ renderListStack.length - 1 ];
|
|
1101
1175
|
|
|
1102
|
-
|
|
1176
|
+
} else {
|
|
1103
1177
|
|
|
1104
|
-
|
|
1178
|
+
currentRenderList = null;
|
|
1105
1179
|
|
|
1106
|
-
|
|
1180
|
+
}
|
|
1107
1181
|
|
|
1108
|
-
|
|
1182
|
+
};
|
|
1109
1183
|
|
|
1110
|
-
|
|
1184
|
+
function projectObject( object, camera, groupOrder, sortObjects ) {
|
|
1111
1185
|
|
|
1112
|
-
|
|
1186
|
+
if ( object.visible === false ) return;
|
|
1113
1187
|
|
|
1114
|
-
|
|
1188
|
+
const visible = object.layers.test( camera.layers );
|
|
1115
1189
|
|
|
1116
|
-
|
|
1190
|
+
if ( visible ) {
|
|
1117
1191
|
|
|
1118
|
-
|
|
1192
|
+
if ( object.isGroup ) {
|
|
1119
1193
|
|
|
1120
|
-
|
|
1194
|
+
groupOrder = object.renderOrder;
|
|
1121
1195
|
|
|
1122
|
-
|
|
1196
|
+
} else if ( object.isLOD ) {
|
|
1123
1197
|
|
|
1124
|
-
|
|
1125
|
-
.applyMatrix4( _projScreenMatrix );
|
|
1198
|
+
if ( object.autoUpdate === true ) object.update( camera );
|
|
1126
1199
|
|
|
1127
|
-
|
|
1200
|
+
} else if ( object.isLight ) {
|
|
1128
1201
|
|
|
1129
|
-
|
|
1130
|
-
const material = object.material;
|
|
1202
|
+
currentRenderState.pushLight( object );
|
|
1131
1203
|
|
|
1132
|
-
if (
|
|
1204
|
+
if ( object.castShadow ) {
|
|
1133
1205
|
|
|
1134
|
-
|
|
1206
|
+
currentRenderState.pushShadow( object );
|
|
1135
1207
|
|
|
1136
1208
|
}
|
|
1137
1209
|
|
|
1138
|
-
}
|
|
1210
|
+
} else if ( object.isSprite ) {
|
|
1211
|
+
|
|
1212
|
+
if ( ! object.frustumCulled || _frustum.intersectsSprite( object ) ) {
|
|
1139
1213
|
|
|
1140
|
-
|
|
1214
|
+
if ( sortObjects ) {
|
|
1215
|
+
|
|
1216
|
+
_vector3.setFromMatrixPosition( object.matrixWorld )
|
|
1217
|
+
.applyMatrix4( _projScreenMatrix );
|
|
1218
|
+
|
|
1219
|
+
}
|
|
1141
1220
|
|
|
1142
|
-
|
|
1221
|
+
const geometry = objects.update( object );
|
|
1222
|
+
const material = object.material;
|
|
1143
1223
|
|
|
1144
|
-
|
|
1224
|
+
if ( material.visible ) {
|
|
1145
1225
|
|
|
1146
|
-
|
|
1226
|
+
currentRenderList.push( object, geometry, material, groupOrder, _vector3.z, null );
|
|
1147
1227
|
|
|
1148
|
-
|
|
1149
|
-
object.skeleton.frame = info.render.frame;
|
|
1228
|
+
}
|
|
1150
1229
|
|
|
1151
1230
|
}
|
|
1152
1231
|
|
|
1153
|
-
}
|
|
1232
|
+
} else if ( object.isMesh || object.isLine || object.isPoints ) {
|
|
1154
1233
|
|
|
1155
|
-
|
|
1234
|
+
if ( ! object.frustumCulled || _frustum.intersectsObject( object ) ) {
|
|
1156
1235
|
|
|
1157
|
-
|
|
1236
|
+
if ( object.isSkinnedMesh ) {
|
|
1158
1237
|
|
|
1159
|
-
|
|
1160
|
-
.applyMatrix4( _projScreenMatrix );
|
|
1238
|
+
// update skeleton only once in a frame
|
|
1161
1239
|
|
|
1162
|
-
|
|
1240
|
+
if ( object.skeleton.frame !== info.render.frame ) {
|
|
1163
1241
|
|
|
1164
|
-
|
|
1165
|
-
|
|
1242
|
+
object.skeleton.update();
|
|
1243
|
+
object.skeleton.frame = info.render.frame;
|
|
1166
1244
|
|
|
1167
|
-
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
}
|
|
1168
1248
|
|
|
1169
|
-
const
|
|
1249
|
+
const geometry = objects.update( object );
|
|
1250
|
+
const material = object.material;
|
|
1170
1251
|
|
|
1171
|
-
|
|
1252
|
+
if ( sortObjects ) {
|
|
1172
1253
|
|
|
1173
|
-
|
|
1174
|
-
const groupMaterial = material[ group.materialIndex ];
|
|
1254
|
+
if ( object.boundingSphere !== undefined ) {
|
|
1175
1255
|
|
|
1176
|
-
|
|
1256
|
+
if ( object.boundingSphere === null ) object.computeBoundingSphere();
|
|
1257
|
+
_vector3.copy( object.boundingSphere.center );
|
|
1177
1258
|
|
|
1178
|
-
|
|
1259
|
+
} else {
|
|
1260
|
+
|
|
1261
|
+
if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
|
|
1262
|
+
_vector3.copy( geometry.boundingSphere.center );
|
|
1179
1263
|
|
|
1180
1264
|
}
|
|
1181
1265
|
|
|
1266
|
+
_vector3
|
|
1267
|
+
.applyMatrix4( object.matrixWorld )
|
|
1268
|
+
.applyMatrix4( _projScreenMatrix );
|
|
1269
|
+
|
|
1182
1270
|
}
|
|
1183
1271
|
|
|
1184
|
-
|
|
1272
|
+
if ( Array.isArray( material ) ) {
|
|
1273
|
+
|
|
1274
|
+
const groups = geometry.groups;
|
|
1275
|
+
|
|
1276
|
+
for ( let i = 0, l = groups.length; i < l; i ++ ) {
|
|
1277
|
+
|
|
1278
|
+
const group = groups[ i ];
|
|
1279
|
+
const groupMaterial = material[ group.materialIndex ];
|
|
1280
|
+
|
|
1281
|
+
if ( groupMaterial && groupMaterial.visible ) {
|
|
1282
|
+
|
|
1283
|
+
currentRenderList.push( object, geometry, groupMaterial, groupOrder, _vector3.z, group );
|
|
1185
1284
|
|
|
1186
|
-
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
} else if ( material.visible ) {
|
|
1290
|
+
|
|
1291
|
+
currentRenderList.push( object, geometry, material, groupOrder, _vector3.z, null );
|
|
1292
|
+
|
|
1293
|
+
}
|
|
1187
1294
|
|
|
1188
1295
|
}
|
|
1189
1296
|
|
|
@@ -1191,1064 +1298,1154 @@ function WebGLRenderer( parameters = {} ) {
|
|
|
1191
1298
|
|
|
1192
1299
|
}
|
|
1193
1300
|
|
|
1194
|
-
|
|
1301
|
+
const children = object.children;
|
|
1195
1302
|
|
|
1196
|
-
|
|
1303
|
+
for ( let i = 0, l = children.length; i < l; i ++ ) {
|
|
1197
1304
|
|
|
1198
|
-
|
|
1305
|
+
projectObject( children[ i ], camera, groupOrder, sortObjects );
|
|
1199
1306
|
|
|
1200
|
-
|
|
1307
|
+
}
|
|
1201
1308
|
|
|
1202
1309
|
}
|
|
1203
1310
|
|
|
1204
|
-
|
|
1311
|
+
function renderScene( currentRenderList, scene, camera, viewport ) {
|
|
1205
1312
|
|
|
1206
|
-
|
|
1313
|
+
const opaqueObjects = currentRenderList.opaque;
|
|
1314
|
+
const transmissiveObjects = currentRenderList.transmissive;
|
|
1315
|
+
const transparentObjects = currentRenderList.transparent;
|
|
1207
1316
|
|
|
1208
|
-
|
|
1209
|
-
const transmissiveObjects = currentRenderList.transmissive;
|
|
1210
|
-
const transparentObjects = currentRenderList.transparent;
|
|
1317
|
+
currentRenderState.setupLightsView( camera );
|
|
1211
1318
|
|
|
1212
|
-
|
|
1319
|
+
if ( _clippingEnabled === true ) clipping.setGlobalState( _this.clippingPlanes, camera );
|
|
1213
1320
|
|
|
1214
|
-
|
|
1321
|
+
if ( transmissiveObjects.length > 0 ) renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera );
|
|
1215
1322
|
|
|
1216
|
-
|
|
1323
|
+
if ( viewport ) state.viewport( _currentViewport.copy( viewport ) );
|
|
1217
1324
|
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1325
|
+
if ( opaqueObjects.length > 0 ) renderObjects( opaqueObjects, scene, camera );
|
|
1326
|
+
if ( transmissiveObjects.length > 0 ) renderObjects( transmissiveObjects, scene, camera );
|
|
1327
|
+
if ( transparentObjects.length > 0 ) renderObjects( transparentObjects, scene, camera );
|
|
1221
1328
|
|
|
1222
|
-
|
|
1329
|
+
// Ensure depth buffer writing is enabled so it can be cleared on next render
|
|
1223
1330
|
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1331
|
+
state.buffers.depth.setTest( true );
|
|
1332
|
+
state.buffers.depth.setMask( true );
|
|
1333
|
+
state.buffers.color.setMask( true );
|
|
1227
1334
|
|
|
1228
|
-
|
|
1335
|
+
state.setPolygonOffset( false );
|
|
1229
1336
|
|
|
1230
|
-
|
|
1337
|
+
}
|
|
1231
1338
|
|
|
1232
|
-
|
|
1339
|
+
function renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera ) {
|
|
1233
1340
|
|
|
1234
|
-
|
|
1341
|
+
const isWebGL2 = capabilities.isWebGL2;
|
|
1235
1342
|
|
|
1236
|
-
|
|
1343
|
+
if ( _transmissionRenderTarget === null ) {
|
|
1237
1344
|
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1345
|
+
_transmissionRenderTarget = new WebGLRenderTarget( 1, 1, {
|
|
1346
|
+
generateMipmaps: true,
|
|
1347
|
+
type: extensions.has( 'EXT_color_buffer_half_float' ) ? HalfFloatType : UnsignedByteType,
|
|
1348
|
+
minFilter: LinearMipmapLinearFilter,
|
|
1349
|
+
samples: ( isWebGL2 && antialias === true ) ? 4 : 0
|
|
1350
|
+
} );
|
|
1244
1351
|
|
|
1245
|
-
|
|
1352
|
+
// debug
|
|
1246
1353
|
|
|
1247
|
-
|
|
1354
|
+
/*
|
|
1355
|
+
const geometry = new PlaneGeometry();
|
|
1356
|
+
const material = new MeshBasicMaterial( { map: _transmissionRenderTarget.texture } );
|
|
1248
1357
|
|
|
1249
|
-
|
|
1358
|
+
const mesh = new Mesh( geometry, material );
|
|
1359
|
+
scene.add( mesh );
|
|
1360
|
+
*/
|
|
1250
1361
|
|
|
1251
|
-
|
|
1362
|
+
}
|
|
1252
1363
|
|
|
1253
|
-
|
|
1364
|
+
_this.getDrawingBufferSize( _vector2 );
|
|
1254
1365
|
|
|
1255
|
-
|
|
1366
|
+
if ( isWebGL2 ) {
|
|
1256
1367
|
|
|
1257
|
-
|
|
1368
|
+
_transmissionRenderTarget.setSize( _vector2.x, _vector2.y );
|
|
1258
1369
|
|
|
1259
|
-
|
|
1370
|
+
} else {
|
|
1260
1371
|
|
|
1261
|
-
|
|
1262
|
-
_this.setRenderTarget( _transmissionRenderTarget );
|
|
1263
|
-
_this.clear();
|
|
1372
|
+
_transmissionRenderTarget.setSize( floorPowerOfTwo( _vector2.x ), floorPowerOfTwo( _vector2.y ) );
|
|
1264
1373
|
|
|
1265
|
-
|
|
1266
|
-
// Otherwise they are applied twice in opaque objects pass and transmission objects pass.
|
|
1267
|
-
const currentToneMapping = _this.toneMapping;
|
|
1268
|
-
_this.toneMapping = NoToneMapping;
|
|
1374
|
+
}
|
|
1269
1375
|
|
|
1270
|
-
|
|
1376
|
+
//
|
|
1271
1377
|
|
|
1272
|
-
|
|
1378
|
+
const currentRenderTarget = _this.getRenderTarget();
|
|
1379
|
+
_this.setRenderTarget( _transmissionRenderTarget );
|
|
1273
1380
|
|
|
1274
|
-
|
|
1275
|
-
|
|
1381
|
+
_this.getClearColor( _currentClearColor );
|
|
1382
|
+
_currentClearAlpha = _this.getClearAlpha();
|
|
1383
|
+
if ( _currentClearAlpha < 1 ) _this.setClearColor( 0xffffff, 0.5 );
|
|
1276
1384
|
|
|
1277
|
-
|
|
1385
|
+
_this.clear();
|
|
1278
1386
|
|
|
1279
|
-
|
|
1387
|
+
// Turn off the features which can affect the frag color for opaque objects pass.
|
|
1388
|
+
// Otherwise they are applied twice in opaque objects pass and transmission objects pass.
|
|
1389
|
+
const currentToneMapping = _this.toneMapping;
|
|
1390
|
+
_this.toneMapping = NoToneMapping;
|
|
1280
1391
|
|
|
1281
|
-
|
|
1392
|
+
renderObjects( opaqueObjects, scene, camera );
|
|
1282
1393
|
|
|
1283
|
-
|
|
1394
|
+
textures.updateMultisampleRenderTarget( _transmissionRenderTarget );
|
|
1395
|
+
textures.updateRenderTargetMipmap( _transmissionRenderTarget );
|
|
1284
1396
|
|
|
1285
|
-
|
|
1397
|
+
let renderTargetNeedsUpdate = false;
|
|
1286
1398
|
|
|
1287
|
-
|
|
1399
|
+
for ( let i = 0, l = transmissiveObjects.length; i < l; i ++ ) {
|
|
1288
1400
|
|
|
1289
|
-
|
|
1290
|
-
const geometry = renderItem.geometry;
|
|
1291
|
-
const material = overrideMaterial === null ? renderItem.material : overrideMaterial;
|
|
1292
|
-
const group = renderItem.group;
|
|
1401
|
+
const renderItem = transmissiveObjects[ i ];
|
|
1293
1402
|
|
|
1294
|
-
|
|
1403
|
+
const object = renderItem.object;
|
|
1404
|
+
const geometry = renderItem.geometry;
|
|
1405
|
+
const material = renderItem.material;
|
|
1406
|
+
const group = renderItem.group;
|
|
1295
1407
|
|
|
1296
|
-
|
|
1408
|
+
if ( material.side === DoubleSide && object.layers.test( camera.layers ) ) {
|
|
1297
1409
|
|
|
1298
|
-
|
|
1410
|
+
const currentSide = material.side;
|
|
1299
1411
|
|
|
1300
|
-
|
|
1412
|
+
material.side = BackSide;
|
|
1413
|
+
material.needsUpdate = true;
|
|
1301
1414
|
|
|
1302
|
-
|
|
1415
|
+
renderObject( object, scene, camera, geometry, material, group );
|
|
1303
1416
|
|
|
1304
|
-
|
|
1417
|
+
material.side = currentSide;
|
|
1418
|
+
material.needsUpdate = true;
|
|
1305
1419
|
|
|
1306
|
-
|
|
1420
|
+
renderTargetNeedsUpdate = true;
|
|
1307
1421
|
|
|
1308
|
-
|
|
1309
|
-
object.normalMatrix.getNormalMatrix( object.modelViewMatrix );
|
|
1422
|
+
}
|
|
1310
1423
|
|
|
1311
|
-
|
|
1424
|
+
}
|
|
1312
1425
|
|
|
1313
|
-
|
|
1426
|
+
if ( renderTargetNeedsUpdate === true ) {
|
|
1314
1427
|
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
_this.renderBufferDirect( camera, scene, geometry, material, object, group );
|
|
1428
|
+
textures.updateMultisampleRenderTarget( _transmissionRenderTarget );
|
|
1429
|
+
textures.updateRenderTargetMipmap( _transmissionRenderTarget );
|
|
1318
1430
|
|
|
1319
|
-
|
|
1320
|
-
material.needsUpdate = true;
|
|
1321
|
-
_this.renderBufferDirect( camera, scene, geometry, material, object, group );
|
|
1431
|
+
}
|
|
1322
1432
|
|
|
1323
|
-
|
|
1433
|
+
_this.setRenderTarget( currentRenderTarget );
|
|
1324
1434
|
|
|
1325
|
-
|
|
1435
|
+
_this.setClearColor( _currentClearColor, _currentClearAlpha );
|
|
1326
1436
|
|
|
1327
|
-
_this.
|
|
1437
|
+
_this.toneMapping = currentToneMapping;
|
|
1328
1438
|
|
|
1329
1439
|
}
|
|
1330
1440
|
|
|
1331
|
-
|
|
1441
|
+
function renderObjects( renderList, scene, camera ) {
|
|
1332
1442
|
|
|
1333
|
-
|
|
1443
|
+
const overrideMaterial = scene.isScene === true ? scene.overrideMaterial : null;
|
|
1334
1444
|
|
|
1335
|
-
|
|
1445
|
+
for ( let i = 0, l = renderList.length; i < l; i ++ ) {
|
|
1336
1446
|
|
|
1337
|
-
|
|
1447
|
+
const renderItem = renderList[ i ];
|
|
1338
1448
|
|
|
1339
|
-
|
|
1449
|
+
const object = renderItem.object;
|
|
1450
|
+
const geometry = renderItem.geometry;
|
|
1451
|
+
const material = overrideMaterial === null ? renderItem.material : overrideMaterial;
|
|
1452
|
+
const group = renderItem.group;
|
|
1340
1453
|
|
|
1341
|
-
|
|
1342
|
-
const shadowsArray = currentRenderState.state.shadowsArray;
|
|
1454
|
+
if ( object.layers.test( camera.layers ) ) {
|
|
1343
1455
|
|
|
1344
|
-
|
|
1456
|
+
renderObject( object, scene, camera, geometry, material, group );
|
|
1345
1457
|
|
|
1346
|
-
|
|
1347
|
-
const programCacheKey = programCache.getProgramCacheKey( parameters );
|
|
1458
|
+
}
|
|
1348
1459
|
|
|
1349
|
-
|
|
1460
|
+
}
|
|
1350
1461
|
|
|
1351
|
-
|
|
1462
|
+
}
|
|
1352
1463
|
|
|
1353
|
-
|
|
1354
|
-
materialProperties.fog = scene.fog;
|
|
1355
|
-
materialProperties.envMap = ( material.isMeshStandardMaterial ? cubeuvmaps : cubemaps ).get( material.envMap || materialProperties.environment );
|
|
1464
|
+
function renderObject( object, scene, camera, geometry, material, group ) {
|
|
1356
1465
|
|
|
1357
|
-
|
|
1466
|
+
object.onBeforeRender( _this, scene, camera, geometry, material, group );
|
|
1358
1467
|
|
|
1359
|
-
|
|
1468
|
+
object.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld );
|
|
1469
|
+
object.normalMatrix.getNormalMatrix( object.modelViewMatrix );
|
|
1360
1470
|
|
|
1361
|
-
material.
|
|
1471
|
+
material.onBeforeRender( _this, scene, camera, geometry, object, group );
|
|
1362
1472
|
|
|
1363
|
-
|
|
1364
|
-
materialProperties.programs = programs;
|
|
1473
|
+
if ( material.transparent === true && material.side === DoubleSide && material.forceSinglePass === false ) {
|
|
1365
1474
|
|
|
1366
|
-
|
|
1475
|
+
material.side = BackSide;
|
|
1476
|
+
material.needsUpdate = true;
|
|
1477
|
+
_this.renderBufferDirect( camera, scene, geometry, material, object, group );
|
|
1367
1478
|
|
|
1368
|
-
|
|
1479
|
+
material.side = FrontSide;
|
|
1480
|
+
material.needsUpdate = true;
|
|
1481
|
+
_this.renderBufferDirect( camera, scene, geometry, material, object, group );
|
|
1369
1482
|
|
|
1370
|
-
|
|
1483
|
+
material.side = DoubleSide;
|
|
1371
1484
|
|
|
1372
|
-
|
|
1485
|
+
} else {
|
|
1373
1486
|
|
|
1374
|
-
|
|
1487
|
+
_this.renderBufferDirect( camera, scene, geometry, material, object, group );
|
|
1375
1488
|
|
|
1376
|
-
|
|
1489
|
+
}
|
|
1377
1490
|
|
|
1378
|
-
|
|
1491
|
+
object.onAfterRender( _this, scene, camera, geometry, material, group );
|
|
1379
1492
|
|
|
1380
|
-
|
|
1493
|
+
}
|
|
1381
1494
|
|
|
1382
|
-
|
|
1495
|
+
function getProgram( material, scene, object ) {
|
|
1383
1496
|
|
|
1384
|
-
|
|
1497
|
+
if ( scene.isScene !== true ) scene = _emptyScene; // scene could be a Mesh, Line, Points, ...
|
|
1385
1498
|
|
|
1386
|
-
|
|
1499
|
+
const materialProperties = properties.get( material );
|
|
1387
1500
|
|
|
1388
|
-
|
|
1501
|
+
const lights = currentRenderState.state.lights;
|
|
1502
|
+
const shadowsArray = currentRenderState.state.shadowsArray;
|
|
1389
1503
|
|
|
1390
|
-
|
|
1391
|
-
programs.set( programCacheKey, program );
|
|
1504
|
+
const lightsStateVersion = lights.state.version;
|
|
1392
1505
|
|
|
1393
|
-
|
|
1506
|
+
const parameters = programCache.getParameters( material, lights.state, shadowsArray, scene, object );
|
|
1507
|
+
const programCacheKey = programCache.getProgramCacheKey( parameters );
|
|
1394
1508
|
|
|
1395
|
-
|
|
1509
|
+
let programs = materialProperties.programs;
|
|
1396
1510
|
|
|
1397
|
-
|
|
1511
|
+
// always update environment and fog - changing these trigger an getProgram call, but it's possible that the program doesn't change
|
|
1398
1512
|
|
|
1399
|
-
|
|
1513
|
+
materialProperties.environment = material.isMeshStandardMaterial ? scene.environment : null;
|
|
1514
|
+
materialProperties.fog = scene.fog;
|
|
1515
|
+
materialProperties.envMap = ( material.isMeshStandardMaterial ? cubeuvmaps : cubemaps ).get( material.envMap || materialProperties.environment );
|
|
1400
1516
|
|
|
1401
|
-
|
|
1517
|
+
if ( programs === undefined ) {
|
|
1402
1518
|
|
|
1403
|
-
|
|
1519
|
+
// new material
|
|
1404
1520
|
|
|
1405
|
-
|
|
1521
|
+
material.addEventListener( 'dispose', onMaterialDispose );
|
|
1406
1522
|
|
|
1407
|
-
|
|
1523
|
+
programs = new Map();
|
|
1524
|
+
materialProperties.programs = programs;
|
|
1408
1525
|
|
|
1409
|
-
|
|
1410
|
-
materialProperties.lightsStateVersion = lightsStateVersion;
|
|
1526
|
+
}
|
|
1411
1527
|
|
|
1412
|
-
|
|
1528
|
+
let program = programs.get( programCacheKey );
|
|
1413
1529
|
|
|
1414
|
-
|
|
1530
|
+
if ( program !== undefined ) {
|
|
1415
1531
|
|
|
1416
|
-
|
|
1417
|
-
uniforms.lightProbe.value = lights.state.probe;
|
|
1418
|
-
uniforms.directionalLights.value = lights.state.directional;
|
|
1419
|
-
uniforms.directionalLightShadows.value = lights.state.directionalShadow;
|
|
1420
|
-
uniforms.spotLights.value = lights.state.spot;
|
|
1421
|
-
uniforms.spotLightShadows.value = lights.state.spotShadow;
|
|
1422
|
-
uniforms.rectAreaLights.value = lights.state.rectArea;
|
|
1423
|
-
uniforms.ltc_1.value = lights.state.rectAreaLTC1;
|
|
1424
|
-
uniforms.ltc_2.value = lights.state.rectAreaLTC2;
|
|
1425
|
-
uniforms.pointLights.value = lights.state.point;
|
|
1426
|
-
uniforms.pointLightShadows.value = lights.state.pointShadow;
|
|
1427
|
-
uniforms.hemisphereLights.value = lights.state.hemi;
|
|
1532
|
+
// early out if program and light state is identical
|
|
1428
1533
|
|
|
1429
|
-
|
|
1430
|
-
uniforms.directionalShadowMatrix.value = lights.state.directionalShadowMatrix;
|
|
1431
|
-
uniforms.spotShadowMap.value = lights.state.spotShadowMap;
|
|
1432
|
-
uniforms.spotLightMatrix.value = lights.state.spotLightMatrix;
|
|
1433
|
-
uniforms.spotLightMap.value = lights.state.spotLightMap;
|
|
1434
|
-
uniforms.pointShadowMap.value = lights.state.pointShadowMap;
|
|
1435
|
-
uniforms.pointShadowMatrix.value = lights.state.pointShadowMatrix;
|
|
1436
|
-
// TODO (abelnation): add area lights shadow info to uniforms
|
|
1534
|
+
if ( materialProperties.currentProgram === program && materialProperties.lightsStateVersion === lightsStateVersion ) {
|
|
1437
1535
|
|
|
1438
|
-
|
|
1536
|
+
updateCommonMaterialProperties( material, parameters );
|
|
1439
1537
|
|
|
1440
|
-
|
|
1441
|
-
const uniformsList = WebGLUniforms.seqWithValue( progUniforms.seq, uniforms );
|
|
1538
|
+
return program;
|
|
1442
1539
|
|
|
1443
|
-
|
|
1444
|
-
materialProperties.uniformsList = uniformsList;
|
|
1540
|
+
}
|
|
1445
1541
|
|
|
1446
|
-
|
|
1542
|
+
} else {
|
|
1447
1543
|
|
|
1448
|
-
|
|
1544
|
+
parameters.uniforms = programCache.getUniforms( material );
|
|
1449
1545
|
|
|
1450
|
-
|
|
1546
|
+
material.onBuild( object, parameters, _this );
|
|
1451
1547
|
|
|
1452
|
-
|
|
1548
|
+
material.onBeforeCompile( parameters, _this );
|
|
1453
1549
|
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
materialProperties.skinning = parameters.skinning;
|
|
1457
|
-
materialProperties.morphTargets = parameters.morphTargets;
|
|
1458
|
-
materialProperties.morphNormals = parameters.morphNormals;
|
|
1459
|
-
materialProperties.morphColors = parameters.morphColors;
|
|
1460
|
-
materialProperties.morphTargetsCount = parameters.morphTargetsCount;
|
|
1461
|
-
materialProperties.numClippingPlanes = parameters.numClippingPlanes;
|
|
1462
|
-
materialProperties.numIntersection = parameters.numClipIntersection;
|
|
1463
|
-
materialProperties.vertexAlphas = parameters.vertexAlphas;
|
|
1464
|
-
materialProperties.vertexTangents = parameters.vertexTangents;
|
|
1465
|
-
materialProperties.toneMapping = parameters.toneMapping;
|
|
1550
|
+
program = programCache.acquireProgram( parameters, programCacheKey );
|
|
1551
|
+
programs.set( programCacheKey, program );
|
|
1466
1552
|
|
|
1467
|
-
|
|
1553
|
+
materialProperties.uniforms = parameters.uniforms;
|
|
1468
1554
|
|
|
1469
|
-
|
|
1555
|
+
}
|
|
1470
1556
|
|
|
1471
|
-
|
|
1557
|
+
const uniforms = materialProperties.uniforms;
|
|
1472
1558
|
|
|
1473
|
-
|
|
1559
|
+
if ( ( ! material.isShaderMaterial && ! material.isRawShaderMaterial ) || material.clipping === true ) {
|
|
1474
1560
|
|
|
1475
|
-
|
|
1476
|
-
const environment = material.isMeshStandardMaterial ? scene.environment : null;
|
|
1477
|
-
const encoding = ( _currentRenderTarget === null ) ? _this.outputEncoding : ( _currentRenderTarget.isXRRenderTarget === true ? _currentRenderTarget.texture.encoding : LinearEncoding );
|
|
1478
|
-
const envMap = ( material.isMeshStandardMaterial ? cubeuvmaps : cubemaps ).get( material.envMap || environment );
|
|
1479
|
-
const vertexAlphas = material.vertexColors === true && !! geometry.attributes.color && geometry.attributes.color.itemSize === 4;
|
|
1480
|
-
const vertexTangents = !! material.normalMap && !! geometry.attributes.tangent;
|
|
1481
|
-
const morphTargets = !! geometry.morphAttributes.position;
|
|
1482
|
-
const morphNormals = !! geometry.morphAttributes.normal;
|
|
1483
|
-
const morphColors = !! geometry.morphAttributes.color;
|
|
1484
|
-
const toneMapping = material.toneMapped ? _this.toneMapping : NoToneMapping;
|
|
1561
|
+
uniforms.clippingPlanes = clipping.uniform;
|
|
1485
1562
|
|
|
1486
|
-
|
|
1487
|
-
const morphTargetsCount = ( morphAttribute !== undefined ) ? morphAttribute.length : 0;
|
|
1563
|
+
}
|
|
1488
1564
|
|
|
1489
|
-
|
|
1490
|
-
const lights = currentRenderState.state.lights;
|
|
1565
|
+
updateCommonMaterialProperties( material, parameters );
|
|
1491
1566
|
|
|
1492
|
-
|
|
1567
|
+
// store the light setup it was created for
|
|
1493
1568
|
|
|
1494
|
-
|
|
1569
|
+
materialProperties.needsLights = materialNeedsLights( material );
|
|
1570
|
+
materialProperties.lightsStateVersion = lightsStateVersion;
|
|
1495
1571
|
|
|
1496
|
-
|
|
1497
|
-
camera === _currentCamera &&
|
|
1498
|
-
material.id === _currentMaterialId;
|
|
1572
|
+
if ( materialProperties.needsLights ) {
|
|
1499
1573
|
|
|
1500
|
-
//
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1574
|
+
// wire up the material to this renderer's lighting state
|
|
1575
|
+
|
|
1576
|
+
uniforms.ambientLightColor.value = lights.state.ambient;
|
|
1577
|
+
uniforms.lightProbe.value = lights.state.probe;
|
|
1578
|
+
uniforms.directionalLights.value = lights.state.directional;
|
|
1579
|
+
uniforms.directionalLightShadows.value = lights.state.directionalShadow;
|
|
1580
|
+
uniforms.spotLights.value = lights.state.spot;
|
|
1581
|
+
uniforms.spotLightShadows.value = lights.state.spotShadow;
|
|
1582
|
+
uniforms.rectAreaLights.value = lights.state.rectArea;
|
|
1583
|
+
uniforms.ltc_1.value = lights.state.rectAreaLTC1;
|
|
1584
|
+
uniforms.ltc_2.value = lights.state.rectAreaLTC2;
|
|
1585
|
+
uniforms.pointLights.value = lights.state.point;
|
|
1586
|
+
uniforms.pointLightShadows.value = lights.state.pointShadow;
|
|
1587
|
+
uniforms.hemisphereLights.value = lights.state.hemi;
|
|
1588
|
+
|
|
1589
|
+
uniforms.directionalShadowMap.value = lights.state.directionalShadowMap;
|
|
1590
|
+
uniforms.directionalShadowMatrix.value = lights.state.directionalShadowMatrix;
|
|
1591
|
+
uniforms.spotShadowMap.value = lights.state.spotShadowMap;
|
|
1592
|
+
uniforms.spotLightMatrix.value = lights.state.spotLightMatrix;
|
|
1593
|
+
uniforms.spotLightMap.value = lights.state.spotLightMap;
|
|
1594
|
+
uniforms.pointShadowMap.value = lights.state.pointShadowMap;
|
|
1595
|
+
uniforms.pointShadowMatrix.value = lights.state.pointShadowMatrix;
|
|
1596
|
+
// TODO (abelnation): add area lights shadow info to uniforms
|
|
1504
1597
|
|
|
1505
1598
|
}
|
|
1506
1599
|
|
|
1507
|
-
|
|
1600
|
+
const progUniforms = program.getUniforms();
|
|
1601
|
+
const uniformsList = WebGLUniforms.seqWithValue( progUniforms.seq, uniforms );
|
|
1508
1602
|
|
|
1509
|
-
|
|
1603
|
+
materialProperties.currentProgram = program;
|
|
1604
|
+
materialProperties.uniformsList = uniformsList;
|
|
1510
1605
|
|
|
1511
|
-
|
|
1606
|
+
return program;
|
|
1512
1607
|
|
|
1513
|
-
|
|
1608
|
+
}
|
|
1514
1609
|
|
|
1515
|
-
|
|
1610
|
+
function updateCommonMaterialProperties( material, parameters ) {
|
|
1516
1611
|
|
|
1517
|
-
|
|
1612
|
+
const materialProperties = properties.get( material );
|
|
1518
1613
|
|
|
1519
|
-
|
|
1614
|
+
materialProperties.outputColorSpace = parameters.outputColorSpace;
|
|
1615
|
+
materialProperties.instancing = parameters.instancing;
|
|
1616
|
+
materialProperties.skinning = parameters.skinning;
|
|
1617
|
+
materialProperties.morphTargets = parameters.morphTargets;
|
|
1618
|
+
materialProperties.morphNormals = parameters.morphNormals;
|
|
1619
|
+
materialProperties.morphColors = parameters.morphColors;
|
|
1620
|
+
materialProperties.morphTargetsCount = parameters.morphTargetsCount;
|
|
1621
|
+
materialProperties.numClippingPlanes = parameters.numClippingPlanes;
|
|
1622
|
+
materialProperties.numIntersection = parameters.numClipIntersection;
|
|
1623
|
+
materialProperties.vertexAlphas = parameters.vertexAlphas;
|
|
1624
|
+
materialProperties.vertexTangents = parameters.vertexTangents;
|
|
1625
|
+
materialProperties.toneMapping = parameters.toneMapping;
|
|
1520
1626
|
|
|
1521
|
-
|
|
1627
|
+
}
|
|
1522
1628
|
|
|
1523
|
-
|
|
1629
|
+
function setProgram( camera, scene, geometry, material, object ) {
|
|
1524
1630
|
|
|
1525
|
-
|
|
1631
|
+
if ( scene.isScene !== true ) scene = _emptyScene; // scene could be a Mesh, Line, Points, ...
|
|
1526
1632
|
|
|
1527
|
-
|
|
1633
|
+
textures.resetTextureUnits();
|
|
1528
1634
|
|
|
1529
|
-
|
|
1635
|
+
const fog = scene.fog;
|
|
1636
|
+
const environment = material.isMeshStandardMaterial ? scene.environment : null;
|
|
1637
|
+
const colorSpace = ( _currentRenderTarget === null ) ? _this.outputColorSpace : ( _currentRenderTarget.isXRRenderTarget === true ? _currentRenderTarget.texture.colorSpace : LinearSRGBColorSpace );
|
|
1638
|
+
const envMap = ( material.isMeshStandardMaterial ? cubeuvmaps : cubemaps ).get( material.envMap || environment );
|
|
1639
|
+
const vertexAlphas = material.vertexColors === true && !! geometry.attributes.color && geometry.attributes.color.itemSize === 4;
|
|
1640
|
+
const vertexTangents = !! geometry.attributes.tangent && ( !! material.normalMap || material.anisotropy > 0 );
|
|
1641
|
+
const morphTargets = !! geometry.morphAttributes.position;
|
|
1642
|
+
const morphNormals = !! geometry.morphAttributes.normal;
|
|
1643
|
+
const morphColors = !! geometry.morphAttributes.color;
|
|
1644
|
+
const toneMapping = material.toneMapped ? _this.toneMapping : NoToneMapping;
|
|
1530
1645
|
|
|
1531
|
-
|
|
1646
|
+
const morphAttribute = geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color;
|
|
1647
|
+
const morphTargetsCount = ( morphAttribute !== undefined ) ? morphAttribute.length : 0;
|
|
1532
1648
|
|
|
1533
|
-
|
|
1649
|
+
const materialProperties = properties.get( material );
|
|
1650
|
+
const lights = currentRenderState.state.lights;
|
|
1534
1651
|
|
|
1535
|
-
|
|
1652
|
+
if ( _clippingEnabled === true ) {
|
|
1536
1653
|
|
|
1537
|
-
|
|
1654
|
+
if ( _localClippingEnabled === true || camera !== _currentCamera ) {
|
|
1538
1655
|
|
|
1539
|
-
|
|
1656
|
+
const useCache =
|
|
1657
|
+
camera === _currentCamera &&
|
|
1658
|
+
material.id === _currentMaterialId;
|
|
1540
1659
|
|
|
1541
|
-
|
|
1660
|
+
// we might want to call this function with some ClippingGroup
|
|
1661
|
+
// object instead of the material, once it becomes feasible
|
|
1662
|
+
// (#8465, #8379)
|
|
1663
|
+
clipping.setState( material, camera, useCache );
|
|
1542
1664
|
|
|
1543
|
-
|
|
1665
|
+
}
|
|
1544
1666
|
|
|
1545
|
-
|
|
1667
|
+
}
|
|
1546
1668
|
|
|
1547
|
-
|
|
1548
|
-
( materialProperties.numClippingPlanes !== clipping.numPlanes ||
|
|
1549
|
-
materialProperties.numIntersection !== clipping.numIntersection ) ) {
|
|
1669
|
+
//
|
|
1550
1670
|
|
|
1551
|
-
|
|
1671
|
+
let needsProgramChange = false;
|
|
1552
1672
|
|
|
1553
|
-
|
|
1673
|
+
if ( material.version === materialProperties.__version ) {
|
|
1554
1674
|
|
|
1555
|
-
|
|
1675
|
+
if ( materialProperties.needsLights && ( materialProperties.lightsStateVersion !== lights.state.version ) ) {
|
|
1556
1676
|
|
|
1557
|
-
|
|
1677
|
+
needsProgramChange = true;
|
|
1558
1678
|
|
|
1559
|
-
|
|
1679
|
+
} else if ( materialProperties.outputColorSpace !== colorSpace ) {
|
|
1560
1680
|
|
|
1561
|
-
|
|
1681
|
+
needsProgramChange = true;
|
|
1562
1682
|
|
|
1563
|
-
|
|
1683
|
+
} else if ( object.isInstancedMesh && materialProperties.instancing === false ) {
|
|
1564
1684
|
|
|
1565
|
-
|
|
1685
|
+
needsProgramChange = true;
|
|
1566
1686
|
|
|
1567
|
-
|
|
1687
|
+
} else if ( ! object.isInstancedMesh && materialProperties.instancing === true ) {
|
|
1568
1688
|
|
|
1569
|
-
|
|
1689
|
+
needsProgramChange = true;
|
|
1570
1690
|
|
|
1571
|
-
|
|
1691
|
+
} else if ( object.isSkinnedMesh && materialProperties.skinning === false ) {
|
|
1572
1692
|
|
|
1573
|
-
|
|
1693
|
+
needsProgramChange = true;
|
|
1574
1694
|
|
|
1575
|
-
|
|
1695
|
+
} else if ( ! object.isSkinnedMesh && materialProperties.skinning === true ) {
|
|
1576
1696
|
|
|
1577
|
-
|
|
1697
|
+
needsProgramChange = true;
|
|
1578
1698
|
|
|
1579
|
-
|
|
1699
|
+
} else if ( materialProperties.envMap !== envMap ) {
|
|
1580
1700
|
|
|
1581
|
-
|
|
1701
|
+
needsProgramChange = true;
|
|
1582
1702
|
|
|
1583
|
-
|
|
1703
|
+
} else if ( material.fog === true && materialProperties.fog !== fog ) {
|
|
1584
1704
|
|
|
1585
|
-
|
|
1586
|
-
materialProperties.__version = material.version;
|
|
1705
|
+
needsProgramChange = true;
|
|
1587
1706
|
|
|
1588
|
-
|
|
1707
|
+
} else if ( materialProperties.numClippingPlanes !== undefined &&
|
|
1708
|
+
( materialProperties.numClippingPlanes !== clipping.numPlanes ||
|
|
1709
|
+
materialProperties.numIntersection !== clipping.numIntersection ) ) {
|
|
1589
1710
|
|
|
1590
|
-
|
|
1711
|
+
needsProgramChange = true;
|
|
1591
1712
|
|
|
1592
|
-
|
|
1713
|
+
} else if ( materialProperties.vertexAlphas !== vertexAlphas ) {
|
|
1593
1714
|
|
|
1594
|
-
|
|
1715
|
+
needsProgramChange = true;
|
|
1595
1716
|
|
|
1596
|
-
|
|
1717
|
+
} else if ( materialProperties.vertexTangents !== vertexTangents ) {
|
|
1597
1718
|
|
|
1598
|
-
|
|
1719
|
+
needsProgramChange = true;
|
|
1599
1720
|
|
|
1600
|
-
|
|
1601
|
-
let refreshMaterial = false;
|
|
1602
|
-
let refreshLights = false;
|
|
1721
|
+
} else if ( materialProperties.morphTargets !== morphTargets ) {
|
|
1603
1722
|
|
|
1604
|
-
|
|
1605
|
-
m_uniforms = materialProperties.uniforms;
|
|
1723
|
+
needsProgramChange = true;
|
|
1606
1724
|
|
|
1607
|
-
|
|
1725
|
+
} else if ( materialProperties.morphNormals !== morphNormals ) {
|
|
1608
1726
|
|
|
1609
|
-
|
|
1610
|
-
refreshMaterial = true;
|
|
1611
|
-
refreshLights = true;
|
|
1727
|
+
needsProgramChange = true;
|
|
1612
1728
|
|
|
1613
|
-
|
|
1729
|
+
} else if ( materialProperties.morphColors !== morphColors ) {
|
|
1614
1730
|
|
|
1615
|
-
|
|
1731
|
+
needsProgramChange = true;
|
|
1616
1732
|
|
|
1617
|
-
|
|
1733
|
+
} else if ( materialProperties.toneMapping !== toneMapping ) {
|
|
1618
1734
|
|
|
1619
|
-
|
|
1735
|
+
needsProgramChange = true;
|
|
1620
1736
|
|
|
1621
|
-
|
|
1737
|
+
} else if ( capabilities.isWebGL2 === true && materialProperties.morphTargetsCount !== morphTargetsCount ) {
|
|
1622
1738
|
|
|
1623
|
-
|
|
1739
|
+
needsProgramChange = true;
|
|
1624
1740
|
|
|
1625
|
-
|
|
1741
|
+
}
|
|
1626
1742
|
|
|
1627
|
-
|
|
1743
|
+
} else {
|
|
1628
1744
|
|
|
1629
|
-
|
|
1630
|
-
|
|
1745
|
+
needsProgramChange = true;
|
|
1746
|
+
materialProperties.__version = material.version;
|
|
1631
1747
|
|
|
1632
1748
|
}
|
|
1633
1749
|
|
|
1634
|
-
|
|
1750
|
+
//
|
|
1635
1751
|
|
|
1636
|
-
|
|
1752
|
+
let program = materialProperties.currentProgram;
|
|
1637
1753
|
|
|
1638
|
-
|
|
1639
|
-
// now, in case this material supports lights - or later, when
|
|
1640
|
-
// the next material that does gets activated:
|
|
1754
|
+
if ( needsProgramChange === true ) {
|
|
1641
1755
|
|
|
1642
|
-
|
|
1643
|
-
refreshLights = true; // remains set until update done
|
|
1756
|
+
program = getProgram( material, scene, object );
|
|
1644
1757
|
|
|
1645
1758
|
}
|
|
1646
1759
|
|
|
1647
|
-
|
|
1648
|
-
|
|
1760
|
+
let refreshProgram = false;
|
|
1761
|
+
let refreshMaterial = false;
|
|
1762
|
+
let refreshLights = false;
|
|
1763
|
+
|
|
1764
|
+
const p_uniforms = program.getUniforms(),
|
|
1765
|
+
m_uniforms = materialProperties.uniforms;
|
|
1649
1766
|
|
|
1650
|
-
if (
|
|
1651
|
-
material.isMeshPhongMaterial ||
|
|
1652
|
-
material.isMeshToonMaterial ||
|
|
1653
|
-
material.isMeshStandardMaterial ||
|
|
1654
|
-
material.envMap ) {
|
|
1767
|
+
if ( state.useProgram( program.program ) ) {
|
|
1655
1768
|
|
|
1656
|
-
|
|
1769
|
+
refreshProgram = true;
|
|
1770
|
+
refreshMaterial = true;
|
|
1771
|
+
refreshLights = true;
|
|
1657
1772
|
|
|
1658
|
-
|
|
1773
|
+
}
|
|
1659
1774
|
|
|
1660
|
-
|
|
1661
|
-
_vector3.setFromMatrixPosition( camera.matrixWorld ) );
|
|
1775
|
+
if ( material.id !== _currentMaterialId ) {
|
|
1662
1776
|
|
|
1663
|
-
|
|
1777
|
+
_currentMaterialId = material.id;
|
|
1778
|
+
|
|
1779
|
+
refreshMaterial = true;
|
|
1664
1780
|
|
|
1665
1781
|
}
|
|
1666
1782
|
|
|
1667
|
-
if (
|
|
1668
|
-
material.isMeshToonMaterial ||
|
|
1669
|
-
material.isMeshLambertMaterial ||
|
|
1670
|
-
material.isMeshBasicMaterial ||
|
|
1671
|
-
material.isMeshStandardMaterial ||
|
|
1672
|
-
material.isShaderMaterial ) {
|
|
1783
|
+
if ( refreshProgram || _currentCamera !== camera ) {
|
|
1673
1784
|
|
|
1674
|
-
p_uniforms.setValue( _gl, '
|
|
1785
|
+
p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
|
|
1675
1786
|
|
|
1676
|
-
|
|
1787
|
+
if ( capabilities.logarithmicDepthBuffer ) {
|
|
1788
|
+
|
|
1789
|
+
p_uniforms.setValue( _gl, 'logDepthBufFC',
|
|
1790
|
+
2.0 / ( Math.log( camera.far + 1.0 ) / Math.LN2 ) );
|
|
1677
1791
|
|
|
1678
|
-
|
|
1679
|
-
material.isMeshToonMaterial ||
|
|
1680
|
-
material.isMeshLambertMaterial ||
|
|
1681
|
-
material.isMeshBasicMaterial ||
|
|
1682
|
-
material.isMeshStandardMaterial ||
|
|
1683
|
-
material.isShaderMaterial ||
|
|
1684
|
-
material.isShadowMaterial ||
|
|
1685
|
-
object.isSkinnedMesh ) {
|
|
1792
|
+
}
|
|
1686
1793
|
|
|
1687
|
-
|
|
1794
|
+
if ( _currentCamera !== camera ) {
|
|
1688
1795
|
|
|
1689
|
-
|
|
1796
|
+
_currentCamera = camera;
|
|
1690
1797
|
|
|
1691
|
-
|
|
1798
|
+
// lighting uniforms depend on the camera so enforce an update
|
|
1799
|
+
// now, in case this material supports lights - or later, when
|
|
1800
|
+
// the next material that does gets activated:
|
|
1692
1801
|
|
|
1693
|
-
//
|
|
1694
|
-
//
|
|
1695
|
-
// otherwise textures used for skinning and morphing can take over texture units reserved for other material textures
|
|
1802
|
+
refreshMaterial = true; // set to true on material change
|
|
1803
|
+
refreshLights = true; // remains set until update done
|
|
1696
1804
|
|
|
1697
|
-
|
|
1805
|
+
}
|
|
1698
1806
|
|
|
1699
|
-
|
|
1700
|
-
|
|
1807
|
+
// load material specific uniforms
|
|
1808
|
+
// (shader material also gets them for the sake of genericity)
|
|
1701
1809
|
|
|
1702
|
-
|
|
1810
|
+
if ( material.isShaderMaterial ||
|
|
1811
|
+
material.isMeshPhongMaterial ||
|
|
1812
|
+
material.isMeshToonMaterial ||
|
|
1813
|
+
material.isMeshStandardMaterial ||
|
|
1814
|
+
material.envMap ) {
|
|
1703
1815
|
|
|
1704
|
-
|
|
1816
|
+
const uCamPos = p_uniforms.map.cameraPosition;
|
|
1705
1817
|
|
|
1706
|
-
|
|
1818
|
+
if ( uCamPos !== undefined ) {
|
|
1707
1819
|
|
|
1708
|
-
|
|
1820
|
+
uCamPos.setValue( _gl,
|
|
1821
|
+
_vector3.setFromMatrixPosition( camera.matrixWorld ) );
|
|
1709
1822
|
|
|
1710
|
-
|
|
1711
|
-
p_uniforms.setValue( _gl, 'boneTextureSize', skeleton.boneTextureSize );
|
|
1823
|
+
}
|
|
1712
1824
|
|
|
1713
|
-
}
|
|
1825
|
+
}
|
|
1714
1826
|
|
|
1715
|
-
|
|
1827
|
+
if ( material.isMeshPhongMaterial ||
|
|
1828
|
+
material.isMeshToonMaterial ||
|
|
1829
|
+
material.isMeshLambertMaterial ||
|
|
1830
|
+
material.isMeshBasicMaterial ||
|
|
1831
|
+
material.isMeshStandardMaterial ||
|
|
1832
|
+
material.isShaderMaterial ) {
|
|
1833
|
+
|
|
1834
|
+
p_uniforms.setValue( _gl, 'isOrthographic', camera.isOrthographicCamera === true );
|
|
1835
|
+
|
|
1836
|
+
}
|
|
1837
|
+
|
|
1838
|
+
if ( material.isMeshPhongMaterial ||
|
|
1839
|
+
material.isMeshToonMaterial ||
|
|
1840
|
+
material.isMeshLambertMaterial ||
|
|
1841
|
+
material.isMeshBasicMaterial ||
|
|
1842
|
+
material.isMeshStandardMaterial ||
|
|
1843
|
+
material.isShaderMaterial ||
|
|
1844
|
+
material.isShadowMaterial ||
|
|
1845
|
+
object.isSkinnedMesh ) {
|
|
1846
|
+
|
|
1847
|
+
p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );
|
|
1716
1848
|
|
|
1717
1849
|
}
|
|
1718
1850
|
|
|
1719
1851
|
}
|
|
1720
1852
|
|
|
1721
|
-
|
|
1853
|
+
// skinning and morph target uniforms must be set even if material didn't change
|
|
1854
|
+
// auto-setting of texture unit for bone and morph texture must go before other textures
|
|
1855
|
+
// otherwise textures used for skinning and morphing can take over texture units reserved for other material textures
|
|
1722
1856
|
|
|
1723
|
-
|
|
1857
|
+
if ( object.isSkinnedMesh ) {
|
|
1724
1858
|
|
|
1725
|
-
|
|
1859
|
+
p_uniforms.setOptional( _gl, object, 'bindMatrix' );
|
|
1860
|
+
p_uniforms.setOptional( _gl, object, 'bindMatrixInverse' );
|
|
1726
1861
|
|
|
1727
|
-
|
|
1862
|
+
const skeleton = object.skeleton;
|
|
1728
1863
|
|
|
1729
|
-
|
|
1864
|
+
if ( skeleton ) {
|
|
1730
1865
|
|
|
1731
|
-
|
|
1866
|
+
if ( capabilities.floatVertexTextures ) {
|
|
1732
1867
|
|
|
1733
|
-
|
|
1734
|
-
p_uniforms.setValue( _gl, 'receiveShadow', object.receiveShadow );
|
|
1868
|
+
if ( skeleton.boneTexture === null ) skeleton.computeBoneTexture();
|
|
1735
1869
|
|
|
1736
|
-
|
|
1870
|
+
p_uniforms.setValue( _gl, 'boneTexture', skeleton.boneTexture, textures );
|
|
1871
|
+
p_uniforms.setValue( _gl, 'boneTextureSize', skeleton.boneTextureSize );
|
|
1737
1872
|
|
|
1738
|
-
|
|
1873
|
+
} else {
|
|
1739
1874
|
|
|
1740
|
-
|
|
1875
|
+
console.warn( 'THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required.' );
|
|
1741
1876
|
|
|
1742
|
-
|
|
1877
|
+
}
|
|
1743
1878
|
|
|
1744
|
-
|
|
1879
|
+
}
|
|
1745
1880
|
|
|
1746
|
-
|
|
1881
|
+
}
|
|
1747
1882
|
|
|
1748
|
-
|
|
1883
|
+
const morphAttributes = geometry.morphAttributes;
|
|
1749
1884
|
|
|
1750
|
-
|
|
1885
|
+
if ( morphAttributes.position !== undefined || morphAttributes.normal !== undefined || ( morphAttributes.color !== undefined && capabilities.isWebGL2 === true ) ) {
|
|
1751
1886
|
|
|
1752
|
-
|
|
1887
|
+
morphtargets.update( object, geometry, program );
|
|
1753
1888
|
|
|
1754
|
-
|
|
1889
|
+
}
|
|
1755
1890
|
|
|
1756
|
-
|
|
1757
|
-
// they simply reference the renderer's state for their
|
|
1758
|
-
// values
|
|
1759
|
-
//
|
|
1760
|
-
// use the current material's .needsUpdate flags to set
|
|
1761
|
-
// the GL state when required
|
|
1891
|
+
if ( refreshMaterial || materialProperties.receiveShadow !== object.receiveShadow ) {
|
|
1762
1892
|
|
|
1763
|
-
|
|
1893
|
+
materialProperties.receiveShadow = object.receiveShadow;
|
|
1894
|
+
p_uniforms.setValue( _gl, 'receiveShadow', object.receiveShadow );
|
|
1764
1895
|
|
|
1765
1896
|
}
|
|
1766
1897
|
|
|
1767
|
-
//
|
|
1898
|
+
// https://github.com/mrdoob/three.js/pull/24467#issuecomment-1209031512
|
|
1768
1899
|
|
|
1769
|
-
if (
|
|
1900
|
+
if ( material.isMeshGouraudMaterial && material.envMap !== null ) {
|
|
1770
1901
|
|
|
1771
|
-
|
|
1902
|
+
m_uniforms.envMap.value = envMap;
|
|
1903
|
+
|
|
1904
|
+
m_uniforms.flipEnvMap.value = ( envMap.isCubeTexture && envMap.isRenderTargetTexture === false ) ? - 1 : 1;
|
|
1772
1905
|
|
|
1773
1906
|
}
|
|
1774
1907
|
|
|
1775
|
-
|
|
1908
|
+
if ( refreshMaterial ) {
|
|
1776
1909
|
|
|
1777
|
-
|
|
1910
|
+
p_uniforms.setValue( _gl, 'toneMappingExposure', _this.toneMappingExposure );
|
|
1778
1911
|
|
|
1779
|
-
|
|
1912
|
+
if ( materialProperties.needsLights ) {
|
|
1780
1913
|
|
|
1781
|
-
|
|
1914
|
+
// the current material requires lighting info
|
|
1782
1915
|
|
|
1783
|
-
|
|
1784
|
-
|
|
1916
|
+
// note: all lighting uniforms are always set correctly
|
|
1917
|
+
// they simply reference the renderer's state for their
|
|
1918
|
+
// values
|
|
1919
|
+
//
|
|
1920
|
+
// use the current material's .needsUpdate flags to set
|
|
1921
|
+
// the GL state when required
|
|
1785
1922
|
|
|
1786
|
-
|
|
1923
|
+
markUniformsLightsNeedsUpdate( m_uniforms, refreshLights );
|
|
1787
1924
|
|
|
1788
|
-
|
|
1925
|
+
}
|
|
1789
1926
|
|
|
1790
|
-
|
|
1927
|
+
// refresh uniforms common to several materials
|
|
1791
1928
|
|
|
1792
|
-
|
|
1929
|
+
if ( fog && material.fog === true ) {
|
|
1930
|
+
|
|
1931
|
+
materials.refreshFogUniforms( m_uniforms, fog );
|
|
1932
|
+
|
|
1933
|
+
}
|
|
1793
1934
|
|
|
1794
|
-
|
|
1935
|
+
materials.refreshMaterialUniforms( m_uniforms, material, _pixelRatio, _height, _transmissionRenderTarget );
|
|
1795
1936
|
|
|
1796
|
-
|
|
1797
|
-
p_uniforms.setValue( _gl, 'normalMatrix', object.normalMatrix );
|
|
1798
|
-
p_uniforms.setValue( _gl, 'modelMatrix', object.matrixWorld );
|
|
1937
|
+
WebGLUniforms.upload( _gl, materialProperties.uniformsList, m_uniforms, textures );
|
|
1799
1938
|
|
|
1800
|
-
|
|
1939
|
+
}
|
|
1801
1940
|
|
|
1802
|
-
|
|
1941
|
+
if ( material.isShaderMaterial && material.uniformsNeedUpdate === true ) {
|
|
1803
1942
|
|
|
1804
|
-
|
|
1943
|
+
WebGLUniforms.upload( _gl, materialProperties.uniformsList, m_uniforms, textures );
|
|
1944
|
+
material.uniformsNeedUpdate = false;
|
|
1805
1945
|
|
|
1806
|
-
|
|
1946
|
+
}
|
|
1807
1947
|
|
|
1808
|
-
|
|
1948
|
+
if ( material.isSpriteMaterial ) {
|
|
1809
1949
|
|
|
1810
|
-
|
|
1950
|
+
p_uniforms.setValue( _gl, 'center', object.center );
|
|
1811
1951
|
|
|
1812
|
-
|
|
1813
|
-
uniformsGroups.bind( group, program );
|
|
1952
|
+
}
|
|
1814
1953
|
|
|
1815
|
-
|
|
1954
|
+
// common matrices
|
|
1955
|
+
|
|
1956
|
+
p_uniforms.setValue( _gl, 'modelViewMatrix', object.modelViewMatrix );
|
|
1957
|
+
p_uniforms.setValue( _gl, 'normalMatrix', object.normalMatrix );
|
|
1958
|
+
p_uniforms.setValue( _gl, 'modelMatrix', object.matrixWorld );
|
|
1959
|
+
|
|
1960
|
+
// UBOs
|
|
1961
|
+
|
|
1962
|
+
if ( material.isShaderMaterial || material.isRawShaderMaterial ) {
|
|
1963
|
+
|
|
1964
|
+
const groups = material.uniformsGroups;
|
|
1965
|
+
|
|
1966
|
+
for ( let i = 0, l = groups.length; i < l; i ++ ) {
|
|
1967
|
+
|
|
1968
|
+
if ( capabilities.isWebGL2 ) {
|
|
1969
|
+
|
|
1970
|
+
const group = groups[ i ];
|
|
1971
|
+
|
|
1972
|
+
uniformsGroups.update( group, program );
|
|
1973
|
+
uniformsGroups.bind( group, program );
|
|
1974
|
+
|
|
1975
|
+
} else {
|
|
1816
1976
|
|
|
1817
|
-
|
|
1977
|
+
console.warn( 'THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.' );
|
|
1978
|
+
|
|
1979
|
+
}
|
|
1818
1980
|
|
|
1819
1981
|
}
|
|
1820
1982
|
|
|
1821
1983
|
}
|
|
1822
1984
|
|
|
1985
|
+
return program;
|
|
1986
|
+
|
|
1823
1987
|
}
|
|
1824
1988
|
|
|
1825
|
-
|
|
1989
|
+
// If uniforms are marked as clean, they don't need to be loaded to the GPU.
|
|
1826
1990
|
|
|
1827
|
-
|
|
1991
|
+
function markUniformsLightsNeedsUpdate( uniforms, value ) {
|
|
1828
1992
|
|
|
1829
|
-
|
|
1993
|
+
uniforms.ambientLightColor.needsUpdate = value;
|
|
1994
|
+
uniforms.lightProbe.needsUpdate = value;
|
|
1830
1995
|
|
|
1831
|
-
|
|
1996
|
+
uniforms.directionalLights.needsUpdate = value;
|
|
1997
|
+
uniforms.directionalLightShadows.needsUpdate = value;
|
|
1998
|
+
uniforms.pointLights.needsUpdate = value;
|
|
1999
|
+
uniforms.pointLightShadows.needsUpdate = value;
|
|
2000
|
+
uniforms.spotLights.needsUpdate = value;
|
|
2001
|
+
uniforms.spotLightShadows.needsUpdate = value;
|
|
2002
|
+
uniforms.rectAreaLights.needsUpdate = value;
|
|
2003
|
+
uniforms.hemisphereLights.needsUpdate = value;
|
|
1832
2004
|
|
|
1833
|
-
|
|
1834
|
-
uniforms.lightProbe.needsUpdate = value;
|
|
1835
|
-
|
|
1836
|
-
uniforms.directionalLights.needsUpdate = value;
|
|
1837
|
-
uniforms.directionalLightShadows.needsUpdate = value;
|
|
1838
|
-
uniforms.pointLights.needsUpdate = value;
|
|
1839
|
-
uniforms.pointLightShadows.needsUpdate = value;
|
|
1840
|
-
uniforms.spotLights.needsUpdate = value;
|
|
1841
|
-
uniforms.spotLightShadows.needsUpdate = value;
|
|
1842
|
-
uniforms.rectAreaLights.needsUpdate = value;
|
|
1843
|
-
uniforms.hemisphereLights.needsUpdate = value;
|
|
2005
|
+
}
|
|
1844
2006
|
|
|
1845
|
-
|
|
2007
|
+
function materialNeedsLights( material ) {
|
|
1846
2008
|
|
|
1847
|
-
|
|
2009
|
+
return material.isMeshLambertMaterial || material.isMeshToonMaterial || material.isMeshPhongMaterial ||
|
|
2010
|
+
material.isMeshStandardMaterial || material.isShadowMaterial ||
|
|
2011
|
+
( material.isShaderMaterial && material.lights === true );
|
|
1848
2012
|
|
|
1849
|
-
|
|
1850
|
-
material.isMeshStandardMaterial || material.isShadowMaterial ||
|
|
1851
|
-
( material.isShaderMaterial && material.lights === true );
|
|
2013
|
+
}
|
|
1852
2014
|
|
|
1853
|
-
|
|
2015
|
+
this.getActiveCubeFace = function () {
|
|
1854
2016
|
|
|
1855
|
-
|
|
2017
|
+
return _currentActiveCubeFace;
|
|
1856
2018
|
|
|
1857
|
-
|
|
2019
|
+
};
|
|
1858
2020
|
|
|
1859
|
-
|
|
2021
|
+
this.getActiveMipmapLevel = function () {
|
|
1860
2022
|
|
|
1861
|
-
|
|
2023
|
+
return _currentActiveMipmapLevel;
|
|
1862
2024
|
|
|
1863
|
-
|
|
2025
|
+
};
|
|
1864
2026
|
|
|
1865
|
-
|
|
2027
|
+
this.getRenderTarget = function () {
|
|
1866
2028
|
|
|
1867
|
-
|
|
2029
|
+
return _currentRenderTarget;
|
|
1868
2030
|
|
|
1869
|
-
|
|
2031
|
+
};
|
|
1870
2032
|
|
|
1871
|
-
|
|
2033
|
+
this.setRenderTargetTextures = function ( renderTarget, colorTexture, depthTexture ) {
|
|
1872
2034
|
|
|
1873
|
-
|
|
2035
|
+
properties.get( renderTarget.texture ).__webglTexture = colorTexture;
|
|
2036
|
+
properties.get( renderTarget.depthTexture ).__webglTexture = depthTexture;
|
|
1874
2037
|
|
|
1875
|
-
|
|
1876
|
-
|
|
2038
|
+
const renderTargetProperties = properties.get( renderTarget );
|
|
2039
|
+
renderTargetProperties.__hasExternalTextures = true;
|
|
1877
2040
|
|
|
1878
|
-
|
|
1879
|
-
renderTargetProperties.__hasExternalTextures = true;
|
|
2041
|
+
if ( renderTargetProperties.__hasExternalTextures ) {
|
|
1880
2042
|
|
|
1881
|
-
|
|
2043
|
+
renderTargetProperties.__autoAllocateDepthBuffer = depthTexture === undefined;
|
|
1882
2044
|
|
|
1883
|
-
|
|
2045
|
+
if ( ! renderTargetProperties.__autoAllocateDepthBuffer ) {
|
|
1884
2046
|
|
|
1885
|
-
|
|
2047
|
+
// The multisample_render_to_texture extension doesn't work properly if there
|
|
2048
|
+
// are midframe flushes and an external depth buffer. Disable use of the extension.
|
|
2049
|
+
if ( extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true ) {
|
|
1886
2050
|
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
if ( extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true ) {
|
|
2051
|
+
console.warn( 'THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided' );
|
|
2052
|
+
renderTargetProperties.__useRenderToTexture = false;
|
|
1890
2053
|
|
|
1891
|
-
|
|
1892
|
-
renderTargetProperties.__useRenderToTexture = false;
|
|
2054
|
+
}
|
|
1893
2055
|
|
|
1894
2056
|
}
|
|
1895
2057
|
|
|
1896
2058
|
}
|
|
1897
2059
|
|
|
1898
|
-
}
|
|
2060
|
+
};
|
|
1899
2061
|
|
|
1900
|
-
|
|
2062
|
+
this.setRenderTargetFramebuffer = function ( renderTarget, defaultFramebuffer ) {
|
|
1901
2063
|
|
|
1902
|
-
|
|
2064
|
+
const renderTargetProperties = properties.get( renderTarget );
|
|
2065
|
+
renderTargetProperties.__webglFramebuffer = defaultFramebuffer;
|
|
2066
|
+
renderTargetProperties.__useDefaultFramebuffer = defaultFramebuffer === undefined;
|
|
1903
2067
|
|
|
1904
|
-
|
|
1905
|
-
renderTargetProperties.__webglFramebuffer = defaultFramebuffer;
|
|
1906
|
-
renderTargetProperties.__useDefaultFramebuffer = defaultFramebuffer === undefined;
|
|
2068
|
+
};
|
|
1907
2069
|
|
|
1908
|
-
|
|
2070
|
+
this.setRenderTarget = function ( renderTarget, activeCubeFace = 0, activeMipmapLevel = 0 ) {
|
|
1909
2071
|
|
|
1910
|
-
|
|
2072
|
+
_currentRenderTarget = renderTarget;
|
|
2073
|
+
_currentActiveCubeFace = activeCubeFace;
|
|
2074
|
+
_currentActiveMipmapLevel = activeMipmapLevel;
|
|
1911
2075
|
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
2076
|
+
let useDefaultFramebuffer = true;
|
|
2077
|
+
let framebuffer = null;
|
|
2078
|
+
let isCube = false;
|
|
2079
|
+
let isRenderTarget3D = false;
|
|
1915
2080
|
|
|
1916
|
-
|
|
1917
|
-
let framebuffer = null;
|
|
1918
|
-
let isCube = false;
|
|
1919
|
-
let isRenderTarget3D = false;
|
|
2081
|
+
if ( renderTarget ) {
|
|
1920
2082
|
|
|
1921
|
-
|
|
2083
|
+
const renderTargetProperties = properties.get( renderTarget );
|
|
1922
2084
|
|
|
1923
|
-
|
|
2085
|
+
if ( renderTargetProperties.__useDefaultFramebuffer !== undefined ) {
|
|
1924
2086
|
|
|
1925
|
-
|
|
2087
|
+
// We need to make sure to rebind the framebuffer.
|
|
2088
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, null );
|
|
2089
|
+
useDefaultFramebuffer = false;
|
|
1926
2090
|
|
|
1927
|
-
|
|
1928
|
-
state.bindFramebuffer( _gl.FRAMEBUFFER, null );
|
|
1929
|
-
useDefaultFramebuffer = false;
|
|
2091
|
+
} else if ( renderTargetProperties.__webglFramebuffer === undefined ) {
|
|
1930
2092
|
|
|
1931
|
-
|
|
2093
|
+
textures.setupRenderTarget( renderTarget );
|
|
1932
2094
|
|
|
1933
|
-
|
|
2095
|
+
} else if ( renderTargetProperties.__hasExternalTextures ) {
|
|
1934
2096
|
|
|
1935
|
-
|
|
2097
|
+
// Color and depth texture must be rebound in order for the swapchain to update.
|
|
2098
|
+
textures.rebindTextures( renderTarget, properties.get( renderTarget.texture ).__webglTexture, properties.get( renderTarget.depthTexture ).__webglTexture );
|
|
1936
2099
|
|
|
1937
|
-
|
|
1938
|
-
textures.rebindTextures( renderTarget, properties.get( renderTarget.texture ).__webglTexture, properties.get( renderTarget.depthTexture ).__webglTexture );
|
|
2100
|
+
}
|
|
1939
2101
|
|
|
1940
|
-
|
|
2102
|
+
const texture = renderTarget.texture;
|
|
2103
|
+
|
|
2104
|
+
if ( texture.isData3DTexture || texture.isDataArrayTexture || texture.isCompressedArrayTexture ) {
|
|
1941
2105
|
|
|
1942
|
-
|
|
2106
|
+
isRenderTarget3D = true;
|
|
1943
2107
|
|
|
1944
|
-
|
|
2108
|
+
}
|
|
1945
2109
|
|
|
1946
|
-
|
|
2110
|
+
const __webglFramebuffer = properties.get( renderTarget ).__webglFramebuffer;
|
|
1947
2111
|
|
|
1948
|
-
|
|
2112
|
+
if ( renderTarget.isWebGLCubeRenderTarget ) {
|
|
1949
2113
|
|
|
1950
|
-
|
|
2114
|
+
framebuffer = __webglFramebuffer[ activeCubeFace ];
|
|
2115
|
+
isCube = true;
|
|
1951
2116
|
|
|
1952
|
-
|
|
2117
|
+
} else if ( ( capabilities.isWebGL2 && renderTarget.samples > 0 ) && textures.useMultisampledRTT( renderTarget ) === false ) {
|
|
2118
|
+
|
|
2119
|
+
framebuffer = properties.get( renderTarget ).__webglMultisampledFramebuffer;
|
|
2120
|
+
|
|
2121
|
+
} else {
|
|
1953
2122
|
|
|
1954
|
-
|
|
1955
|
-
isCube = true;
|
|
2123
|
+
framebuffer = __webglFramebuffer;
|
|
1956
2124
|
|
|
1957
|
-
|
|
2125
|
+
}
|
|
1958
2126
|
|
|
1959
|
-
|
|
2127
|
+
_currentViewport.copy( renderTarget.viewport );
|
|
2128
|
+
_currentScissor.copy( renderTarget.scissor );
|
|
2129
|
+
_currentScissorTest = renderTarget.scissorTest;
|
|
1960
2130
|
|
|
1961
2131
|
} else {
|
|
1962
2132
|
|
|
1963
|
-
|
|
2133
|
+
_currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).floor();
|
|
2134
|
+
_currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).floor();
|
|
2135
|
+
_currentScissorTest = _scissorTest;
|
|
1964
2136
|
|
|
1965
2137
|
}
|
|
1966
2138
|
|
|
1967
|
-
|
|
1968
|
-
_currentScissor.copy( renderTarget.scissor );
|
|
1969
|
-
_currentScissorTest = renderTarget.scissorTest;
|
|
2139
|
+
const framebufferBound = state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
1970
2140
|
|
|
1971
|
-
|
|
2141
|
+
if ( framebufferBound && capabilities.drawBuffers && useDefaultFramebuffer ) {
|
|
1972
2142
|
|
|
1973
|
-
|
|
1974
|
-
_currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).floor();
|
|
1975
|
-
_currentScissorTest = _scissorTest;
|
|
2143
|
+
state.drawBuffers( renderTarget, framebuffer );
|
|
1976
2144
|
|
|
1977
|
-
|
|
2145
|
+
}
|
|
1978
2146
|
|
|
1979
|
-
|
|
2147
|
+
state.viewport( _currentViewport );
|
|
2148
|
+
state.scissor( _currentScissor );
|
|
2149
|
+
state.setScissorTest( _currentScissorTest );
|
|
1980
2150
|
|
|
1981
|
-
|
|
2151
|
+
if ( isCube ) {
|
|
1982
2152
|
|
|
1983
|
-
|
|
2153
|
+
const textureProperties = properties.get( renderTarget.texture );
|
|
2154
|
+
_gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_CUBE_MAP_POSITIVE_X + activeCubeFace, textureProperties.__webglTexture, activeMipmapLevel );
|
|
1984
2155
|
|
|
1985
|
-
|
|
2156
|
+
} else if ( isRenderTarget3D ) {
|
|
2157
|
+
|
|
2158
|
+
const textureProperties = properties.get( renderTarget.texture );
|
|
2159
|
+
const layer = activeCubeFace || 0;
|
|
2160
|
+
_gl.framebufferTextureLayer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, textureProperties.__webglTexture, activeMipmapLevel || 0, layer );
|
|
1986
2161
|
|
|
1987
|
-
|
|
1988
|
-
state.scissor( _currentScissor );
|
|
1989
|
-
state.setScissorTest( _currentScissorTest );
|
|
2162
|
+
}
|
|
1990
2163
|
|
|
1991
|
-
|
|
2164
|
+
_currentMaterialId = - 1; // reset current material to ensure correct uniform bindings
|
|
1992
2165
|
|
|
1993
|
-
|
|
1994
|
-
_gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_CUBE_MAP_POSITIVE_X + activeCubeFace, textureProperties.__webglTexture, activeMipmapLevel );
|
|
2166
|
+
};
|
|
1995
2167
|
|
|
1996
|
-
|
|
2168
|
+
this.readRenderTargetPixels = function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex ) {
|
|
1997
2169
|
|
|
1998
|
-
|
|
1999
|
-
const layer = activeCubeFace || 0;
|
|
2000
|
-
_gl.framebufferTextureLayer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, textureProperties.__webglTexture, activeMipmapLevel || 0, layer );
|
|
2170
|
+
if ( ! ( renderTarget && renderTarget.isWebGLRenderTarget ) ) {
|
|
2001
2171
|
|
|
2002
|
-
|
|
2172
|
+
console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.' );
|
|
2173
|
+
return;
|
|
2003
2174
|
|
|
2004
|
-
|
|
2175
|
+
}
|
|
2005
2176
|
|
|
2006
|
-
|
|
2177
|
+
let framebuffer = properties.get( renderTarget ).__webglFramebuffer;
|
|
2007
2178
|
|
|
2008
|
-
|
|
2179
|
+
if ( renderTarget.isWebGLCubeRenderTarget && activeCubeFaceIndex !== undefined ) {
|
|
2009
2180
|
|
|
2010
|
-
|
|
2181
|
+
framebuffer = framebuffer[ activeCubeFaceIndex ];
|
|
2011
2182
|
|
|
2012
|
-
|
|
2013
|
-
return;
|
|
2183
|
+
}
|
|
2014
2184
|
|
|
2015
|
-
|
|
2185
|
+
if ( framebuffer ) {
|
|
2016
2186
|
|
|
2017
|
-
|
|
2187
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
2018
2188
|
|
|
2019
|
-
|
|
2189
|
+
try {
|
|
2020
2190
|
|
|
2021
|
-
|
|
2191
|
+
const texture = renderTarget.texture;
|
|
2192
|
+
const textureFormat = texture.format;
|
|
2193
|
+
const textureType = texture.type;
|
|
2022
2194
|
|
|
2023
|
-
|
|
2195
|
+
if ( textureFormat !== RGBAFormat && utils.convert( textureFormat ) !== _gl.getParameter( _gl.IMPLEMENTATION_COLOR_READ_FORMAT ) ) {
|
|
2024
2196
|
|
|
2025
|
-
|
|
2197
|
+
console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.' );
|
|
2198
|
+
return;
|
|
2026
2199
|
|
|
2027
|
-
|
|
2200
|
+
}
|
|
2028
2201
|
|
|
2029
|
-
|
|
2202
|
+
const halfFloatSupportedByExt = ( textureType === HalfFloatType ) && ( extensions.has( 'EXT_color_buffer_half_float' ) || ( capabilities.isWebGL2 && extensions.has( 'EXT_color_buffer_float' ) ) );
|
|
2030
2203
|
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2204
|
+
if ( textureType !== UnsignedByteType && utils.convert( textureType ) !== _gl.getParameter( _gl.IMPLEMENTATION_COLOR_READ_TYPE ) && // Edge and Chrome Mac < 52 (#9513)
|
|
2205
|
+
! ( textureType === FloatType && ( capabilities.isWebGL2 || extensions.has( 'OES_texture_float' ) || extensions.has( 'WEBGL_color_buffer_float' ) ) ) && // Chrome Mac >= 52 and Firefox
|
|
2206
|
+
! halfFloatSupportedByExt ) {
|
|
2034
2207
|
|
|
2035
|
-
|
|
2208
|
+
console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.' );
|
|
2209
|
+
return;
|
|
2036
2210
|
|
|
2037
|
-
|
|
2038
|
-
return;
|
|
2211
|
+
}
|
|
2039
2212
|
|
|
2040
|
-
|
|
2213
|
+
// the following if statement ensures valid read requests (no out-of-bounds pixels, see #8604)
|
|
2214
|
+
|
|
2215
|
+
if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
|
|
2216
|
+
|
|
2217
|
+
_gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), buffer );
|
|
2218
|
+
|
|
2219
|
+
}
|
|
2041
2220
|
|
|
2042
|
-
|
|
2221
|
+
} finally {
|
|
2043
2222
|
|
|
2044
|
-
|
|
2045
|
-
! ( textureType === FloatType && ( capabilities.isWebGL2 || extensions.has( 'OES_texture_float' ) || extensions.has( 'WEBGL_color_buffer_float' ) ) ) && // Chrome Mac >= 52 and Firefox
|
|
2046
|
-
! halfFloatSupportedByExt ) {
|
|
2223
|
+
// restore framebuffer of current render target if necessary
|
|
2047
2224
|
|
|
2048
|
-
|
|
2049
|
-
|
|
2225
|
+
const framebuffer = ( _currentRenderTarget !== null ) ? properties.get( _currentRenderTarget ).__webglFramebuffer : null;
|
|
2226
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
2050
2227
|
|
|
2051
2228
|
}
|
|
2052
2229
|
|
|
2053
|
-
|
|
2230
|
+
}
|
|
2054
2231
|
|
|
2055
|
-
|
|
2232
|
+
};
|
|
2056
2233
|
|
|
2057
|
-
|
|
2234
|
+
this.copyFramebufferToTexture = function ( position, texture, level = 0 ) {
|
|
2058
2235
|
|
|
2059
|
-
|
|
2236
|
+
const levelScale = Math.pow( 2, - level );
|
|
2237
|
+
const width = Math.floor( texture.image.width * levelScale );
|
|
2238
|
+
const height = Math.floor( texture.image.height * levelScale );
|
|
2060
2239
|
|
|
2061
|
-
|
|
2240
|
+
textures.setTexture2D( texture, 0 );
|
|
2062
2241
|
|
|
2063
|
-
|
|
2242
|
+
_gl.copyTexSubImage2D( _gl.TEXTURE_2D, level, 0, 0, position.x, position.y, width, height );
|
|
2064
2243
|
|
|
2065
|
-
|
|
2066
|
-
state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
2244
|
+
state.unbindTexture();
|
|
2067
2245
|
|
|
2068
|
-
|
|
2246
|
+
};
|
|
2069
2247
|
|
|
2070
|
-
|
|
2248
|
+
this.copyTextureToTexture = function ( position, srcTexture, dstTexture, level = 0 ) {
|
|
2071
2249
|
|
|
2072
|
-
|
|
2250
|
+
const width = srcTexture.image.width;
|
|
2251
|
+
const height = srcTexture.image.height;
|
|
2252
|
+
const glFormat = utils.convert( dstTexture.format );
|
|
2253
|
+
const glType = utils.convert( dstTexture.type );
|
|
2073
2254
|
|
|
2074
|
-
|
|
2255
|
+
textures.setTexture2D( dstTexture, 0 );
|
|
2075
2256
|
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2257
|
+
// As another texture upload may have changed pixelStorei
|
|
2258
|
+
// parameters, make sure they are correct for the dstTexture
|
|
2259
|
+
_gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY );
|
|
2260
|
+
_gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );
|
|
2261
|
+
_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
|
|
2079
2262
|
|
|
2080
|
-
|
|
2263
|
+
if ( srcTexture.isDataTexture ) {
|
|
2081
2264
|
|
|
2082
|
-
|
|
2265
|
+
_gl.texSubImage2D( _gl.TEXTURE_2D, level, position.x, position.y, width, height, glFormat, glType, srcTexture.image.data );
|
|
2083
2266
|
|
|
2084
|
-
|
|
2267
|
+
} else {
|
|
2085
2268
|
|
|
2086
|
-
|
|
2269
|
+
if ( srcTexture.isCompressedTexture ) {
|
|
2087
2270
|
|
|
2088
|
-
|
|
2271
|
+
_gl.compressedTexSubImage2D( _gl.TEXTURE_2D, level, position.x, position.y, srcTexture.mipmaps[ 0 ].width, srcTexture.mipmaps[ 0 ].height, glFormat, srcTexture.mipmaps[ 0 ].data );
|
|
2089
2272
|
|
|
2090
|
-
|
|
2091
|
-
const height = srcTexture.image.height;
|
|
2092
|
-
const glFormat = utils.convert( dstTexture.format );
|
|
2093
|
-
const glType = utils.convert( dstTexture.type );
|
|
2273
|
+
} else {
|
|
2094
2274
|
|
|
2095
|
-
|
|
2275
|
+
_gl.texSubImage2D( _gl.TEXTURE_2D, level, position.x, position.y, glFormat, glType, srcTexture.image );
|
|
2096
2276
|
|
|
2097
|
-
|
|
2098
|
-
// parameters, make sure they are correct for the dstTexture
|
|
2099
|
-
_gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY );
|
|
2100
|
-
_gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );
|
|
2101
|
-
_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
|
|
2277
|
+
}
|
|
2102
2278
|
|
|
2103
|
-
|
|
2279
|
+
}
|
|
2104
2280
|
|
|
2105
|
-
|
|
2281
|
+
// Generate mipmaps only when copying level 0
|
|
2282
|
+
if ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( _gl.TEXTURE_2D );
|
|
2106
2283
|
|
|
2107
|
-
|
|
2284
|
+
state.unbindTexture();
|
|
2108
2285
|
|
|
2109
|
-
|
|
2286
|
+
};
|
|
2110
2287
|
|
|
2111
|
-
|
|
2288
|
+
this.copyTextureToTexture3D = function ( sourceBox, position, srcTexture, dstTexture, level = 0 ) {
|
|
2112
2289
|
|
|
2113
|
-
|
|
2290
|
+
if ( _this.isWebGL1Renderer ) {
|
|
2114
2291
|
|
|
2115
|
-
|
|
2292
|
+
console.warn( 'THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.' );
|
|
2293
|
+
return;
|
|
2116
2294
|
|
|
2117
2295
|
}
|
|
2118
2296
|
|
|
2119
|
-
|
|
2297
|
+
const width = sourceBox.max.x - sourceBox.min.x + 1;
|
|
2298
|
+
const height = sourceBox.max.y - sourceBox.min.y + 1;
|
|
2299
|
+
const depth = sourceBox.max.z - sourceBox.min.z + 1;
|
|
2300
|
+
const glFormat = utils.convert( dstTexture.format );
|
|
2301
|
+
const glType = utils.convert( dstTexture.type );
|
|
2302
|
+
let glTarget;
|
|
2120
2303
|
|
|
2121
|
-
|
|
2122
|
-
if ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( _gl.TEXTURE_2D );
|
|
2304
|
+
if ( dstTexture.isData3DTexture ) {
|
|
2123
2305
|
|
|
2124
|
-
|
|
2306
|
+
textures.setTexture3D( dstTexture, 0 );
|
|
2307
|
+
glTarget = _gl.TEXTURE_3D;
|
|
2125
2308
|
|
|
2126
|
-
|
|
2309
|
+
} else if ( dstTexture.isDataArrayTexture ) {
|
|
2127
2310
|
|
|
2128
|
-
|
|
2311
|
+
textures.setTexture2DArray( dstTexture, 0 );
|
|
2312
|
+
glTarget = _gl.TEXTURE_2D_ARRAY;
|
|
2129
2313
|
|
|
2130
|
-
|
|
2314
|
+
} else {
|
|
2131
2315
|
|
|
2132
|
-
|
|
2133
|
-
|
|
2316
|
+
console.warn( 'THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.' );
|
|
2317
|
+
return;
|
|
2134
2318
|
|
|
2135
|
-
|
|
2319
|
+
}
|
|
2136
2320
|
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
const glFormat = utils.convert( dstTexture.format );
|
|
2141
|
-
const glType = utils.convert( dstTexture.type );
|
|
2142
|
-
let glTarget;
|
|
2321
|
+
_gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY );
|
|
2322
|
+
_gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );
|
|
2323
|
+
_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
|
|
2143
2324
|
|
|
2144
|
-
|
|
2325
|
+
const unpackRowLen = _gl.getParameter( _gl.UNPACK_ROW_LENGTH );
|
|
2326
|
+
const unpackImageHeight = _gl.getParameter( _gl.UNPACK_IMAGE_HEIGHT );
|
|
2327
|
+
const unpackSkipPixels = _gl.getParameter( _gl.UNPACK_SKIP_PIXELS );
|
|
2328
|
+
const unpackSkipRows = _gl.getParameter( _gl.UNPACK_SKIP_ROWS );
|
|
2329
|
+
const unpackSkipImages = _gl.getParameter( _gl.UNPACK_SKIP_IMAGES );
|
|
2145
2330
|
|
|
2146
|
-
|
|
2147
|
-
glTarget = _gl.TEXTURE_3D;
|
|
2331
|
+
const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ 0 ] : srcTexture.image;
|
|
2148
2332
|
|
|
2149
|
-
|
|
2333
|
+
_gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, image.width );
|
|
2334
|
+
_gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, image.height );
|
|
2335
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, sourceBox.min.x );
|
|
2336
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, sourceBox.min.y );
|
|
2337
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, sourceBox.min.z );
|
|
2150
2338
|
|
|
2151
|
-
|
|
2152
|
-
glTarget = _gl.TEXTURE_2D_ARRAY;
|
|
2339
|
+
if ( srcTexture.isDataTexture || srcTexture.isData3DTexture ) {
|
|
2153
2340
|
|
|
2154
|
-
|
|
2341
|
+
_gl.texSubImage3D( glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, glType, image.data );
|
|
2155
2342
|
|
|
2156
|
-
|
|
2157
|
-
return;
|
|
2343
|
+
} else {
|
|
2158
2344
|
|
|
2159
|
-
|
|
2345
|
+
if ( srcTexture.isCompressedArrayTexture ) {
|
|
2160
2346
|
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
|
|
2347
|
+
console.warn( 'THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture.' );
|
|
2348
|
+
_gl.compressedTexSubImage3D( glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, image.data );
|
|
2164
2349
|
|
|
2165
|
-
|
|
2166
|
-
const unpackImageHeight = _gl.getParameter( _gl.UNPACK_IMAGE_HEIGHT );
|
|
2167
|
-
const unpackSkipPixels = _gl.getParameter( _gl.UNPACK_SKIP_PIXELS );
|
|
2168
|
-
const unpackSkipRows = _gl.getParameter( _gl.UNPACK_SKIP_ROWS );
|
|
2169
|
-
const unpackSkipImages = _gl.getParameter( _gl.UNPACK_SKIP_IMAGES );
|
|
2350
|
+
} else {
|
|
2170
2351
|
|
|
2171
|
-
|
|
2352
|
+
_gl.texSubImage3D( glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, glType, image );
|
|
2172
2353
|
|
|
2173
|
-
|
|
2174
|
-
_gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, image.height );
|
|
2175
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, sourceBox.min.x );
|
|
2176
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, sourceBox.min.y );
|
|
2177
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, sourceBox.min.z );
|
|
2354
|
+
}
|
|
2178
2355
|
|
|
2179
|
-
|
|
2356
|
+
}
|
|
2180
2357
|
|
|
2181
|
-
_gl.
|
|
2358
|
+
_gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, unpackRowLen );
|
|
2359
|
+
_gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, unpackImageHeight );
|
|
2360
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, unpackSkipPixels );
|
|
2361
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, unpackSkipRows );
|
|
2362
|
+
_gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, unpackSkipImages );
|
|
2182
2363
|
|
|
2183
|
-
|
|
2364
|
+
// Generate mipmaps only when copying level 0
|
|
2365
|
+
if ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( glTarget );
|
|
2366
|
+
|
|
2367
|
+
state.unbindTexture();
|
|
2368
|
+
|
|
2369
|
+
};
|
|
2370
|
+
|
|
2371
|
+
this.initTexture = function ( texture ) {
|
|
2372
|
+
|
|
2373
|
+
if ( texture.isCubeTexture ) {
|
|
2374
|
+
|
|
2375
|
+
textures.setTextureCube( texture, 0 );
|
|
2376
|
+
|
|
2377
|
+
} else if ( texture.isData3DTexture ) {
|
|
2378
|
+
|
|
2379
|
+
textures.setTexture3D( texture, 0 );
|
|
2184
2380
|
|
|
2185
|
-
if (
|
|
2381
|
+
} else if ( texture.isDataArrayTexture || texture.isCompressedArrayTexture ) {
|
|
2186
2382
|
|
|
2187
|
-
|
|
2188
|
-
_gl.compressedTexSubImage3D( glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, image.data );
|
|
2383
|
+
textures.setTexture2DArray( texture, 0 );
|
|
2189
2384
|
|
|
2190
2385
|
} else {
|
|
2191
2386
|
|
|
2192
|
-
|
|
2387
|
+
textures.setTexture2D( texture, 0 );
|
|
2193
2388
|
|
|
2194
2389
|
}
|
|
2195
2390
|
|
|
2196
|
-
|
|
2391
|
+
state.unbindTexture();
|
|
2197
2392
|
|
|
2198
|
-
|
|
2199
|
-
_gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, unpackImageHeight );
|
|
2200
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, unpackSkipPixels );
|
|
2201
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, unpackSkipRows );
|
|
2202
|
-
_gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, unpackSkipImages );
|
|
2393
|
+
};
|
|
2203
2394
|
|
|
2204
|
-
|
|
2205
|
-
if ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( glTarget );
|
|
2395
|
+
this.resetState = function () {
|
|
2206
2396
|
|
|
2207
|
-
|
|
2397
|
+
_currentActiveCubeFace = 0;
|
|
2398
|
+
_currentActiveMipmapLevel = 0;
|
|
2399
|
+
_currentRenderTarget = null;
|
|
2208
2400
|
|
|
2209
|
-
|
|
2401
|
+
state.reset();
|
|
2402
|
+
bindingStates.reset();
|
|
2210
2403
|
|
|
2211
|
-
|
|
2404
|
+
};
|
|
2212
2405
|
|
|
2213
|
-
if (
|
|
2406
|
+
if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {
|
|
2214
2407
|
|
|
2215
|
-
|
|
2408
|
+
__THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) );
|
|
2216
2409
|
|
|
2217
|
-
}
|
|
2410
|
+
}
|
|
2218
2411
|
|
|
2219
|
-
|
|
2412
|
+
}
|
|
2220
2413
|
|
|
2221
|
-
|
|
2414
|
+
get coordinateSystem() {
|
|
2222
2415
|
|
|
2223
|
-
|
|
2416
|
+
return WebGLCoordinateSystem;
|
|
2224
2417
|
|
|
2225
|
-
|
|
2418
|
+
}
|
|
2226
2419
|
|
|
2227
|
-
|
|
2420
|
+
get physicallyCorrectLights() { // @deprecated, r150
|
|
2228
2421
|
|
|
2229
|
-
|
|
2422
|
+
console.warn( 'THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead.' );
|
|
2423
|
+
return ! this.useLegacyLights;
|
|
2230
2424
|
|
|
2231
|
-
|
|
2425
|
+
}
|
|
2232
2426
|
|
|
2233
|
-
|
|
2427
|
+
set physicallyCorrectLights( value ) { // @deprecated, r150
|
|
2234
2428
|
|
|
2235
|
-
|
|
2429
|
+
console.warn( 'THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead.' );
|
|
2430
|
+
this.useLegacyLights = ! value;
|
|
2236
2431
|
|
|
2237
|
-
|
|
2238
|
-
_currentActiveMipmapLevel = 0;
|
|
2239
|
-
_currentRenderTarget = null;
|
|
2432
|
+
}
|
|
2240
2433
|
|
|
2241
|
-
|
|
2242
|
-
bindingStates.reset();
|
|
2434
|
+
get outputEncoding() { // @deprecated, r152
|
|
2243
2435
|
|
|
2244
|
-
|
|
2436
|
+
console.warn( 'THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead.' );
|
|
2437
|
+
return this.outputColorSpace === SRGBColorSpace ? sRGBEncoding : LinearEncoding;
|
|
2245
2438
|
|
|
2246
|
-
|
|
2439
|
+
}
|
|
2440
|
+
|
|
2441
|
+
set outputEncoding( encoding ) { // @deprecated, r152
|
|
2247
2442
|
|
|
2248
|
-
|
|
2443
|
+
console.warn( 'THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead.' );
|
|
2444
|
+
this.outputColorSpace = encoding === sRGBEncoding ? SRGBColorSpace : LinearSRGBColorSpace;
|
|
2249
2445
|
|
|
2250
2446
|
}
|
|
2251
2447
|
|
|
2252
2448
|
}
|
|
2253
2449
|
|
|
2450
|
+
|
|
2254
2451
|
export { WebGLRenderer };
|