super-three 0.155.0 → 0.157.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/three.cjs +361 -324
- package/build/three.js +361 -324
- package/build/three.min.js +2 -2
- package/build/three.module.js +354 -323
- package/build/three.module.min.js +1 -1
- package/examples/jsm/capabilities/WebGL.js +17 -0
- package/examples/jsm/controls/DragControls.js +3 -2
- package/examples/jsm/controls/OrbitControls.js +13 -5
- package/examples/jsm/csm/CSMShader.js +59 -21
- package/examples/jsm/exporters/EXRExporter.js +102 -24
- package/examples/jsm/exporters/GLTFExporter.js +1 -1
- package/examples/jsm/libs/rhino3dm/rhino3dm.js +8726 -4
- package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +8737 -4
- package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
- package/examples/jsm/libs/tween.module.js +790 -735
- package/examples/jsm/libs/utif.module.js +1644 -1558
- package/examples/jsm/lights/LightProbeGenerator.js +37 -3
- package/examples/jsm/lines/LineMaterial.js +90 -156
- package/examples/jsm/loaders/3DMLoader.js +378 -104
- package/examples/jsm/loaders/DDSLoader.js +46 -3
- package/examples/jsm/loaders/EXRLoader.js +4 -4
- package/examples/jsm/loaders/FBXLoader.js +2 -0
- package/examples/jsm/loaders/GLTFLoader.js +18 -8
- package/examples/jsm/loaders/KTX2Loader.js +126 -77
- package/examples/jsm/loaders/LDrawLoader.js +22 -16
- package/examples/jsm/loaders/LogLuvLoader.js +2 -2
- package/examples/jsm/loaders/MMDLoader.js +10 -7
- package/examples/jsm/loaders/RGBELoader.js +48 -66
- package/examples/jsm/loaders/STLLoader.js +7 -0
- package/examples/jsm/loaders/USDZLoader.js +215 -12
- package/examples/jsm/materials/MeshGouraudMaterial.js +22 -18
- package/examples/jsm/nodes/Nodes.js +8 -1
- package/examples/jsm/nodes/accessors/BitangentNode.js +1 -1
- package/examples/jsm/nodes/accessors/BufferAttributeNode.js +30 -4
- package/examples/jsm/nodes/accessors/BufferNode.js +1 -1
- package/examples/jsm/nodes/accessors/CameraNode.js +1 -1
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +19 -4
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +4 -5
- package/examples/jsm/nodes/accessors/InstanceNode.js +2 -2
- package/examples/jsm/nodes/accessors/LineMaterialNode.js +29 -0
- package/examples/jsm/nodes/accessors/MaterialNode.js +23 -13
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +12 -9
- package/examples/jsm/nodes/accessors/ModelNode.js +1 -1
- package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +5 -4
- package/examples/jsm/nodes/accessors/MorphNode.js +4 -4
- package/examples/jsm/nodes/accessors/NormalNode.js +1 -1
- package/examples/jsm/nodes/accessors/Object3DNode.js +3 -3
- package/examples/jsm/nodes/accessors/PointUVNode.js +1 -1
- package/examples/jsm/nodes/accessors/PositionNode.js +1 -1
- package/examples/jsm/nodes/accessors/ReferenceNode.js +13 -7
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +2 -2
- package/examples/jsm/nodes/accessors/SceneNode.js +2 -2
- package/examples/jsm/nodes/accessors/SkinningNode.js +2 -2
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +1 -1
- package/examples/jsm/nodes/accessors/TangentNode.js +1 -1
- package/examples/jsm/nodes/accessors/TextureBicubicNode.js +2 -2
- package/examples/jsm/nodes/accessors/TextureNode.js +18 -8
- package/examples/jsm/nodes/accessors/TextureSizeNode.js +2 -2
- package/examples/jsm/nodes/accessors/TextureStoreNode.js +29 -0
- package/examples/jsm/nodes/accessors/UVNode.js +1 -1
- package/examples/jsm/nodes/accessors/UserDataNode.js +2 -2
- package/examples/jsm/nodes/code/CodeNode.js +1 -1
- package/examples/jsm/nodes/code/ExpressionNode.js +1 -1
- package/examples/jsm/nodes/code/FunctionCallNode.js +1 -1
- package/examples/jsm/nodes/code/FunctionNode.js +18 -7
- package/examples/jsm/nodes/code/ScriptableNode.js +2 -2
- package/examples/jsm/nodes/code/ScriptableValueNode.js +2 -2
- package/examples/jsm/nodes/core/ArrayUniformNode.js +1 -1
- package/examples/jsm/nodes/core/AttributeNode.js +3 -3
- package/examples/jsm/nodes/core/BypassNode.js +1 -1
- package/examples/jsm/nodes/core/CacheNode.js +1 -1
- package/examples/jsm/nodes/core/ConstNode.js +1 -1
- package/examples/jsm/nodes/core/ContextNode.js +2 -2
- package/examples/jsm/nodes/core/IndexNode.js +1 -1
- package/examples/jsm/nodes/core/InputNode.js +1 -1
- package/examples/jsm/nodes/core/Node.js +45 -14
- package/examples/jsm/nodes/core/NodeBuilder.js +83 -15
- package/examples/jsm/nodes/core/NodeFrame.js +37 -14
- package/examples/jsm/nodes/core/NodeUniform.js +1 -1
- package/examples/jsm/nodes/core/OutputStructNode.js +62 -0
- package/examples/jsm/nodes/core/PropertyNode.js +3 -1
- package/examples/jsm/nodes/core/StackNode.js +5 -5
- package/examples/jsm/nodes/core/StructTypeNode.js +24 -0
- package/examples/jsm/nodes/core/TempNode.js +1 -1
- package/examples/jsm/nodes/core/UniformNode.js +3 -1
- package/examples/jsm/nodes/core/VarNode.js +1 -1
- package/examples/jsm/nodes/core/VaryingNode.js +1 -1
- package/examples/jsm/nodes/core/constants.js +1 -1
- package/examples/jsm/nodes/display/BlendModeNode.js +2 -2
- package/examples/jsm/nodes/display/BumpMapNode.js +2 -2
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +2 -2
- package/examples/jsm/nodes/display/ColorSpaceNode.js +2 -2
- package/examples/jsm/nodes/display/FrontFacingNode.js +1 -1
- package/examples/jsm/nodes/display/NormalMapNode.js +2 -2
- package/examples/jsm/nodes/display/PosterizeNode.js +2 -2
- package/examples/jsm/nodes/display/ToneMappingNode.js +2 -2
- package/examples/jsm/nodes/display/ViewportDepthNode.js +2 -2
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +1 -1
- package/examples/jsm/nodes/display/ViewportNode.js +21 -7
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +1 -1
- package/examples/jsm/nodes/display/ViewportTextureNode.js +1 -1
- package/examples/jsm/nodes/fog/FogExp2Node.js +2 -2
- package/examples/jsm/nodes/fog/FogNode.js +2 -2
- package/examples/jsm/nodes/fog/FogRangeNode.js +2 -2
- package/examples/jsm/nodes/geometry/RangeNode.js +2 -2
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +1 -1
- package/examples/jsm/nodes/lighting/AONode.js +2 -2
- package/examples/jsm/nodes/lighting/AmbientLightNode.js +3 -3
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +4 -4
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +4 -4
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +2 -2
- package/examples/jsm/nodes/lighting/HemisphereLightNode.js +3 -3
- package/examples/jsm/nodes/lighting/IESSpotLightNode.js +2 -2
- package/examples/jsm/nodes/lighting/LightNode.js +2 -2
- package/examples/jsm/nodes/lighting/LightingContextNode.js +3 -3
- package/examples/jsm/nodes/lighting/LightingNode.js +1 -1
- package/examples/jsm/nodes/lighting/LightsNode.js +4 -4
- package/examples/jsm/nodes/lighting/PointLightNode.js +3 -3
- package/examples/jsm/nodes/lighting/SpotLightNode.js +4 -4
- package/examples/jsm/nodes/materials/Line2NodeMaterial.js +449 -0
- package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +1 -1
- package/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +54 -0
- package/examples/jsm/nodes/materials/Materials.js +2 -0
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +1 -1
- package/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +2 -2
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +2 -2
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +3 -3
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +6 -6
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +3 -3
- package/examples/jsm/nodes/materials/NodeMaterial.js +39 -29
- package/examples/jsm/nodes/materials/PointsNodeMaterial.js +1 -1
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +2 -2
- package/examples/jsm/nodes/math/CondNode.js +1 -1
- package/examples/jsm/nodes/math/HashNode.js +34 -0
- package/examples/jsm/nodes/math/MathNode.js +2 -2
- package/examples/jsm/nodes/math/OperatorNode.js +1 -1
- package/examples/jsm/nodes/procedural/CheckerNode.js +3 -3
- package/examples/jsm/nodes/shadernode/ShaderNode.js +85 -28
- package/examples/jsm/nodes/utils/ArrayElementNode.js +1 -1
- package/examples/jsm/nodes/utils/ConvertNode.js +1 -1
- package/examples/jsm/nodes/utils/DiscardNode.js +1 -1
- package/examples/jsm/nodes/utils/EquirectUVNode.js +2 -2
- package/examples/jsm/nodes/utils/JoinNode.js +1 -1
- package/examples/jsm/nodes/utils/LoopNode.js +11 -11
- package/examples/jsm/nodes/utils/MatcapUVNode.js +2 -2
- package/examples/jsm/nodes/utils/MaxMipLevelNode.js +1 -1
- package/examples/jsm/nodes/utils/OscNode.js +2 -2
- package/examples/jsm/nodes/utils/PackingNode.js +2 -2
- package/examples/jsm/nodes/utils/RemapNode.js +2 -2
- package/examples/jsm/nodes/utils/RotateUVNode.js +2 -2
- package/examples/jsm/nodes/utils/SetNode.js +62 -0
- package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +2 -2
- package/examples/jsm/nodes/utils/SplitNode.js +2 -2
- package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +2 -2
- package/examples/jsm/nodes/utils/TimerNode.js +2 -2
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +2 -2
- package/examples/jsm/objects/Sky.js +1 -3
- package/examples/jsm/postprocessing/FilmPass.js +3 -5
- package/examples/jsm/postprocessing/OutputPass.js +3 -2
- package/examples/jsm/postprocessing/RenderPass.js +30 -12
- package/examples/jsm/postprocessing/SAOPass.js +23 -98
- package/examples/jsm/postprocessing/SSAOPass.js +10 -30
- package/examples/jsm/renderers/common/Backend.js +11 -8
- package/examples/jsm/renderers/common/Background.js +2 -2
- package/examples/jsm/renderers/common/Binding.js +6 -0
- package/examples/jsm/renderers/common/Bindings.js +4 -5
- package/examples/jsm/renderers/common/Pipelines.js +9 -9
- package/examples/jsm/renderers/common/RenderContext.js +3 -0
- package/examples/jsm/renderers/common/RenderContexts.js +26 -1
- package/examples/jsm/renderers/common/RenderList.js +12 -4
- package/examples/jsm/renderers/common/RenderObject.js +43 -15
- package/examples/jsm/renderers/common/RenderObjects.js +8 -14
- package/examples/jsm/renderers/common/Renderer.js +52 -16
- package/examples/jsm/renderers/common/SampledTexture.js +6 -3
- package/examples/jsm/renderers/common/Sampler.js +1 -1
- package/examples/jsm/renderers/common/StorageBuffer.js +1 -1
- package/examples/jsm/renderers/common/StorageTexture.js +19 -0
- package/examples/jsm/renderers/common/Textures.js +166 -21
- package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +35 -0
- package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +21 -11
- package/examples/jsm/renderers/common/nodes/NodeSampler.js +1 -7
- package/examples/jsm/renderers/common/nodes/Nodes.js +79 -18
- package/examples/jsm/renderers/webgl/WebGLBackend.js +702 -0
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +207 -20
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +84 -0
- package/examples/jsm/renderers/webgl/utils/WebGLExtensions.js +26 -0
- package/examples/jsm/renderers/webgl/utils/WebGLState.js +529 -0
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +212 -0
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +242 -0
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +340 -0
- package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodeBuilder.js +4 -4
- package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodes.js +14 -2
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +282 -43
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +18 -2
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +93 -60
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +2 -2
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +15 -2
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +39 -14
- package/examples/jsm/renderers/webgpu/utils/WebGPUTexturePassUtils.js +285 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +205 -284
- package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +6 -5
- package/examples/jsm/shaders/FilmShader.js +11 -54
- package/examples/jsm/shaders/GammaCorrectionShader.js +1 -1
- package/examples/jsm/shaders/MMDToonShader.js +4 -4
- package/examples/jsm/shaders/OutputShader.js +2 -2
- package/examples/jsm/shaders/SAOShader.js +0 -13
- package/examples/jsm/shaders/SSAOShader.js +33 -26
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +6 -6
- package/examples/jsm/utils/BufferGeometryUtils.js +6 -4
- package/package.json +1 -1
- package/src/Three.js +1 -2
- package/src/animation/AnimationUtils.js +3 -20
- package/src/animation/KeyframeTrack.js +8 -8
- package/src/audio/Audio.js +6 -0
- package/src/cameras/Camera.js +1 -5
- package/src/cameras/CubeCamera.js +14 -8
- package/src/constants.js +10 -1
- package/src/core/Object3D.js +1 -14
- package/src/core/RenderTarget.js +16 -7
- package/src/core/UniformsGroup.js +2 -2
- package/src/extras/core/CurvePath.js +4 -1
- package/src/loaders/DataTextureLoader.js +0 -2
- package/src/loaders/MaterialLoader.js +1 -1
- package/src/loaders/ObjectLoader.js +6 -0
- package/src/materials/Material.js +10 -10
- package/src/math/Color.js +1 -5
- package/src/math/ColorManagement.js +82 -60
- package/src/math/Vector2.js +2 -2
- package/src/math/Vector3.js +3 -3
- package/src/math/Vector4.js +4 -4
- package/src/objects/Line.js +1 -1
- package/src/objects/Mesh.js +1 -1
- package/src/objects/Points.js +1 -1
- package/src/objects/Sprite.js +2 -2
- package/src/renderers/WebGLRenderer.js +42 -51
- package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +35 -2
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -9
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +19 -15
- package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +4 -4
- package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +3 -3
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +11 -6
- package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +4 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +16 -16
- package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +3 -3
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +11 -1
- package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/background.glsl.js +8 -0
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +1 -1
- package/src/renderers/shaders/UniformsUtils.js +2 -2
- package/src/renderers/webgl/WebGLBackground.js +9 -17
- package/src/renderers/webgl/WebGLLights.js +14 -3
- package/src/renderers/webgl/WebGLProgram.js +36 -5
- package/src/renderers/webgl/WebGLPrograms.js +9 -1
- package/src/renderers/webgl/WebGLTextures.js +19 -8
- package/src/renderers/webgl/WebGLUtils.js +25 -20
- package/src/scenes/Fog.js +1 -0
- package/src/scenes/FogExp2.js +1 -0
- package/src/textures/Source.js +2 -2
- package/src/textures/Texture.js +2 -2
- package/src/utils.js +9 -1
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureMipmapUtils.js +0 -163
- package/src/lights/AmbientLightProbe.js +0 -21
- package/src/lights/HemisphereLightProbe.js +0 -30
- /package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/SlotNode.js +0 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBAFormat, DepthFormat, DepthStencilFormat, UnsignedShortType, UnsignedIntType, UnsignedInt248Type, FloatType, HalfFloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping, UnsignedByteType, _SRGBAFormat, NoColorSpace, LinearSRGBColorSpace, SRGBColorSpace, NeverCompare, AlwaysCompare, LessCompare, LessEqualCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare } from 'three';
|
|
2
|
+
|
|
3
|
+
let initialized = false, wrappingToGL, filterToGL, compareToGL;
|
|
4
|
+
|
|
5
|
+
class WebGLTextureUtils {
|
|
6
|
+
|
|
7
|
+
constructor( backend ) {
|
|
8
|
+
|
|
9
|
+
this.backend = backend;
|
|
10
|
+
|
|
11
|
+
this.gl = backend.gl;
|
|
12
|
+
this.extensions = backend.extensions;
|
|
13
|
+
|
|
14
|
+
if ( initialized === false ) {
|
|
15
|
+
|
|
16
|
+
this._init( this.gl );
|
|
17
|
+
|
|
18
|
+
initialized = true;
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
_init( gl ) {
|
|
25
|
+
|
|
26
|
+
// Store only WebGL constants here.
|
|
27
|
+
|
|
28
|
+
wrappingToGL = {
|
|
29
|
+
[ RepeatWrapping ]: gl.REPEAT,
|
|
30
|
+
[ ClampToEdgeWrapping ]: gl.CLAMP_TO_EDGE,
|
|
31
|
+
[ MirroredRepeatWrapping ]: gl.MIRRORED_REPEAT
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
filterToGL = {
|
|
35
|
+
[ NearestFilter ]: gl.NEAREST,
|
|
36
|
+
[ NearestMipmapNearestFilter ]: gl.NEAREST_MIPMAP_NEAREST,
|
|
37
|
+
[ NearestMipmapLinearFilter ]: gl.NEAREST_MIPMAP_LINEAR,
|
|
38
|
+
|
|
39
|
+
[ LinearFilter ]: gl.LINEAR,
|
|
40
|
+
[ LinearMipmapNearestFilter ]: gl.LINEAR_MIPMAP_NEAREST,
|
|
41
|
+
[ LinearMipmapLinearFilter ]: gl.LINEAR_MIPMAP_LINEAR
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
compareToGL = {
|
|
45
|
+
[ NeverCompare ]: gl.NEVER,
|
|
46
|
+
[ AlwaysCompare ]: gl.ALWAYS,
|
|
47
|
+
[ LessCompare ]: gl.LESS,
|
|
48
|
+
[ LessEqualCompare ]: gl.LEQUAL,
|
|
49
|
+
[ EqualCompare ]: gl.EQUAL,
|
|
50
|
+
[ GreaterEqualCompare ]: gl.GEQUAL,
|
|
51
|
+
[ GreaterCompare ]: gl.GREATER,
|
|
52
|
+
[ NotEqualCompare ]: gl.NOTEQUAL
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
filterFallback( f ) {
|
|
58
|
+
|
|
59
|
+
const { gl } = this;
|
|
60
|
+
|
|
61
|
+
if ( f === NearestFilter || f === NearestMipmapNearestFilter || f === NearestMipmapLinearFilter ) {
|
|
62
|
+
|
|
63
|
+
return gl.NEAREST;
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return gl.LINEAR;
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
getGLTextureType( texture ) {
|
|
72
|
+
|
|
73
|
+
const { gl } = this;
|
|
74
|
+
|
|
75
|
+
let glTextureType;
|
|
76
|
+
|
|
77
|
+
if ( texture.isCubeTexture === true ) {
|
|
78
|
+
|
|
79
|
+
glTextureType = gl.TEXTURE_CUBE_MAP;
|
|
80
|
+
|
|
81
|
+
} else {
|
|
82
|
+
|
|
83
|
+
glTextureType = gl.TEXTURE_2D;
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return glTextureType;
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
getInternalFormat( internalFormatName, glFormat, glType, colorSpace, forceLinearTransfer = false ) {
|
|
93
|
+
|
|
94
|
+
const { gl, extensions } = this;
|
|
95
|
+
|
|
96
|
+
if ( internalFormatName !== null ) {
|
|
97
|
+
|
|
98
|
+
if ( gl[ internalFormatName ] !== undefined ) return gl[ internalFormatName ];
|
|
99
|
+
|
|
100
|
+
console.warn( 'THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format \'' + internalFormatName + '\'' );
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
let internalFormat = glFormat;
|
|
105
|
+
|
|
106
|
+
if ( glFormat === gl.RED ) {
|
|
107
|
+
|
|
108
|
+
if ( glType === gl.FLOAT ) internalFormat = gl.R32F;
|
|
109
|
+
if ( glType === gl.HALF_FLOAT ) internalFormat = gl.R16F;
|
|
110
|
+
if ( glType === gl.UNSIGNED_BYTE ) internalFormat = gl.R8;
|
|
111
|
+
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if ( glFormat === gl.RED_INTEGER ) {
|
|
115
|
+
|
|
116
|
+
if ( glType === gl.UNSIGNED_BYTE ) internalFormat = gl.R8UI;
|
|
117
|
+
if ( glType === gl.UNSIGNED_SHORT ) internalFormat = gl.R16UI;
|
|
118
|
+
if ( glType === gl.UNSIGNED_INT ) internalFormat = gl.R32UI;
|
|
119
|
+
if ( glType === gl.BYTE ) internalFormat = gl.R8I;
|
|
120
|
+
if ( glType === gl.SHORT ) internalFormat = gl.R16I;
|
|
121
|
+
if ( glType === gl.INT ) internalFormat = gl.R32I;
|
|
122
|
+
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if ( glFormat === gl.RG ) {
|
|
126
|
+
|
|
127
|
+
if ( glType === gl.FLOAT ) internalFormat = gl.RG32F;
|
|
128
|
+
if ( glType === gl.HALF_FLOAT ) internalFormat = gl.RG16F;
|
|
129
|
+
if ( glType === gl.UNSIGNED_BYTE ) internalFormat = gl.RG8;
|
|
130
|
+
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if ( glFormat === gl.RGBA ) {
|
|
134
|
+
|
|
135
|
+
if ( glType === gl.FLOAT ) internalFormat = gl.RGBA32F;
|
|
136
|
+
if ( glType === gl.HALF_FLOAT ) internalFormat = gl.RGBA16F;
|
|
137
|
+
if ( glType === gl.UNSIGNED_BYTE ) internalFormat = ( colorSpace === SRGBColorSpace && forceLinearTransfer === false ) ? gl.SRGB8_ALPHA8 : gl.RGBA8;
|
|
138
|
+
if ( glType === gl.UNSIGNED_SHORT_4_4_4_4 ) internalFormat = gl.RGBA4;
|
|
139
|
+
if ( glType === gl.UNSIGNED_SHORT_5_5_5_1 ) internalFormat = gl.RGB5_A1;
|
|
140
|
+
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if ( glFormat === gl.DEPTH_COMPONENT ) {
|
|
144
|
+
|
|
145
|
+
if ( glType === gl.UNSIGNED_INT ) internalFormat = gl.DEPTH_COMPONENT24;
|
|
146
|
+
if ( glType === gl.FLOAT ) internalFormat = gl.DEPTH_COMPONENT32F;
|
|
147
|
+
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if ( glFormat === gl.DEPTH_STENCIL ) {
|
|
151
|
+
|
|
152
|
+
if ( glType === gl.UNSIGNED_INT_24_8 ) internalFormat = gl.DEPTH24_STENCIL8;
|
|
153
|
+
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if ( internalFormat === gl.R16F || internalFormat === gl.R32F ||
|
|
157
|
+
internalFormat === gl.RG16F || internalFormat === gl.RG32F ||
|
|
158
|
+
internalFormat === gl.RGBA16F || internalFormat === gl.RGBA32F ) {
|
|
159
|
+
|
|
160
|
+
extensions.get( 'EXT_color_buffer_float' );
|
|
161
|
+
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return internalFormat;
|
|
165
|
+
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
setTextureParameters( textureType, texture ) {
|
|
169
|
+
|
|
170
|
+
const { gl, extensions } = this;
|
|
171
|
+
|
|
172
|
+
gl.texParameteri( textureType, gl.TEXTURE_WRAP_S, wrappingToGL[ texture.wrapS ] );
|
|
173
|
+
gl.texParameteri( textureType, gl.TEXTURE_WRAP_T, wrappingToGL[ texture.wrapT ] );
|
|
174
|
+
|
|
175
|
+
if ( textureType === gl.TEXTURE_3D || textureType === gl.TEXTURE_2D_ARRAY ) {
|
|
176
|
+
|
|
177
|
+
gl.texParameteri( textureType, gl.TEXTURE_WRAP_R, wrappingToGL[ texture.wrapR ] );
|
|
178
|
+
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
gl.texParameteri( textureType, gl.TEXTURE_MAG_FILTER, filterToGL[ texture.magFilter ] );
|
|
182
|
+
gl.texParameteri( textureType, gl.TEXTURE_MIN_FILTER, filterToGL[ texture.minFilter ] );
|
|
183
|
+
|
|
184
|
+
if ( texture.compareFunction ) {
|
|
185
|
+
|
|
186
|
+
gl.texParameteri( textureType, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE );
|
|
187
|
+
gl.texParameteri( textureType, gl.TEXTURE_COMPARE_FUNC, compareToGL[ texture.compareFunction ] );
|
|
188
|
+
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if ( extensions.has( 'EXT_texture_filter_anisotropic' ) === true ) {
|
|
192
|
+
|
|
193
|
+
//extension = extensions.get( 'EXT_texture_filter_anisotropic' );
|
|
194
|
+
|
|
195
|
+
if ( texture.magFilter === NearestFilter ) return;
|
|
196
|
+
if ( texture.minFilter !== NearestMipmapLinearFilter && texture.minFilter !== LinearMipmapLinearFilter ) return;
|
|
197
|
+
if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false ) return; // verify extension for WebGL 1 and WebGL 2
|
|
198
|
+
|
|
199
|
+
if ( texture.anisotropy > 1 /*|| properties.get( texture ).__currentAnisotropy*/ ) {
|
|
200
|
+
|
|
201
|
+
//gl.texParameterf( textureType, extension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min( texture.anisotropy, capabilities.getMaxAnisotropy() ) );
|
|
202
|
+
//properties.get( texture ).__currentAnisotropy = texture.anisotropy;
|
|
203
|
+
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export default WebGLTextureUtils;
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT5_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT1_Format, RGB_S3TC_DXT1_Format, DepthFormat, DepthStencilFormat, LuminanceAlphaFormat, LuminanceFormat, RedFormat, RGBAFormat, AlphaFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBAIntegerFormat, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType, RGBA_BPTC_Format, _SRGBAFormat, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format, SRGBColorSpace, NoColorSpace } from 'three';
|
|
2
|
+
|
|
3
|
+
class WebGLUtils {
|
|
4
|
+
|
|
5
|
+
constructor( backend ) {
|
|
6
|
+
|
|
7
|
+
this.backend = backend;
|
|
8
|
+
|
|
9
|
+
this.gl = this.backend.gl;
|
|
10
|
+
this.extensions = backend.extensions;
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
convert( p, colorSpace = NoColorSpace ) {
|
|
15
|
+
|
|
16
|
+
const { gl, extensions } = this;
|
|
17
|
+
|
|
18
|
+
let extension;
|
|
19
|
+
|
|
20
|
+
if ( p === UnsignedByteType ) return gl.UNSIGNED_BYTE;
|
|
21
|
+
if ( p === UnsignedShort4444Type ) return gl.UNSIGNED_SHORT_4_4_4_4;
|
|
22
|
+
if ( p === UnsignedShort5551Type ) return gl.UNSIGNED_SHORT_5_5_5_1;
|
|
23
|
+
|
|
24
|
+
if ( p === ByteType ) return gl.BYTE;
|
|
25
|
+
if ( p === ShortType ) return gl.SHORT;
|
|
26
|
+
if ( p === UnsignedShortType ) return gl.UNSIGNED_SHORT;
|
|
27
|
+
if ( p === IntType ) return gl.INT;
|
|
28
|
+
if ( p === UnsignedIntType ) return gl.UNSIGNED_INT;
|
|
29
|
+
if ( p === FloatType ) return gl.FLOAT;
|
|
30
|
+
|
|
31
|
+
if ( p === HalfFloatType ) {
|
|
32
|
+
|
|
33
|
+
return gl.HALF_FLOAT;
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if ( p === AlphaFormat ) return gl.ALPHA;
|
|
38
|
+
if ( p === RGBAFormat ) return gl.RGBA;
|
|
39
|
+
if ( p === LuminanceFormat ) return gl.LUMINANCE;
|
|
40
|
+
if ( p === LuminanceAlphaFormat ) return gl.LUMINANCE_ALPHA;
|
|
41
|
+
if ( p === DepthFormat ) return gl.DEPTH_COMPONENT;
|
|
42
|
+
if ( p === DepthStencilFormat ) return gl.DEPTH_STENCIL;
|
|
43
|
+
|
|
44
|
+
// WebGL2 formats.
|
|
45
|
+
|
|
46
|
+
if ( p === RedFormat ) return gl.RED;
|
|
47
|
+
if ( p === RedIntegerFormat ) return gl.RED_INTEGER;
|
|
48
|
+
if ( p === RGFormat ) return gl.RG;
|
|
49
|
+
if ( p === RGIntegerFormat ) return gl.RG_INTEGER;
|
|
50
|
+
if ( p === RGBAIntegerFormat ) return gl.RGBA_INTEGER;
|
|
51
|
+
|
|
52
|
+
// S3TC
|
|
53
|
+
|
|
54
|
+
if ( p === RGB_S3TC_DXT1_Format || p === RGBA_S3TC_DXT1_Format || p === RGBA_S3TC_DXT3_Format || p === RGBA_S3TC_DXT5_Format ) {
|
|
55
|
+
|
|
56
|
+
if ( colorSpace === SRGBColorSpace ) {
|
|
57
|
+
|
|
58
|
+
extension = extensions.get( 'WEBGL_compressed_texture_s3tc_srgb' );
|
|
59
|
+
|
|
60
|
+
if ( extension !== null ) {
|
|
61
|
+
|
|
62
|
+
if ( p === RGB_S3TC_DXT1_Format ) return extension.COMPRESSED_SRGB_S3TC_DXT1_EXT;
|
|
63
|
+
if ( p === RGBA_S3TC_DXT1_Format ) return extension.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;
|
|
64
|
+
if ( p === RGBA_S3TC_DXT3_Format ) return extension.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;
|
|
65
|
+
if ( p === RGBA_S3TC_DXT5_Format ) return extension.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;
|
|
66
|
+
|
|
67
|
+
} else {
|
|
68
|
+
|
|
69
|
+
return null;
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
} else {
|
|
74
|
+
|
|
75
|
+
extension = extensions.get( 'WEBGL_compressed_texture_s3tc' );
|
|
76
|
+
|
|
77
|
+
if ( extension !== null ) {
|
|
78
|
+
|
|
79
|
+
if ( p === RGB_S3TC_DXT1_Format ) return extension.COMPRESSED_RGB_S3TC_DXT1_EXT;
|
|
80
|
+
if ( p === RGBA_S3TC_DXT1_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT1_EXT;
|
|
81
|
+
if ( p === RGBA_S3TC_DXT3_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT3_EXT;
|
|
82
|
+
if ( p === RGBA_S3TC_DXT5_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT5_EXT;
|
|
83
|
+
|
|
84
|
+
} else {
|
|
85
|
+
|
|
86
|
+
return null;
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// PVRTC
|
|
95
|
+
|
|
96
|
+
if ( p === RGB_PVRTC_4BPPV1_Format || p === RGB_PVRTC_2BPPV1_Format || p === RGBA_PVRTC_4BPPV1_Format || p === RGBA_PVRTC_2BPPV1_Format ) {
|
|
97
|
+
|
|
98
|
+
extension = extensions.get( 'WEBGL_compressed_texture_pvrtc' );
|
|
99
|
+
|
|
100
|
+
if ( extension !== null ) {
|
|
101
|
+
|
|
102
|
+
if ( p === RGB_PVRTC_4BPPV1_Format ) return extension.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
|
|
103
|
+
if ( p === RGB_PVRTC_2BPPV1_Format ) return extension.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
|
|
104
|
+
if ( p === RGBA_PVRTC_4BPPV1_Format ) return extension.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
|
|
105
|
+
if ( p === RGBA_PVRTC_2BPPV1_Format ) return extension.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
|
|
106
|
+
|
|
107
|
+
} else {
|
|
108
|
+
|
|
109
|
+
return null;
|
|
110
|
+
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// ETC1
|
|
116
|
+
|
|
117
|
+
if ( p === RGB_ETC1_Format ) {
|
|
118
|
+
|
|
119
|
+
extension = extensions.get( 'WEBGL_compressed_texture_etc1' );
|
|
120
|
+
|
|
121
|
+
if ( extension !== null ) {
|
|
122
|
+
|
|
123
|
+
return extension.COMPRESSED_RGB_ETC1_WEBGL;
|
|
124
|
+
|
|
125
|
+
} else {
|
|
126
|
+
|
|
127
|
+
return null;
|
|
128
|
+
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// ETC2
|
|
134
|
+
|
|
135
|
+
if ( p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format ) {
|
|
136
|
+
|
|
137
|
+
extension = extensions.get( 'WEBGL_compressed_texture_etc' );
|
|
138
|
+
|
|
139
|
+
if ( extension !== null ) {
|
|
140
|
+
|
|
141
|
+
if ( p === RGB_ETC2_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2;
|
|
142
|
+
if ( p === RGBA_ETC2_EAC_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : extension.COMPRESSED_RGBA8_ETC2_EAC;
|
|
143
|
+
|
|
144
|
+
} else {
|
|
145
|
+
|
|
146
|
+
return null;
|
|
147
|
+
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// ASTC
|
|
153
|
+
|
|
154
|
+
if ( p === RGBA_ASTC_4x4_Format || p === RGBA_ASTC_5x4_Format || p === RGBA_ASTC_5x5_Format ||
|
|
155
|
+
p === RGBA_ASTC_6x5_Format || p === RGBA_ASTC_6x6_Format || p === RGBA_ASTC_8x5_Format ||
|
|
156
|
+
p === RGBA_ASTC_8x6_Format || p === RGBA_ASTC_8x8_Format || p === RGBA_ASTC_10x5_Format ||
|
|
157
|
+
p === RGBA_ASTC_10x6_Format || p === RGBA_ASTC_10x8_Format || p === RGBA_ASTC_10x10_Format ||
|
|
158
|
+
p === RGBA_ASTC_12x10_Format || p === RGBA_ASTC_12x12_Format ) {
|
|
159
|
+
|
|
160
|
+
extension = extensions.get( 'WEBGL_compressed_texture_astc' );
|
|
161
|
+
|
|
162
|
+
if ( extension !== null ) {
|
|
163
|
+
|
|
164
|
+
if ( p === RGBA_ASTC_4x4_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : extension.COMPRESSED_RGBA_ASTC_4x4_KHR;
|
|
165
|
+
if ( p === RGBA_ASTC_5x4_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : extension.COMPRESSED_RGBA_ASTC_5x4_KHR;
|
|
166
|
+
if ( p === RGBA_ASTC_5x5_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : extension.COMPRESSED_RGBA_ASTC_5x5_KHR;
|
|
167
|
+
if ( p === RGBA_ASTC_6x5_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : extension.COMPRESSED_RGBA_ASTC_6x5_KHR;
|
|
168
|
+
if ( p === RGBA_ASTC_6x6_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : extension.COMPRESSED_RGBA_ASTC_6x6_KHR;
|
|
169
|
+
if ( p === RGBA_ASTC_8x5_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : extension.COMPRESSED_RGBA_ASTC_8x5_KHR;
|
|
170
|
+
if ( p === RGBA_ASTC_8x6_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : extension.COMPRESSED_RGBA_ASTC_8x6_KHR;
|
|
171
|
+
if ( p === RGBA_ASTC_8x8_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : extension.COMPRESSED_RGBA_ASTC_8x8_KHR;
|
|
172
|
+
if ( p === RGBA_ASTC_10x5_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : extension.COMPRESSED_RGBA_ASTC_10x5_KHR;
|
|
173
|
+
if ( p === RGBA_ASTC_10x6_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : extension.COMPRESSED_RGBA_ASTC_10x6_KHR;
|
|
174
|
+
if ( p === RGBA_ASTC_10x8_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : extension.COMPRESSED_RGBA_ASTC_10x8_KHR;
|
|
175
|
+
if ( p === RGBA_ASTC_10x10_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : extension.COMPRESSED_RGBA_ASTC_10x10_KHR;
|
|
176
|
+
if ( p === RGBA_ASTC_12x10_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : extension.COMPRESSED_RGBA_ASTC_12x10_KHR;
|
|
177
|
+
if ( p === RGBA_ASTC_12x12_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : extension.COMPRESSED_RGBA_ASTC_12x12_KHR;
|
|
178
|
+
|
|
179
|
+
} else {
|
|
180
|
+
|
|
181
|
+
return null;
|
|
182
|
+
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// BPTC
|
|
188
|
+
|
|
189
|
+
if ( p === RGBA_BPTC_Format ) {
|
|
190
|
+
|
|
191
|
+
extension = extensions.get( 'EXT_texture_compression_bptc' );
|
|
192
|
+
|
|
193
|
+
if ( extension !== null ) {
|
|
194
|
+
|
|
195
|
+
if ( p === RGBA_BPTC_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : extension.COMPRESSED_RGBA_BPTC_UNORM_EXT;
|
|
196
|
+
|
|
197
|
+
} else {
|
|
198
|
+
|
|
199
|
+
return null;
|
|
200
|
+
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// RGTC
|
|
206
|
+
|
|
207
|
+
if ( p === RED_RGTC1_Format || p === SIGNED_RED_RGTC1_Format || p === RED_GREEN_RGTC2_Format || p === SIGNED_RED_GREEN_RGTC2_Format ) {
|
|
208
|
+
|
|
209
|
+
extension = extensions.get( 'EXT_texture_compression_rgtc' );
|
|
210
|
+
|
|
211
|
+
if ( extension !== null ) {
|
|
212
|
+
|
|
213
|
+
if ( p === RGBA_BPTC_Format ) return extension.COMPRESSED_RED_RGTC1_EXT;
|
|
214
|
+
if ( p === SIGNED_RED_RGTC1_Format ) return extension.COMPRESSED_SIGNED_RED_RGTC1_EXT;
|
|
215
|
+
if ( p === RED_GREEN_RGTC2_Format ) return extension.COMPRESSED_RED_GREEN_RGTC2_EXT;
|
|
216
|
+
if ( p === SIGNED_RED_GREEN_RGTC2_Format ) return extension.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT;
|
|
217
|
+
|
|
218
|
+
} else {
|
|
219
|
+
|
|
220
|
+
return null;
|
|
221
|
+
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
//
|
|
227
|
+
|
|
228
|
+
if ( p === UnsignedInt248Type ) {
|
|
229
|
+
|
|
230
|
+
return gl.UNSIGNED_INT_24_8;
|
|
231
|
+
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// if "p" can't be resolved, assume the user defines a WebGL constant as a string (fallback/workaround for packed RGB formats)
|
|
235
|
+
|
|
236
|
+
return ( gl[ p ] !== undefined ) ? gl[ p ] : null;
|
|
237
|
+
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export default WebGLUtils;
|