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