@needle-tools/three 0.154.2 → 0.160.2
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 +21 -21
- package/README.md +86 -84
- package/build/three.cjs +53679 -51654
- package/build/three.module.js +53263 -51253
- package/build/three.module.min.js +6 -6
- package/examples/fonts/LICENSE +13 -13
- package/examples/fonts/README.md +11 -11
- package/examples/fonts/droid/NOTICE +190 -190
- package/examples/fonts/droid/README.txt +18 -18
- package/examples/fonts/ttf/README.md +9 -9
- package/examples/jsm/Addons.js +294 -0
- package/examples/jsm/animation/AnimationClipCreator.js +116 -116
- package/examples/jsm/animation/CCDIKSolver.js +482 -482
- package/examples/jsm/animation/MMDAnimationHelper.js +1207 -1207
- package/examples/jsm/animation/MMDPhysics.js +1406 -1406
- package/examples/jsm/cameras/CinematicCamera.js +208 -208
- package/examples/jsm/capabilities/WebGL.js +108 -91
- package/examples/jsm/capabilities/WebGPU.js +57 -53
- package/examples/jsm/controls/ArcballControls.js +3224 -3224
- package/examples/jsm/controls/DragControls.js +221 -220
- package/examples/jsm/controls/FirstPersonControls.js +325 -325
- package/examples/jsm/controls/FlyControls.js +326 -300
- package/examples/jsm/controls/MapControls.js +28 -28
- package/examples/jsm/controls/OrbitControls.js +1521 -1279
- package/examples/jsm/controls/PointerLockControls.js +162 -162
- package/examples/jsm/controls/TrackballControls.js +828 -828
- package/examples/jsm/controls/TransformControls.js +1573 -1557
- package/examples/jsm/csm/CSM.js +384 -384
- package/examples/jsm/csm/CSMFrustum.js +152 -152
- package/examples/jsm/csm/CSMHelper.js +193 -193
- package/examples/jsm/csm/CSMShader.js +295 -252
- package/examples/jsm/curves/CurveExtras.js +422 -422
- package/examples/jsm/curves/NURBSCurve.js +80 -80
- package/examples/jsm/curves/NURBSSurface.js +52 -52
- package/examples/jsm/curves/NURBSUtils.js +487 -487
- package/examples/jsm/effects/AnaglyphEffect.js +154 -154
- package/examples/jsm/effects/AsciiEffect.js +263 -263
- package/examples/jsm/effects/OutlineEffect.js +539 -539
- package/examples/jsm/effects/ParallaxBarrierEffect.js +119 -119
- package/examples/jsm/effects/PeppersGhostEffect.js +153 -153
- package/examples/jsm/effects/StereoEffect.js +55 -55
- package/examples/jsm/environments/DebugEnvironment.js +52 -52
- package/examples/jsm/environments/RoomEnvironment.js +148 -148
- package/examples/jsm/exporters/DRACOExporter.js +267 -267
- package/examples/jsm/exporters/EXRExporter.js +579 -501
- package/examples/jsm/exporters/GLTFExporter.js +3311 -3163
- package/examples/jsm/exporters/KTX2Exporter.js +292 -292
- package/examples/jsm/exporters/MMDExporter.js +217 -217
- package/examples/jsm/exporters/OBJExporter.js +284 -284
- package/examples/jsm/exporters/PLYExporter.js +528 -528
- package/examples/jsm/exporters/STLExporter.js +199 -199
- package/examples/jsm/exporters/USDZExporter.js +720 -710
- package/examples/jsm/geometries/BoxLineGeometry.js +69 -69
- package/examples/jsm/geometries/ConvexGeometry.js +53 -53
- package/examples/jsm/geometries/DecalGeometry.js +356 -356
- package/examples/jsm/geometries/InstancedPointsGeometry.js +174 -0
- package/examples/jsm/geometries/ParametricGeometries.js +254 -254
- package/examples/jsm/geometries/ParametricGeometry.js +139 -139
- package/examples/jsm/geometries/RoundedBoxGeometry.js +155 -155
- package/examples/jsm/geometries/SDFGeometryGenerator.js +144 -0
- package/examples/jsm/geometries/TeapotGeometry.js +704 -704
- package/examples/jsm/geometries/TextGeometry.js +57 -57
- package/examples/jsm/helpers/LightProbeHelper.js +130 -130
- package/examples/jsm/helpers/OctreeHelper.js +73 -73
- package/examples/jsm/helpers/PositionalAudioHelper.js +109 -109
- package/examples/jsm/helpers/RectAreaLightHelper.js +85 -85
- package/examples/jsm/helpers/TextureHelper.js +237 -0
- package/examples/jsm/helpers/VertexNormalsHelper.js +96 -96
- package/examples/jsm/helpers/VertexTangentsHelper.js +88 -88
- package/examples/jsm/helpers/ViewHelper.js +333 -333
- package/examples/jsm/interactive/HTMLMesh.js +572 -565
- package/examples/jsm/interactive/InteractiveGroup.js +116 -116
- package/examples/jsm/interactive/SelectionBox.js +227 -227
- package/examples/jsm/interactive/SelectionHelper.js +104 -97
- package/examples/jsm/libs/ammo.wasm.js +822 -822
- package/examples/jsm/libs/basis/README.md +46 -46
- package/examples/jsm/libs/basis/basis_transcoder.js +21 -21
- package/examples/jsm/libs/chevrotain.module.min.js +141 -141
- package/examples/jsm/libs/draco/README.md +32 -32
- package/examples/jsm/libs/draco/draco_decoder.js +34 -34
- package/examples/jsm/libs/draco/draco_encoder.js +33 -33
- package/examples/jsm/libs/draco/draco_wasm_wrapper.js +117 -117
- package/examples/jsm/libs/draco/gltf/draco_decoder.js +33 -33
- package/examples/jsm/libs/draco/gltf/draco_encoder.js +33 -33
- package/examples/jsm/libs/draco/gltf/draco_wasm_wrapper.js +116 -116
- package/examples/jsm/libs/ecsy.module.js +1792 -1792
- package/examples/jsm/libs/fflate.module.js +2474 -2474
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/libs/lil-gui.module.min.js +8 -8
- package/examples/jsm/libs/lottie_canvas.module.js +14849 -14844
- package/examples/jsm/libs/meshopt_decoder.module.js +178 -178
- package/examples/jsm/libs/mikktspace.module.js +128 -128
- package/examples/jsm/libs/mmdparser.module.js +11530 -11530
- package/examples/jsm/libs/motion-controllers.module.js +397 -397
- package/examples/jsm/libs/opentype.module.js +14506 -14568
- package/examples/jsm/libs/potpack.module.js +124 -124
- package/examples/jsm/libs/rhino3dm/rhino3dm.js +8743 -21
- package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +8748 -15
- package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
- package/examples/jsm/libs/stats.module.js +167 -167
- package/examples/jsm/libs/surfaceNet.js +201 -0
- package/examples/jsm/libs/tween.module.js +858 -803
- package/examples/jsm/libs/utif.module.js +1664 -1578
- package/examples/jsm/libs/zstddec.module.js +1 -1
- package/examples/jsm/lights/IESSpotLight.js +25 -25
- package/examples/jsm/lights/LightProbeGenerator.js +286 -252
- package/examples/jsm/lights/RectAreaLightUniformsLib.js +79 -79
- package/examples/jsm/lines/Line2.js +19 -19
- package/examples/jsm/lines/LineGeometry.js +79 -79
- package/examples/jsm/lines/LineMaterial.js +619 -702
- package/examples/jsm/lines/LineSegments2.js +361 -361
- package/examples/jsm/lines/LineSegmentsGeometry.js +241 -241
- package/examples/jsm/lines/Wireframe.js +56 -56
- package/examples/jsm/lines/WireframeGeometry2.js +24 -24
- package/examples/jsm/loaders/3DMLoader.js +1772 -1497
- package/examples/jsm/loaders/3MFLoader.js +1478 -1478
- package/examples/jsm/loaders/AMFLoader.js +521 -521
- package/examples/jsm/loaders/BVHLoader.js +437 -437
- package/examples/jsm/loaders/ColladaLoader.js +4116 -4122
- package/examples/jsm/loaders/DDSLoader.js +318 -274
- package/examples/jsm/loaders/DRACOLoader.js +613 -612
- package/examples/jsm/loaders/EXRLoader.js +2309 -2309
- package/examples/jsm/loaders/FBXLoader.js +4314 -4142
- package/examples/jsm/loaders/FontLoader.js +183 -183
- package/examples/jsm/loaders/GCodeLoader.js +261 -261
- package/examples/jsm/loaders/GLTFLoader.js +4666 -4579
- package/examples/jsm/loaders/GLTFLoaderAnimationPointer.js +719 -683
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +115 -115
- package/examples/jsm/loaders/IESLoader.js +337 -337
- package/examples/jsm/loaders/KMZLoader.js +130 -130
- package/examples/jsm/loaders/KTX2Loader.js +932 -868
- package/examples/jsm/loaders/KTXLoader.js +176 -176
- package/examples/jsm/loaders/LDrawLoader.js +2470 -2464
- package/examples/jsm/loaders/LUT3dlLoader.js +183 -151
- package/examples/jsm/loaders/LUTCubeLoader.js +167 -153
- package/examples/jsm/loaders/LUTImageLoader.js +163 -0
- package/examples/jsm/loaders/LWOLoader.js +1052 -1052
- package/examples/jsm/loaders/LogLuvLoader.js +606 -606
- package/examples/jsm/loaders/LottieLoader.js +77 -77
- package/examples/jsm/loaders/MD2Loader.js +399 -399
- package/examples/jsm/loaders/MDDLoader.js +102 -102
- package/examples/jsm/loaders/MMDLoader.js +2276 -2273
- package/examples/jsm/loaders/MTLLoader.js +567 -567
- package/examples/jsm/loaders/MaterialXLoader.js +852 -734
- package/examples/jsm/loaders/NRRDLoader.js +686 -699
- package/examples/jsm/loaders/OBJLoader.js +905 -905
- package/examples/jsm/loaders/PCDLoader.js +467 -467
- package/examples/jsm/loaders/PDBLoader.js +232 -232
- package/examples/jsm/loaders/PLYLoader.js +771 -771
- package/examples/jsm/loaders/PVRLoader.js +251 -251
- package/examples/jsm/loaders/RGBELoader.js +450 -468
- package/examples/jsm/loaders/RGBMLoader.js +1065 -1065
- package/examples/jsm/loaders/STLLoader.js +410 -403
- package/examples/jsm/loaders/SVGLoader.js +3173 -3172
- package/examples/jsm/loaders/TDSLoader.js +1124 -1124
- package/examples/jsm/loaders/TGALoader.js +517 -517
- package/examples/jsm/loaders/TIFFLoader.js +36 -36
- package/examples/jsm/loaders/TTFLoader.js +214 -214
- package/examples/jsm/loaders/TiltLoader.js +520 -520
- package/examples/jsm/loaders/USDZLoader.js +822 -633
- package/examples/jsm/loaders/VOXLoader.js +311 -311
- package/examples/jsm/loaders/VRMLLoader.js +3533 -3533
- package/examples/jsm/loaders/VTKLoader.js +1163 -1163
- package/examples/jsm/loaders/XYZLoader.js +106 -106
- package/examples/jsm/loaders/lwo/IFFParser.js +1214 -1218
- package/examples/jsm/loaders/lwo/LWO2Parser.js +414 -414
- package/examples/jsm/loaders/lwo/LWO3Parser.js +373 -373
- package/examples/jsm/materials/MeshGouraudMaterial.js +426 -420
- package/examples/jsm/materials/MeshPostProcessingMaterial.js +144 -0
- package/examples/jsm/math/Capsule.js +82 -137
- package/examples/jsm/math/ColorConverter.js +36 -36
- package/examples/jsm/math/ConvexHull.js +1271 -1271
- package/examples/jsm/math/ImprovedNoise.js +71 -71
- package/examples/jsm/math/Lut.js +204 -204
- package/examples/jsm/math/MeshSurfaceSampler.js +250 -250
- package/examples/jsm/math/OBB.js +423 -423
- package/examples/jsm/math/Octree.js +540 -462
- package/examples/jsm/math/SimplexNoise.js +444 -444
- package/examples/jsm/misc/ConvexObjectBreaker.js +519 -519
- package/examples/jsm/misc/GPUComputationRenderer.js +446 -455
- package/examples/jsm/misc/Gyroscope.js +66 -66
- package/examples/jsm/misc/MD2Character.js +276 -276
- package/examples/jsm/misc/MD2CharacterComplex.js +576 -576
- package/examples/jsm/misc/MorphAnimMesh.js +75 -75
- package/examples/jsm/misc/MorphBlendMesh.js +322 -322
- package/examples/jsm/misc/ProgressiveLightMap.js +323 -323
- package/examples/jsm/misc/RollerCoaster.js +566 -566
- package/examples/jsm/misc/Timer.js +119 -0
- package/examples/jsm/misc/TubePainter.js +202 -205
- package/examples/jsm/misc/Volume.js +473 -475
- package/examples/jsm/misc/VolumeSlice.js +229 -229
- package/examples/jsm/modifiers/CurveModifier.js +344 -326
- package/examples/jsm/modifiers/EdgeSplitModifier.js +279 -279
- package/examples/jsm/modifiers/SimplifyModifier.js +617 -525
- package/examples/jsm/modifiers/TessellateModifier.js +307 -307
- package/examples/jsm/nodes/Nodes.js +189 -172
- package/examples/jsm/nodes/accessors/BitangentNode.js +89 -89
- package/examples/jsm/nodes/accessors/BufferAttributeNode.js +127 -99
- package/examples/jsm/nodes/accessors/BufferNode.js +30 -30
- package/examples/jsm/nodes/accessors/CameraNode.js +120 -98
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +61 -101
- package/examples/jsm/nodes/accessors/InstanceNode.js +71 -71
- package/examples/jsm/nodes/accessors/InstancedPointsMaterialNode.js +21 -0
- package/examples/jsm/nodes/accessors/MaterialNode.js +314 -277
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +51 -39
- package/examples/jsm/nodes/accessors/ModelNode.js +33 -34
- package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +39 -29
- package/examples/jsm/nodes/accessors/MorphNode.js +245 -70
- package/examples/jsm/nodes/accessors/NormalNode.js +96 -96
- package/examples/jsm/nodes/accessors/Object3DNode.js +150 -150
- package/examples/jsm/nodes/accessors/PointUVNode.js +26 -26
- package/examples/jsm/nodes/accessors/PositionNode.js +104 -104
- package/examples/jsm/nodes/accessors/ReferenceNode.js +102 -72
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +35 -35
- package/examples/jsm/nodes/accessors/SceneNode.js +52 -46
- package/examples/jsm/nodes/accessors/SkinningNode.js +103 -93
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +54 -27
- package/examples/jsm/nodes/accessors/TangentNode.js +103 -103
- package/examples/jsm/nodes/accessors/TextureBicubicNode.js +94 -94
- package/examples/jsm/nodes/accessors/TextureNode.js +367 -230
- package/examples/jsm/nodes/accessors/TextureSizeNode.js +35 -35
- package/examples/jsm/nodes/accessors/TextureStoreNode.js +82 -0
- package/examples/jsm/nodes/accessors/UVNode.js +47 -47
- package/examples/jsm/nodes/accessors/UserDataNode.js +29 -29
- package/examples/jsm/nodes/accessors/VertexColorNode.js +70 -0
- package/examples/jsm/nodes/code/CodeNode.js +78 -78
- package/examples/jsm/nodes/code/ExpressionNode.js +37 -37
- package/examples/jsm/nodes/code/FunctionCallNode.js +96 -96
- package/examples/jsm/nodes/code/FunctionNode.js +138 -127
- package/examples/jsm/nodes/code/ScriptableNode.js +488 -488
- package/examples/jsm/nodes/code/ScriptableValueNode.js +167 -167
- package/examples/jsm/nodes/core/ArrayUniformNode.js +26 -26
- package/examples/jsm/nodes/core/AssignNode.js +72 -0
- package/examples/jsm/nodes/core/AttributeNode.js +108 -102
- package/examples/jsm/nodes/core/BypassNode.js +45 -45
- package/examples/jsm/nodes/core/CacheNode.js +49 -46
- package/examples/jsm/nodes/core/ConstNode.js +32 -32
- package/examples/jsm/nodes/core/ContextNode.js +61 -61
- package/examples/jsm/nodes/core/IndexNode.js +66 -66
- package/examples/jsm/nodes/core/InputNode.js +83 -83
- package/examples/jsm/nodes/core/LightingModel.js +17 -17
- package/examples/jsm/nodes/core/Node.js +483 -445
- package/examples/jsm/nodes/core/NodeAttribute.js +15 -15
- package/examples/jsm/nodes/core/NodeBuilder.js +1267 -1016
- package/examples/jsm/nodes/core/NodeCache.js +26 -26
- package/examples/jsm/nodes/core/NodeCode.js +15 -15
- package/examples/jsm/nodes/core/NodeFrame.js +135 -110
- package/examples/jsm/nodes/core/NodeFunction.js +22 -22
- package/examples/jsm/nodes/core/NodeFunctionInput.js +17 -17
- package/examples/jsm/nodes/core/NodeKeywords.js +80 -80
- package/examples/jsm/nodes/core/NodeParser.js +11 -11
- package/examples/jsm/nodes/core/NodeUniform.js +40 -28
- package/examples/jsm/nodes/core/NodeUtils.js +210 -212
- package/examples/jsm/nodes/core/NodeVar.js +14 -14
- package/examples/jsm/nodes/core/NodeVarying.js +17 -17
- package/examples/jsm/nodes/core/OutputStructNode.js +62 -0
- package/examples/jsm/nodes/core/ParameterNode.js +33 -0
- package/examples/jsm/nodes/core/PropertyNode.js +72 -57
- package/examples/jsm/nodes/core/StackNode.js +89 -99
- package/examples/jsm/nodes/core/StructTypeNode.js +24 -0
- package/examples/jsm/nodes/core/TempNode.js +58 -58
- package/examples/jsm/nodes/core/UniformGroup.js +13 -0
- package/examples/jsm/nodes/core/UniformGroupNode.js +36 -0
- package/examples/jsm/nodes/core/UniformNode.js +80 -61
- package/examples/jsm/nodes/core/VarNode.js +60 -87
- package/examples/jsm/nodes/core/VaryingNode.js +65 -69
- package/examples/jsm/nodes/core/constants.js +27 -27
- package/examples/jsm/nodes/display/AfterImageNode.js +134 -0
- package/examples/jsm/nodes/display/BlendModeNode.js +99 -99
- package/examples/jsm/nodes/display/BumpMapNode.js +99 -0
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +96 -100
- package/examples/jsm/nodes/display/ColorSpaceNode.js +108 -108
- package/examples/jsm/nodes/display/FrontFacingNode.js +27 -27
- package/examples/jsm/nodes/display/GaussianBlurNode.js +177 -0
- package/examples/jsm/nodes/display/NormalMapNode.js +108 -106
- package/examples/jsm/nodes/display/PassNode.js +182 -0
- package/examples/jsm/nodes/display/PosterizeNode.js +32 -32
- package/examples/jsm/nodes/display/ToneMappingNode.js +184 -141
- package/examples/jsm/nodes/display/ViewportDepthNode.js +97 -69
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +31 -34
- package/examples/jsm/nodes/display/ViewportNode.js +134 -115
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +31 -31
- package/examples/jsm/nodes/display/ViewportTextureNode.js +75 -75
- package/examples/jsm/nodes/fog/FogExp2Node.js +35 -35
- package/examples/jsm/nodes/fog/FogNode.js +38 -37
- package/examples/jsm/nodes/fog/FogRangeNode.js +34 -34
- package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +40 -32
- package/examples/jsm/nodes/functions/BSDF/BRDF_Lambert.js +9 -9
- package/examples/jsm/nodes/functions/BSDF/BRDF_Sheen.js +57 -43
- package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +30 -29
- package/examples/jsm/nodes/functions/BSDF/D_GGX.js +23 -18
- package/examples/jsm/nodes/functions/BSDF/EnvironmentBRDF.js +13 -13
- package/examples/jsm/nodes/functions/BSDF/F_Schlick.js +16 -16
- package/examples/jsm/nodes/functions/BSDF/Schlick_to_F0.js +21 -0
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +28 -20
- package/examples/jsm/nodes/functions/PhongLightingModel.js +67 -28
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +393 -204
- package/examples/jsm/nodes/functions/material/getGeometryRoughness.js +13 -13
- package/examples/jsm/nodes/functions/material/getRoughness.js +18 -18
- package/examples/jsm/nodes/geometry/RangeNode.js +104 -104
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +85 -72
- package/examples/jsm/nodes/lighting/AONode.js +27 -27
- package/examples/jsm/nodes/lighting/AmbientLightNode.js +27 -27
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +238 -146
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +40 -43
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +181 -181
- package/examples/jsm/nodes/lighting/HemisphereLightNode.js +55 -55
- package/examples/jsm/nodes/lighting/IESSpotLightNode.js +39 -39
- package/examples/jsm/nodes/lighting/LightNode.js +57 -57
- package/examples/jsm/nodes/lighting/LightUtils.js +17 -17
- package/examples/jsm/nodes/lighting/LightingContextNode.js +66 -99
- package/examples/jsm/nodes/lighting/LightingNode.js +21 -21
- package/examples/jsm/nodes/lighting/LightsNode.js +188 -128
- package/examples/jsm/nodes/lighting/PointLightNode.js +68 -71
- package/examples/jsm/nodes/lighting/SpotLightNode.js +89 -92
- package/examples/jsm/nodes/loaders/NodeLoader.js +108 -108
- package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +59 -59
- package/examples/jsm/nodes/loaders/NodeObjectLoader.js +70 -70
- package/examples/jsm/nodes/materials/InstancedPointsNodeMaterial.js +162 -0
- package/examples/jsm/nodes/materials/Line2NodeMaterial.js +436 -0
- package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +28 -28
- package/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +54 -0
- package/examples/jsm/nodes/materials/Materials.js +16 -11
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +28 -27
- package/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +34 -0
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +40 -38
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +65 -65
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +155 -111
- package/examples/jsm/nodes/materials/MeshSSSNodeMaterial.js +84 -0
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +80 -80
- package/examples/jsm/nodes/materials/NodeMaterial.js +568 -510
- package/examples/jsm/nodes/materials/PointsNodeMaterial.js +39 -49
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +96 -103
- package/examples/jsm/nodes/materialx/DISCLAIMER.md +199 -199
- package/examples/jsm/nodes/materialx/MaterialXNodes.js +68 -68
- package/examples/jsm/nodes/materialx/lib/mx_hsv.js +130 -56
- package/examples/jsm/nodes/materialx/lib/mx_noise.js +1430 -618
- package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +29 -19
- package/examples/jsm/nodes/math/CondNode.js +86 -86
- package/examples/jsm/nodes/math/HashNode.js +34 -0
- package/examples/jsm/nodes/math/MathNode.js +382 -359
- package/examples/jsm/nodes/math/OperatorNode.js +266 -269
- package/examples/jsm/nodes/math/TriNoise3D.js +71 -0
- package/examples/jsm/nodes/parsers/GLSLNodeFunction.js +152 -152
- package/examples/jsm/nodes/parsers/GLSLNodeParser.js +14 -14
- package/examples/jsm/nodes/procedural/CheckerNode.js +42 -42
- package/examples/jsm/nodes/shadernode/ShaderNode.js +625 -420
- package/examples/jsm/nodes/utils/ArrayElementNode.js +41 -33
- package/examples/jsm/nodes/utils/ConvertNode.js +65 -65
- package/examples/jsm/nodes/utils/DiscardNode.js +27 -26
- package/examples/jsm/nodes/utils/EquirectUVNode.js +33 -33
- package/examples/jsm/nodes/utils/FunctionOverloadingNode.js +95 -0
- package/examples/jsm/nodes/utils/JoinNode.js +61 -51
- package/examples/jsm/nodes/utils/LoopNode.js +198 -186
- package/examples/jsm/nodes/utils/MatcapUVNode.js +30 -30
- package/examples/jsm/nodes/utils/MaxMipLevelNode.js +46 -46
- package/examples/jsm/nodes/utils/OscNode.js +81 -81
- package/examples/jsm/nodes/utils/PackingNode.js +55 -55
- package/examples/jsm/nodes/utils/RemapNode.js +42 -42
- package/examples/jsm/nodes/utils/RotateNode.js +43 -0
- package/examples/jsm/nodes/utils/RotateUVNode.js +43 -43
- package/examples/jsm/nodes/utils/SetNode.js +62 -0
- package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +37 -37
- package/examples/jsm/nodes/utils/SplitNode.js +112 -104
- package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +41 -41
- package/examples/jsm/nodes/utils/TimerNode.js +94 -94
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +62 -62
- package/examples/jsm/objects/GroundedSkybox.js +50 -0
- package/examples/jsm/objects/InstancedPoints.js +21 -0
- package/examples/jsm/objects/Lensflare.js +397 -377
- package/examples/jsm/objects/MarchingCubes.js +1176 -1176
- package/examples/jsm/objects/QuadMesh.js +66 -0
- package/examples/jsm/objects/Reflector.js +264 -272
- package/examples/jsm/objects/ReflectorForSSRPass.js +352 -349
- package/examples/jsm/objects/Refractor.js +327 -332
- package/examples/jsm/objects/ShadowMesh.js +80 -80
- package/examples/jsm/objects/Sky.js +219 -219
- package/examples/jsm/objects/Water.js +333 -330
- package/examples/jsm/objects/Water2.js +361 -358
- package/examples/jsm/offscreen/jank.js +45 -45
- package/examples/jsm/offscreen/offscreen.js +8 -8
- package/examples/jsm/offscreen/scene.js +86 -87
- package/examples/jsm/physics/AmmoPhysics.js +306 -285
- package/examples/jsm/physics/RapierPhysics.js +220 -199
- package/examples/jsm/postprocessing/AfterimagePass.js +104 -104
- package/examples/jsm/postprocessing/BloomPass.js +172 -172
- package/examples/jsm/postprocessing/BokehPass.js +141 -140
- package/examples/jsm/postprocessing/ClearPass.js +46 -46
- package/examples/jsm/postprocessing/CubeTexturePass.js +85 -85
- package/examples/jsm/postprocessing/DotScreenPass.js +65 -65
- package/examples/jsm/postprocessing/EffectComposer.js +231 -231
- package/examples/jsm/postprocessing/FilmPass.js +64 -66
- package/examples/jsm/postprocessing/GTAOPass.js +582 -0
- package/examples/jsm/postprocessing/GlitchPass.js +128 -128
- package/examples/jsm/postprocessing/HalftonePass.js +79 -79
- package/examples/jsm/postprocessing/LUTPass.js +174 -173
- package/examples/jsm/postprocessing/MaskPass.js +104 -101
- package/examples/jsm/postprocessing/OutlinePass.js +654 -654
- package/examples/jsm/postprocessing/OutputPass.js +95 -72
- package/examples/jsm/postprocessing/Pass.js +95 -84
- package/examples/jsm/postprocessing/RenderPass.js +99 -81
- package/examples/jsm/postprocessing/RenderPixelatedPass.js +235 -235
- package/examples/jsm/postprocessing/SAOPass.js +335 -411
- package/examples/jsm/postprocessing/SMAAPass.js +199 -201
- package/examples/jsm/postprocessing/SSAARenderPass.js +228 -228
- package/examples/jsm/postprocessing/SSAOPass.js +420 -440
- package/examples/jsm/postprocessing/SSRPass.js +641 -641
- package/examples/jsm/postprocessing/SavePass.js +79 -79
- package/examples/jsm/postprocessing/ShaderPass.js +77 -77
- package/examples/jsm/postprocessing/TAARenderPass.js +188 -189
- package/examples/jsm/postprocessing/TexturePass.js +67 -67
- package/examples/jsm/postprocessing/UnrealBloomPass.js +415 -411
- package/examples/jsm/renderers/CSS2DRenderer.js +215 -215
- package/examples/jsm/renderers/CSS3DRenderer.js +329 -335
- package/examples/jsm/renderers/Projector.js +918 -918
- package/examples/jsm/renderers/SVGRenderer.js +556 -553
- package/examples/jsm/renderers/common/Animation.js +47 -58
- package/examples/jsm/renderers/common/Attributes.js +75 -75
- package/examples/jsm/renderers/common/Backend.js +193 -162
- package/examples/jsm/renderers/common/Background.js +134 -134
- package/examples/jsm/renderers/common/Binding.js +25 -11
- package/examples/jsm/renderers/common/Bindings.js +173 -169
- package/examples/jsm/renderers/common/Buffer.js +38 -38
- package/examples/jsm/renderers/common/BufferUtils.js +33 -33
- package/examples/jsm/renderers/common/ChainMap.js +89 -89
- package/examples/jsm/renderers/common/Color4.js +37 -0
- package/examples/jsm/renderers/common/ComputePipeline.js +17 -17
- package/examples/jsm/renderers/common/Constants.js +14 -14
- package/examples/jsm/renderers/common/CubeRenderTarget.js +65 -65
- package/examples/jsm/renderers/common/DataMap.js +54 -54
- package/examples/jsm/renderers/common/Geometries.js +215 -215
- package/examples/jsm/renderers/common/Info.js +107 -73
- package/examples/jsm/renderers/common/Pipeline.js +13 -13
- package/examples/jsm/renderers/common/Pipelines.js +322 -321
- package/examples/jsm/renderers/common/PostProcessing.js +25 -0
- package/examples/jsm/renderers/common/ProgrammableStage.js +20 -18
- package/examples/jsm/renderers/common/RenderContext.js +41 -37
- package/examples/jsm/renderers/common/RenderContexts.js +74 -38
- package/examples/jsm/renderers/common/RenderList.js +186 -178
- package/examples/jsm/renderers/common/RenderLists.js +38 -38
- package/examples/jsm/renderers/common/RenderObject.js +178 -113
- package/examples/jsm/renderers/common/RenderObjects.js +91 -92
- package/examples/jsm/renderers/common/RenderPipeline.js +16 -16
- package/examples/jsm/renderers/common/Renderer.js +1062 -864
- package/examples/jsm/renderers/common/SampledTexture.js +83 -80
- package/examples/jsm/renderers/common/Sampler.js +18 -18
- package/examples/jsm/renderers/common/StorageBuffer.js +17 -17
- package/examples/jsm/renderers/common/StorageBufferAttribute.js +21 -0
- package/examples/jsm/renderers/common/StorageTexture.js +20 -0
- package/examples/jsm/renderers/common/Textures.js +354 -206
- package/examples/jsm/renderers/common/Uniform.js +140 -140
- package/examples/jsm/renderers/common/UniformBuffer.js +15 -15
- package/examples/jsm/renderers/common/UniformsGroup.js +299 -299
- package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +44 -0
- package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +49 -39
- package/examples/jsm/renderers/common/nodes/NodeSampler.js +15 -21
- package/examples/jsm/renderers/common/nodes/NodeUniform.js +135 -135
- package/examples/jsm/renderers/common/nodes/NodeUniformsGroup.js +44 -0
- package/examples/jsm/renderers/common/nodes/Nodes.js +495 -319
- package/examples/jsm/renderers/webgl/WebGLBackend.js +1290 -0
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +679 -340
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +252 -0
- package/examples/jsm/renderers/webgl/utils/WebGLCapabilities.js +36 -0
- package/examples/jsm/renderers/webgl/utils/WebGLConstants.js +11 -0
- package/examples/jsm/renderers/webgl/utils/WebGLExtensions.js +36 -0
- package/examples/jsm/renderers/webgl/utils/WebGLState.js +738 -0
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +647 -0
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +284 -0
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +320 -0
- package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/SlotNode.js +26 -26
- package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodeBuilder.js +794 -764
- package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodes.js +51 -49
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +1321 -847
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +53 -32
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +1098 -878
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +104 -104
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeParser.js +14 -14
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +287 -255
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +244 -145
- package/examples/jsm/renderers/webgpu/utils/WebGPUConstants.js +324 -322
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +570 -580
- package/examples/jsm/renderers/webgpu/utils/WebGPUTexturePassUtils.js +285 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +1040 -937
- package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +93 -92
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +89 -87
- package/examples/jsm/shaders/AfterimageShader.js +58 -56
- package/examples/jsm/shaders/BasicShader.js +29 -27
- package/examples/jsm/shaders/BleachBypassShader.js +62 -62
- package/examples/jsm/shaders/BlendShader.js +49 -47
- package/examples/jsm/shaders/BokehShader.js +145 -143
- package/examples/jsm/shaders/BokehShader2.js +397 -393
- package/examples/jsm/shaders/BrightnessContrastShader.js +56 -54
- package/examples/jsm/shaders/ColorCorrectionShader.js +52 -50
- package/examples/jsm/shaders/ColorifyShader.js +51 -51
- package/examples/jsm/shaders/ConvolutionShader.js +103 -103
- package/examples/jsm/shaders/CopyShader.js +45 -45
- package/examples/jsm/shaders/DOFMipMapShader.js +56 -54
- package/examples/jsm/shaders/DepthLimitedBlurShader.js +171 -166
- package/examples/jsm/shaders/DigitalGlitch.js +101 -101
- package/examples/jsm/shaders/DotScreenShader.js +70 -70
- package/examples/jsm/shaders/ExposureShader.js +44 -44
- package/examples/jsm/shaders/FXAAShader.js +288 -286
- package/examples/jsm/shaders/FilmShader.js +59 -102
- package/examples/jsm/shaders/FocusShader.js +89 -87
- package/examples/jsm/shaders/FreiChenShader.js +96 -94
- package/examples/jsm/shaders/GTAOShader.js +424 -0
- package/examples/jsm/shaders/GammaCorrectionShader.js +43 -43
- package/examples/jsm/shaders/GodRaysShader.js +321 -313
- package/examples/jsm/shaders/HalftoneShader.js +312 -310
- package/examples/jsm/shaders/HorizontalBlurShader.js +59 -59
- package/examples/jsm/shaders/HorizontalTiltShiftShader.js +63 -61
- package/examples/jsm/shaders/HueSaturationShader.js +67 -65
- package/examples/jsm/shaders/KaleidoShader.js +58 -56
- package/examples/jsm/shaders/LuminosityHighPassShader.js +66 -64
- package/examples/jsm/shaders/LuminosityShader.js +48 -46
- package/examples/jsm/shaders/MMDToonShader.js +134 -132
- package/examples/jsm/shaders/MirrorShader.js +56 -54
- package/examples/jsm/shaders/NormalMapShader.js +55 -53
- package/examples/jsm/shaders/OutputShader.js +81 -61
- package/examples/jsm/shaders/PoissonDenoiseShader.js +226 -0
- package/examples/jsm/shaders/RGBShiftShader.js +54 -54
- package/examples/jsm/shaders/SAOShader.js +179 -188
- package/examples/jsm/shaders/SMAAShader.js +466 -460
- package/examples/jsm/shaders/SSAOShader.js +300 -288
- package/examples/jsm/shaders/SSRShader.js +370 -364
- package/examples/jsm/shaders/SepiaShader.js +52 -52
- package/examples/jsm/shaders/SobelOperatorShader.js +92 -90
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +90 -88
- package/examples/jsm/shaders/TechnicolorShader.js +45 -43
- package/examples/jsm/shaders/ToonShader.js +326 -326
- package/examples/jsm/shaders/TriangleBlurShader.js +74 -72
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +47 -45
- package/examples/jsm/shaders/VelocityShader.js +130 -128
- package/examples/jsm/shaders/VerticalBlurShader.js +59 -59
- package/examples/jsm/shaders/VerticalTiltShiftShader.js +63 -61
- package/examples/jsm/shaders/VignetteShader.js +51 -51
- package/examples/jsm/shaders/VolumeShader.js +289 -289
- package/examples/jsm/shaders/WaterRefractionShader.js +95 -93
- package/examples/jsm/textures/FlakesTexture.js +40 -40
- package/examples/jsm/transpiler/AST.js +270 -0
- package/examples/jsm/transpiler/GLSLDecoder.js +941 -0
- package/examples/jsm/transpiler/ShaderToyDecoder.js +49 -0
- package/examples/jsm/transpiler/TSLEncoder.js +715 -0
- package/examples/jsm/transpiler/Transpiler.js +18 -0
- package/examples/jsm/utils/BufferGeometryUtils.js +1371 -1364
- package/examples/jsm/utils/CameraUtils.js +73 -73
- package/examples/jsm/utils/GPUStatsPanel.js +128 -128
- package/examples/jsm/utils/GeometryCompressionUtils.js +639 -639
- package/examples/jsm/utils/GeometryUtils.js +221 -221
- package/examples/jsm/utils/LDrawUtils.js +202 -202
- package/examples/jsm/utils/PackedPhongMaterial.js +178 -178
- package/examples/jsm/utils/SceneUtils.js +254 -254
- package/examples/jsm/utils/ShadowMapViewer.js +210 -210
- package/examples/jsm/utils/SkeletonUtils.js +413 -413
- package/examples/jsm/utils/SortUtils.js +160 -0
- package/examples/jsm/utils/TextureUtils.js +98 -86
- package/examples/jsm/utils/UVsDebug.js +165 -165
- package/examples/jsm/utils/WorkerPool.js +102 -102
- package/examples/jsm/webxr/ARButton.js +232 -208
- package/examples/jsm/webxr/OculusHandModel.js +109 -109
- package/examples/jsm/webxr/OculusHandPointerModel.js +416 -415
- package/examples/jsm/webxr/Text2D.js +38 -38
- package/examples/jsm/webxr/VRButton.js +225 -200
- package/examples/jsm/webxr/XRButton.js +224 -198
- package/examples/jsm/webxr/XRControllerModelFactory.js +315 -310
- package/examples/jsm/webxr/XREstimatedLight.js +223 -223
- package/examples/jsm/webxr/XRHandMeshModel.js +116 -113
- package/examples/jsm/webxr/XRHandModelFactory.js +105 -105
- package/examples/jsm/webxr/XRHandPrimitiveModel.js +105 -104
- package/examples/jsm/webxr/XRPlanes.js +100 -100
- package/package.json +129 -126
- package/src/Three.Legacy.js +1 -1
- package/src/Three.js +184 -182
- package/src/animation/AnimationAction.js +700 -700
- package/src/animation/AnimationClip.js +473 -473
- package/src/animation/AnimationMixer.js +770 -770
- package/src/animation/AnimationObjectGroup.js +387 -387
- package/src/animation/AnimationUtils.js +356 -373
- package/src/animation/KeyframeTrack.js +462 -462
- package/src/animation/PropertyBinding.js +719 -719
- package/src/animation/PropertyMixer.js +318 -318
- package/src/animation/tracks/BooleanKeyframeTrack.js +19 -19
- package/src/animation/tracks/ColorKeyframeTrack.js +15 -15
- package/src/animation/tracks/NumberKeyframeTrack.js +12 -12
- package/src/animation/tracks/QuaternionKeyframeTrack.js +23 -23
- package/src/animation/tracks/StringKeyframeTrack.js +15 -15
- package/src/animation/tracks/VectorKeyframeTrack.js +12 -12
- package/src/audio/Audio.js +400 -396
- package/src/audio/AudioAnalyser.js +40 -40
- package/src/audio/AudioContext.js +25 -25
- package/src/audio/AudioListener.js +140 -137
- package/src/audio/PositionalAudio.js +146 -146
- package/src/cameras/ArrayCamera.js +17 -17
- package/src/cameras/Camera.js +69 -73
- package/src/cameras/CubeCamera.js +173 -170
- package/src/cameras/OrthographicCamera.js +136 -136
- package/src/cameras/PerspectiveCamera.js +268 -233
- package/src/cameras/StereoCamera.js +100 -100
- package/src/constants.js +216 -201
- package/src/core/BufferAttribute.js +650 -610
- package/src/core/BufferGeometry.js +1079 -1079
- package/src/core/Clock.js +74 -74
- package/src/core/EventDispatcher.js +87 -87
- package/src/core/GLBufferAttribute.js +60 -60
- package/src/core/InstancedBufferAttribute.js +39 -39
- package/src/core/InstancedBufferGeometry.js +40 -40
- package/src/core/InstancedInterleavedBuffer.js +48 -48
- package/src/core/InterleavedBuffer.js +166 -145
- package/src/core/InterleavedBufferAttribute.js +351 -331
- package/src/core/Layers.js +60 -60
- package/src/core/Object3D.js +1008 -973
- package/src/core/Raycaster.js +110 -110
- package/src/core/RenderTarget.js +131 -0
- package/src/core/Uniform.js +17 -17
- package/src/core/UniformsGroup.js +98 -92
- package/src/extras/DataUtils.js +176 -176
- package/src/extras/Earcut.js +789 -789
- package/src/extras/ImageUtils.js +129 -129
- package/src/extras/PMREMGenerator.js +910 -903
- package/src/extras/ShapeUtils.js +92 -92
- package/src/extras/core/Curve.js +416 -416
- package/src/extras/core/CurvePath.js +255 -252
- package/src/extras/core/Interpolations.js +79 -79
- package/src/extras/core/Path.js +196 -196
- package/src/extras/core/Shape.js +102 -102
- package/src/extras/core/ShapePath.js +291 -291
- package/src/extras/curves/ArcCurve.js +17 -17
- package/src/extras/curves/CatmullRomCurve3.js +255 -255
- package/src/extras/curves/CubicBezierCurve.js +78 -78
- package/src/extras/curves/CubicBezierCurve3.js +79 -79
- package/src/extras/curves/Curves.js +10 -10
- package/src/extras/curves/EllipseCurve.js +156 -156
- package/src/extras/curves/LineCurve.js +92 -92
- package/src/extras/curves/LineCurve3.js +92 -88
- package/src/extras/curves/QuadraticBezierCurve.js +74 -74
- package/src/extras/curves/QuadraticBezierCurve3.js +75 -75
- package/src/extras/curves/SplineCurve.js +97 -97
- package/src/geometries/BoxGeometry.js +180 -180
- package/src/geometries/CapsuleGeometry.js +33 -33
- package/src/geometries/CircleGeometry.js +101 -101
- package/src/geometries/ConeGeometry.js +31 -31
- package/src/geometries/CylinderGeometry.js +286 -286
- package/src/geometries/DodecahedronGeometry.js +66 -66
- package/src/geometries/EdgesGeometry.js +152 -152
- package/src/geometries/ExtrudeGeometry.js +814 -814
- package/src/geometries/Geometries.js +21 -21
- package/src/geometries/IcosahedronGeometry.js +42 -42
- package/src/geometries/LatheGeometry.js +189 -189
- package/src/geometries/OctahedronGeometry.js +37 -37
- package/src/geometries/PlaneGeometry.js +98 -98
- package/src/geometries/PolyhedronGeometry.js +319 -319
- package/src/geometries/RingGeometry.js +128 -128
- package/src/geometries/ShapeGeometry.js +195 -195
- package/src/geometries/SphereGeometry.js +137 -137
- package/src/geometries/TetrahedronGeometry.js +34 -34
- package/src/geometries/TorusGeometry.js +120 -120
- package/src/geometries/TorusKnotGeometry.js +167 -167
- package/src/geometries/TubeGeometry.js +203 -203
- package/src/geometries/WireframeGeometry.js +147 -147
- package/src/helpers/ArrowHelper.js +114 -114
- package/src/helpers/AxesHelper.js +68 -68
- package/src/helpers/Box3Helper.js +55 -55
- package/src/helpers/BoxHelper.js +113 -113
- package/src/helpers/CameraHelper.js +269 -269
- package/src/helpers/DirectionalLightHelper.js +93 -93
- package/src/helpers/GridHelper.js +56 -56
- package/src/helpers/HemisphereLightHelper.js +88 -88
- package/src/helpers/PlaneHelper.js +63 -63
- package/src/helpers/PointLightHelper.js +92 -92
- package/src/helpers/PolarGridHelper.js +96 -96
- package/src/helpers/SkeletonHelper.js +128 -128
- package/src/helpers/SpotLightHelper.js +94 -94
- package/src/lights/AmbientLight.js +17 -17
- package/src/lights/DirectionalLight.js +43 -43
- package/src/lights/DirectionalLightShadow.js +16 -16
- package/src/lights/HemisphereLight.js +34 -34
- package/src/lights/Light.js +58 -58
- package/src/lights/LightProbe.js +47 -47
- package/src/lights/LightShadow.js +147 -147
- package/src/lights/PointLight.js +57 -57
- package/src/lights/PointLightShadow.js +96 -96
- package/src/lights/RectAreaLight.js +56 -56
- package/src/lights/SpotLight.js +71 -71
- package/src/lights/SpotLightShadow.js +50 -50
- package/src/loaders/AnimationLoader.js +66 -66
- package/src/loaders/AudioLoader.js +66 -66
- package/src/loaders/BufferGeometryLoader.js +217 -224
- package/src/loaders/Cache.js +42 -42
- package/src/loaders/CompressedTextureLoader.js +134 -134
- package/src/loaders/CubeTextureLoader.js +58 -58
- package/src/loaders/DataTextureLoader.js +135 -118
- package/src/loaders/FileLoader.js +284 -284
- package/src/loaders/ImageBitmapLoader.js +123 -99
- package/src/loaders/ImageLoader.js +91 -91
- package/src/loaders/Loader.js +72 -72
- package/src/loaders/LoaderUtils.js +75 -75
- package/src/loaders/LoadingManager.js +142 -142
- package/src/loaders/MaterialLoader.js +372 -364
- package/src/loaders/ObjectLoader.js +1148 -1093
- package/src/loaders/TextureLoader.js +41 -41
- package/src/materials/LineBasicMaterial.js +53 -49
- package/src/materials/LineDashedMaterial.js +35 -35
- package/src/materials/Material.js +522 -508
- package/src/materials/Materials.js +39 -39
- package/src/materials/MeshBasicMaterial.js +85 -81
- package/src/materials/MeshDepthMaterial.js +54 -54
- package/src/materials/MeshDistanceMaterial.js +43 -43
- package/src/materials/MeshLambertMaterial.js +120 -116
- package/src/materials/MeshMatcapMaterial.js +85 -81
- package/src/materials/MeshNormalMaterial.js +61 -61
- package/src/materials/MeshPhongMaterial.js +124 -120
- package/src/materials/MeshPhysicalMaterial.js +224 -224
- package/src/materials/MeshStandardMaterial.js +128 -124
- package/src/materials/MeshToonMaterial.js +106 -102
- package/src/materials/PointsMaterial.js +54 -50
- package/src/materials/RawShaderMaterial.js +17 -17
- package/src/materials/ShaderMaterial.js +190 -187
- package/src/materials/ShadowMaterial.js +37 -37
- package/src/materials/SpriteMaterial.js +54 -54
- package/src/math/Box2.js +204 -204
- package/src/math/Box3.js +534 -517
- package/src/math/Color.js +623 -627
- package/src/math/ColorManagement.js +139 -133
- package/src/math/Cylindrical.js +61 -61
- package/src/math/Euler.js +315 -315
- package/src/math/Frustum.js +186 -186
- package/src/math/Interpolant.js +241 -241
- package/src/math/Line3.js +115 -115
- package/src/math/MathUtils.js +363 -363
- package/src/math/Matrix3.js +388 -388
- package/src/math/Matrix4.js +915 -915
- package/src/math/Plane.js +205 -205
- package/src/math/Quaternion.js +685 -684
- package/src/math/Ray.js +493 -493
- package/src/math/Sphere.js +245 -243
- package/src/math/Spherical.js +86 -86
- package/src/math/SphericalHarmonics3.js +243 -243
- package/src/math/Triangle.js +311 -329
- package/src/math/Vector2.js +480 -480
- package/src/math/Vector3.js +724 -725
- package/src/math/Vector4.js +644 -644
- package/src/math/interpolants/CubicInterpolant.js +150 -150
- package/src/math/interpolants/DiscreteInterpolant.js +26 -26
- package/src/math/interpolants/LinearInterpolant.js +38 -38
- package/src/math/interpolants/QuaternionLinearInterpolant.js +39 -39
- package/src/objects/BatchedMesh.js +1019 -0
- package/src/objects/Bone.js +17 -17
- package/src/objects/Group.js +17 -17
- package/src/objects/InstancedMesh.js +214 -214
- package/src/objects/LOD.js +214 -214
- package/src/objects/Line.js +222 -222
- package/src/objects/LineLoop.js +17 -17
- package/src/objects/LineSegments.js +55 -55
- package/src/objects/Mesh.js +429 -429
- package/src/objects/Points.js +166 -166
- package/src/objects/Skeleton.js +277 -279
- package/src/objects/SkinnedMesh.js +257 -266
- package/src/objects/Sprite.js +181 -181
- package/src/renderers/WebGL1Renderer.js +7 -7
- package/src/renderers/WebGL3DRenderTarget.js +22 -22
- package/src/renderers/WebGLArrayRenderTarget.js +22 -22
- package/src/renderers/WebGLCubeRenderTarget.js +155 -155
- package/src/renderers/WebGLMultipleRenderTargets.js +82 -84
- package/src/renderers/WebGLRenderTarget.js +15 -122
- package/src/renderers/WebGLRenderer.js +2631 -2439
- package/src/renderers/shaders/ShaderChunk/alphahash_fragment.glsl.js +7 -7
- package/src/renderers/shaders/ShaderChunk/alphahash_pars_fragment.glsl.js +68 -68
- package/src/renderers/shaders/ShaderChunk/alphamap_fragment.glsl.js +7 -7
- package/src/renderers/shaders/ShaderChunk/alphamap_pars_fragment.glsl.js +7 -7
- package/src/renderers/shaders/ShaderChunk/alphatest_fragment.glsl.js +16 -7
- package/src/renderers/shaders/ShaderChunk/alphatest_pars_fragment.glsl.js +5 -5
- package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +26 -18
- package/src/renderers/shaders/ShaderChunk/aomap_pars_fragment.glsl.js +8 -8
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +19 -0
- package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +5 -0
- package/src/renderers/shaders/ShaderChunk/begin_vertex.glsl.js +9 -9
- package/src/renderers/shaders/ShaderChunk/beginnormal_vertex.glsl.js +9 -9
- package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +33 -33
- package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +43 -42
- package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js +7 -7
- package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_maps.glsl.js +10 -10
- package/src/renderers/shaders/ShaderChunk/clearcoat_pars_fragment.glsl.js +21 -21
- package/src/renderers/shaders/ShaderChunk/clipping_planes_fragment.glsl.js +78 -33
- package/src/renderers/shaders/ShaderChunk/clipping_planes_pars_fragment.glsl.js +9 -9
- package/src/renderers/shaders/ShaderChunk/clipping_planes_pars_vertex.glsl.js +7 -7
- package/src/renderers/shaders/ShaderChunk/clipping_planes_vertex.glsl.js +7 -7
- package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +11 -11
- package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +11 -11
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +11 -11
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +23 -23
- package/src/renderers/shaders/ShaderChunk/colorspace_fragment.glsl.js +3 -3
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +44 -11
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +147 -156
- package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +186 -191
- package/src/renderers/shaders/ShaderChunk/default_fragment.glsl.js +5 -5
- package/src/renderers/shaders/ShaderChunk/default_vertex.glsl.js +5 -5
- package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +63 -36
- package/src/renderers/shaders/ShaderChunk/displacementmap_pars_vertex.glsl.js +9 -9
- package/src/renderers/shaders/ShaderChunk/displacementmap_vertex.glsl.js +7 -7
- package/src/renderers/shaders/ShaderChunk/dithering_fragment.glsl.js +7 -7
- package/src/renderers/shaders/ShaderChunk/dithering_pars_fragment.glsl.js +20 -20
- package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +9 -9
- package/src/renderers/shaders/ShaderChunk/emissivemap_pars_fragment.glsl.js +7 -7
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +14 -14
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +62 -62
- package/src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js +21 -21
- package/src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js +22 -22
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +69 -69
- package/src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js +37 -37
- package/src/renderers/shaders/ShaderChunk/fog_fragment.glsl.js +17 -17
- package/src/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl.js +19 -19
- package/src/renderers/shaders/ShaderChunk/fog_pars_vertex.glsl.js +7 -7
- package/src/renderers/shaders/ShaderChunk/fog_vertex.glsl.js +7 -7
- package/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js +27 -27
- package/src/renderers/shaders/ShaderChunk/iridescence_fragment.glsl.js +120 -121
- package/src/renderers/shaders/ShaderChunk/iridescence_pars_fragment.glsl.js +14 -14
- package/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +10 -10
- package/src/renderers/shaders/ShaderChunk/lightmap_pars_fragment.glsl.js +8 -8
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +202 -198
- package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +13 -13
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +40 -40
- package/src/renderers/shaders/ShaderChunk/lights_lambert_fragment.glsl.js +5 -5
- package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +28 -28
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +228 -223
- package/src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl.js +7 -7
- package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +32 -32
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +151 -146
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +562 -560
- package/src/renderers/shaders/ShaderChunk/lights_toon_fragment.glsl.js +4 -4
- package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +26 -26
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +9 -9
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +9 -9
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +16 -16
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +22 -22
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +21 -13
- package/src/renderers/shaders/ShaderChunk/map_pars_fragment.glsl.js +11 -11
- package/src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js +27 -27
- package/src/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl.js +27 -27
- package/src/renderers/shaders/ShaderChunk/metalnessmap_fragment.glsl.js +12 -12
- package/src/renderers/shaders/ShaderChunk/metalnessmap_pars_fragment.glsl.js +7 -7
- package/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js +24 -24
- package/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +27 -27
- package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +38 -38
- package/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js +36 -36
- package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +76 -76
- package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +33 -33
- package/src/renderers/shaders/ShaderChunk/normal_pars_fragment.glsl.js +14 -14
- package/src/renderers/shaders/ShaderChunk/normal_pars_vertex.glsl.js +14 -14
- package/src/renderers/shaders/ShaderChunk/normal_vertex.glsl.js +14 -14
- package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +43 -43
- package/src/renderers/shaders/ShaderChunk/occlusion_fragment.glsl.js +20 -0
- package/src/renderers/shaders/ShaderChunk/occlusion_pars_fragment.glsl.js +97 -0
- package/src/renderers/shaders/ShaderChunk/opaque_fragment.glsl.js +11 -11
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +68 -68
- package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +8 -8
- package/src/renderers/shaders/ShaderChunk/project_vertex.glsl.js +19 -13
- package/src/renderers/shaders/ShaderChunk/roughnessmap_fragment.glsl.js +12 -12
- package/src/renderers/shaders/ShaderChunk/roughnessmap_pars_fragment.glsl.js +7 -7
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +314 -314
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +68 -68
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +68 -68
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +66 -66
- package/src/renderers/shaders/ShaderChunk/skinbase_vertex.glsl.js +10 -10
- package/src/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl.js +25 -33
- package/src/renderers/shaders/ShaderChunk/skinning_vertex.glsl.js +15 -15
- package/src/renderers/shaders/ShaderChunk/skinnormal_vertex.glsl.js +20 -20
- package/src/renderers/shaders/ShaderChunk/specularmap_fragment.glsl.js +14 -14
- package/src/renderers/shaders/ShaderChunk/specularmap_pars_fragment.glsl.js +7 -7
- package/src/renderers/shaders/ShaderChunk/tonemapping_fragment.glsl.js +7 -7
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +169 -77
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +36 -36
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +201 -201
- package/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js +119 -119
- package/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js +145 -145
- package/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js +122 -122
- package/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js +21 -15
- package/src/renderers/shaders/ShaderChunk.js +274 -266
- package/src/renderers/shaders/ShaderLib/background.glsl.js +40 -32
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +62 -62
- package/src/renderers/shaders/ShaderLib/cube.glsl.js +36 -36
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +95 -94
- package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +76 -75
- package/src/renderers/shaders/ShaderLib/equirect.glsl.js +35 -35
- package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +77 -75
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +117 -114
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +126 -122
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +113 -109
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +89 -82
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +128 -124
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +226 -222
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +120 -116
- package/src/renderers/shaders/ShaderLib/points.glsl.js +88 -86
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +57 -54
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +81 -81
- package/src/renderers/shaders/ShaderLib/vsm.glsl.js +53 -53
- package/src/renderers/shaders/ShaderLib.js +367 -359
- package/src/renderers/shaders/UniformsLib.js +236 -230
- package/src/renderers/shaders/UniformsUtils.js +104 -104
- package/src/renderers/webgl/WebGLAnimation.js +53 -53
- package/src/renderers/webgl/WebGLAttributes.js +229 -195
- package/src/renderers/webgl/WebGLBackground.js +239 -247
- package/src/renderers/webgl/WebGLBindingStates.js +631 -631
- package/src/renderers/webgl/WebGLBufferRenderer.js +92 -61
- package/src/renderers/webgl/WebGLCapabilities.js +120 -120
- package/src/renderers/webgl/WebGLClipping.js +171 -171
- package/src/renderers/webgl/WebGLCubeMaps.js +99 -99
- package/src/renderers/webgl/WebGLCubeUVMaps.js +132 -130
- package/src/renderers/webgl/WebGLExtensions.js +97 -96
- package/src/renderers/webgl/WebGLGeometries.js +211 -207
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +102 -71
- package/src/renderers/webgl/WebGLInfo.js +71 -71
- package/src/renderers/webgl/WebGLLights.js +590 -570
- package/src/renderers/webgl/WebGLMaterials.js +576 -567
- package/src/renderers/webgl/WebGLMorphtargets.js +300 -300
- package/src/renderers/webgl/WebGLObjects.js +92 -92
- package/src/renderers/webgl/WebGLProgram.js +1112 -1002
- package/src/renderers/webgl/WebGLPrograms.js +663 -625
- package/src/renderers/webgl/WebGLProperties.js +48 -48
- package/src/renderers/webgl/WebGLRenderLists.js +238 -238
- package/src/renderers/webgl/WebGLRenderStates.js +107 -107
- package/src/renderers/webgl/WebGLShader.js +12 -12
- package/src/renderers/webgl/WebGLShaderCache.js +124 -124
- package/src/renderers/webgl/WebGLShadowMap.js +424 -389
- package/src/renderers/webgl/WebGLState.js +1328 -1307
- package/src/renderers/webgl/WebGLTextures.js +2117 -2017
- package/src/renderers/webgl/WebGLUniforms.js +1156 -1146
- package/src/renderers/webgl/WebGLUniformsGroups.js +392 -413
- package/src/renderers/webgl/WebGLUtils.js +283 -278
- package/src/renderers/webxr/WebXRController.js +343 -343
- package/src/renderers/webxr/WebXRManager.js +840 -770
- package/src/scenes/Fog.js +38 -37
- package/src/scenes/FogExp2.js +35 -34
- package/src/scenes/Scene.js +63 -63
- package/src/textures/CanvasTexture.js +17 -17
- package/src/textures/CompressedArrayTexture.js +18 -18
- package/src/textures/CompressedCubeTexture.js +19 -0
- package/src/textures/CompressedTexture.js +28 -28
- package/src/textures/CubeTexture.js +33 -33
- package/src/textures/Data3DTexture.js +35 -35
- package/src/textures/DataArrayTexture.js +27 -27
- package/src/textures/DataTexture.js +22 -22
- package/src/textures/DepthTexture.js +58 -58
- package/src/textures/FramebufferTexture.js +23 -23
- package/src/textures/Source.js +127 -127
- package/src/textures/Texture.js +338 -338
- package/src/textures/VideoTexture.js +55 -55
- package/src/utils.js +91 -83
- package/build/three.js +0 -51661
- package/build/three.min.js +0 -7
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +0 -64
- package/examples/jsm/nodes/functions/BSDF/BRDF_BlinnPhong.js +0 -30
- package/examples/jsm/objects/GroundProjectedSkybox.js +0 -172
- package/examples/jsm/renderers/common/RenderTarget.js +0 -15
- package/examples/jsm/renderers/common/nodes/NodeRender.js +0 -302
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureMipmapUtils.js +0 -163
- package/src/lights/AmbientLightProbe.js +0 -21
- package/src/lights/HemisphereLightProbe.js +0 -30
|
@@ -1,2017 +1,2117 @@
|
|
|
1
|
-
import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBAFormat, DepthFormat, DepthStencilFormat, UnsignedShortType, UnsignedIntType, UnsignedInt248Type, FloatType, HalfFloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping, UnsignedByteType, _SRGBAFormat, NoColorSpace, LinearSRGBColorSpace,
|
|
2
|
-
import * as MathUtils from '../../math/MathUtils.js';
|
|
3
|
-
import { ImageUtils } from '../../extras/ImageUtils.js';
|
|
4
|
-
import { createElementNS } from '../../utils.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
canvas.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if ( glType === _gl.
|
|
163
|
-
if ( glType === _gl.
|
|
164
|
-
if ( glType === _gl.
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
if ( glFormat === _gl.
|
|
169
|
-
|
|
170
|
-
if ( glType === _gl.FLOAT ) internalFormat = _gl.
|
|
171
|
-
if ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.
|
|
172
|
-
if ( glType === _gl.UNSIGNED_BYTE ) internalFormat =
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
return image.
|
|
205
|
-
|
|
206
|
-
} else {
|
|
207
|
-
|
|
208
|
-
//
|
|
209
|
-
|
|
210
|
-
return
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
const
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
if (
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
}
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
const
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
}
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
}
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
generateMipmap(
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
if (
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
if (
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
1
|
+
import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBAFormat, RGB_ETC1_Format, DepthFormat, DepthStencilFormat, UnsignedShortType, UnsignedIntType, UnsignedInt248Type, FloatType, HalfFloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping, UnsignedByteType, _SRGBAFormat, NoColorSpace, LinearSRGBColorSpace, NeverCompare, AlwaysCompare, LessCompare, LessEqualCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare, SRGBTransfer, LinearTransfer } from '../../constants.js';
|
|
2
|
+
import * as MathUtils from '../../math/MathUtils.js';
|
|
3
|
+
import { ImageUtils } from '../../extras/ImageUtils.js';
|
|
4
|
+
import { createElementNS } from '../../utils.js';
|
|
5
|
+
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
6
|
+
|
|
7
|
+
function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) {
|
|
8
|
+
|
|
9
|
+
const isWebGL2 = capabilities.isWebGL2;
|
|
10
|
+
const multisampledRTTExt = extensions.has( 'WEBGL_multisampled_render_to_texture' ) ? extensions.get( 'WEBGL_multisampled_render_to_texture' ) : null;
|
|
11
|
+
const supportsInvalidateFramebuffer = typeof navigator === 'undefined' ? false : /OculusBrowser/g.test( navigator.userAgent );
|
|
12
|
+
|
|
13
|
+
const _videoTextures = new WeakMap();
|
|
14
|
+
let _canvas;
|
|
15
|
+
|
|
16
|
+
const _sources = new WeakMap(); // maps WebglTexture objects to instances of Source
|
|
17
|
+
|
|
18
|
+
// cordova iOS (as of 5.0) still uses UIWebView, which provides OffscreenCanvas,
|
|
19
|
+
// also OffscreenCanvas.getContext("webgl"), but not OffscreenCanvas.getContext("2d")!
|
|
20
|
+
// Some implementations may only implement OffscreenCanvas partially (e.g. lacking 2d).
|
|
21
|
+
|
|
22
|
+
let useOffscreenCanvas = false;
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
|
|
26
|
+
useOffscreenCanvas = typeof OffscreenCanvas !== 'undefined'
|
|
27
|
+
// eslint-disable-next-line compat/compat
|
|
28
|
+
&& ( new OffscreenCanvas( 1, 1 ).getContext( '2d' ) ) !== null;
|
|
29
|
+
|
|
30
|
+
} catch ( err ) {
|
|
31
|
+
|
|
32
|
+
// Ignore any errors
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function createCanvas( width, height ) {
|
|
37
|
+
|
|
38
|
+
// Use OffscreenCanvas when available. Specially needed in web workers
|
|
39
|
+
|
|
40
|
+
return useOffscreenCanvas ?
|
|
41
|
+
// eslint-disable-next-line compat/compat
|
|
42
|
+
new OffscreenCanvas( width, height ) : createElementNS( 'canvas' );
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function resizeImage( image, needsPowerOfTwo, needsNewCanvas, maxSize ) {
|
|
47
|
+
|
|
48
|
+
let scale = 1;
|
|
49
|
+
|
|
50
|
+
// handle case if texture exceeds max size
|
|
51
|
+
|
|
52
|
+
if ( image.width > maxSize || image.height > maxSize ) {
|
|
53
|
+
|
|
54
|
+
scale = maxSize / Math.max( image.width, image.height );
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// only perform resize if necessary
|
|
59
|
+
|
|
60
|
+
if ( scale < 1 || needsPowerOfTwo === true ) {
|
|
61
|
+
|
|
62
|
+
// only perform resize for certain image types
|
|
63
|
+
|
|
64
|
+
if ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) ||
|
|
65
|
+
( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) ||
|
|
66
|
+
( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ) {
|
|
67
|
+
|
|
68
|
+
const floor = needsPowerOfTwo ? MathUtils.floorPowerOfTwo : Math.floor;
|
|
69
|
+
|
|
70
|
+
const width = floor( scale * image.width );
|
|
71
|
+
const height = floor( scale * image.height );
|
|
72
|
+
|
|
73
|
+
if ( _canvas === undefined ) _canvas = createCanvas( width, height );
|
|
74
|
+
|
|
75
|
+
// cube textures can't reuse the same canvas
|
|
76
|
+
|
|
77
|
+
const canvas = needsNewCanvas ? createCanvas( width, height ) : _canvas;
|
|
78
|
+
|
|
79
|
+
canvas.width = width;
|
|
80
|
+
canvas.height = height;
|
|
81
|
+
|
|
82
|
+
const context = canvas.getContext( '2d' );
|
|
83
|
+
context.drawImage( image, 0, 0, width, height );
|
|
84
|
+
|
|
85
|
+
console.warn( 'THREE.WebGLRenderer: Texture has been resized from (' + image.width + 'x' + image.height + ') to (' + width + 'x' + height + ').' );
|
|
86
|
+
|
|
87
|
+
return canvas;
|
|
88
|
+
|
|
89
|
+
} else {
|
|
90
|
+
|
|
91
|
+
if ( 'data' in image ) {
|
|
92
|
+
|
|
93
|
+
console.warn( 'THREE.WebGLRenderer: Image in DataTexture is too big (' + image.width + 'x' + image.height + ').' );
|
|
94
|
+
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return image;
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return image;
|
|
104
|
+
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function isPowerOfTwo( image ) {
|
|
108
|
+
|
|
109
|
+
return MathUtils.isPowerOfTwo( image.width ) && MathUtils.isPowerOfTwo( image.height );
|
|
110
|
+
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function textureNeedsPowerOfTwo( texture ) {
|
|
114
|
+
|
|
115
|
+
if ( isWebGL2 ) return false;
|
|
116
|
+
|
|
117
|
+
return ( texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping ) ||
|
|
118
|
+
( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter );
|
|
119
|
+
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function textureNeedsGenerateMipmaps( texture, supportsMips ) {
|
|
123
|
+
|
|
124
|
+
return texture.generateMipmaps && supportsMips &&
|
|
125
|
+
texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;
|
|
126
|
+
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function generateMipmap( target ) {
|
|
130
|
+
|
|
131
|
+
_gl.generateMipmap( target );
|
|
132
|
+
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function getInternalFormat( internalFormatName, glFormat, glType, colorSpace, forceLinearTransfer = false ) {
|
|
136
|
+
|
|
137
|
+
if ( isWebGL2 === false ) return glFormat;
|
|
138
|
+
|
|
139
|
+
if ( internalFormatName !== null ) {
|
|
140
|
+
|
|
141
|
+
if ( _gl[ internalFormatName ] !== undefined ) return _gl[ internalFormatName ];
|
|
142
|
+
|
|
143
|
+
console.warn( 'THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format \'' + internalFormatName + '\'' );
|
|
144
|
+
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
let internalFormat = glFormat;
|
|
148
|
+
|
|
149
|
+
if ( glFormat === _gl.RED ) {
|
|
150
|
+
|
|
151
|
+
if ( glType === _gl.FLOAT ) internalFormat = _gl.R32F;
|
|
152
|
+
if ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.R16F;
|
|
153
|
+
if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.R8;
|
|
154
|
+
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if ( glFormat === _gl.RED_INTEGER ) {
|
|
158
|
+
|
|
159
|
+
if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.R8UI;
|
|
160
|
+
if ( glType === _gl.UNSIGNED_SHORT ) internalFormat = _gl.R16UI;
|
|
161
|
+
if ( glType === _gl.UNSIGNED_INT ) internalFormat = _gl.R32UI;
|
|
162
|
+
if ( glType === _gl.BYTE ) internalFormat = _gl.R8I;
|
|
163
|
+
if ( glType === _gl.SHORT ) internalFormat = _gl.R16I;
|
|
164
|
+
if ( glType === _gl.INT ) internalFormat = _gl.R32I;
|
|
165
|
+
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if ( glFormat === _gl.RG ) {
|
|
169
|
+
|
|
170
|
+
if ( glType === _gl.FLOAT ) internalFormat = _gl.RG32F;
|
|
171
|
+
if ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.RG16F;
|
|
172
|
+
if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RG8;
|
|
173
|
+
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if ( glFormat === _gl.RGBA ) {
|
|
177
|
+
|
|
178
|
+
const transfer = forceLinearTransfer ? LinearTransfer : ColorManagement.getTransfer( colorSpace );
|
|
179
|
+
|
|
180
|
+
if ( glType === _gl.FLOAT ) internalFormat = _gl.RGBA32F;
|
|
181
|
+
if ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.RGBA16F;
|
|
182
|
+
if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = ( transfer === SRGBTransfer ) ? _gl.SRGB8_ALPHA8 : _gl.RGBA8;
|
|
183
|
+
if ( glType === _gl.UNSIGNED_SHORT_4_4_4_4 ) internalFormat = _gl.RGBA4;
|
|
184
|
+
if ( glType === _gl.UNSIGNED_SHORT_5_5_5_1 ) internalFormat = _gl.RGB5_A1;
|
|
185
|
+
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if ( internalFormat === _gl.R16F || internalFormat === _gl.R32F ||
|
|
189
|
+
internalFormat === _gl.RG16F || internalFormat === _gl.RG32F ||
|
|
190
|
+
internalFormat === _gl.RGBA16F || internalFormat === _gl.RGBA32F ) {
|
|
191
|
+
|
|
192
|
+
extensions.get( 'EXT_color_buffer_float' );
|
|
193
|
+
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return internalFormat;
|
|
197
|
+
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function getMipLevels( texture, image, supportsMips ) {
|
|
201
|
+
|
|
202
|
+
if ( textureNeedsGenerateMipmaps( texture, supportsMips ) === true || ( texture.isFramebufferTexture && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) ) {
|
|
203
|
+
|
|
204
|
+
return Math.log2( Math.max( image.width, image.height ) ) + 1;
|
|
205
|
+
|
|
206
|
+
} else if ( texture.mipmaps !== undefined && texture.mipmaps.length > 0 ) {
|
|
207
|
+
|
|
208
|
+
// user-defined mipmaps
|
|
209
|
+
|
|
210
|
+
return texture.mipmaps.length;
|
|
211
|
+
|
|
212
|
+
} else if ( texture.isCompressedTexture && Array.isArray( texture.image ) ) {
|
|
213
|
+
|
|
214
|
+
return image.mipmaps.length;
|
|
215
|
+
|
|
216
|
+
} else {
|
|
217
|
+
|
|
218
|
+
// texture without mipmaps (only base level)
|
|
219
|
+
|
|
220
|
+
return 1;
|
|
221
|
+
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Fallback filters for non-power-of-2 textures
|
|
227
|
+
|
|
228
|
+
function filterFallback( f ) {
|
|
229
|
+
|
|
230
|
+
if ( f === NearestFilter || f === NearestMipmapNearestFilter || f === NearestMipmapLinearFilter ) {
|
|
231
|
+
|
|
232
|
+
return _gl.NEAREST;
|
|
233
|
+
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return _gl.LINEAR;
|
|
237
|
+
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
//
|
|
241
|
+
|
|
242
|
+
function onTextureDispose( event ) {
|
|
243
|
+
|
|
244
|
+
const texture = event.target;
|
|
245
|
+
|
|
246
|
+
texture.removeEventListener( 'dispose', onTextureDispose );
|
|
247
|
+
|
|
248
|
+
deallocateTexture( texture );
|
|
249
|
+
|
|
250
|
+
if ( texture.isVideoTexture ) {
|
|
251
|
+
|
|
252
|
+
_videoTextures.delete( texture );
|
|
253
|
+
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function onRenderTargetDispose( event ) {
|
|
259
|
+
|
|
260
|
+
const renderTarget = event.target;
|
|
261
|
+
|
|
262
|
+
renderTarget.removeEventListener( 'dispose', onRenderTargetDispose );
|
|
263
|
+
|
|
264
|
+
deallocateRenderTarget( renderTarget );
|
|
265
|
+
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
//
|
|
269
|
+
|
|
270
|
+
function deallocateTexture( texture ) {
|
|
271
|
+
|
|
272
|
+
const textureProperties = properties.get( texture );
|
|
273
|
+
|
|
274
|
+
if ( textureProperties.__webglInit === undefined ) return;
|
|
275
|
+
|
|
276
|
+
// check if it's necessary to remove the WebGLTexture object
|
|
277
|
+
|
|
278
|
+
const source = texture.source;
|
|
279
|
+
const webglTextures = _sources.get( source );
|
|
280
|
+
|
|
281
|
+
if ( webglTextures ) {
|
|
282
|
+
|
|
283
|
+
const webglTexture = webglTextures[ textureProperties.__cacheKey ];
|
|
284
|
+
webglTexture.usedTimes --;
|
|
285
|
+
|
|
286
|
+
// the WebGLTexture object is not used anymore, remove it
|
|
287
|
+
|
|
288
|
+
if ( webglTexture.usedTimes === 0 ) {
|
|
289
|
+
|
|
290
|
+
deleteTexture( texture );
|
|
291
|
+
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// remove the weak map entry if no WebGLTexture uses the source anymore
|
|
295
|
+
|
|
296
|
+
if ( Object.keys( webglTextures ).length === 0 ) {
|
|
297
|
+
|
|
298
|
+
_sources.delete( source );
|
|
299
|
+
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
properties.remove( texture );
|
|
305
|
+
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function deleteTexture( texture ) {
|
|
309
|
+
|
|
310
|
+
const textureProperties = properties.get( texture );
|
|
311
|
+
_gl.deleteTexture( textureProperties.__webglTexture );
|
|
312
|
+
|
|
313
|
+
const source = texture.source;
|
|
314
|
+
const webglTextures = _sources.get( source );
|
|
315
|
+
delete webglTextures[ textureProperties.__cacheKey ];
|
|
316
|
+
|
|
317
|
+
info.memory.textures --;
|
|
318
|
+
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
function deallocateRenderTarget( renderTarget ) {
|
|
322
|
+
|
|
323
|
+
const texture = renderTarget.texture;
|
|
324
|
+
|
|
325
|
+
const renderTargetProperties = properties.get( renderTarget );
|
|
326
|
+
const textureProperties = properties.get( texture );
|
|
327
|
+
|
|
328
|
+
if ( textureProperties.__webglTexture !== undefined ) {
|
|
329
|
+
|
|
330
|
+
_gl.deleteTexture( textureProperties.__webglTexture );
|
|
331
|
+
|
|
332
|
+
info.memory.textures --;
|
|
333
|
+
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
if ( renderTarget.depthTexture ) {
|
|
337
|
+
|
|
338
|
+
renderTarget.depthTexture.dispose();
|
|
339
|
+
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
if ( renderTarget.isWebGLCubeRenderTarget ) {
|
|
343
|
+
|
|
344
|
+
for ( let i = 0; i < 6; i ++ ) {
|
|
345
|
+
|
|
346
|
+
if ( Array.isArray( renderTargetProperties.__webglFramebuffer[ i ] ) ) {
|
|
347
|
+
|
|
348
|
+
for ( let level = 0; level < renderTargetProperties.__webglFramebuffer[ i ].length; level ++ ) _gl.deleteFramebuffer( renderTargetProperties.__webglFramebuffer[ i ][ level ] );
|
|
349
|
+
|
|
350
|
+
} else {
|
|
351
|
+
|
|
352
|
+
_gl.deleteFramebuffer( renderTargetProperties.__webglFramebuffer[ i ] );
|
|
353
|
+
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
if ( renderTargetProperties.__webglDepthbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglDepthbuffer[ i ] );
|
|
357
|
+
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
} else {
|
|
361
|
+
|
|
362
|
+
if ( Array.isArray( renderTargetProperties.__webglFramebuffer ) ) {
|
|
363
|
+
|
|
364
|
+
for ( let level = 0; level < renderTargetProperties.__webglFramebuffer.length; level ++ ) _gl.deleteFramebuffer( renderTargetProperties.__webglFramebuffer[ level ] );
|
|
365
|
+
|
|
366
|
+
} else {
|
|
367
|
+
|
|
368
|
+
_gl.deleteFramebuffer( renderTargetProperties.__webglFramebuffer );
|
|
369
|
+
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
if ( renderTargetProperties.__webglDepthbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglDepthbuffer );
|
|
373
|
+
if ( renderTargetProperties.__webglMultisampledFramebuffer ) _gl.deleteFramebuffer( renderTargetProperties.__webglMultisampledFramebuffer );
|
|
374
|
+
|
|
375
|
+
if ( renderTargetProperties.__webglColorRenderbuffer ) {
|
|
376
|
+
|
|
377
|
+
for ( let i = 0; i < renderTargetProperties.__webglColorRenderbuffer.length; i ++ ) {
|
|
378
|
+
|
|
379
|
+
if ( renderTargetProperties.__webglColorRenderbuffer[ i ] ) _gl.deleteRenderbuffer( renderTargetProperties.__webglColorRenderbuffer[ i ] );
|
|
380
|
+
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
if ( renderTargetProperties.__webglDepthRenderbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglDepthRenderbuffer );
|
|
386
|
+
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
if ( renderTarget.isWebGLMultipleRenderTargets ) {
|
|
390
|
+
|
|
391
|
+
for ( let i = 0, il = texture.length; i < il; i ++ ) {
|
|
392
|
+
|
|
393
|
+
const attachmentProperties = properties.get( texture[ i ] );
|
|
394
|
+
|
|
395
|
+
if ( attachmentProperties.__webglTexture ) {
|
|
396
|
+
|
|
397
|
+
_gl.deleteTexture( attachmentProperties.__webglTexture );
|
|
398
|
+
|
|
399
|
+
info.memory.textures --;
|
|
400
|
+
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
properties.remove( texture[ i ] );
|
|
404
|
+
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
properties.remove( texture );
|
|
410
|
+
properties.remove( renderTarget );
|
|
411
|
+
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
//
|
|
415
|
+
|
|
416
|
+
let textureUnits = 0;
|
|
417
|
+
|
|
418
|
+
function resetTextureUnits() {
|
|
419
|
+
|
|
420
|
+
textureUnits = 0;
|
|
421
|
+
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
function allocateTextureUnit() {
|
|
425
|
+
|
|
426
|
+
const textureUnit = textureUnits;
|
|
427
|
+
|
|
428
|
+
if ( textureUnit >= capabilities.maxTextures ) {
|
|
429
|
+
|
|
430
|
+
console.warn( 'THREE.WebGLTextures: Trying to use ' + textureUnit + ' texture units while this GPU supports only ' + capabilities.maxTextures );
|
|
431
|
+
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
textureUnits += 1;
|
|
435
|
+
|
|
436
|
+
return textureUnit;
|
|
437
|
+
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
function getTextureCacheKey( texture ) {
|
|
441
|
+
|
|
442
|
+
const array = [];
|
|
443
|
+
|
|
444
|
+
array.push( texture.wrapS );
|
|
445
|
+
array.push( texture.wrapT );
|
|
446
|
+
array.push( texture.wrapR || 0 );
|
|
447
|
+
array.push( texture.magFilter );
|
|
448
|
+
array.push( texture.minFilter );
|
|
449
|
+
array.push( texture.anisotropy );
|
|
450
|
+
array.push( texture.internalFormat );
|
|
451
|
+
array.push( texture.format );
|
|
452
|
+
array.push( texture.type );
|
|
453
|
+
array.push( texture.generateMipmaps );
|
|
454
|
+
array.push( texture.premultiplyAlpha );
|
|
455
|
+
array.push( texture.flipY );
|
|
456
|
+
array.push( texture.unpackAlignment );
|
|
457
|
+
array.push( texture.colorSpace );
|
|
458
|
+
|
|
459
|
+
return array.join();
|
|
460
|
+
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
//
|
|
464
|
+
|
|
465
|
+
function setTexture2D( texture, slot ) {
|
|
466
|
+
|
|
467
|
+
const textureProperties = properties.get( texture );
|
|
468
|
+
|
|
469
|
+
if ( texture.isVideoTexture ) updateVideoTexture( texture );
|
|
470
|
+
|
|
471
|
+
if ( texture.isRenderTargetTexture === false && texture.version > 0 && textureProperties.__version !== texture.version ) {
|
|
472
|
+
|
|
473
|
+
const image = texture.image;
|
|
474
|
+
|
|
475
|
+
if ( image === null ) {
|
|
476
|
+
|
|
477
|
+
console.warn( 'THREE.WebGLRenderer: Texture marked for update but no image data found.' );
|
|
478
|
+
|
|
479
|
+
} else if ( image.complete === false ) {
|
|
480
|
+
|
|
481
|
+
console.warn( 'THREE.WebGLRenderer: Texture marked for update but image is incomplete' );
|
|
482
|
+
|
|
483
|
+
} else {
|
|
484
|
+
|
|
485
|
+
uploadTexture( textureProperties, texture, slot );
|
|
486
|
+
return;
|
|
487
|
+
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
state.bindTexture( _gl.TEXTURE_2D, textureProperties.__webglTexture, _gl.TEXTURE0 + slot );
|
|
493
|
+
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
function setTexture2DArray( texture, slot ) {
|
|
497
|
+
|
|
498
|
+
const textureProperties = properties.get( texture );
|
|
499
|
+
|
|
500
|
+
if ( texture.version > 0 && textureProperties.__version !== texture.version ) {
|
|
501
|
+
|
|
502
|
+
uploadTexture( textureProperties, texture, slot );
|
|
503
|
+
return;
|
|
504
|
+
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
state.bindTexture( _gl.TEXTURE_2D_ARRAY, textureProperties.__webglTexture, _gl.TEXTURE0 + slot );
|
|
508
|
+
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
function setTexture3D( texture, slot ) {
|
|
512
|
+
|
|
513
|
+
const textureProperties = properties.get( texture );
|
|
514
|
+
|
|
515
|
+
if ( texture.version > 0 && textureProperties.__version !== texture.version ) {
|
|
516
|
+
|
|
517
|
+
uploadTexture( textureProperties, texture, slot );
|
|
518
|
+
return;
|
|
519
|
+
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
state.bindTexture( _gl.TEXTURE_3D, textureProperties.__webglTexture, _gl.TEXTURE0 + slot );
|
|
523
|
+
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
function setTextureCube( texture, slot ) {
|
|
527
|
+
|
|
528
|
+
const textureProperties = properties.get( texture );
|
|
529
|
+
|
|
530
|
+
if ( texture.version > 0 && textureProperties.__version !== texture.version ) {
|
|
531
|
+
|
|
532
|
+
uploadCubeTexture( textureProperties, texture, slot );
|
|
533
|
+
return;
|
|
534
|
+
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
state.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture, _gl.TEXTURE0 + slot );
|
|
538
|
+
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
const wrappingToGL = {
|
|
542
|
+
[ RepeatWrapping ]: _gl.REPEAT,
|
|
543
|
+
[ ClampToEdgeWrapping ]: _gl.CLAMP_TO_EDGE,
|
|
544
|
+
[ MirroredRepeatWrapping ]: _gl.MIRRORED_REPEAT
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
const filterToGL = {
|
|
548
|
+
[ NearestFilter ]: _gl.NEAREST,
|
|
549
|
+
[ NearestMipmapNearestFilter ]: _gl.NEAREST_MIPMAP_NEAREST,
|
|
550
|
+
[ NearestMipmapLinearFilter ]: _gl.NEAREST_MIPMAP_LINEAR,
|
|
551
|
+
|
|
552
|
+
[ LinearFilter ]: _gl.LINEAR,
|
|
553
|
+
[ LinearMipmapNearestFilter ]: _gl.LINEAR_MIPMAP_NEAREST,
|
|
554
|
+
[ LinearMipmapLinearFilter ]: _gl.LINEAR_MIPMAP_LINEAR
|
|
555
|
+
};
|
|
556
|
+
|
|
557
|
+
const compareToGL = {
|
|
558
|
+
[ NeverCompare ]: _gl.NEVER,
|
|
559
|
+
[ AlwaysCompare ]: _gl.ALWAYS,
|
|
560
|
+
[ LessCompare ]: _gl.LESS,
|
|
561
|
+
[ LessEqualCompare ]: _gl.LEQUAL,
|
|
562
|
+
[ EqualCompare ]: _gl.EQUAL,
|
|
563
|
+
[ GreaterEqualCompare ]: _gl.GEQUAL,
|
|
564
|
+
[ GreaterCompare ]: _gl.GREATER,
|
|
565
|
+
[ NotEqualCompare ]: _gl.NOTEQUAL
|
|
566
|
+
};
|
|
567
|
+
|
|
568
|
+
function setTextureParameters( textureType, texture, supportsMips ) {
|
|
569
|
+
|
|
570
|
+
if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false &&
|
|
571
|
+
( texture.magFilter === LinearFilter || texture.magFilter === LinearMipmapNearestFilter || texture.magFilter === NearestMipmapLinearFilter || texture.magFilter === LinearMipmapLinearFilter ||
|
|
572
|
+
texture.minFilter === LinearFilter || texture.minFilter === LinearMipmapNearestFilter || texture.minFilter === NearestMipmapLinearFilter || texture.minFilter === LinearMipmapLinearFilter ) ) {
|
|
573
|
+
|
|
574
|
+
console.warn( 'THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.' );
|
|
575
|
+
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
if ( supportsMips ) {
|
|
579
|
+
|
|
580
|
+
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, wrappingToGL[ texture.wrapS ] );
|
|
581
|
+
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, wrappingToGL[ texture.wrapT ] );
|
|
582
|
+
|
|
583
|
+
if ( textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY ) {
|
|
584
|
+
|
|
585
|
+
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_R, wrappingToGL[ texture.wrapR ] );
|
|
586
|
+
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
_gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterToGL[ texture.magFilter ] );
|
|
590
|
+
_gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterToGL[ texture.minFilter ] );
|
|
591
|
+
|
|
592
|
+
} else {
|
|
593
|
+
|
|
594
|
+
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, _gl.CLAMP_TO_EDGE );
|
|
595
|
+
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, _gl.CLAMP_TO_EDGE );
|
|
596
|
+
|
|
597
|
+
if ( textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY ) {
|
|
598
|
+
|
|
599
|
+
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_R, _gl.CLAMP_TO_EDGE );
|
|
600
|
+
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
if ( texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping ) {
|
|
604
|
+
|
|
605
|
+
console.warn( 'THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.' );
|
|
606
|
+
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
_gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterFallback( texture.magFilter ) );
|
|
610
|
+
_gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterFallback( texture.minFilter ) );
|
|
611
|
+
|
|
612
|
+
if ( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) {
|
|
613
|
+
|
|
614
|
+
console.warn( 'THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.' );
|
|
615
|
+
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
if ( texture.compareFunction ) {
|
|
621
|
+
|
|
622
|
+
_gl.texParameteri( textureType, _gl.TEXTURE_COMPARE_MODE, _gl.COMPARE_REF_TO_TEXTURE );
|
|
623
|
+
_gl.texParameteri( textureType, _gl.TEXTURE_COMPARE_FUNC, compareToGL[ texture.compareFunction ] );
|
|
624
|
+
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
if ( extensions.has( 'EXT_texture_filter_anisotropic' ) === true ) {
|
|
628
|
+
|
|
629
|
+
const extension = extensions.get( 'EXT_texture_filter_anisotropic' );
|
|
630
|
+
|
|
631
|
+
if ( texture.magFilter === NearestFilter ) return;
|
|
632
|
+
if ( texture.minFilter !== NearestMipmapLinearFilter && texture.minFilter !== LinearMipmapLinearFilter ) return;
|
|
633
|
+
if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false ) return; // verify extension for WebGL 1 and WebGL 2
|
|
634
|
+
if ( isWebGL2 === false && ( texture.type === HalfFloatType && extensions.has( 'OES_texture_half_float_linear' ) === false ) ) return; // verify extension for WebGL 1 only
|
|
635
|
+
|
|
636
|
+
if ( texture.anisotropy > 1 || properties.get( texture ).__currentAnisotropy ) {
|
|
637
|
+
|
|
638
|
+
_gl.texParameterf( textureType, extension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min( texture.anisotropy, capabilities.getMaxAnisotropy() ) );
|
|
639
|
+
properties.get( texture ).__currentAnisotropy = texture.anisotropy;
|
|
640
|
+
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
function initTexture( textureProperties, texture ) {
|
|
648
|
+
|
|
649
|
+
let forceUpload = false;
|
|
650
|
+
|
|
651
|
+
if ( textureProperties.__webglInit === undefined ) {
|
|
652
|
+
|
|
653
|
+
textureProperties.__webglInit = true;
|
|
654
|
+
|
|
655
|
+
texture.addEventListener( 'dispose', onTextureDispose );
|
|
656
|
+
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
// create Source <-> WebGLTextures mapping if necessary
|
|
660
|
+
|
|
661
|
+
const source = texture.source;
|
|
662
|
+
let webglTextures = _sources.get( source );
|
|
663
|
+
|
|
664
|
+
if ( webglTextures === undefined ) {
|
|
665
|
+
|
|
666
|
+
webglTextures = {};
|
|
667
|
+
_sources.set( source, webglTextures );
|
|
668
|
+
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
// check if there is already a WebGLTexture object for the given texture parameters
|
|
672
|
+
|
|
673
|
+
const textureCacheKey = getTextureCacheKey( texture );
|
|
674
|
+
|
|
675
|
+
if ( textureCacheKey !== textureProperties.__cacheKey ) {
|
|
676
|
+
|
|
677
|
+
// if not, create a new instance of WebGLTexture
|
|
678
|
+
|
|
679
|
+
if ( webglTextures[ textureCacheKey ] === undefined ) {
|
|
680
|
+
|
|
681
|
+
// create new entry
|
|
682
|
+
|
|
683
|
+
webglTextures[ textureCacheKey ] = {
|
|
684
|
+
texture: _gl.createTexture(),
|
|
685
|
+
usedTimes: 0
|
|
686
|
+
};
|
|
687
|
+
|
|
688
|
+
info.memory.textures ++;
|
|
689
|
+
|
|
690
|
+
// when a new instance of WebGLTexture was created, a texture upload is required
|
|
691
|
+
// even if the image contents are identical
|
|
692
|
+
|
|
693
|
+
forceUpload = true;
|
|
694
|
+
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
webglTextures[ textureCacheKey ].usedTimes ++;
|
|
698
|
+
|
|
699
|
+
// every time the texture cache key changes, it's necessary to check if an instance of
|
|
700
|
+
// WebGLTexture can be deleted in order to avoid a memory leak.
|
|
701
|
+
|
|
702
|
+
const webglTexture = webglTextures[ textureProperties.__cacheKey ];
|
|
703
|
+
|
|
704
|
+
if ( webglTexture !== undefined ) {
|
|
705
|
+
|
|
706
|
+
webglTextures[ textureProperties.__cacheKey ].usedTimes --;
|
|
707
|
+
|
|
708
|
+
if ( webglTexture.usedTimes === 0 ) {
|
|
709
|
+
|
|
710
|
+
deleteTexture( texture );
|
|
711
|
+
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
// store references to cache key and WebGLTexture object
|
|
717
|
+
|
|
718
|
+
textureProperties.__cacheKey = textureCacheKey;
|
|
719
|
+
textureProperties.__webglTexture = webglTextures[ textureCacheKey ].texture;
|
|
720
|
+
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
return forceUpload;
|
|
724
|
+
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
function uploadTexture( textureProperties, texture, slot ) {
|
|
728
|
+
|
|
729
|
+
let textureType = _gl.TEXTURE_2D;
|
|
730
|
+
|
|
731
|
+
if ( texture.isDataArrayTexture || texture.isCompressedArrayTexture ) textureType = _gl.TEXTURE_2D_ARRAY;
|
|
732
|
+
if ( texture.isData3DTexture ) textureType = _gl.TEXTURE_3D;
|
|
733
|
+
|
|
734
|
+
const forceUpload = initTexture( textureProperties, texture );
|
|
735
|
+
const source = texture.source;
|
|
736
|
+
|
|
737
|
+
state.bindTexture( textureType, textureProperties.__webglTexture, _gl.TEXTURE0 + slot );
|
|
738
|
+
|
|
739
|
+
const sourceProperties = properties.get( source );
|
|
740
|
+
|
|
741
|
+
if ( source.version !== sourceProperties.__version || forceUpload === true ) {
|
|
742
|
+
|
|
743
|
+
state.activeTexture( _gl.TEXTURE0 + slot );
|
|
744
|
+
|
|
745
|
+
const workingPrimaries = ColorManagement.getPrimaries( ColorManagement.workingColorSpace );
|
|
746
|
+
const texturePrimaries = texture.colorSpace === NoColorSpace ? null : ColorManagement.getPrimaries( texture.colorSpace );
|
|
747
|
+
const unpackConversion = texture.colorSpace === NoColorSpace || workingPrimaries === texturePrimaries ? _gl.NONE : _gl.BROWSER_DEFAULT_WEBGL;
|
|
748
|
+
|
|
749
|
+
_gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, texture.flipY );
|
|
750
|
+
_gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha );
|
|
751
|
+
_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, texture.unpackAlignment );
|
|
752
|
+
_gl.pixelStorei( _gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion );
|
|
753
|
+
|
|
754
|
+
const needsPowerOfTwo = textureNeedsPowerOfTwo( texture ) && isPowerOfTwo( texture.image ) === false;
|
|
755
|
+
let image = resizeImage( texture.image, needsPowerOfTwo, false, capabilities.maxTextureSize );
|
|
756
|
+
image = verifyColorSpace( texture, image );
|
|
757
|
+
|
|
758
|
+
const supportsMips = isPowerOfTwo( image ) || isWebGL2,
|
|
759
|
+
glFormat = utils.convert( texture.format, texture.colorSpace );
|
|
760
|
+
|
|
761
|
+
let glType = utils.convert( texture.type ),
|
|
762
|
+
glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace, texture.isVideoTexture );
|
|
763
|
+
|
|
764
|
+
setTextureParameters( textureType, texture, supportsMips );
|
|
765
|
+
|
|
766
|
+
let mipmap;
|
|
767
|
+
const mipmaps = texture.mipmaps;
|
|
768
|
+
|
|
769
|
+
const useTexStorage = ( isWebGL2 && texture.isVideoTexture !== true && glInternalFormat !== RGB_ETC1_Format );
|
|
770
|
+
const allocateMemory = ( sourceProperties.__version === undefined ) || ( forceUpload === true );
|
|
771
|
+
const levels = getMipLevels( texture, image, supportsMips );
|
|
772
|
+
|
|
773
|
+
if ( texture.isDepthTexture ) {
|
|
774
|
+
|
|
775
|
+
// populate depth texture with dummy data
|
|
776
|
+
|
|
777
|
+
glInternalFormat = _gl.DEPTH_COMPONENT;
|
|
778
|
+
|
|
779
|
+
if ( isWebGL2 ) {
|
|
780
|
+
|
|
781
|
+
if ( texture.type === FloatType ) {
|
|
782
|
+
|
|
783
|
+
glInternalFormat = _gl.DEPTH_COMPONENT32F;
|
|
784
|
+
|
|
785
|
+
} else if ( texture.type === UnsignedIntType ) {
|
|
786
|
+
|
|
787
|
+
glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
788
|
+
|
|
789
|
+
} else if ( texture.type === UnsignedInt248Type ) {
|
|
790
|
+
|
|
791
|
+
glInternalFormat = _gl.DEPTH24_STENCIL8;
|
|
792
|
+
|
|
793
|
+
} else {
|
|
794
|
+
|
|
795
|
+
glInternalFormat = _gl.DEPTH_COMPONENT16; // WebGL2 requires sized internalformat for glTexImage2D
|
|
796
|
+
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
} else {
|
|
800
|
+
|
|
801
|
+
if ( texture.type === FloatType ) {
|
|
802
|
+
|
|
803
|
+
console.error( 'WebGLRenderer: Floating point depth texture requires WebGL2.' );
|
|
804
|
+
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
// validation checks for WebGL 1
|
|
810
|
+
|
|
811
|
+
if ( texture.format === DepthFormat && glInternalFormat === _gl.DEPTH_COMPONENT ) {
|
|
812
|
+
|
|
813
|
+
// The error INVALID_OPERATION is generated by texImage2D if format and internalformat are
|
|
814
|
+
// DEPTH_COMPONENT and type is not UNSIGNED_SHORT or UNSIGNED_INT
|
|
815
|
+
// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)
|
|
816
|
+
if ( texture.type !== UnsignedShortType && texture.type !== UnsignedIntType ) {
|
|
817
|
+
|
|
818
|
+
console.warn( 'THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture.' );
|
|
819
|
+
|
|
820
|
+
texture.type = UnsignedIntType;
|
|
821
|
+
glType = utils.convert( texture.type );
|
|
822
|
+
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
if ( texture.format === DepthStencilFormat && glInternalFormat === _gl.DEPTH_COMPONENT ) {
|
|
828
|
+
|
|
829
|
+
// Depth stencil textures need the DEPTH_STENCIL internal format
|
|
830
|
+
// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)
|
|
831
|
+
glInternalFormat = _gl.DEPTH_STENCIL;
|
|
832
|
+
|
|
833
|
+
// The error INVALID_OPERATION is generated by texImage2D if format and internalformat are
|
|
834
|
+
// DEPTH_STENCIL and type is not UNSIGNED_INT_24_8_WEBGL.
|
|
835
|
+
// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)
|
|
836
|
+
if ( texture.type !== UnsignedInt248Type ) {
|
|
837
|
+
|
|
838
|
+
console.warn( 'THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture.' );
|
|
839
|
+
|
|
840
|
+
texture.type = UnsignedInt248Type;
|
|
841
|
+
glType = utils.convert( texture.type );
|
|
842
|
+
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
//
|
|
848
|
+
|
|
849
|
+
if ( allocateMemory ) {
|
|
850
|
+
|
|
851
|
+
if ( useTexStorage ) {
|
|
852
|
+
|
|
853
|
+
state.texStorage2D( _gl.TEXTURE_2D, 1, glInternalFormat, image.width, image.height );
|
|
854
|
+
|
|
855
|
+
} else {
|
|
856
|
+
|
|
857
|
+
state.texImage2D( _gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null );
|
|
858
|
+
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
} else if ( texture.isDataTexture ) {
|
|
864
|
+
|
|
865
|
+
// use manually created mipmaps if available
|
|
866
|
+
// if there are no manual mipmaps
|
|
867
|
+
// set 0 level mipmap and then use GL to generate other mipmap levels
|
|
868
|
+
|
|
869
|
+
if ( mipmaps.length > 0 && supportsMips ) {
|
|
870
|
+
|
|
871
|
+
if ( useTexStorage && allocateMemory ) {
|
|
872
|
+
|
|
873
|
+
state.texStorage2D( _gl.TEXTURE_2D, levels, glInternalFormat, mipmaps[ 0 ].width, mipmaps[ 0 ].height );
|
|
874
|
+
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
for ( let i = 0, il = mipmaps.length; i < il; i ++ ) {
|
|
878
|
+
|
|
879
|
+
mipmap = mipmaps[ i ];
|
|
880
|
+
|
|
881
|
+
if ( useTexStorage ) {
|
|
882
|
+
|
|
883
|
+
state.texSubImage2D( _gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data );
|
|
884
|
+
|
|
885
|
+
} else {
|
|
886
|
+
|
|
887
|
+
state.texImage2D( _gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );
|
|
888
|
+
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
texture.generateMipmaps = false;
|
|
894
|
+
|
|
895
|
+
} else {
|
|
896
|
+
|
|
897
|
+
if ( useTexStorage ) {
|
|
898
|
+
|
|
899
|
+
if ( allocateMemory ) {
|
|
900
|
+
|
|
901
|
+
state.texStorage2D( _gl.TEXTURE_2D, levels, glInternalFormat, image.width, image.height );
|
|
902
|
+
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
state.texSubImage2D( _gl.TEXTURE_2D, 0, 0, 0, image.width, image.height, glFormat, glType, image.data );
|
|
906
|
+
|
|
907
|
+
} else {
|
|
908
|
+
|
|
909
|
+
state.texImage2D( _gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, image.data );
|
|
910
|
+
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
} else if ( texture.isCompressedTexture ) {
|
|
916
|
+
|
|
917
|
+
if ( texture.isCompressedArrayTexture ) {
|
|
918
|
+
|
|
919
|
+
if ( useTexStorage && allocateMemory ) {
|
|
920
|
+
|
|
921
|
+
state.texStorage3D( _gl.TEXTURE_2D_ARRAY, levels, glInternalFormat, mipmaps[ 0 ].width, mipmaps[ 0 ].height, image.depth );
|
|
922
|
+
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
for ( let i = 0, il = mipmaps.length; i < il; i ++ ) {
|
|
926
|
+
|
|
927
|
+
mipmap = mipmaps[ i ];
|
|
928
|
+
|
|
929
|
+
if ( texture.format !== RGBAFormat ) {
|
|
930
|
+
|
|
931
|
+
if ( glFormat !== null ) {
|
|
932
|
+
|
|
933
|
+
if ( useTexStorage ) {
|
|
934
|
+
|
|
935
|
+
state.compressedTexSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, 0, mipmap.width, mipmap.height, image.depth, glFormat, mipmap.data, 0, 0 );
|
|
936
|
+
|
|
937
|
+
} else {
|
|
938
|
+
|
|
939
|
+
state.compressedTexImage3D( _gl.TEXTURE_2D_ARRAY, i, glInternalFormat, mipmap.width, mipmap.height, image.depth, 0, mipmap.data, 0, 0 );
|
|
940
|
+
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
} else {
|
|
944
|
+
|
|
945
|
+
console.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()' );
|
|
946
|
+
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
} else {
|
|
950
|
+
|
|
951
|
+
if ( useTexStorage ) {
|
|
952
|
+
|
|
953
|
+
state.texSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, 0, mipmap.width, mipmap.height, image.depth, glFormat, glType, mipmap.data );
|
|
954
|
+
|
|
955
|
+
} else {
|
|
956
|
+
|
|
957
|
+
state.texImage3D( _gl.TEXTURE_2D_ARRAY, i, glInternalFormat, mipmap.width, mipmap.height, image.depth, 0, glFormat, glType, mipmap.data );
|
|
958
|
+
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
} else {
|
|
966
|
+
|
|
967
|
+
if ( useTexStorage && allocateMemory ) {
|
|
968
|
+
|
|
969
|
+
state.texStorage2D( _gl.TEXTURE_2D, levels, glInternalFormat, mipmaps[ 0 ].width, mipmaps[ 0 ].height );
|
|
970
|
+
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
for ( let i = 0, il = mipmaps.length; i < il; i ++ ) {
|
|
974
|
+
|
|
975
|
+
mipmap = mipmaps[ i ];
|
|
976
|
+
|
|
977
|
+
if ( texture.format !== RGBAFormat ) {
|
|
978
|
+
|
|
979
|
+
if ( glFormat !== null ) {
|
|
980
|
+
|
|
981
|
+
if ( useTexStorage ) {
|
|
982
|
+
|
|
983
|
+
state.compressedTexSubImage2D( _gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, mipmap.data );
|
|
984
|
+
|
|
985
|
+
} else {
|
|
986
|
+
|
|
987
|
+
state.compressedTexImage2D( _gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );
|
|
988
|
+
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
} else {
|
|
992
|
+
|
|
993
|
+
console.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()' );
|
|
994
|
+
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
} else {
|
|
998
|
+
|
|
999
|
+
if ( useTexStorage ) {
|
|
1000
|
+
|
|
1001
|
+
state.texSubImage2D( _gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data );
|
|
1002
|
+
|
|
1003
|
+
} else {
|
|
1004
|
+
|
|
1005
|
+
state.texImage2D( _gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );
|
|
1006
|
+
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
} else if ( texture.isDataArrayTexture ) {
|
|
1016
|
+
|
|
1017
|
+
if ( useTexStorage ) {
|
|
1018
|
+
|
|
1019
|
+
if ( allocateMemory ) {
|
|
1020
|
+
|
|
1021
|
+
state.texStorage3D( _gl.TEXTURE_2D_ARRAY, levels, glInternalFormat, image.width, image.height, image.depth );
|
|
1022
|
+
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
state.texSubImage3D( _gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data );
|
|
1026
|
+
|
|
1027
|
+
} else {
|
|
1028
|
+
|
|
1029
|
+
state.texImage3D( _gl.TEXTURE_2D_ARRAY, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data );
|
|
1030
|
+
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
} else if ( texture.isData3DTexture ) {
|
|
1034
|
+
|
|
1035
|
+
if ( useTexStorage ) {
|
|
1036
|
+
|
|
1037
|
+
if ( allocateMemory ) {
|
|
1038
|
+
|
|
1039
|
+
state.texStorage3D( _gl.TEXTURE_3D, levels, glInternalFormat, image.width, image.height, image.depth );
|
|
1040
|
+
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
state.texSubImage3D( _gl.TEXTURE_3D, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data );
|
|
1044
|
+
|
|
1045
|
+
} else {
|
|
1046
|
+
|
|
1047
|
+
state.texImage3D( _gl.TEXTURE_3D, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data );
|
|
1048
|
+
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
} else if ( texture.isFramebufferTexture ) {
|
|
1052
|
+
|
|
1053
|
+
if ( allocateMemory ) {
|
|
1054
|
+
|
|
1055
|
+
if ( useTexStorage ) {
|
|
1056
|
+
|
|
1057
|
+
state.texStorage2D( _gl.TEXTURE_2D, levels, glInternalFormat, image.width, image.height );
|
|
1058
|
+
|
|
1059
|
+
} else {
|
|
1060
|
+
|
|
1061
|
+
let width = image.width, height = image.height;
|
|
1062
|
+
|
|
1063
|
+
for ( let i = 0; i < levels; i ++ ) {
|
|
1064
|
+
|
|
1065
|
+
state.texImage2D( _gl.TEXTURE_2D, i, glInternalFormat, width, height, 0, glFormat, glType, null );
|
|
1066
|
+
|
|
1067
|
+
width >>= 1;
|
|
1068
|
+
height >>= 1;
|
|
1069
|
+
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
} else {
|
|
1077
|
+
|
|
1078
|
+
// regular Texture (image, video, canvas)
|
|
1079
|
+
|
|
1080
|
+
// use manually created mipmaps if available
|
|
1081
|
+
// if there are no manual mipmaps
|
|
1082
|
+
// set 0 level mipmap and then use GL to generate other mipmap levels
|
|
1083
|
+
|
|
1084
|
+
if ( mipmaps.length > 0 && supportsMips ) {
|
|
1085
|
+
|
|
1086
|
+
if ( useTexStorage && allocateMemory ) {
|
|
1087
|
+
|
|
1088
|
+
state.texStorage2D( _gl.TEXTURE_2D, levels, glInternalFormat, mipmaps[ 0 ].width, mipmaps[ 0 ].height );
|
|
1089
|
+
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
for ( let i = 0, il = mipmaps.length; i < il; i ++ ) {
|
|
1093
|
+
|
|
1094
|
+
mipmap = mipmaps[ i ];
|
|
1095
|
+
|
|
1096
|
+
if ( useTexStorage ) {
|
|
1097
|
+
|
|
1098
|
+
state.texSubImage2D( _gl.TEXTURE_2D, i, 0, 0, glFormat, glType, mipmap );
|
|
1099
|
+
|
|
1100
|
+
} else {
|
|
1101
|
+
|
|
1102
|
+
state.texImage2D( _gl.TEXTURE_2D, i, glInternalFormat, glFormat, glType, mipmap );
|
|
1103
|
+
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
texture.generateMipmaps = false;
|
|
1109
|
+
|
|
1110
|
+
} else {
|
|
1111
|
+
|
|
1112
|
+
if ( useTexStorage ) {
|
|
1113
|
+
|
|
1114
|
+
if ( allocateMemory ) {
|
|
1115
|
+
|
|
1116
|
+
state.texStorage2D( _gl.TEXTURE_2D, levels, glInternalFormat, image.width, image.height );
|
|
1117
|
+
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
state.texSubImage2D( _gl.TEXTURE_2D, 0, 0, 0, glFormat, glType, image );
|
|
1121
|
+
|
|
1122
|
+
} else {
|
|
1123
|
+
|
|
1124
|
+
state.texImage2D( _gl.TEXTURE_2D, 0, glInternalFormat, glFormat, glType, image );
|
|
1125
|
+
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
|
|
1133
|
+
|
|
1134
|
+
generateMipmap( textureType );
|
|
1135
|
+
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
sourceProperties.__version = source.version;
|
|
1139
|
+
|
|
1140
|
+
if ( texture.onUpdate ) texture.onUpdate( texture );
|
|
1141
|
+
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
textureProperties.__version = texture.version;
|
|
1145
|
+
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
function uploadCubeTexture( textureProperties, texture, slot ) {
|
|
1149
|
+
|
|
1150
|
+
if ( texture.image.length !== 6 ) return;
|
|
1151
|
+
|
|
1152
|
+
const forceUpload = initTexture( textureProperties, texture );
|
|
1153
|
+
const source = texture.source;
|
|
1154
|
+
|
|
1155
|
+
state.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture, _gl.TEXTURE0 + slot );
|
|
1156
|
+
|
|
1157
|
+
const sourceProperties = properties.get( source );
|
|
1158
|
+
|
|
1159
|
+
if ( source.version !== sourceProperties.__version || forceUpload === true ) {
|
|
1160
|
+
|
|
1161
|
+
state.activeTexture( _gl.TEXTURE0 + slot );
|
|
1162
|
+
|
|
1163
|
+
const workingPrimaries = ColorManagement.getPrimaries( ColorManagement.workingColorSpace );
|
|
1164
|
+
const texturePrimaries = texture.colorSpace === NoColorSpace ? null : ColorManagement.getPrimaries( texture.colorSpace );
|
|
1165
|
+
const unpackConversion = texture.colorSpace === NoColorSpace || workingPrimaries === texturePrimaries ? _gl.NONE : _gl.BROWSER_DEFAULT_WEBGL;
|
|
1166
|
+
|
|
1167
|
+
_gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, texture.flipY );
|
|
1168
|
+
_gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha );
|
|
1169
|
+
_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, texture.unpackAlignment );
|
|
1170
|
+
_gl.pixelStorei( _gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion );
|
|
1171
|
+
|
|
1172
|
+
const isCompressed = ( texture.isCompressedTexture || texture.image[ 0 ].isCompressedTexture );
|
|
1173
|
+
const isDataTexture = ( texture.image[ 0 ] && texture.image[ 0 ].isDataTexture );
|
|
1174
|
+
|
|
1175
|
+
const cubeImage = [];
|
|
1176
|
+
|
|
1177
|
+
for ( let i = 0; i < 6; i ++ ) {
|
|
1178
|
+
|
|
1179
|
+
if ( ! isCompressed && ! isDataTexture ) {
|
|
1180
|
+
|
|
1181
|
+
cubeImage[ i ] = resizeImage( texture.image[ i ], false, true, capabilities.maxCubemapSize );
|
|
1182
|
+
|
|
1183
|
+
} else {
|
|
1184
|
+
|
|
1185
|
+
cubeImage[ i ] = isDataTexture ? texture.image[ i ].image : texture.image[ i ];
|
|
1186
|
+
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
cubeImage[ i ] = verifyColorSpace( texture, cubeImage[ i ] );
|
|
1190
|
+
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
const image = cubeImage[ 0 ],
|
|
1194
|
+
supportsMips = isPowerOfTwo( image ) || isWebGL2,
|
|
1195
|
+
glFormat = utils.convert( texture.format, texture.colorSpace ),
|
|
1196
|
+
glType = utils.convert( texture.type ),
|
|
1197
|
+
glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace );
|
|
1198
|
+
|
|
1199
|
+
const useTexStorage = ( isWebGL2 && texture.isVideoTexture !== true );
|
|
1200
|
+
const allocateMemory = ( sourceProperties.__version === undefined ) || ( forceUpload === true );
|
|
1201
|
+
let levels = getMipLevels( texture, image, supportsMips );
|
|
1202
|
+
|
|
1203
|
+
setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture, supportsMips );
|
|
1204
|
+
|
|
1205
|
+
let mipmaps;
|
|
1206
|
+
|
|
1207
|
+
if ( isCompressed ) {
|
|
1208
|
+
|
|
1209
|
+
if ( useTexStorage && allocateMemory ) {
|
|
1210
|
+
|
|
1211
|
+
state.texStorage2D( _gl.TEXTURE_CUBE_MAP, levels, glInternalFormat, image.width, image.height );
|
|
1212
|
+
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
for ( let i = 0; i < 6; i ++ ) {
|
|
1216
|
+
|
|
1217
|
+
mipmaps = cubeImage[ i ].mipmaps;
|
|
1218
|
+
|
|
1219
|
+
for ( let j = 0; j < mipmaps.length; j ++ ) {
|
|
1220
|
+
|
|
1221
|
+
const mipmap = mipmaps[ j ];
|
|
1222
|
+
|
|
1223
|
+
if ( texture.format !== RGBAFormat ) {
|
|
1224
|
+
|
|
1225
|
+
if ( glFormat !== null ) {
|
|
1226
|
+
|
|
1227
|
+
if ( useTexStorage ) {
|
|
1228
|
+
|
|
1229
|
+
state.compressedTexSubImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, 0, 0, mipmap.width, mipmap.height, glFormat, mipmap.data );
|
|
1230
|
+
|
|
1231
|
+
} else {
|
|
1232
|
+
|
|
1233
|
+
state.compressedTexImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );
|
|
1234
|
+
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
} else {
|
|
1238
|
+
|
|
1239
|
+
console.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()' );
|
|
1240
|
+
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
} else {
|
|
1244
|
+
|
|
1245
|
+
if ( useTexStorage ) {
|
|
1246
|
+
|
|
1247
|
+
state.texSubImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data );
|
|
1248
|
+
|
|
1249
|
+
} else {
|
|
1250
|
+
|
|
1251
|
+
state.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );
|
|
1252
|
+
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
} else {
|
|
1262
|
+
|
|
1263
|
+
mipmaps = texture.mipmaps;
|
|
1264
|
+
|
|
1265
|
+
if ( useTexStorage && allocateMemory ) {
|
|
1266
|
+
|
|
1267
|
+
// TODO: Uniformly handle mipmap definitions
|
|
1268
|
+
// Normal textures and compressed cube textures define base level + mips with their mipmap array
|
|
1269
|
+
// Uncompressed cube textures use their mipmap array only for mips (no base level)
|
|
1270
|
+
|
|
1271
|
+
if ( mipmaps.length > 0 ) levels ++;
|
|
1272
|
+
|
|
1273
|
+
state.texStorage2D( _gl.TEXTURE_CUBE_MAP, levels, glInternalFormat, cubeImage[ 0 ].width, cubeImage[ 0 ].height );
|
|
1274
|
+
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
for ( let i = 0; i < 6; i ++ ) {
|
|
1278
|
+
|
|
1279
|
+
if ( isDataTexture ) {
|
|
1280
|
+
|
|
1281
|
+
if ( useTexStorage ) {
|
|
1282
|
+
|
|
1283
|
+
state.texSubImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, 0, 0, cubeImage[ i ].width, cubeImage[ i ].height, glFormat, glType, cubeImage[ i ].data );
|
|
1284
|
+
|
|
1285
|
+
} else {
|
|
1286
|
+
|
|
1287
|
+
state.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, cubeImage[ i ].width, cubeImage[ i ].height, 0, glFormat, glType, cubeImage[ i ].data );
|
|
1288
|
+
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
for ( let j = 0; j < mipmaps.length; j ++ ) {
|
|
1292
|
+
|
|
1293
|
+
const mipmap = mipmaps[ j ];
|
|
1294
|
+
const mipmapImage = mipmap.image[ i ].image;
|
|
1295
|
+
|
|
1296
|
+
if ( useTexStorage ) {
|
|
1297
|
+
|
|
1298
|
+
state.texSubImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, 0, 0, mipmapImage.width, mipmapImage.height, glFormat, glType, mipmapImage.data );
|
|
1299
|
+
|
|
1300
|
+
} else {
|
|
1301
|
+
|
|
1302
|
+
state.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, glInternalFormat, mipmapImage.width, mipmapImage.height, 0, glFormat, glType, mipmapImage.data );
|
|
1303
|
+
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
} else {
|
|
1309
|
+
|
|
1310
|
+
if ( useTexStorage ) {
|
|
1311
|
+
|
|
1312
|
+
state.texSubImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, 0, 0, glFormat, glType, cubeImage[ i ] );
|
|
1313
|
+
|
|
1314
|
+
} else {
|
|
1315
|
+
|
|
1316
|
+
state.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, glFormat, glType, cubeImage[ i ] );
|
|
1317
|
+
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
for ( let j = 0; j < mipmaps.length; j ++ ) {
|
|
1321
|
+
|
|
1322
|
+
const mipmap = mipmaps[ j ];
|
|
1323
|
+
|
|
1324
|
+
if ( useTexStorage ) {
|
|
1325
|
+
|
|
1326
|
+
state.texSubImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, 0, 0, glFormat, glType, mipmap.image[ i ] );
|
|
1327
|
+
|
|
1328
|
+
} else {
|
|
1329
|
+
|
|
1330
|
+
state.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, glInternalFormat, glFormat, glType, mipmap.image[ i ] );
|
|
1331
|
+
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
|
|
1343
|
+
|
|
1344
|
+
// We assume images for cube map have the same size.
|
|
1345
|
+
generateMipmap( _gl.TEXTURE_CUBE_MAP );
|
|
1346
|
+
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
sourceProperties.__version = source.version;
|
|
1350
|
+
|
|
1351
|
+
if ( texture.onUpdate ) texture.onUpdate( texture );
|
|
1352
|
+
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
textureProperties.__version = texture.version;
|
|
1356
|
+
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
// Render targets
|
|
1360
|
+
|
|
1361
|
+
// Setup storage for target texture and bind it to correct framebuffer
|
|
1362
|
+
function setupFrameBufferTexture( framebuffer, renderTarget, texture, attachment, textureTarget, level ) {
|
|
1363
|
+
|
|
1364
|
+
const glFormat = utils.convert( texture.format, texture.colorSpace );
|
|
1365
|
+
const glType = utils.convert( texture.type );
|
|
1366
|
+
const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace );
|
|
1367
|
+
const renderTargetProperties = properties.get( renderTarget );
|
|
1368
|
+
|
|
1369
|
+
if ( ! renderTargetProperties.__hasExternalTextures ) {
|
|
1370
|
+
|
|
1371
|
+
const width = Math.max( 1, renderTarget.width >> level );
|
|
1372
|
+
const height = Math.max( 1, renderTarget.height >> level );
|
|
1373
|
+
|
|
1374
|
+
if ( textureTarget === _gl.TEXTURE_3D || textureTarget === _gl.TEXTURE_2D_ARRAY ) {
|
|
1375
|
+
|
|
1376
|
+
state.texImage3D( textureTarget, level, glInternalFormat, width, height, renderTarget.depth, 0, glFormat, glType, null );
|
|
1377
|
+
|
|
1378
|
+
} else {
|
|
1379
|
+
|
|
1380
|
+
state.texImage2D( textureTarget, level, glInternalFormat, width, height, 0, glFormat, glType, null );
|
|
1381
|
+
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
1387
|
+
|
|
1388
|
+
if ( useMultisampledRTT( renderTarget ) ) {
|
|
1389
|
+
|
|
1390
|
+
multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, attachment, textureTarget, properties.get( texture ).__webglTexture, 0, getRenderTargetSamples( renderTarget ) );
|
|
1391
|
+
|
|
1392
|
+
} else if ( textureTarget === _gl.TEXTURE_2D || ( textureTarget >= _gl.TEXTURE_CUBE_MAP_POSITIVE_X && textureTarget <= _gl.TEXTURE_CUBE_MAP_NEGATIVE_Z ) ) { // see #24753
|
|
1393
|
+
|
|
1394
|
+
_gl.framebufferTexture2D( _gl.FRAMEBUFFER, attachment, textureTarget, properties.get( texture ).__webglTexture, level );
|
|
1395
|
+
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, null );
|
|
1399
|
+
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
|
|
1403
|
+
// Setup storage for internal depth/stencil buffers and bind to correct framebuffer
|
|
1404
|
+
function setupRenderBufferStorage( renderbuffer, renderTarget, isMultisample ) {
|
|
1405
|
+
|
|
1406
|
+
_gl.bindRenderbuffer( _gl.RENDERBUFFER, renderbuffer );
|
|
1407
|
+
|
|
1408
|
+
if ( renderTarget.depthBuffer && ! renderTarget.stencilBuffer ) {
|
|
1409
|
+
|
|
1410
|
+
let glInternalFormat = ( isWebGL2 === true ) ? _gl.DEPTH_COMPONENT24 : _gl.DEPTH_COMPONENT16;
|
|
1411
|
+
|
|
1412
|
+
if ( isMultisample || useMultisampledRTT( renderTarget ) ) {
|
|
1413
|
+
|
|
1414
|
+
const depthTexture = renderTarget.depthTexture;
|
|
1415
|
+
|
|
1416
|
+
if ( depthTexture && depthTexture.isDepthTexture ) {
|
|
1417
|
+
|
|
1418
|
+
if ( depthTexture.type === FloatType ) {
|
|
1419
|
+
|
|
1420
|
+
glInternalFormat = _gl.DEPTH_COMPONENT32F;
|
|
1421
|
+
|
|
1422
|
+
} else if ( depthTexture.type === UnsignedIntType ) {
|
|
1423
|
+
|
|
1424
|
+
glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
1425
|
+
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
const samples = getRenderTargetSamples( renderTarget );
|
|
1431
|
+
|
|
1432
|
+
if ( useMultisampledRTT( renderTarget ) ) {
|
|
1433
|
+
|
|
1434
|
+
multisampledRTTExt.renderbufferStorageMultisampleEXT( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
1435
|
+
|
|
1436
|
+
} else {
|
|
1437
|
+
|
|
1438
|
+
_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
1439
|
+
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
} else {
|
|
1443
|
+
|
|
1444
|
+
_gl.renderbufferStorage( _gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
1445
|
+
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.RENDERBUFFER, renderbuffer );
|
|
1449
|
+
|
|
1450
|
+
} else if ( renderTarget.depthBuffer && renderTarget.stencilBuffer ) {
|
|
1451
|
+
|
|
1452
|
+
const samples = getRenderTargetSamples( renderTarget );
|
|
1453
|
+
|
|
1454
|
+
if ( isMultisample && useMultisampledRTT( renderTarget ) === false ) {
|
|
1455
|
+
|
|
1456
|
+
_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, _gl.DEPTH24_STENCIL8, renderTarget.width, renderTarget.height );
|
|
1457
|
+
|
|
1458
|
+
} else if ( useMultisampledRTT( renderTarget ) ) {
|
|
1459
|
+
|
|
1460
|
+
multisampledRTTExt.renderbufferStorageMultisampleEXT( _gl.RENDERBUFFER, samples, _gl.DEPTH24_STENCIL8, renderTarget.width, renderTarget.height );
|
|
1461
|
+
|
|
1462
|
+
} else {
|
|
1463
|
+
|
|
1464
|
+
_gl.renderbufferStorage( _gl.RENDERBUFFER, _gl.DEPTH_STENCIL, renderTarget.width, renderTarget.height );
|
|
1465
|
+
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
|
|
1469
|
+
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.RENDERBUFFER, renderbuffer );
|
|
1470
|
+
|
|
1471
|
+
} else {
|
|
1472
|
+
|
|
1473
|
+
const textures = renderTarget.isWebGLMultipleRenderTargets === true ? renderTarget.texture : [ renderTarget.texture ];
|
|
1474
|
+
|
|
1475
|
+
for ( let i = 0; i < textures.length; i ++ ) {
|
|
1476
|
+
|
|
1477
|
+
const texture = textures[ i ];
|
|
1478
|
+
|
|
1479
|
+
const glFormat = utils.convert( texture.format, texture.colorSpace );
|
|
1480
|
+
const glType = utils.convert( texture.type );
|
|
1481
|
+
const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace );
|
|
1482
|
+
const samples = getRenderTargetSamples( renderTarget );
|
|
1483
|
+
|
|
1484
|
+
if ( isMultisample && useMultisampledRTT( renderTarget ) === false ) {
|
|
1485
|
+
|
|
1486
|
+
_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
1487
|
+
|
|
1488
|
+
} else if ( useMultisampledRTT( renderTarget ) ) {
|
|
1489
|
+
|
|
1490
|
+
multisampledRTTExt.renderbufferStorageMultisampleEXT( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
1491
|
+
|
|
1492
|
+
} else {
|
|
1493
|
+
|
|
1494
|
+
_gl.renderbufferStorage( _gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
1495
|
+
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1502
|
+
_gl.bindRenderbuffer( _gl.RENDERBUFFER, null );
|
|
1503
|
+
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
// Setup resources for a Depth Texture for a FBO (needs an extension)
|
|
1507
|
+
function setupDepthTexture( framebuffer, renderTarget ) {
|
|
1508
|
+
|
|
1509
|
+
const isCube = ( renderTarget && renderTarget.isWebGLCubeRenderTarget );
|
|
1510
|
+
if ( isCube ) throw new Error( 'Depth Texture with cube render targets is not supported' );
|
|
1511
|
+
|
|
1512
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
1513
|
+
|
|
1514
|
+
if ( ! ( renderTarget.depthTexture && renderTarget.depthTexture.isDepthTexture ) ) {
|
|
1515
|
+
|
|
1516
|
+
throw new Error( 'renderTarget.depthTexture must be an instance of THREE.DepthTexture' );
|
|
1517
|
+
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
// upload an empty depth texture with framebuffer size
|
|
1521
|
+
if ( ! properties.get( renderTarget.depthTexture ).__webglTexture ||
|
|
1522
|
+
renderTarget.depthTexture.image.width !== renderTarget.width ||
|
|
1523
|
+
renderTarget.depthTexture.image.height !== renderTarget.height ) {
|
|
1524
|
+
|
|
1525
|
+
renderTarget.depthTexture.image.width = renderTarget.width;
|
|
1526
|
+
renderTarget.depthTexture.image.height = renderTarget.height;
|
|
1527
|
+
renderTarget.depthTexture.needsUpdate = true;
|
|
1528
|
+
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1531
|
+
setTexture2D( renderTarget.depthTexture, 0 );
|
|
1532
|
+
|
|
1533
|
+
const webglDepthTexture = properties.get( renderTarget.depthTexture ).__webglTexture;
|
|
1534
|
+
const samples = getRenderTargetSamples( renderTarget );
|
|
1535
|
+
|
|
1536
|
+
if ( renderTarget.depthTexture.format === DepthFormat ) {
|
|
1537
|
+
|
|
1538
|
+
if ( useMultisampledRTT( renderTarget ) ) {
|
|
1539
|
+
|
|
1540
|
+
multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0, samples );
|
|
1541
|
+
|
|
1542
|
+
} else {
|
|
1543
|
+
|
|
1544
|
+
_gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0 );
|
|
1545
|
+
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
} else if ( renderTarget.depthTexture.format === DepthStencilFormat ) {
|
|
1549
|
+
|
|
1550
|
+
if ( useMultisampledRTT( renderTarget ) ) {
|
|
1551
|
+
|
|
1552
|
+
multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0, samples );
|
|
1553
|
+
|
|
1554
|
+
} else {
|
|
1555
|
+
|
|
1556
|
+
_gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0 );
|
|
1557
|
+
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
} else {
|
|
1561
|
+
|
|
1562
|
+
throw new Error( 'Unknown depthTexture format' );
|
|
1563
|
+
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1568
|
+
// Setup GL resources for a non-texture depth buffer
|
|
1569
|
+
function setupDepthRenderbuffer( renderTarget ) {
|
|
1570
|
+
|
|
1571
|
+
const renderTargetProperties = properties.get( renderTarget );
|
|
1572
|
+
const isCube = ( renderTarget.isWebGLCubeRenderTarget === true );
|
|
1573
|
+
|
|
1574
|
+
if ( renderTarget.depthTexture && ! renderTargetProperties.__autoAllocateDepthBuffer ) {
|
|
1575
|
+
|
|
1576
|
+
if ( isCube ) throw new Error( 'target.depthTexture not supported in Cube render targets' );
|
|
1577
|
+
|
|
1578
|
+
setupDepthTexture( renderTargetProperties.__webglFramebuffer, renderTarget );
|
|
1579
|
+
|
|
1580
|
+
} else {
|
|
1581
|
+
|
|
1582
|
+
if ( isCube ) {
|
|
1583
|
+
|
|
1584
|
+
renderTargetProperties.__webglDepthbuffer = [];
|
|
1585
|
+
|
|
1586
|
+
for ( let i = 0; i < 6; i ++ ) {
|
|
1587
|
+
|
|
1588
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer[ i ] );
|
|
1589
|
+
renderTargetProperties.__webglDepthbuffer[ i ] = _gl.createRenderbuffer();
|
|
1590
|
+
setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer[ i ], renderTarget, false );
|
|
1591
|
+
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
} else {
|
|
1595
|
+
|
|
1596
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
|
|
1597
|
+
renderTargetProperties.__webglDepthbuffer = _gl.createRenderbuffer();
|
|
1598
|
+
setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer, renderTarget, false );
|
|
1599
|
+
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1604
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, null );
|
|
1605
|
+
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
// rebind framebuffer with external textures
|
|
1609
|
+
function rebindTextures( renderTarget, colorTexture, depthTexture ) {
|
|
1610
|
+
|
|
1611
|
+
const renderTargetProperties = properties.get( renderTarget );
|
|
1612
|
+
|
|
1613
|
+
if ( colorTexture !== undefined ) {
|
|
1614
|
+
|
|
1615
|
+
setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, renderTarget.texture, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D, 0 );
|
|
1616
|
+
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1619
|
+
if ( depthTexture !== undefined ) {
|
|
1620
|
+
|
|
1621
|
+
setupDepthRenderbuffer( renderTarget );
|
|
1622
|
+
|
|
1623
|
+
}
|
|
1624
|
+
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
// Set up GL resources for the render target
|
|
1628
|
+
function setupRenderTarget( renderTarget ) {
|
|
1629
|
+
|
|
1630
|
+
const texture = renderTarget.texture;
|
|
1631
|
+
|
|
1632
|
+
const renderTargetProperties = properties.get( renderTarget );
|
|
1633
|
+
const textureProperties = properties.get( texture );
|
|
1634
|
+
|
|
1635
|
+
renderTarget.addEventListener( 'dispose', onRenderTargetDispose );
|
|
1636
|
+
|
|
1637
|
+
if ( renderTarget.isWebGLMultipleRenderTargets !== true ) {
|
|
1638
|
+
|
|
1639
|
+
if ( textureProperties.__webglTexture === undefined ) {
|
|
1640
|
+
|
|
1641
|
+
textureProperties.__webglTexture = _gl.createTexture();
|
|
1642
|
+
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
textureProperties.__version = texture.version;
|
|
1646
|
+
info.memory.textures ++;
|
|
1647
|
+
|
|
1648
|
+
}
|
|
1649
|
+
|
|
1650
|
+
const isCube = ( renderTarget.isWebGLCubeRenderTarget === true );
|
|
1651
|
+
const isMultipleRenderTargets = ( renderTarget.isWebGLMultipleRenderTargets === true );
|
|
1652
|
+
const supportsMips = isPowerOfTwo( renderTarget ) || isWebGL2;
|
|
1653
|
+
|
|
1654
|
+
// Setup framebuffer
|
|
1655
|
+
|
|
1656
|
+
if ( isCube ) {
|
|
1657
|
+
|
|
1658
|
+
renderTargetProperties.__webglFramebuffer = [];
|
|
1659
|
+
|
|
1660
|
+
for ( let i = 0; i < 6; i ++ ) {
|
|
1661
|
+
|
|
1662
|
+
if ( isWebGL2 && texture.mipmaps && texture.mipmaps.length > 0 ) {
|
|
1663
|
+
|
|
1664
|
+
renderTargetProperties.__webglFramebuffer[ i ] = [];
|
|
1665
|
+
|
|
1666
|
+
for ( let level = 0; level < texture.mipmaps.length; level ++ ) {
|
|
1667
|
+
|
|
1668
|
+
renderTargetProperties.__webglFramebuffer[ i ][ level ] = _gl.createFramebuffer();
|
|
1669
|
+
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1672
|
+
} else {
|
|
1673
|
+
|
|
1674
|
+
renderTargetProperties.__webglFramebuffer[ i ] = _gl.createFramebuffer();
|
|
1675
|
+
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
} else {
|
|
1681
|
+
|
|
1682
|
+
if ( isWebGL2 && texture.mipmaps && texture.mipmaps.length > 0 ) {
|
|
1683
|
+
|
|
1684
|
+
renderTargetProperties.__webglFramebuffer = [];
|
|
1685
|
+
|
|
1686
|
+
for ( let level = 0; level < texture.mipmaps.length; level ++ ) {
|
|
1687
|
+
|
|
1688
|
+
renderTargetProperties.__webglFramebuffer[ level ] = _gl.createFramebuffer();
|
|
1689
|
+
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1692
|
+
} else {
|
|
1693
|
+
|
|
1694
|
+
renderTargetProperties.__webglFramebuffer = _gl.createFramebuffer();
|
|
1695
|
+
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1698
|
+
if ( isMultipleRenderTargets ) {
|
|
1699
|
+
|
|
1700
|
+
if ( capabilities.drawBuffers ) {
|
|
1701
|
+
|
|
1702
|
+
const textures = renderTarget.texture;
|
|
1703
|
+
|
|
1704
|
+
for ( let i = 0, il = textures.length; i < il; i ++ ) {
|
|
1705
|
+
|
|
1706
|
+
const attachmentProperties = properties.get( textures[ i ] );
|
|
1707
|
+
|
|
1708
|
+
if ( attachmentProperties.__webglTexture === undefined ) {
|
|
1709
|
+
|
|
1710
|
+
attachmentProperties.__webglTexture = _gl.createTexture();
|
|
1711
|
+
|
|
1712
|
+
info.memory.textures ++;
|
|
1713
|
+
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
} else {
|
|
1719
|
+
|
|
1720
|
+
console.warn( 'THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.' );
|
|
1721
|
+
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
if ( ( isWebGL2 && renderTarget.samples > 0 ) && useMultisampledRTT( renderTarget ) === false ) {
|
|
1727
|
+
|
|
1728
|
+
const textures = isMultipleRenderTargets ? texture : [ texture ];
|
|
1729
|
+
|
|
1730
|
+
renderTargetProperties.__webglMultisampledFramebuffer = _gl.createFramebuffer();
|
|
1731
|
+
renderTargetProperties.__webglColorRenderbuffer = [];
|
|
1732
|
+
|
|
1733
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
|
|
1734
|
+
|
|
1735
|
+
for ( let i = 0; i < textures.length; i ++ ) {
|
|
1736
|
+
|
|
1737
|
+
const texture = textures[ i ];
|
|
1738
|
+
renderTargetProperties.__webglColorRenderbuffer[ i ] = _gl.createRenderbuffer();
|
|
1739
|
+
|
|
1740
|
+
_gl.bindRenderbuffer( _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[ i ] );
|
|
1741
|
+
|
|
1742
|
+
const glFormat = utils.convert( texture.format, texture.colorSpace );
|
|
1743
|
+
const glType = utils.convert( texture.type );
|
|
1744
|
+
const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace, renderTarget.isXRRenderTarget === true );
|
|
1745
|
+
const samples = getRenderTargetSamples( renderTarget );
|
|
1746
|
+
_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
1747
|
+
|
|
1748
|
+
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[ i ] );
|
|
1749
|
+
|
|
1750
|
+
}
|
|
1751
|
+
|
|
1752
|
+
_gl.bindRenderbuffer( _gl.RENDERBUFFER, null );
|
|
1753
|
+
|
|
1754
|
+
if ( renderTarget.depthBuffer ) {
|
|
1755
|
+
|
|
1756
|
+
renderTargetProperties.__webglDepthRenderbuffer = _gl.createRenderbuffer();
|
|
1757
|
+
setupRenderBufferStorage( renderTargetProperties.__webglDepthRenderbuffer, renderTarget, true );
|
|
1758
|
+
|
|
1759
|
+
}
|
|
1760
|
+
|
|
1761
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, null );
|
|
1762
|
+
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
}
|
|
1766
|
+
|
|
1767
|
+
// Setup color buffer
|
|
1768
|
+
|
|
1769
|
+
if ( isCube ) {
|
|
1770
|
+
|
|
1771
|
+
state.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture );
|
|
1772
|
+
setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture, supportsMips );
|
|
1773
|
+
|
|
1774
|
+
for ( let i = 0; i < 6; i ++ ) {
|
|
1775
|
+
|
|
1776
|
+
if ( isWebGL2 && texture.mipmaps && texture.mipmaps.length > 0 ) {
|
|
1777
|
+
|
|
1778
|
+
for ( let level = 0; level < texture.mipmaps.length; level ++ ) {
|
|
1779
|
+
|
|
1780
|
+
setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer[ i ][ level ], renderTarget, texture, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, level );
|
|
1781
|
+
|
|
1782
|
+
}
|
|
1783
|
+
|
|
1784
|
+
} else {
|
|
1785
|
+
|
|
1786
|
+
setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer[ i ], renderTarget, texture, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0 );
|
|
1787
|
+
|
|
1788
|
+
}
|
|
1789
|
+
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
|
|
1793
|
+
|
|
1794
|
+
generateMipmap( _gl.TEXTURE_CUBE_MAP );
|
|
1795
|
+
|
|
1796
|
+
}
|
|
1797
|
+
|
|
1798
|
+
state.unbindTexture();
|
|
1799
|
+
|
|
1800
|
+
} else if ( isMultipleRenderTargets ) {
|
|
1801
|
+
|
|
1802
|
+
const textures = renderTarget.texture;
|
|
1803
|
+
|
|
1804
|
+
for ( let i = 0, il = textures.length; i < il; i ++ ) {
|
|
1805
|
+
|
|
1806
|
+
const attachment = textures[ i ];
|
|
1807
|
+
const attachmentProperties = properties.get( attachment );
|
|
1808
|
+
|
|
1809
|
+
state.bindTexture( _gl.TEXTURE_2D, attachmentProperties.__webglTexture );
|
|
1810
|
+
setTextureParameters( _gl.TEXTURE_2D, attachment, supportsMips );
|
|
1811
|
+
setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, attachment, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, 0 );
|
|
1812
|
+
|
|
1813
|
+
if ( textureNeedsGenerateMipmaps( attachment, supportsMips ) ) {
|
|
1814
|
+
|
|
1815
|
+
generateMipmap( _gl.TEXTURE_2D );
|
|
1816
|
+
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
}
|
|
1820
|
+
|
|
1821
|
+
state.unbindTexture();
|
|
1822
|
+
|
|
1823
|
+
} else {
|
|
1824
|
+
|
|
1825
|
+
let glTextureType = _gl.TEXTURE_2D;
|
|
1826
|
+
|
|
1827
|
+
if ( renderTarget.isWebGL3DRenderTarget || renderTarget.isWebGLArrayRenderTarget ) {
|
|
1828
|
+
|
|
1829
|
+
if ( isWebGL2 ) {
|
|
1830
|
+
|
|
1831
|
+
glTextureType = renderTarget.isWebGL3DRenderTarget ? _gl.TEXTURE_3D : _gl.TEXTURE_2D_ARRAY;
|
|
1832
|
+
|
|
1833
|
+
} else {
|
|
1834
|
+
|
|
1835
|
+
console.error( 'THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.' );
|
|
1836
|
+
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1839
|
+
}
|
|
1840
|
+
|
|
1841
|
+
state.bindTexture( glTextureType, textureProperties.__webglTexture );
|
|
1842
|
+
setTextureParameters( glTextureType, texture, supportsMips );
|
|
1843
|
+
|
|
1844
|
+
if ( isWebGL2 && texture.mipmaps && texture.mipmaps.length > 0 ) {
|
|
1845
|
+
|
|
1846
|
+
for ( let level = 0; level < texture.mipmaps.length; level ++ ) {
|
|
1847
|
+
|
|
1848
|
+
setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer[ level ], renderTarget, texture, _gl.COLOR_ATTACHMENT0, glTextureType, level );
|
|
1849
|
+
|
|
1850
|
+
}
|
|
1851
|
+
|
|
1852
|
+
} else {
|
|
1853
|
+
|
|
1854
|
+
setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, texture, _gl.COLOR_ATTACHMENT0, glTextureType, 0 );
|
|
1855
|
+
|
|
1856
|
+
}
|
|
1857
|
+
|
|
1858
|
+
if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
|
|
1859
|
+
|
|
1860
|
+
generateMipmap( glTextureType );
|
|
1861
|
+
|
|
1862
|
+
}
|
|
1863
|
+
|
|
1864
|
+
state.unbindTexture();
|
|
1865
|
+
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1868
|
+
// Setup depth and stencil buffers
|
|
1869
|
+
|
|
1870
|
+
if ( renderTarget.depthBuffer ) {
|
|
1871
|
+
|
|
1872
|
+
setupDepthRenderbuffer( renderTarget );
|
|
1873
|
+
|
|
1874
|
+
}
|
|
1875
|
+
|
|
1876
|
+
}
|
|
1877
|
+
|
|
1878
|
+
function updateRenderTargetMipmap( renderTarget ) {
|
|
1879
|
+
|
|
1880
|
+
const supportsMips = isPowerOfTwo( renderTarget ) || isWebGL2;
|
|
1881
|
+
|
|
1882
|
+
const textures = renderTarget.isWebGLMultipleRenderTargets === true ? renderTarget.texture : [ renderTarget.texture ];
|
|
1883
|
+
|
|
1884
|
+
for ( let i = 0, il = textures.length; i < il; i ++ ) {
|
|
1885
|
+
|
|
1886
|
+
const texture = textures[ i ];
|
|
1887
|
+
|
|
1888
|
+
if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
|
|
1889
|
+
|
|
1890
|
+
const target = renderTarget.isWebGLCubeRenderTarget ? _gl.TEXTURE_CUBE_MAP : _gl.TEXTURE_2D;
|
|
1891
|
+
const webglTexture = properties.get( texture ).__webglTexture;
|
|
1892
|
+
|
|
1893
|
+
state.bindTexture( target, webglTexture );
|
|
1894
|
+
generateMipmap( target );
|
|
1895
|
+
state.unbindTexture();
|
|
1896
|
+
|
|
1897
|
+
}
|
|
1898
|
+
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1903
|
+
function updateMultisampleRenderTarget( renderTarget ) {
|
|
1904
|
+
|
|
1905
|
+
if ( ( isWebGL2 && renderTarget.samples > 0 ) && useMultisampledRTT( renderTarget ) === false ) {
|
|
1906
|
+
|
|
1907
|
+
const textures = renderTarget.isWebGLMultipleRenderTargets ? renderTarget.texture : [ renderTarget.texture ];
|
|
1908
|
+
const width = renderTarget.width;
|
|
1909
|
+
const height = renderTarget.height;
|
|
1910
|
+
let mask = _gl.COLOR_BUFFER_BIT;
|
|
1911
|
+
const invalidationArray = [];
|
|
1912
|
+
const depthStyle = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
|
|
1913
|
+
const renderTargetProperties = properties.get( renderTarget );
|
|
1914
|
+
const isMultipleRenderTargets = ( renderTarget.isWebGLMultipleRenderTargets === true );
|
|
1915
|
+
|
|
1916
|
+
// If MRT we need to remove FBO attachments
|
|
1917
|
+
if ( isMultipleRenderTargets ) {
|
|
1918
|
+
|
|
1919
|
+
for ( let i = 0; i < textures.length; i ++ ) {
|
|
1920
|
+
|
|
1921
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
|
|
1922
|
+
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.RENDERBUFFER, null );
|
|
1923
|
+
|
|
1924
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
|
|
1925
|
+
_gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, null, 0 );
|
|
1926
|
+
|
|
1927
|
+
}
|
|
1928
|
+
|
|
1929
|
+
}
|
|
1930
|
+
|
|
1931
|
+
state.bindFramebuffer( _gl.READ_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
|
|
1932
|
+
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
|
|
1933
|
+
|
|
1934
|
+
for ( let i = 0; i < textures.length; i ++ ) {
|
|
1935
|
+
|
|
1936
|
+
invalidationArray.push( _gl.COLOR_ATTACHMENT0 + i );
|
|
1937
|
+
|
|
1938
|
+
if ( renderTarget.depthBuffer ) {
|
|
1939
|
+
|
|
1940
|
+
invalidationArray.push( depthStyle );
|
|
1941
|
+
|
|
1942
|
+
}
|
|
1943
|
+
|
|
1944
|
+
const ignoreDepthValues = ( renderTargetProperties.__ignoreDepthValues !== undefined ) ? renderTargetProperties.__ignoreDepthValues : false;
|
|
1945
|
+
|
|
1946
|
+
if ( ignoreDepthValues === false ) {
|
|
1947
|
+
|
|
1948
|
+
if ( renderTarget.depthBuffer ) mask |= _gl.DEPTH_BUFFER_BIT;
|
|
1949
|
+
if ( renderTarget.stencilBuffer ) mask |= _gl.STENCIL_BUFFER_BIT;
|
|
1950
|
+
|
|
1951
|
+
}
|
|
1952
|
+
|
|
1953
|
+
if ( isMultipleRenderTargets ) {
|
|
1954
|
+
|
|
1955
|
+
_gl.framebufferRenderbuffer( _gl.READ_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[ i ] );
|
|
1956
|
+
|
|
1957
|
+
}
|
|
1958
|
+
|
|
1959
|
+
if ( ignoreDepthValues === true ) {
|
|
1960
|
+
|
|
1961
|
+
_gl.invalidateFramebuffer( _gl.READ_FRAMEBUFFER, [ depthStyle ] );
|
|
1962
|
+
_gl.invalidateFramebuffer( _gl.DRAW_FRAMEBUFFER, [ depthStyle ] );
|
|
1963
|
+
|
|
1964
|
+
}
|
|
1965
|
+
|
|
1966
|
+
if ( isMultipleRenderTargets ) {
|
|
1967
|
+
|
|
1968
|
+
const webglTexture = properties.get( textures[ i ] ).__webglTexture;
|
|
1969
|
+
_gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D, webglTexture, 0 );
|
|
1970
|
+
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1973
|
+
_gl.blitFramebuffer( 0, 0, width, height, 0, 0, width, height, mask, _gl.NEAREST );
|
|
1974
|
+
|
|
1975
|
+
if ( supportsInvalidateFramebuffer ) {
|
|
1976
|
+
|
|
1977
|
+
_gl.invalidateFramebuffer( _gl.READ_FRAMEBUFFER, invalidationArray );
|
|
1978
|
+
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1981
|
+
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
state.bindFramebuffer( _gl.READ_FRAMEBUFFER, null );
|
|
1985
|
+
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, null );
|
|
1986
|
+
|
|
1987
|
+
// If MRT since pre-blit we removed the FBO we need to reconstruct the attachments
|
|
1988
|
+
if ( isMultipleRenderTargets ) {
|
|
1989
|
+
|
|
1990
|
+
for ( let i = 0; i < textures.length; i ++ ) {
|
|
1991
|
+
|
|
1992
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
|
|
1993
|
+
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[ i ] );
|
|
1994
|
+
|
|
1995
|
+
const webglTexture = properties.get( textures[ i ] ).__webglTexture;
|
|
1996
|
+
|
|
1997
|
+
state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
|
|
1998
|
+
_gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, webglTexture, 0 );
|
|
1999
|
+
|
|
2000
|
+
}
|
|
2001
|
+
|
|
2002
|
+
}
|
|
2003
|
+
|
|
2004
|
+
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
|
|
2005
|
+
|
|
2006
|
+
}
|
|
2007
|
+
|
|
2008
|
+
}
|
|
2009
|
+
|
|
2010
|
+
function getRenderTargetSamples( renderTarget ) {
|
|
2011
|
+
|
|
2012
|
+
return Math.min( capabilities.maxSamples, renderTarget.samples );
|
|
2013
|
+
|
|
2014
|
+
}
|
|
2015
|
+
|
|
2016
|
+
function useMultisampledRTT( renderTarget ) {
|
|
2017
|
+
|
|
2018
|
+
const renderTargetProperties = properties.get( renderTarget );
|
|
2019
|
+
|
|
2020
|
+
return isWebGL2 && renderTarget.samples > 0 && extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true && renderTargetProperties.__useRenderToTexture !== false;
|
|
2021
|
+
|
|
2022
|
+
}
|
|
2023
|
+
|
|
2024
|
+
function updateVideoTexture( texture ) {
|
|
2025
|
+
|
|
2026
|
+
const frame = info.render.frame;
|
|
2027
|
+
|
|
2028
|
+
// Check the last frame we updated the VideoTexture
|
|
2029
|
+
|
|
2030
|
+
if ( _videoTextures.get( texture ) !== frame ) {
|
|
2031
|
+
|
|
2032
|
+
_videoTextures.set( texture, frame );
|
|
2033
|
+
texture.update();
|
|
2034
|
+
|
|
2035
|
+
}
|
|
2036
|
+
|
|
2037
|
+
}
|
|
2038
|
+
|
|
2039
|
+
function verifyColorSpace( texture, image ) {
|
|
2040
|
+
|
|
2041
|
+
const colorSpace = texture.colorSpace;
|
|
2042
|
+
const format = texture.format;
|
|
2043
|
+
const type = texture.type;
|
|
2044
|
+
|
|
2045
|
+
if ( texture.isCompressedTexture === true || texture.isVideoTexture === true || texture.format === _SRGBAFormat ) return image;
|
|
2046
|
+
|
|
2047
|
+
if ( colorSpace !== LinearSRGBColorSpace && colorSpace !== NoColorSpace ) {
|
|
2048
|
+
|
|
2049
|
+
// sRGB
|
|
2050
|
+
|
|
2051
|
+
if ( ColorManagement.getTransfer( colorSpace ) === SRGBTransfer ) {
|
|
2052
|
+
|
|
2053
|
+
if ( isWebGL2 === false ) {
|
|
2054
|
+
|
|
2055
|
+
// in WebGL 1, try to use EXT_sRGB extension and unsized formats
|
|
2056
|
+
|
|
2057
|
+
if ( extensions.has( 'EXT_sRGB' ) === true && format === RGBAFormat ) {
|
|
2058
|
+
|
|
2059
|
+
texture.format = _SRGBAFormat;
|
|
2060
|
+
|
|
2061
|
+
// it's not possible to generate mips in WebGL 1 with this extension
|
|
2062
|
+
|
|
2063
|
+
texture.minFilter = LinearFilter;
|
|
2064
|
+
texture.generateMipmaps = false;
|
|
2065
|
+
|
|
2066
|
+
} else {
|
|
2067
|
+
|
|
2068
|
+
// slow fallback (CPU decode)
|
|
2069
|
+
|
|
2070
|
+
image = ImageUtils.sRGBToLinear( image );
|
|
2071
|
+
|
|
2072
|
+
}
|
|
2073
|
+
|
|
2074
|
+
} else {
|
|
2075
|
+
|
|
2076
|
+
// in WebGL 2 uncompressed textures can only be sRGB encoded if they have the RGBA8 format
|
|
2077
|
+
|
|
2078
|
+
if ( format !== RGBAFormat || type !== UnsignedByteType ) {
|
|
2079
|
+
|
|
2080
|
+
console.warn( 'THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.' );
|
|
2081
|
+
|
|
2082
|
+
}
|
|
2083
|
+
|
|
2084
|
+
}
|
|
2085
|
+
|
|
2086
|
+
} else {
|
|
2087
|
+
|
|
2088
|
+
console.error( 'THREE.WebGLTextures: Unsupported texture color space:', colorSpace );
|
|
2089
|
+
|
|
2090
|
+
}
|
|
2091
|
+
|
|
2092
|
+
}
|
|
2093
|
+
|
|
2094
|
+
return image;
|
|
2095
|
+
|
|
2096
|
+
}
|
|
2097
|
+
|
|
2098
|
+
//
|
|
2099
|
+
|
|
2100
|
+
this.allocateTextureUnit = allocateTextureUnit;
|
|
2101
|
+
this.resetTextureUnits = resetTextureUnits;
|
|
2102
|
+
|
|
2103
|
+
this.setTexture2D = setTexture2D;
|
|
2104
|
+
this.setTexture2DArray = setTexture2DArray;
|
|
2105
|
+
this.setTexture3D = setTexture3D;
|
|
2106
|
+
this.setTextureCube = setTextureCube;
|
|
2107
|
+
this.rebindTextures = rebindTextures;
|
|
2108
|
+
this.setupRenderTarget = setupRenderTarget;
|
|
2109
|
+
this.updateRenderTargetMipmap = updateRenderTargetMipmap;
|
|
2110
|
+
this.updateMultisampleRenderTarget = updateMultisampleRenderTarget;
|
|
2111
|
+
this.setupDepthRenderbuffer = setupDepthRenderbuffer;
|
|
2112
|
+
this.setupFrameBufferTexture = setupFrameBufferTexture;
|
|
2113
|
+
this.useMultisampledRTT = useMultisampledRTT;
|
|
2114
|
+
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2117
|
+
export { WebGLTextures };
|