@needle-tools/three 0.162.2 → 0.162.3
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 -86
- package/build/three.cjs +53266 -53266
- package/build/three.module.js +53266 -53266
- 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 +295 -295
- 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 -108
- package/examples/jsm/capabilities/WebGPU.js +57 -57
- package/examples/jsm/controls/ArcballControls.js +3224 -3224
- package/examples/jsm/controls/DragControls.js +282 -282
- package/examples/jsm/controls/FirstPersonControls.js +325 -325
- package/examples/jsm/controls/FlyControls.js +326 -326
- package/examples/jsm/controls/MapControls.js +28 -28
- package/examples/jsm/controls/OrbitControls.js +1548 -1548
- package/examples/jsm/controls/PointerLockControls.js +162 -162
- package/examples/jsm/controls/TrackballControls.js +828 -828
- package/examples/jsm/controls/TransformControls.js +1573 -1573
- 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 -295
- 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 +542 -542
- package/examples/jsm/curves/NURBSVolume.js +62 -62
- 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 -579
- package/examples/jsm/exporters/GLTFExporter.js +3322 -3321
- 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 -720
- 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 -174
- 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 -144
- 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 -237
- 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 -572
- package/examples/jsm/interactive/InteractiveGroup.js +106 -106
- package/examples/jsm/interactive/SelectionBox.js +227 -227
- package/examples/jsm/interactive/SelectionHelper.js +104 -104
- 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 -14849
- 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 -14506
- package/examples/jsm/libs/potpack.module.js +124 -124
- package/examples/jsm/libs/rhino3dm/rhino3dm.js +21 -21
- package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +15 -15
- package/examples/jsm/libs/stats.module.js +167 -167
- package/examples/jsm/libs/surfaceNet.js +200 -200
- package/examples/jsm/libs/tween.module.js +876 -876
- package/examples/jsm/libs/utif.module.js +1664 -1664
- package/examples/jsm/libs/zstddec.module.js +1 -1
- package/examples/jsm/lights/IESSpotLight.js +25 -25
- package/examples/jsm/lights/LightProbeGenerator.js +286 -286
- 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 -619
- 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 +1764 -1764
- 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 -4116
- package/examples/jsm/loaders/DDSLoader.js +318 -318
- package/examples/jsm/loaders/DRACOLoader.js +613 -613
- package/examples/jsm/loaders/EXRLoader.js +2309 -2309
- package/examples/jsm/loaders/FBXLoader.js +4314 -4314
- package/examples/jsm/loaders/FontLoader.js +183 -183
- package/examples/jsm/loaders/GCodeLoader.js +261 -261
- package/examples/jsm/loaders/GLTFLoader.js +4666 -4666
- package/examples/jsm/loaders/GLTFLoaderAnimationPointer.js +729 -729
- 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 -932
- package/examples/jsm/loaders/KTXLoader.js +176 -176
- package/examples/jsm/loaders/LDrawLoader.js +2470 -2470
- package/examples/jsm/loaders/LUT3dlLoader.js +183 -183
- package/examples/jsm/loaders/LUTCubeLoader.js +167 -167
- package/examples/jsm/loaders/LUTImageLoader.js +163 -163
- 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 -2276
- package/examples/jsm/loaders/MTLLoader.js +567 -567
- package/examples/jsm/loaders/MaterialXLoader.js +852 -852
- package/examples/jsm/loaders/NRRDLoader.js +686 -686
- 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 -450
- package/examples/jsm/loaders/RGBMLoader.js +1065 -1065
- package/examples/jsm/loaders/STLLoader.js +410 -410
- package/examples/jsm/loaders/SVGLoader.js +3173 -3173
- 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 -822
- package/examples/jsm/loaders/VOXLoader.js +318 -318
- package/examples/jsm/loaders/VRMLLoader.js +3537 -3537
- package/examples/jsm/loaders/VTKLoader.js +1163 -1163
- package/examples/jsm/loaders/XYZLoader.js +106 -106
- package/examples/jsm/loaders/lwo/IFFParser.js +1214 -1214
- 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 -426
- package/examples/jsm/materials/MeshPostProcessingMaterial.js +144 -144
- package/examples/jsm/math/Capsule.js +82 -82
- 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 -540
- package/examples/jsm/math/SimplexNoise.js +444 -444
- package/examples/jsm/misc/ConvexObjectBreaker.js +519 -519
- package/examples/jsm/misc/GPUComputationRenderer.js +446 -446
- 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 +324 -324
- package/examples/jsm/misc/RollerCoaster.js +566 -566
- package/examples/jsm/misc/Timer.js +128 -128
- package/examples/jsm/misc/TubePainter.js +202 -202
- package/examples/jsm/misc/Volume.js +473 -473
- package/examples/jsm/misc/VolumeSlice.js +229 -229
- package/examples/jsm/modifiers/CurveModifier.js +344 -344
- package/examples/jsm/modifiers/EdgeSplitModifier.js +279 -279
- package/examples/jsm/modifiers/SimplifyModifier.js +617 -617
- package/examples/jsm/modifiers/TessellateModifier.js +307 -307
- package/examples/jsm/nodes/Nodes.js +195 -195
- package/examples/jsm/nodes/accessors/AccessorsUtils.js +10 -10
- package/examples/jsm/nodes/accessors/BitangentNode.js +89 -89
- package/examples/jsm/nodes/accessors/BufferAttributeNode.js +127 -127
- package/examples/jsm/nodes/accessors/BufferNode.js +30 -30
- package/examples/jsm/nodes/accessors/CameraNode.js +119 -119
- package/examples/jsm/nodes/accessors/ClippingNode.js +144 -144
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +61 -61
- package/examples/jsm/nodes/accessors/InstanceNode.js +71 -71
- package/examples/jsm/nodes/accessors/InstancedPointsMaterialNode.js +21 -21
- package/examples/jsm/nodes/accessors/MaterialNode.js +314 -314
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +41 -41
- package/examples/jsm/nodes/accessors/ModelNode.js +33 -33
- package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +39 -39
- package/examples/jsm/nodes/accessors/MorphNode.js +245 -245
- 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 +160 -160
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +35 -35
- package/examples/jsm/nodes/accessors/SceneNode.js +52 -52
- package/examples/jsm/nodes/accessors/SkinningNode.js +124 -124
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +72 -72
- package/examples/jsm/nodes/accessors/TangentNode.js +109 -109
- package/examples/jsm/nodes/accessors/TextureBicubicNode.js +94 -94
- package/examples/jsm/nodes/accessors/TextureNode.js +367 -367
- package/examples/jsm/nodes/accessors/TextureSizeNode.js +35 -35
- package/examples/jsm/nodes/accessors/TextureStoreNode.js +82 -82
- package/examples/jsm/nodes/accessors/UVNode.js +47 -47
- package/examples/jsm/nodes/accessors/UniformsNode.js +140 -140
- package/examples/jsm/nodes/accessors/UserDataNode.js +29 -29
- package/examples/jsm/nodes/accessors/VertexColorNode.js +70 -70
- package/examples/jsm/nodes/code/CodeNode.js +84 -84
- 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 -138
- package/examples/jsm/nodes/code/ScriptableNode.js +488 -488
- package/examples/jsm/nodes/code/ScriptableValueNode.js +167 -167
- package/examples/jsm/nodes/core/AssignNode.js +128 -128
- package/examples/jsm/nodes/core/AttributeNode.js +108 -108
- package/examples/jsm/nodes/core/BypassNode.js +45 -45
- package/examples/jsm/nodes/core/CacheNode.js +49 -49
- 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 +493 -493
- package/examples/jsm/nodes/core/NodeAttribute.js +15 -15
- package/examples/jsm/nodes/core/NodeBuilder.js +1250 -1250
- 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 +143 -143
- 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 -40
- package/examples/jsm/nodes/core/NodeUtils.js +210 -210
- 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 -62
- package/examples/jsm/nodes/core/ParameterNode.js +33 -33
- package/examples/jsm/nodes/core/PropertyNode.js +72 -72
- package/examples/jsm/nodes/core/StackNode.js +89 -89
- package/examples/jsm/nodes/core/StructTypeNode.js +24 -24
- package/examples/jsm/nodes/core/TempNode.js +58 -58
- package/examples/jsm/nodes/core/UniformGroup.js +13 -13
- package/examples/jsm/nodes/core/UniformGroupNode.js +36 -36
- package/examples/jsm/nodes/core/UniformNode.js +80 -80
- package/examples/jsm/nodes/core/VarNode.js +60 -60
- package/examples/jsm/nodes/core/VaryingNode.js +65 -65
- package/examples/jsm/nodes/core/constants.js +28 -28
- package/examples/jsm/nodes/display/AfterImageNode.js +148 -148
- package/examples/jsm/nodes/display/AnamorphicNode.js +148 -148
- package/examples/jsm/nodes/display/BlendModeNode.js +128 -128
- package/examples/jsm/nodes/display/BumpMapNode.js +99 -99
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +99 -99
- 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 +190 -190
- package/examples/jsm/nodes/display/NormalMapNode.js +106 -106
- package/examples/jsm/nodes/display/PassNode.js +183 -183
- package/examples/jsm/nodes/display/PosterizeNode.js +32 -32
- package/examples/jsm/nodes/display/ToneMappingNode.js +184 -184
- package/examples/jsm/nodes/display/ViewportDepthNode.js +97 -97
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +31 -31
- package/examples/jsm/nodes/display/ViewportNode.js +134 -134
- 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 -38
- package/examples/jsm/nodes/fog/FogRangeNode.js +34 -34
- package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +40 -40
- package/examples/jsm/nodes/functions/BSDF/BRDF_Lambert.js +9 -9
- package/examples/jsm/nodes/functions/BSDF/BRDF_Sheen.js +57 -57
- package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +30 -30
- package/examples/jsm/nodes/functions/BSDF/D_GGX.js +23 -23
- 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 -21
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +28 -28
- package/examples/jsm/nodes/functions/PhongLightingModel.js +67 -67
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +393 -393
- 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 -85
- 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 +241 -241
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +40 -40
- 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 -66
- package/examples/jsm/nodes/lighting/LightingNode.js +21 -21
- package/examples/jsm/nodes/lighting/LightsNode.js +188 -188
- package/examples/jsm/nodes/lighting/PointLightNode.js +68 -68
- package/examples/jsm/nodes/lighting/SpotLightNode.js +89 -89
- 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 -162
- package/examples/jsm/nodes/materials/Line2NodeMaterial.js +436 -436
- package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +28 -28
- package/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +54 -54
- package/examples/jsm/nodes/materials/Materials.js +16 -16
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +28 -28
- package/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +34 -34
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +40 -40
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +65 -65
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +155 -155
- package/examples/jsm/nodes/materials/MeshSSSNodeMaterial.js +84 -84
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +80 -80
- package/examples/jsm/nodes/materials/NodeMaterial.js +601 -601
- package/examples/jsm/nodes/materials/PointsNodeMaterial.js +39 -39
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +90 -90
- 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 -130
- package/examples/jsm/nodes/materialx/lib/mx_noise.js +1430 -1430
- package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +29 -29
- package/examples/jsm/nodes/math/CondNode.js +121 -121
- package/examples/jsm/nodes/math/HashNode.js +34 -34
- package/examples/jsm/nodes/math/MathNode.js +391 -391
- package/examples/jsm/nodes/math/MathUtils.js +15 -15
- package/examples/jsm/nodes/math/OperatorNode.js +274 -274
- package/examples/jsm/nodes/math/TriNoise3D.js +71 -71
- 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 +634 -634
- package/examples/jsm/nodes/utils/ArrayElementNode.js +35 -35
- package/examples/jsm/nodes/utils/ConvertNode.js +65 -65
- package/examples/jsm/nodes/utils/DiscardNode.js +27 -27
- package/examples/jsm/nodes/utils/EquirectUVNode.js +33 -33
- package/examples/jsm/nodes/utils/FunctionOverloadingNode.js +95 -95
- package/examples/jsm/nodes/utils/JoinNode.js +61 -61
- package/examples/jsm/nodes/utils/LoopNode.js +200 -200
- 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/ReflectorNode.js +227 -227
- package/examples/jsm/nodes/utils/RemapNode.js +42 -42
- package/examples/jsm/nodes/utils/RotateNode.js +68 -68
- package/examples/jsm/nodes/utils/RotateUVNode.js +35 -35
- package/examples/jsm/nodes/utils/SetNode.js +62 -62
- package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +37 -37
- package/examples/jsm/nodes/utils/SplitNode.js +112 -112
- package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +41 -41
- package/examples/jsm/nodes/utils/StorageArrayElementNode.js +91 -91
- 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 -50
- package/examples/jsm/objects/InstancedPoints.js +21 -21
- package/examples/jsm/objects/Lensflare.js +397 -397
- package/examples/jsm/objects/MarchingCubes.js +1176 -1176
- package/examples/jsm/objects/QuadMesh.js +66 -66
- package/examples/jsm/objects/Reflector.js +264 -264
- package/examples/jsm/objects/ReflectorForSSRPass.js +352 -352
- package/examples/jsm/objects/Refractor.js +327 -327
- package/examples/jsm/objects/ShadowMesh.js +80 -80
- package/examples/jsm/objects/Sky.js +219 -219
- package/examples/jsm/objects/Water.js +333 -333
- package/examples/jsm/objects/Water2.js +361 -361
- package/examples/jsm/offscreen/jank.js +45 -45
- package/examples/jsm/offscreen/offscreen.js +8 -8
- package/examples/jsm/offscreen/scene.js +86 -86
- package/examples/jsm/physics/AmmoPhysics.js +306 -306
- package/examples/jsm/physics/RapierPhysics.js +220 -220
- package/examples/jsm/postprocessing/AfterimagePass.js +104 -104
- package/examples/jsm/postprocessing/BloomPass.js +172 -172
- package/examples/jsm/postprocessing/BokehPass.js +141 -141
- 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 -64
- package/examples/jsm/postprocessing/GTAOPass.js +582 -582
- package/examples/jsm/postprocessing/GlitchPass.js +128 -128
- package/examples/jsm/postprocessing/HalftonePass.js +79 -79
- package/examples/jsm/postprocessing/LUTPass.js +174 -174
- package/examples/jsm/postprocessing/MaskPass.js +104 -104
- package/examples/jsm/postprocessing/OutlinePass.js +654 -654
- package/examples/jsm/postprocessing/OutputPass.js +97 -97
- package/examples/jsm/postprocessing/Pass.js +95 -95
- package/examples/jsm/postprocessing/RenderPass.js +99 -99
- package/examples/jsm/postprocessing/RenderPixelatedPass.js +235 -235
- package/examples/jsm/postprocessing/SAOPass.js +335 -335
- package/examples/jsm/postprocessing/SMAAPass.js +199 -199
- package/examples/jsm/postprocessing/SSAARenderPass.js +228 -228
- package/examples/jsm/postprocessing/SSAOPass.js +420 -420
- 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 -188
- package/examples/jsm/postprocessing/TexturePass.js +67 -67
- package/examples/jsm/postprocessing/UnrealBloomPass.js +415 -415
- package/examples/jsm/renderers/CSS2DRenderer.js +215 -215
- package/examples/jsm/renderers/CSS3DRenderer.js +329 -329
- package/examples/jsm/renderers/Projector.js +918 -918
- package/examples/jsm/renderers/SVGRenderer.js +556 -556
- package/examples/jsm/renderers/common/Animation.js +47 -47
- package/examples/jsm/renderers/common/Attributes.js +75 -75
- package/examples/jsm/renderers/common/Backend.js +195 -195
- package/examples/jsm/renderers/common/Background.js +134 -134
- package/examples/jsm/renderers/common/Binding.js +25 -25
- package/examples/jsm/renderers/common/Bindings.js +173 -173
- 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/ClippingContext.js +165 -165
- package/examples/jsm/renderers/common/Color4.js +37 -37
- 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 -107
- package/examples/jsm/renderers/common/Pipeline.js +13 -13
- package/examples/jsm/renderers/common/Pipelines.js +322 -322
- package/examples/jsm/renderers/common/PostProcessing.js +25 -25
- package/examples/jsm/renderers/common/ProgrammableStage.js +20 -20
- package/examples/jsm/renderers/common/RenderContext.js +43 -43
- package/examples/jsm/renderers/common/RenderContexts.js +63 -63
- package/examples/jsm/renderers/common/RenderList.js +186 -186
- package/examples/jsm/renderers/common/RenderLists.js +38 -38
- package/examples/jsm/renderers/common/RenderObject.js +221 -221
- package/examples/jsm/renderers/common/RenderObjects.js +93 -93
- package/examples/jsm/renderers/common/RenderPipeline.js +16 -16
- package/examples/jsm/renderers/common/Renderer.js +1304 -1304
- package/examples/jsm/renderers/common/SampledTexture.js +83 -83
- 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 +17 -17
- package/examples/jsm/renderers/common/StorageInstancedBufferAttribute.js +17 -17
- package/examples/jsm/renderers/common/StorageTexture.js +20 -20
- package/examples/jsm/renderers/common/Textures.js +344 -344
- 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 +301 -301
- package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +44 -44
- package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +49 -49
- package/examples/jsm/renderers/common/nodes/NodeSampler.js +15 -15
- package/examples/jsm/renderers/common/nodes/NodeStorageBuffer.js +23 -23
- package/examples/jsm/renderers/common/nodes/NodeUniform.js +135 -135
- package/examples/jsm/renderers/common/nodes/NodeUniformBuffer.js +23 -23
- package/examples/jsm/renderers/common/nodes/NodeUniformsGroup.js +44 -44
- package/examples/jsm/renderers/common/nodes/Nodes.js +496 -496
- package/examples/jsm/renderers/webgl/WebGLBackend.js +1382 -1382
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +804 -804
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +258 -258
- package/examples/jsm/renderers/webgl/utils/WebGLCapabilities.js +36 -36
- package/examples/jsm/renderers/webgl/utils/WebGLConstants.js +11 -11
- package/examples/jsm/renderers/webgl/utils/WebGLExtensions.js +36 -36
- package/examples/jsm/renderers/webgl/utils/WebGLState.js +738 -738
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +694 -694
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +285 -285
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +320 -320
- package/examples/jsm/renderers/webgl-legacy/nodes/SlotNode.js +26 -26
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +794 -794
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodes.js +51 -51
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +1322 -1322
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +53 -53
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +1078 -1078
- 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 +293 -293
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +244 -244
- package/examples/jsm/renderers/webgpu/utils/WebGPUConstants.js +324 -324
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +591 -591
- package/examples/jsm/renderers/webgpu/utils/WebGPUTexturePassUtils.js +285 -285
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +1040 -1040
- package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +93 -93
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +89 -89
- package/examples/jsm/shaders/AfterimageShader.js +58 -58
- package/examples/jsm/shaders/BasicShader.js +29 -29
- package/examples/jsm/shaders/BleachBypassShader.js +62 -62
- package/examples/jsm/shaders/BlendShader.js +49 -49
- package/examples/jsm/shaders/BokehShader.js +145 -145
- package/examples/jsm/shaders/BokehShader2.js +397 -397
- package/examples/jsm/shaders/BrightnessContrastShader.js +56 -56
- package/examples/jsm/shaders/ColorCorrectionShader.js +52 -52
- 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 -56
- package/examples/jsm/shaders/DepthLimitedBlurShader.js +171 -171
- 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 -288
- package/examples/jsm/shaders/FilmShader.js +59 -59
- package/examples/jsm/shaders/FocusShader.js +89 -89
- package/examples/jsm/shaders/FreiChenShader.js +96 -96
- package/examples/jsm/shaders/GTAOShader.js +424 -424
- package/examples/jsm/shaders/GammaCorrectionShader.js +43 -43
- package/examples/jsm/shaders/GodRaysShader.js +321 -321
- package/examples/jsm/shaders/HalftoneShader.js +312 -312
- package/examples/jsm/shaders/HorizontalBlurShader.js +59 -59
- package/examples/jsm/shaders/HorizontalTiltShiftShader.js +63 -63
- package/examples/jsm/shaders/HueSaturationShader.js +67 -67
- package/examples/jsm/shaders/KaleidoShader.js +58 -58
- package/examples/jsm/shaders/LuminosityHighPassShader.js +66 -66
- package/examples/jsm/shaders/LuminosityShader.js +48 -48
- package/examples/jsm/shaders/MMDToonShader.js +134 -134
- package/examples/jsm/shaders/MirrorShader.js +56 -56
- package/examples/jsm/shaders/NormalMapShader.js +55 -55
- package/examples/jsm/shaders/OutputShader.js +85 -85
- package/examples/jsm/shaders/PoissonDenoiseShader.js +226 -226
- package/examples/jsm/shaders/RGBShiftShader.js +54 -54
- package/examples/jsm/shaders/SAOShader.js +179 -179
- package/examples/jsm/shaders/SMAAShader.js +466 -466
- package/examples/jsm/shaders/SSAOShader.js +300 -300
- package/examples/jsm/shaders/SSRShader.js +370 -370
- package/examples/jsm/shaders/SepiaShader.js +52 -52
- package/examples/jsm/shaders/SobelOperatorShader.js +92 -92
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +90 -90
- package/examples/jsm/shaders/TechnicolorShader.js +45 -45
- package/examples/jsm/shaders/ToonShader.js +326 -326
- package/examples/jsm/shaders/TriangleBlurShader.js +74 -74
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +47 -47
- package/examples/jsm/shaders/VelocityShader.js +130 -130
- package/examples/jsm/shaders/VerticalBlurShader.js +59 -59
- package/examples/jsm/shaders/VerticalTiltShiftShader.js +63 -63
- package/examples/jsm/shaders/VignetteShader.js +51 -51
- package/examples/jsm/shaders/VolumeShader.js +289 -289
- package/examples/jsm/shaders/WaterRefractionShader.js +95 -95
- package/examples/jsm/textures/FlakesTexture.js +40 -40
- package/examples/jsm/transpiler/AST.js +270 -270
- package/examples/jsm/transpiler/GLSLDecoder.js +941 -941
- package/examples/jsm/transpiler/ShaderToyDecoder.js +49 -49
- package/examples/jsm/transpiler/TSLEncoder.js +715 -715
- package/examples/jsm/transpiler/Transpiler.js +18 -18
- package/examples/jsm/utils/BufferGeometryUtils.js +1371 -1371
- 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 +424 -424
- package/examples/jsm/utils/SortUtils.js +160 -160
- package/examples/jsm/utils/TextureUtils.js +98 -98
- package/examples/jsm/utils/UVsDebug.js +165 -165
- package/examples/jsm/utils/WorkerPool.js +102 -102
- package/examples/jsm/webxr/ARButton.js +232 -232
- package/examples/jsm/webxr/OculusHandModel.js +109 -109
- package/examples/jsm/webxr/OculusHandPointerModel.js +416 -416
- package/examples/jsm/webxr/Text2D.js +38 -38
- package/examples/jsm/webxr/VRButton.js +233 -233
- package/examples/jsm/webxr/XRButton.js +223 -223
- package/examples/jsm/webxr/XRControllerModelFactory.js +323 -323
- package/examples/jsm/webxr/XREstimatedLight.js +223 -223
- package/examples/jsm/webxr/XRHandMeshModel.js +116 -116
- package/examples/jsm/webxr/XRHandModelFactory.js +105 -105
- package/examples/jsm/webxr/XRHandPrimitiveModel.js +105 -105
- package/examples/jsm/webxr/XRPlanes.js +100 -100
- package/package.json +129 -129
- package/src/Three.Legacy.js +21 -21
- package/src/Three.js +183 -183
- 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 -356
- 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 -400
- package/src/audio/AudioAnalyser.js +40 -40
- package/src/audio/AudioContext.js +25 -25
- package/src/audio/AudioListener.js +140 -140
- package/src/audio/PositionalAudio.js +146 -146
- package/src/cameras/ArrayCamera.js +17 -17
- package/src/cameras/Camera.js +69 -69
- package/src/cameras/CubeCamera.js +173 -173
- package/src/cameras/OrthographicCamera.js +136 -136
- package/src/cameras/PerspectiveCamera.js +268 -268
- package/src/cameras/StereoCamera.js +100 -100
- package/src/constants.js +217 -217
- package/src/core/BufferAttribute.js +639 -639
- package/src/core/BufferGeometry.js +1073 -1073
- 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 -166
- package/src/core/InterleavedBufferAttribute.js +351 -351
- package/src/core/Layers.js +60 -60
- package/src/core/Object3D.js +1019 -1019
- package/src/core/Raycaster.js +124 -124
- package/src/core/RenderTarget.js +154 -154
- package/src/core/Uniform.js +17 -17
- package/src/core/UniformsGroup.js +98 -98
- 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 +912 -912
- package/src/extras/ShapeUtils.js +92 -92
- package/src/extras/core/Curve.js +416 -416
- package/src/extras/core/CurvePath.js +255 -255
- 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 -92
- 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 +111 -111
- 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 -217
- 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 +131 -131
- package/src/loaders/FileLoader.js +284 -284
- package/src/loaders/ImageBitmapLoader.js +123 -123
- 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 +373 -373
- package/src/loaders/ObjectLoader.js +1149 -1149
- package/src/loaders/TextureLoader.js +41 -41
- package/src/materials/LineBasicMaterial.js +49 -49
- package/src/materials/LineDashedMaterial.js +35 -35
- package/src/materials/Material.js +523 -523
- package/src/materials/Materials.js +39 -39
- package/src/materials/MeshBasicMaterial.js +84 -84
- package/src/materials/MeshDepthMaterial.js +54 -54
- package/src/materials/MeshDistanceMaterial.js +43 -43
- package/src/materials/MeshLambertMaterial.js +119 -119
- package/src/materials/MeshMatcapMaterial.js +81 -81
- package/src/materials/MeshNormalMaterial.js +61 -61
- package/src/materials/MeshPhongMaterial.js +123 -123
- package/src/materials/MeshPhysicalMaterial.js +224 -224
- package/src/materials/MeshStandardMaterial.js +127 -127
- package/src/materials/MeshToonMaterial.js +102 -102
- package/src/materials/PointsMaterial.js +50 -50
- package/src/materials/RawShaderMaterial.js +17 -17
- package/src/materials/ShaderMaterial.js +189 -189
- 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 -534
- package/src/math/Color.js +623 -623
- package/src/math/ColorManagement.js +139 -139
- 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 +686 -686
- package/src/math/Ray.js +493 -493
- package/src/math/Sphere.js +245 -245
- package/src/math/Spherical.js +86 -86
- package/src/math/SphericalHarmonics3.js +243 -243
- package/src/math/Triangle.js +311 -311
- package/src/math/Vector2.js +480 -480
- package/src/math/Vector3.js +724 -724
- 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 +1020 -1020
- package/src/objects/Bone.js +17 -17
- package/src/objects/Group.js +17 -17
- package/src/objects/InstancedMesh.js +267 -267
- 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 +428 -428
- package/src/objects/Points.js +166 -166
- package/src/objects/Skeleton.js +277 -277
- package/src/objects/SkinnedMesh.js +257 -257
- 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 +146 -146
- package/src/renderers/WebGLRenderTarget.js +15 -15
- package/src/renderers/WebGLRenderer.js +2615 -2615
- 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 -16
- package/src/renderers/shaders/ShaderChunk/alphatest_pars_fragment.glsl.js +5 -5
- package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +26 -26
- package/src/renderers/shaders/ShaderChunk/aomap_pars_fragment.glsl.js +8 -8
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +19 -19
- package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +5 -5
- 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 -43
- 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 -78
- 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 -44
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +147 -147
- package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +186 -186
- 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 -63
- 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 +15 -15
- 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 -120
- 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 -202
- 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 -228
- 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 -151
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +562 -562
- 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 -21
- 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/morphinstance_vertex.glsl.js +14 -14
- package/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +27 -27
- package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +47 -47
- 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/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 -19
- 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 -25
- 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 +192 -192
- 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 -21
- package/src/renderers/shaders/ShaderChunk.js +272 -272
- package/src/renderers/shaders/ShaderLib/background.glsl.js +40 -40
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +63 -63
- package/src/renderers/shaders/ShaderLib/cube.glsl.js +36 -36
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +97 -97
- package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +78 -78
- package/src/renderers/shaders/ShaderLib/equirect.glsl.js +35 -35
- package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +76 -76
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +116 -116
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +125 -125
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +112 -112
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +87 -87
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +127 -127
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +225 -225
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +119 -119
- package/src/renderers/shaders/ShaderLib/points.glsl.js +87 -87
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +58 -58
- 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 +360 -360
- package/src/renderers/shaders/UniformsLib.js +231 -231
- package/src/renderers/shaders/UniformsUtils.js +104 -104
- package/src/renderers/webgl/WebGLAnimation.js +53 -53
- package/src/renderers/webgl/WebGLAttributes.js +229 -229
- package/src/renderers/webgl/WebGLBackground.js +257 -257
- package/src/renderers/webgl/WebGLBindingStates.js +631 -631
- package/src/renderers/webgl/WebGLBufferRenderer.js +92 -92
- 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 -132
- package/src/renderers/webgl/WebGLExtensions.js +97 -97
- package/src/renderers/webgl/WebGLGeometries.js +211 -211
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +102 -102
- package/src/renderers/webgl/WebGLInfo.js +71 -71
- package/src/renderers/webgl/WebGLLights.js +590 -590
- package/src/renderers/webgl/WebGLMaterials.js +590 -590
- package/src/renderers/webgl/WebGLMorphtargets.js +307 -307
- package/src/renderers/webgl/WebGLObjects.js +92 -92
- package/src/renderers/webgl/WebGLProgram.js +1120 -1120
- package/src/renderers/webgl/WebGLPrograms.js +664 -664
- 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 -424
- package/src/renderers/webgl/WebGLState.js +1318 -1318
- package/src/renderers/webgl/WebGLTextures.js +2213 -2213
- package/src/renderers/webgl/WebGLUniforms.js +1156 -1156
- package/src/renderers/webgl/WebGLUniformsGroups.js +392 -392
- package/src/renderers/webgl/WebGLUtils.js +283 -283
- package/src/renderers/webxr/WebXRController.js +343 -343
- package/src/renderers/webxr/WebXRDepthSensing.js +105 -105
- package/src/renderers/webxr/WebXRManager.js +824 -824
- package/src/scenes/Fog.js +38 -38
- package/src/scenes/FogExp2.js +35 -35
- package/src/scenes/Scene.js +71 -71
- package/src/textures/CanvasTexture.js +17 -17
- package/src/textures/CompressedArrayTexture.js +18 -18
- package/src/textures/CompressedCubeTexture.js +19 -19
- 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 +128 -128
- package/src/textures/Texture.js +310 -310
- package/src/textures/VideoTexture.js +55 -55
- package/src/utils.js +91 -91
|
@@ -1,1318 +1,1318 @@
|
|
|
1
|
-
import { NotEqualDepth, GreaterDepth, GreaterEqualDepth, EqualDepth, LessEqualDepth, LessDepth, AlwaysDepth, NeverDepth, CullFaceFront, CullFaceBack, CullFaceNone, DoubleSide, BackSide, CustomBlending, MultiplyBlending, SubtractiveBlending, AdditiveBlending, NoBlending, NormalBlending, AddEquation, SubtractEquation, ReverseSubtractEquation, MinEquation, MaxEquation, ZeroFactor, OneFactor, SrcColorFactor, SrcAlphaFactor, SrcAlphaSaturateFactor, DstColorFactor, DstAlphaFactor, OneMinusSrcColorFactor, OneMinusSrcAlphaFactor, OneMinusDstColorFactor, OneMinusDstAlphaFactor, ConstantColorFactor, OneMinusConstantColorFactor, ConstantAlphaFactor, OneMinusConstantAlphaFactor } from '../../constants.js';
|
|
2
|
-
import { Color } from '../../math/Color.js';
|
|
3
|
-
import { Vector4 } from '../../math/Vector4.js';
|
|
4
|
-
|
|
5
|
-
function WebGLState( gl, extensions, capabilities ) {
|
|
6
|
-
|
|
7
|
-
const isWebGL2 = capabilities.isWebGL2;
|
|
8
|
-
|
|
9
|
-
function ColorBuffer() {
|
|
10
|
-
|
|
11
|
-
let locked = false;
|
|
12
|
-
|
|
13
|
-
const color = new Vector4();
|
|
14
|
-
let currentColorMask = null;
|
|
15
|
-
const currentColorClear = new Vector4( 0, 0, 0, 0 );
|
|
16
|
-
|
|
17
|
-
return {
|
|
18
|
-
|
|
19
|
-
setMask: function ( colorMask ) {
|
|
20
|
-
|
|
21
|
-
if ( currentColorMask !== colorMask && ! locked ) {
|
|
22
|
-
|
|
23
|
-
gl.colorMask( colorMask, colorMask, colorMask, colorMask );
|
|
24
|
-
currentColorMask = colorMask;
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
setLocked: function ( lock ) {
|
|
31
|
-
|
|
32
|
-
locked = lock;
|
|
33
|
-
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
setClear: function ( r, g, b, a, premultipliedAlpha ) {
|
|
37
|
-
|
|
38
|
-
if ( premultipliedAlpha === true ) {
|
|
39
|
-
|
|
40
|
-
r *= a; g *= a; b *= a;
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
color.set( r, g, b, a );
|
|
45
|
-
|
|
46
|
-
if ( currentColorClear.equals( color ) === false ) {
|
|
47
|
-
|
|
48
|
-
gl.clearColor( r, g, b, a );
|
|
49
|
-
currentColorClear.copy( color );
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
reset: function () {
|
|
56
|
-
|
|
57
|
-
locked = false;
|
|
58
|
-
|
|
59
|
-
currentColorMask = null;
|
|
60
|
-
currentColorClear.set( - 1, 0, 0, 0 ); // set to invalid state
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function DepthBuffer() {
|
|
69
|
-
|
|
70
|
-
let locked = false;
|
|
71
|
-
|
|
72
|
-
let currentDepthMask = null;
|
|
73
|
-
let currentDepthFunc = null;
|
|
74
|
-
let currentDepthClear = null;
|
|
75
|
-
|
|
76
|
-
return {
|
|
77
|
-
|
|
78
|
-
setTest: function ( depthTest ) {
|
|
79
|
-
|
|
80
|
-
if ( depthTest ) {
|
|
81
|
-
|
|
82
|
-
enable( gl.DEPTH_TEST );
|
|
83
|
-
|
|
84
|
-
} else {
|
|
85
|
-
|
|
86
|
-
disable( gl.DEPTH_TEST );
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
setMask: function ( depthMask ) {
|
|
93
|
-
|
|
94
|
-
if ( currentDepthMask !== depthMask && ! locked ) {
|
|
95
|
-
|
|
96
|
-
gl.depthMask( depthMask );
|
|
97
|
-
currentDepthMask = depthMask;
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
setFunc: function ( depthFunc ) {
|
|
104
|
-
|
|
105
|
-
if ( currentDepthFunc !== depthFunc ) {
|
|
106
|
-
|
|
107
|
-
switch ( depthFunc ) {
|
|
108
|
-
|
|
109
|
-
case NeverDepth:
|
|
110
|
-
|
|
111
|
-
gl.depthFunc( gl.NEVER );
|
|
112
|
-
break;
|
|
113
|
-
|
|
114
|
-
case AlwaysDepth:
|
|
115
|
-
|
|
116
|
-
gl.depthFunc( gl.ALWAYS );
|
|
117
|
-
break;
|
|
118
|
-
|
|
119
|
-
case LessDepth:
|
|
120
|
-
|
|
121
|
-
gl.depthFunc( gl.LESS );
|
|
122
|
-
break;
|
|
123
|
-
|
|
124
|
-
case LessEqualDepth:
|
|
125
|
-
|
|
126
|
-
gl.depthFunc( gl.LEQUAL );
|
|
127
|
-
break;
|
|
128
|
-
|
|
129
|
-
case EqualDepth:
|
|
130
|
-
|
|
131
|
-
gl.depthFunc( gl.EQUAL );
|
|
132
|
-
break;
|
|
133
|
-
|
|
134
|
-
case GreaterEqualDepth:
|
|
135
|
-
|
|
136
|
-
gl.depthFunc( gl.GEQUAL );
|
|
137
|
-
break;
|
|
138
|
-
|
|
139
|
-
case GreaterDepth:
|
|
140
|
-
|
|
141
|
-
gl.depthFunc( gl.GREATER );
|
|
142
|
-
break;
|
|
143
|
-
|
|
144
|
-
case NotEqualDepth:
|
|
145
|
-
|
|
146
|
-
gl.depthFunc( gl.NOTEQUAL );
|
|
147
|
-
break;
|
|
148
|
-
|
|
149
|
-
default:
|
|
150
|
-
|
|
151
|
-
gl.depthFunc( gl.LEQUAL );
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
currentDepthFunc = depthFunc;
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
},
|
|
160
|
-
|
|
161
|
-
setLocked: function ( lock ) {
|
|
162
|
-
|
|
163
|
-
locked = lock;
|
|
164
|
-
|
|
165
|
-
},
|
|
166
|
-
|
|
167
|
-
setClear: function ( depth ) {
|
|
168
|
-
|
|
169
|
-
if ( currentDepthClear !== depth ) {
|
|
170
|
-
|
|
171
|
-
gl.clearDepth( depth );
|
|
172
|
-
currentDepthClear = depth;
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
},
|
|
177
|
-
|
|
178
|
-
reset: function () {
|
|
179
|
-
|
|
180
|
-
locked = false;
|
|
181
|
-
|
|
182
|
-
currentDepthMask = null;
|
|
183
|
-
currentDepthFunc = null;
|
|
184
|
-
currentDepthClear = null;
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
function StencilBuffer() {
|
|
193
|
-
|
|
194
|
-
let locked = false;
|
|
195
|
-
|
|
196
|
-
let currentStencilMask = null;
|
|
197
|
-
let currentStencilFunc = null;
|
|
198
|
-
let currentStencilRef = null;
|
|
199
|
-
let currentStencilFuncMask = null;
|
|
200
|
-
let currentStencilFail = null;
|
|
201
|
-
let currentStencilZFail = null;
|
|
202
|
-
let currentStencilZPass = null;
|
|
203
|
-
let currentStencilClear = null;
|
|
204
|
-
|
|
205
|
-
return {
|
|
206
|
-
|
|
207
|
-
setTest: function ( stencilTest ) {
|
|
208
|
-
|
|
209
|
-
if ( ! locked ) {
|
|
210
|
-
|
|
211
|
-
if ( stencilTest ) {
|
|
212
|
-
|
|
213
|
-
enable( gl.STENCIL_TEST );
|
|
214
|
-
|
|
215
|
-
} else {
|
|
216
|
-
|
|
217
|
-
disable( gl.STENCIL_TEST );
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
},
|
|
224
|
-
|
|
225
|
-
setMask: function ( stencilMask ) {
|
|
226
|
-
|
|
227
|
-
if ( currentStencilMask !== stencilMask && ! locked ) {
|
|
228
|
-
|
|
229
|
-
gl.stencilMask( stencilMask );
|
|
230
|
-
currentStencilMask = stencilMask;
|
|
231
|
-
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
},
|
|
235
|
-
|
|
236
|
-
setFunc: function ( stencilFunc, stencilRef, stencilMask ) {
|
|
237
|
-
|
|
238
|
-
if ( currentStencilFunc !== stencilFunc ||
|
|
239
|
-
currentStencilRef !== stencilRef ||
|
|
240
|
-
currentStencilFuncMask !== stencilMask ) {
|
|
241
|
-
|
|
242
|
-
gl.stencilFunc( stencilFunc, stencilRef, stencilMask );
|
|
243
|
-
|
|
244
|
-
currentStencilFunc = stencilFunc;
|
|
245
|
-
currentStencilRef = stencilRef;
|
|
246
|
-
currentStencilFuncMask = stencilMask;
|
|
247
|
-
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
},
|
|
251
|
-
|
|
252
|
-
setOp: function ( stencilFail, stencilZFail, stencilZPass ) {
|
|
253
|
-
|
|
254
|
-
if ( currentStencilFail !== stencilFail ||
|
|
255
|
-
currentStencilZFail !== stencilZFail ||
|
|
256
|
-
currentStencilZPass !== stencilZPass ) {
|
|
257
|
-
|
|
258
|
-
gl.stencilOp( stencilFail, stencilZFail, stencilZPass );
|
|
259
|
-
|
|
260
|
-
currentStencilFail = stencilFail;
|
|
261
|
-
currentStencilZFail = stencilZFail;
|
|
262
|
-
currentStencilZPass = stencilZPass;
|
|
263
|
-
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
},
|
|
267
|
-
|
|
268
|
-
setLocked: function ( lock ) {
|
|
269
|
-
|
|
270
|
-
locked = lock;
|
|
271
|
-
|
|
272
|
-
},
|
|
273
|
-
|
|
274
|
-
setClear: function ( stencil ) {
|
|
275
|
-
|
|
276
|
-
if ( currentStencilClear !== stencil ) {
|
|
277
|
-
|
|
278
|
-
gl.clearStencil( stencil );
|
|
279
|
-
currentStencilClear = stencil;
|
|
280
|
-
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
},
|
|
284
|
-
|
|
285
|
-
reset: function () {
|
|
286
|
-
|
|
287
|
-
locked = false;
|
|
288
|
-
|
|
289
|
-
currentStencilMask = null;
|
|
290
|
-
currentStencilFunc = null;
|
|
291
|
-
currentStencilRef = null;
|
|
292
|
-
currentStencilFuncMask = null;
|
|
293
|
-
currentStencilFail = null;
|
|
294
|
-
currentStencilZFail = null;
|
|
295
|
-
currentStencilZPass = null;
|
|
296
|
-
currentStencilClear = null;
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
};
|
|
301
|
-
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
//
|
|
305
|
-
|
|
306
|
-
const colorBuffer = new ColorBuffer();
|
|
307
|
-
const depthBuffer = new DepthBuffer();
|
|
308
|
-
const stencilBuffer = new StencilBuffer();
|
|
309
|
-
|
|
310
|
-
const uboBindings = new WeakMap();
|
|
311
|
-
const uboProgramMap = new WeakMap();
|
|
312
|
-
|
|
313
|
-
let enabledCapabilities = {};
|
|
314
|
-
|
|
315
|
-
let currentBoundFramebuffers = {};
|
|
316
|
-
let currentDrawbuffers = new WeakMap();
|
|
317
|
-
let defaultDrawbuffers = [];
|
|
318
|
-
|
|
319
|
-
let currentProgram = null;
|
|
320
|
-
|
|
321
|
-
let currentBlendingEnabled = false;
|
|
322
|
-
let currentBlending = null;
|
|
323
|
-
let currentBlendEquation = null;
|
|
324
|
-
let currentBlendSrc = null;
|
|
325
|
-
let currentBlendDst = null;
|
|
326
|
-
let currentBlendEquationAlpha = null;
|
|
327
|
-
let currentBlendSrcAlpha = null;
|
|
328
|
-
let currentBlendDstAlpha = null;
|
|
329
|
-
let currentBlendColor = new Color( 0, 0, 0 );
|
|
330
|
-
let currentBlendAlpha = 0;
|
|
331
|
-
let currentPremultipledAlpha = false;
|
|
332
|
-
|
|
333
|
-
let currentFlipSided = null;
|
|
334
|
-
let currentCullFace = null;
|
|
335
|
-
|
|
336
|
-
let currentLineWidth = null;
|
|
337
|
-
|
|
338
|
-
let currentPolygonOffsetFactor = null;
|
|
339
|
-
let currentPolygonOffsetUnits = null;
|
|
340
|
-
|
|
341
|
-
const maxTextures = gl.getParameter( gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS );
|
|
342
|
-
|
|
343
|
-
let lineWidthAvailable = false;
|
|
344
|
-
let version = 0;
|
|
345
|
-
const glVersion = gl.getParameter( gl.VERSION );
|
|
346
|
-
|
|
347
|
-
if ( glVersion.indexOf( 'WebGL' ) !== - 1 ) {
|
|
348
|
-
|
|
349
|
-
version = parseFloat( /^WebGL (\d)/.exec( glVersion )[ 1 ] );
|
|
350
|
-
lineWidthAvailable = ( version >= 1.0 );
|
|
351
|
-
|
|
352
|
-
} else if ( glVersion.indexOf( 'OpenGL ES' ) !== - 1 ) {
|
|
353
|
-
|
|
354
|
-
version = parseFloat( /^OpenGL ES (\d)/.exec( glVersion )[ 1 ] );
|
|
355
|
-
lineWidthAvailable = ( version >= 2.0 );
|
|
356
|
-
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
let currentTextureSlot = null;
|
|
360
|
-
let currentBoundTextures = {};
|
|
361
|
-
|
|
362
|
-
const scissorParam = gl.getParameter( gl.SCISSOR_BOX );
|
|
363
|
-
const viewportParam = gl.getParameter( gl.VIEWPORT );
|
|
364
|
-
|
|
365
|
-
const currentScissor = new Vector4().fromArray( scissorParam );
|
|
366
|
-
const currentViewport = new Vector4().fromArray( viewportParam );
|
|
367
|
-
|
|
368
|
-
function createTexture( type, target, count, dimensions ) {
|
|
369
|
-
|
|
370
|
-
const data = new Uint8Array( 4 ); // 4 is required to match default unpack alignment of 4.
|
|
371
|
-
const texture = gl.createTexture();
|
|
372
|
-
|
|
373
|
-
gl.bindTexture( type, texture );
|
|
374
|
-
gl.texParameteri( type, gl.TEXTURE_MIN_FILTER, gl.NEAREST );
|
|
375
|
-
gl.texParameteri( type, gl.TEXTURE_MAG_FILTER, gl.NEAREST );
|
|
376
|
-
|
|
377
|
-
for ( let i = 0; i < count; i ++ ) {
|
|
378
|
-
|
|
379
|
-
if ( isWebGL2 && ( type === gl.TEXTURE_3D || type === gl.TEXTURE_2D_ARRAY ) ) {
|
|
380
|
-
|
|
381
|
-
gl.texImage3D( target, 0, gl.RGBA, 1, 1, dimensions, 0, gl.RGBA, gl.UNSIGNED_BYTE, data );
|
|
382
|
-
|
|
383
|
-
} else {
|
|
384
|
-
|
|
385
|
-
gl.texImage2D( target + i, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, data );
|
|
386
|
-
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
return texture;
|
|
392
|
-
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
const emptyTextures = {};
|
|
396
|
-
emptyTextures[ gl.TEXTURE_2D ] = createTexture( gl.TEXTURE_2D, gl.TEXTURE_2D, 1 );
|
|
397
|
-
emptyTextures[ gl.TEXTURE_CUBE_MAP ] = createTexture( gl.TEXTURE_CUBE_MAP, gl.TEXTURE_CUBE_MAP_POSITIVE_X, 6 );
|
|
398
|
-
|
|
399
|
-
if ( isWebGL2 ) {
|
|
400
|
-
|
|
401
|
-
emptyTextures[ gl.TEXTURE_2D_ARRAY ] = createTexture( gl.TEXTURE_2D_ARRAY, gl.TEXTURE_2D_ARRAY, 1, 1 );
|
|
402
|
-
emptyTextures[ gl.TEXTURE_3D ] = createTexture( gl.TEXTURE_3D, gl.TEXTURE_3D, 1, 1 );
|
|
403
|
-
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
// init
|
|
407
|
-
|
|
408
|
-
colorBuffer.setClear( 0, 0, 0, 1 );
|
|
409
|
-
depthBuffer.setClear( 1 );
|
|
410
|
-
stencilBuffer.setClear( 0 );
|
|
411
|
-
|
|
412
|
-
enable( gl.DEPTH_TEST );
|
|
413
|
-
depthBuffer.setFunc( LessEqualDepth );
|
|
414
|
-
|
|
415
|
-
setFlipSided( false );
|
|
416
|
-
setCullFace( CullFaceBack );
|
|
417
|
-
enable( gl.CULL_FACE );
|
|
418
|
-
|
|
419
|
-
setBlending( NoBlending );
|
|
420
|
-
|
|
421
|
-
//
|
|
422
|
-
|
|
423
|
-
function enable( id ) {
|
|
424
|
-
|
|
425
|
-
if ( enabledCapabilities[ id ] !== true ) {
|
|
426
|
-
|
|
427
|
-
gl.enable( id );
|
|
428
|
-
enabledCapabilities[ id ] = true;
|
|
429
|
-
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
function disable( id ) {
|
|
435
|
-
|
|
436
|
-
if ( enabledCapabilities[ id ] !== false ) {
|
|
437
|
-
|
|
438
|
-
gl.disable( id );
|
|
439
|
-
enabledCapabilities[ id ] = false;
|
|
440
|
-
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
function bindFramebuffer( target, framebuffer ) {
|
|
446
|
-
|
|
447
|
-
if ( currentBoundFramebuffers[ target ] !== framebuffer ) {
|
|
448
|
-
|
|
449
|
-
gl.bindFramebuffer( target, framebuffer );
|
|
450
|
-
|
|
451
|
-
currentBoundFramebuffers[ target ] = framebuffer;
|
|
452
|
-
|
|
453
|
-
if ( isWebGL2 ) {
|
|
454
|
-
|
|
455
|
-
// gl.DRAW_FRAMEBUFFER is equivalent to gl.FRAMEBUFFER
|
|
456
|
-
|
|
457
|
-
if ( target === gl.DRAW_FRAMEBUFFER ) {
|
|
458
|
-
|
|
459
|
-
currentBoundFramebuffers[ gl.FRAMEBUFFER ] = framebuffer;
|
|
460
|
-
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
if ( target === gl.FRAMEBUFFER ) {
|
|
464
|
-
|
|
465
|
-
currentBoundFramebuffers[ gl.DRAW_FRAMEBUFFER ] = framebuffer;
|
|
466
|
-
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
return true;
|
|
472
|
-
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
return false;
|
|
476
|
-
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
function drawBuffers( renderTarget, framebuffer ) {
|
|
480
|
-
|
|
481
|
-
let drawBuffers = defaultDrawbuffers;
|
|
482
|
-
|
|
483
|
-
let needsUpdate = false;
|
|
484
|
-
|
|
485
|
-
if ( renderTarget ) {
|
|
486
|
-
|
|
487
|
-
drawBuffers = currentDrawbuffers.get( framebuffer );
|
|
488
|
-
|
|
489
|
-
if ( drawBuffers === undefined ) {
|
|
490
|
-
|
|
491
|
-
drawBuffers = [];
|
|
492
|
-
currentDrawbuffers.set( framebuffer, drawBuffers );
|
|
493
|
-
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
const textures = renderTarget.textures;
|
|
497
|
-
|
|
498
|
-
if ( drawBuffers.length !== textures.length || drawBuffers[ 0 ] !== gl.COLOR_ATTACHMENT0 ) {
|
|
499
|
-
|
|
500
|
-
for ( let i = 0, il = textures.length; i < il; i ++ ) {
|
|
501
|
-
|
|
502
|
-
drawBuffers[ i ] = gl.COLOR_ATTACHMENT0 + i;
|
|
503
|
-
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
drawBuffers.length = textures.length;
|
|
507
|
-
|
|
508
|
-
needsUpdate = true;
|
|
509
|
-
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
} else {
|
|
513
|
-
|
|
514
|
-
if ( drawBuffers[ 0 ] !== gl.BACK ) {
|
|
515
|
-
|
|
516
|
-
drawBuffers[ 0 ] = gl.BACK;
|
|
517
|
-
|
|
518
|
-
needsUpdate = true;
|
|
519
|
-
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
if ( needsUpdate ) {
|
|
525
|
-
|
|
526
|
-
if ( capabilities.isWebGL2 ) {
|
|
527
|
-
|
|
528
|
-
gl.drawBuffers( drawBuffers );
|
|
529
|
-
|
|
530
|
-
} else if ( extensions.has( 'WEBGL_draw_buffers' ) === true ) {
|
|
531
|
-
|
|
532
|
-
extensions.get( 'WEBGL_draw_buffers' ).drawBuffersWEBGL( drawBuffers );
|
|
533
|
-
|
|
534
|
-
} else {
|
|
535
|
-
|
|
536
|
-
throw new Error( 'THREE.WebGLState: Usage of gl.drawBuffers() require WebGL2 or WEBGL_draw_buffers extension' );
|
|
537
|
-
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
function useProgram( program ) {
|
|
546
|
-
|
|
547
|
-
if ( currentProgram !== program ) {
|
|
548
|
-
|
|
549
|
-
gl.useProgram( program );
|
|
550
|
-
|
|
551
|
-
currentProgram = program;
|
|
552
|
-
|
|
553
|
-
return true;
|
|
554
|
-
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
return false;
|
|
558
|
-
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
const equationToGL = {
|
|
562
|
-
[ AddEquation ]: gl.FUNC_ADD,
|
|
563
|
-
[ SubtractEquation ]: gl.FUNC_SUBTRACT,
|
|
564
|
-
[ ReverseSubtractEquation ]: gl.FUNC_REVERSE_SUBTRACT
|
|
565
|
-
};
|
|
566
|
-
|
|
567
|
-
if ( isWebGL2 ) {
|
|
568
|
-
|
|
569
|
-
equationToGL[ MinEquation ] = gl.MIN;
|
|
570
|
-
equationToGL[ MaxEquation ] = gl.MAX;
|
|
571
|
-
|
|
572
|
-
} else {
|
|
573
|
-
|
|
574
|
-
const extension = extensions.get( 'EXT_blend_minmax' );
|
|
575
|
-
|
|
576
|
-
if ( extension !== null ) {
|
|
577
|
-
|
|
578
|
-
equationToGL[ MinEquation ] = extension.MIN_EXT;
|
|
579
|
-
equationToGL[ MaxEquation ] = extension.MAX_EXT;
|
|
580
|
-
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
const factorToGL = {
|
|
586
|
-
[ ZeroFactor ]: gl.ZERO,
|
|
587
|
-
[ OneFactor ]: gl.ONE,
|
|
588
|
-
[ SrcColorFactor ]: gl.SRC_COLOR,
|
|
589
|
-
[ SrcAlphaFactor ]: gl.SRC_ALPHA,
|
|
590
|
-
[ SrcAlphaSaturateFactor ]: gl.SRC_ALPHA_SATURATE,
|
|
591
|
-
[ DstColorFactor ]: gl.DST_COLOR,
|
|
592
|
-
[ DstAlphaFactor ]: gl.DST_ALPHA,
|
|
593
|
-
[ OneMinusSrcColorFactor ]: gl.ONE_MINUS_SRC_COLOR,
|
|
594
|
-
[ OneMinusSrcAlphaFactor ]: gl.ONE_MINUS_SRC_ALPHA,
|
|
595
|
-
[ OneMinusDstColorFactor ]: gl.ONE_MINUS_DST_COLOR,
|
|
596
|
-
[ OneMinusDstAlphaFactor ]: gl.ONE_MINUS_DST_ALPHA,
|
|
597
|
-
[ ConstantColorFactor ]: gl.CONSTANT_COLOR,
|
|
598
|
-
[ OneMinusConstantColorFactor ]: gl.ONE_MINUS_CONSTANT_COLOR,
|
|
599
|
-
[ ConstantAlphaFactor ]: gl.CONSTANT_ALPHA,
|
|
600
|
-
[ OneMinusConstantAlphaFactor ]: gl.ONE_MINUS_CONSTANT_ALPHA
|
|
601
|
-
};
|
|
602
|
-
|
|
603
|
-
function setBlending( blending, blendEquation, blendSrc, blendDst, blendEquationAlpha, blendSrcAlpha, blendDstAlpha, blendColor, blendAlpha, premultipliedAlpha ) {
|
|
604
|
-
|
|
605
|
-
if ( blending === NoBlending ) {
|
|
606
|
-
|
|
607
|
-
if ( currentBlendingEnabled === true ) {
|
|
608
|
-
|
|
609
|
-
disable( gl.BLEND );
|
|
610
|
-
currentBlendingEnabled = false;
|
|
611
|
-
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
return;
|
|
615
|
-
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
if ( currentBlendingEnabled === false ) {
|
|
619
|
-
|
|
620
|
-
enable( gl.BLEND );
|
|
621
|
-
currentBlendingEnabled = true;
|
|
622
|
-
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
if ( blending !== CustomBlending ) {
|
|
626
|
-
|
|
627
|
-
if ( blending !== currentBlending || premultipliedAlpha !== currentPremultipledAlpha ) {
|
|
628
|
-
|
|
629
|
-
if ( currentBlendEquation !== AddEquation || currentBlendEquationAlpha !== AddEquation ) {
|
|
630
|
-
|
|
631
|
-
gl.blendEquation( gl.FUNC_ADD );
|
|
632
|
-
|
|
633
|
-
currentBlendEquation = AddEquation;
|
|
634
|
-
currentBlendEquationAlpha = AddEquation;
|
|
635
|
-
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
if ( premultipliedAlpha ) {
|
|
639
|
-
|
|
640
|
-
switch ( blending ) {
|
|
641
|
-
|
|
642
|
-
case NormalBlending:
|
|
643
|
-
gl.blendFuncSeparate( gl.ONE, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA );
|
|
644
|
-
break;
|
|
645
|
-
|
|
646
|
-
case AdditiveBlending:
|
|
647
|
-
gl.blendFunc( gl.ONE, gl.ONE );
|
|
648
|
-
break;
|
|
649
|
-
|
|
650
|
-
case SubtractiveBlending:
|
|
651
|
-
gl.blendFuncSeparate( gl.ZERO, gl.ONE_MINUS_SRC_COLOR, gl.ZERO, gl.ONE );
|
|
652
|
-
break;
|
|
653
|
-
|
|
654
|
-
case MultiplyBlending:
|
|
655
|
-
gl.blendFuncSeparate( gl.ZERO, gl.SRC_COLOR, gl.ZERO, gl.SRC_ALPHA );
|
|
656
|
-
break;
|
|
657
|
-
|
|
658
|
-
default:
|
|
659
|
-
console.error( 'THREE.WebGLState: Invalid blending: ', blending );
|
|
660
|
-
break;
|
|
661
|
-
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
} else {
|
|
665
|
-
|
|
666
|
-
switch ( blending ) {
|
|
667
|
-
|
|
668
|
-
case NormalBlending:
|
|
669
|
-
gl.blendFuncSeparate( gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA );
|
|
670
|
-
break;
|
|
671
|
-
|
|
672
|
-
case AdditiveBlending:
|
|
673
|
-
gl.blendFunc( gl.SRC_ALPHA, gl.ONE );
|
|
674
|
-
break;
|
|
675
|
-
|
|
676
|
-
case SubtractiveBlending:
|
|
677
|
-
gl.blendFuncSeparate( gl.ZERO, gl.ONE_MINUS_SRC_COLOR, gl.ZERO, gl.ONE );
|
|
678
|
-
break;
|
|
679
|
-
|
|
680
|
-
case MultiplyBlending:
|
|
681
|
-
gl.blendFunc( gl.ZERO, gl.SRC_COLOR );
|
|
682
|
-
break;
|
|
683
|
-
|
|
684
|
-
default:
|
|
685
|
-
console.error( 'THREE.WebGLState: Invalid blending: ', blending );
|
|
686
|
-
break;
|
|
687
|
-
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
currentBlendSrc = null;
|
|
693
|
-
currentBlendDst = null;
|
|
694
|
-
currentBlendSrcAlpha = null;
|
|
695
|
-
currentBlendDstAlpha = null;
|
|
696
|
-
currentBlendColor.set( 0, 0, 0 );
|
|
697
|
-
currentBlendAlpha = 0;
|
|
698
|
-
|
|
699
|
-
currentBlending = blending;
|
|
700
|
-
currentPremultipledAlpha = premultipliedAlpha;
|
|
701
|
-
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
return;
|
|
705
|
-
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
// custom blending
|
|
709
|
-
|
|
710
|
-
blendEquationAlpha = blendEquationAlpha || blendEquation;
|
|
711
|
-
blendSrcAlpha = blendSrcAlpha || blendSrc;
|
|
712
|
-
blendDstAlpha = blendDstAlpha || blendDst;
|
|
713
|
-
|
|
714
|
-
if ( blendEquation !== currentBlendEquation || blendEquationAlpha !== currentBlendEquationAlpha ) {
|
|
715
|
-
|
|
716
|
-
gl.blendEquationSeparate( equationToGL[ blendEquation ], equationToGL[ blendEquationAlpha ] );
|
|
717
|
-
|
|
718
|
-
currentBlendEquation = blendEquation;
|
|
719
|
-
currentBlendEquationAlpha = blendEquationAlpha;
|
|
720
|
-
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
if ( blendSrc !== currentBlendSrc || blendDst !== currentBlendDst || blendSrcAlpha !== currentBlendSrcAlpha || blendDstAlpha !== currentBlendDstAlpha ) {
|
|
724
|
-
|
|
725
|
-
gl.blendFuncSeparate( factorToGL[ blendSrc ], factorToGL[ blendDst ], factorToGL[ blendSrcAlpha ], factorToGL[ blendDstAlpha ] );
|
|
726
|
-
|
|
727
|
-
currentBlendSrc = blendSrc;
|
|
728
|
-
currentBlendDst = blendDst;
|
|
729
|
-
currentBlendSrcAlpha = blendSrcAlpha;
|
|
730
|
-
currentBlendDstAlpha = blendDstAlpha;
|
|
731
|
-
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
if ( blendColor.equals( currentBlendColor ) === false || blendAlpha !== currentBlendAlpha ) {
|
|
735
|
-
|
|
736
|
-
gl.blendColor( blendColor.r, blendColor.g, blendColor.b, blendAlpha );
|
|
737
|
-
|
|
738
|
-
currentBlendColor.copy( blendColor );
|
|
739
|
-
currentBlendAlpha = blendAlpha;
|
|
740
|
-
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
currentBlending = blending;
|
|
744
|
-
currentPremultipledAlpha = false;
|
|
745
|
-
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
function setMaterial( material, frontFaceCW ) {
|
|
749
|
-
|
|
750
|
-
material.side === DoubleSide
|
|
751
|
-
? disable( gl.CULL_FACE )
|
|
752
|
-
: enable( gl.CULL_FACE );
|
|
753
|
-
|
|
754
|
-
let flipSided = ( material.side === BackSide );
|
|
755
|
-
if ( frontFaceCW ) flipSided = ! flipSided;
|
|
756
|
-
|
|
757
|
-
setFlipSided( flipSided );
|
|
758
|
-
|
|
759
|
-
( material.blending === NormalBlending && material.transparent === false )
|
|
760
|
-
? setBlending( NoBlending )
|
|
761
|
-
: setBlending( material.blending, material.blendEquation, material.blendSrc, material.blendDst, material.blendEquationAlpha, material.blendSrcAlpha, material.blendDstAlpha, material.blendColor, material.blendAlpha, material.premultipliedAlpha );
|
|
762
|
-
|
|
763
|
-
depthBuffer.setFunc( material.depthFunc );
|
|
764
|
-
depthBuffer.setTest( material.depthTest );
|
|
765
|
-
depthBuffer.setMask( material.depthWrite );
|
|
766
|
-
colorBuffer.setMask( material.colorWrite );
|
|
767
|
-
|
|
768
|
-
const stencilWrite = material.stencilWrite;
|
|
769
|
-
stencilBuffer.setTest( stencilWrite );
|
|
770
|
-
if ( stencilWrite ) {
|
|
771
|
-
|
|
772
|
-
stencilBuffer.setMask( material.stencilWriteMask );
|
|
773
|
-
stencilBuffer.setFunc( material.stencilFunc, material.stencilRef, material.stencilFuncMask );
|
|
774
|
-
stencilBuffer.setOp( material.stencilFail, material.stencilZFail, material.stencilZPass );
|
|
775
|
-
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
setPolygonOffset( material.polygonOffset, material.polygonOffsetFactor, material.polygonOffsetUnits );
|
|
779
|
-
|
|
780
|
-
material.alphaToCoverage === true
|
|
781
|
-
? enable( gl.SAMPLE_ALPHA_TO_COVERAGE )
|
|
782
|
-
: disable( gl.SAMPLE_ALPHA_TO_COVERAGE );
|
|
783
|
-
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
//
|
|
787
|
-
|
|
788
|
-
function setFlipSided( flipSided ) {
|
|
789
|
-
|
|
790
|
-
if ( currentFlipSided !== flipSided ) {
|
|
791
|
-
|
|
792
|
-
if ( flipSided ) {
|
|
793
|
-
|
|
794
|
-
gl.frontFace( gl.CW );
|
|
795
|
-
|
|
796
|
-
} else {
|
|
797
|
-
|
|
798
|
-
gl.frontFace( gl.CCW );
|
|
799
|
-
|
|
800
|
-
}
|
|
801
|
-
|
|
802
|
-
currentFlipSided = flipSided;
|
|
803
|
-
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
function setCullFace( cullFace ) {
|
|
809
|
-
|
|
810
|
-
if ( cullFace !== CullFaceNone ) {
|
|
811
|
-
|
|
812
|
-
enable( gl.CULL_FACE );
|
|
813
|
-
|
|
814
|
-
if ( cullFace !== currentCullFace ) {
|
|
815
|
-
|
|
816
|
-
if ( cullFace === CullFaceBack ) {
|
|
817
|
-
|
|
818
|
-
gl.cullFace( gl.BACK );
|
|
819
|
-
|
|
820
|
-
} else if ( cullFace === CullFaceFront ) {
|
|
821
|
-
|
|
822
|
-
gl.cullFace( gl.FRONT );
|
|
823
|
-
|
|
824
|
-
} else {
|
|
825
|
-
|
|
826
|
-
gl.cullFace( gl.FRONT_AND_BACK );
|
|
827
|
-
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
} else {
|
|
833
|
-
|
|
834
|
-
disable( gl.CULL_FACE );
|
|
835
|
-
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
currentCullFace = cullFace;
|
|
839
|
-
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
function setLineWidth( width ) {
|
|
843
|
-
|
|
844
|
-
if ( width !== currentLineWidth ) {
|
|
845
|
-
|
|
846
|
-
if ( lineWidthAvailable ) gl.lineWidth( width );
|
|
847
|
-
|
|
848
|
-
currentLineWidth = width;
|
|
849
|
-
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
function setPolygonOffset( polygonOffset, factor, units ) {
|
|
855
|
-
|
|
856
|
-
if ( polygonOffset ) {
|
|
857
|
-
|
|
858
|
-
enable( gl.POLYGON_OFFSET_FILL );
|
|
859
|
-
|
|
860
|
-
if ( currentPolygonOffsetFactor !== factor || currentPolygonOffsetUnits !== units ) {
|
|
861
|
-
|
|
862
|
-
gl.polygonOffset( factor, units );
|
|
863
|
-
|
|
864
|
-
currentPolygonOffsetFactor = factor;
|
|
865
|
-
currentPolygonOffsetUnits = units;
|
|
866
|
-
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
} else {
|
|
870
|
-
|
|
871
|
-
disable( gl.POLYGON_OFFSET_FILL );
|
|
872
|
-
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
function setScissorTest( scissorTest ) {
|
|
878
|
-
|
|
879
|
-
if ( scissorTest ) {
|
|
880
|
-
|
|
881
|
-
enable( gl.SCISSOR_TEST );
|
|
882
|
-
|
|
883
|
-
} else {
|
|
884
|
-
|
|
885
|
-
disable( gl.SCISSOR_TEST );
|
|
886
|
-
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
// texture
|
|
892
|
-
|
|
893
|
-
function activeTexture( webglSlot ) {
|
|
894
|
-
|
|
895
|
-
if ( webglSlot === undefined ) webglSlot = gl.TEXTURE0 + maxTextures - 1;
|
|
896
|
-
|
|
897
|
-
if ( currentTextureSlot !== webglSlot ) {
|
|
898
|
-
|
|
899
|
-
gl.activeTexture( webglSlot );
|
|
900
|
-
currentTextureSlot = webglSlot;
|
|
901
|
-
|
|
902
|
-
}
|
|
903
|
-
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
function bindTexture( webglType, webglTexture, webglSlot ) {
|
|
907
|
-
|
|
908
|
-
if ( webglSlot === undefined ) {
|
|
909
|
-
|
|
910
|
-
if ( currentTextureSlot === null ) {
|
|
911
|
-
|
|
912
|
-
webglSlot = gl.TEXTURE0 + maxTextures - 1;
|
|
913
|
-
|
|
914
|
-
} else {
|
|
915
|
-
|
|
916
|
-
webglSlot = currentTextureSlot;
|
|
917
|
-
|
|
918
|
-
}
|
|
919
|
-
|
|
920
|
-
}
|
|
921
|
-
|
|
922
|
-
let boundTexture = currentBoundTextures[ webglSlot ];
|
|
923
|
-
|
|
924
|
-
if ( boundTexture === undefined ) {
|
|
925
|
-
|
|
926
|
-
boundTexture = { type: undefined, texture: undefined };
|
|
927
|
-
currentBoundTextures[ webglSlot ] = boundTexture;
|
|
928
|
-
|
|
929
|
-
}
|
|
930
|
-
|
|
931
|
-
if ( boundTexture.type !== webglType || boundTexture.texture !== webglTexture ) {
|
|
932
|
-
|
|
933
|
-
if ( currentTextureSlot !== webglSlot ) {
|
|
934
|
-
|
|
935
|
-
gl.activeTexture( webglSlot );
|
|
936
|
-
currentTextureSlot = webglSlot;
|
|
937
|
-
|
|
938
|
-
}
|
|
939
|
-
|
|
940
|
-
gl.bindTexture( webglType, webglTexture || emptyTextures[ webglType ] );
|
|
941
|
-
|
|
942
|
-
boundTexture.type = webglType;
|
|
943
|
-
boundTexture.texture = webglTexture;
|
|
944
|
-
|
|
945
|
-
}
|
|
946
|
-
|
|
947
|
-
}
|
|
948
|
-
|
|
949
|
-
function unbindTexture() {
|
|
950
|
-
|
|
951
|
-
const boundTexture = currentBoundTextures[ currentTextureSlot ];
|
|
952
|
-
|
|
953
|
-
if ( boundTexture !== undefined && boundTexture.type !== undefined ) {
|
|
954
|
-
|
|
955
|
-
gl.bindTexture( boundTexture.type, null );
|
|
956
|
-
|
|
957
|
-
boundTexture.type = undefined;
|
|
958
|
-
boundTexture.texture = undefined;
|
|
959
|
-
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
}
|
|
963
|
-
|
|
964
|
-
function compressedTexImage2D() {
|
|
965
|
-
|
|
966
|
-
try {
|
|
967
|
-
|
|
968
|
-
gl.compressedTexImage2D.apply( gl, arguments );
|
|
969
|
-
|
|
970
|
-
} catch ( error ) {
|
|
971
|
-
|
|
972
|
-
console.error( 'THREE.WebGLState:', error );
|
|
973
|
-
|
|
974
|
-
}
|
|
975
|
-
|
|
976
|
-
}
|
|
977
|
-
|
|
978
|
-
function compressedTexImage3D() {
|
|
979
|
-
|
|
980
|
-
try {
|
|
981
|
-
|
|
982
|
-
gl.compressedTexImage3D.apply( gl, arguments );
|
|
983
|
-
|
|
984
|
-
} catch ( error ) {
|
|
985
|
-
|
|
986
|
-
console.error( 'THREE.WebGLState:', error );
|
|
987
|
-
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
function texSubImage2D() {
|
|
993
|
-
|
|
994
|
-
try {
|
|
995
|
-
|
|
996
|
-
gl.texSubImage2D.apply( gl, arguments );
|
|
997
|
-
|
|
998
|
-
} catch ( error ) {
|
|
999
|
-
|
|
1000
|
-
console.error( 'THREE.WebGLState:', error );
|
|
1001
|
-
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
|
-
}
|
|
1005
|
-
|
|
1006
|
-
function texSubImage3D() {
|
|
1007
|
-
|
|
1008
|
-
try {
|
|
1009
|
-
|
|
1010
|
-
gl.texSubImage3D.apply( gl, arguments );
|
|
1011
|
-
|
|
1012
|
-
} catch ( error ) {
|
|
1013
|
-
|
|
1014
|
-
console.error( 'THREE.WebGLState:', error );
|
|
1015
|
-
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
}
|
|
1019
|
-
|
|
1020
|
-
function compressedTexSubImage2D() {
|
|
1021
|
-
|
|
1022
|
-
try {
|
|
1023
|
-
|
|
1024
|
-
gl.compressedTexSubImage2D.apply( gl, arguments );
|
|
1025
|
-
|
|
1026
|
-
} catch ( error ) {
|
|
1027
|
-
|
|
1028
|
-
console.error( 'THREE.WebGLState:', error );
|
|
1029
|
-
|
|
1030
|
-
}
|
|
1031
|
-
|
|
1032
|
-
}
|
|
1033
|
-
|
|
1034
|
-
function compressedTexSubImage3D() {
|
|
1035
|
-
|
|
1036
|
-
try {
|
|
1037
|
-
|
|
1038
|
-
gl.compressedTexSubImage3D.apply( gl, arguments );
|
|
1039
|
-
|
|
1040
|
-
} catch ( error ) {
|
|
1041
|
-
|
|
1042
|
-
console.error( 'THREE.WebGLState:', error );
|
|
1043
|
-
|
|
1044
|
-
}
|
|
1045
|
-
|
|
1046
|
-
}
|
|
1047
|
-
|
|
1048
|
-
function texStorage2D() {
|
|
1049
|
-
|
|
1050
|
-
try {
|
|
1051
|
-
|
|
1052
|
-
gl.texStorage2D.apply( gl, arguments );
|
|
1053
|
-
|
|
1054
|
-
} catch ( error ) {
|
|
1055
|
-
|
|
1056
|
-
console.error( 'THREE.WebGLState:', error );
|
|
1057
|
-
|
|
1058
|
-
}
|
|
1059
|
-
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
|
-
function texStorage3D() {
|
|
1063
|
-
|
|
1064
|
-
try {
|
|
1065
|
-
|
|
1066
|
-
gl.texStorage3D.apply( gl, arguments );
|
|
1067
|
-
|
|
1068
|
-
} catch ( error ) {
|
|
1069
|
-
|
|
1070
|
-
console.error( 'THREE.WebGLState:', error );
|
|
1071
|
-
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
function texImage2D() {
|
|
1077
|
-
|
|
1078
|
-
try {
|
|
1079
|
-
|
|
1080
|
-
gl.texImage2D.apply( gl, arguments );
|
|
1081
|
-
|
|
1082
|
-
} catch ( error ) {
|
|
1083
|
-
|
|
1084
|
-
console.error( 'THREE.WebGLState:', error );
|
|
1085
|
-
|
|
1086
|
-
}
|
|
1087
|
-
|
|
1088
|
-
}
|
|
1089
|
-
|
|
1090
|
-
function texImage3D() {
|
|
1091
|
-
|
|
1092
|
-
try {
|
|
1093
|
-
|
|
1094
|
-
gl.texImage3D.apply( gl, arguments );
|
|
1095
|
-
|
|
1096
|
-
} catch ( error ) {
|
|
1097
|
-
|
|
1098
|
-
console.error( 'THREE.WebGLState:', error );
|
|
1099
|
-
|
|
1100
|
-
}
|
|
1101
|
-
|
|
1102
|
-
}
|
|
1103
|
-
|
|
1104
|
-
//
|
|
1105
|
-
|
|
1106
|
-
function scissor( scissor ) {
|
|
1107
|
-
|
|
1108
|
-
if ( currentScissor.equals( scissor ) === false ) {
|
|
1109
|
-
|
|
1110
|
-
gl.scissor( scissor.x, scissor.y, scissor.z, scissor.w );
|
|
1111
|
-
currentScissor.copy( scissor );
|
|
1112
|
-
|
|
1113
|
-
}
|
|
1114
|
-
|
|
1115
|
-
}
|
|
1116
|
-
|
|
1117
|
-
function viewport( viewport ) {
|
|
1118
|
-
|
|
1119
|
-
if ( currentViewport.equals( viewport ) === false ) {
|
|
1120
|
-
|
|
1121
|
-
gl.viewport( viewport.x, viewport.y, viewport.z, viewport.w );
|
|
1122
|
-
currentViewport.copy( viewport );
|
|
1123
|
-
|
|
1124
|
-
}
|
|
1125
|
-
|
|
1126
|
-
}
|
|
1127
|
-
|
|
1128
|
-
function updateUBOMapping( uniformsGroup, program ) {
|
|
1129
|
-
|
|
1130
|
-
let mapping = uboProgramMap.get( program );
|
|
1131
|
-
|
|
1132
|
-
if ( mapping === undefined ) {
|
|
1133
|
-
|
|
1134
|
-
mapping = new WeakMap();
|
|
1135
|
-
|
|
1136
|
-
uboProgramMap.set( program, mapping );
|
|
1137
|
-
|
|
1138
|
-
}
|
|
1139
|
-
|
|
1140
|
-
let blockIndex = mapping.get( uniformsGroup );
|
|
1141
|
-
|
|
1142
|
-
if ( blockIndex === undefined ) {
|
|
1143
|
-
|
|
1144
|
-
blockIndex = gl.getUniformBlockIndex( program, uniformsGroup.name );
|
|
1145
|
-
|
|
1146
|
-
mapping.set( uniformsGroup, blockIndex );
|
|
1147
|
-
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
function uniformBlockBinding( uniformsGroup, program ) {
|
|
1153
|
-
|
|
1154
|
-
const mapping = uboProgramMap.get( program );
|
|
1155
|
-
const blockIndex = mapping.get( uniformsGroup );
|
|
1156
|
-
|
|
1157
|
-
if ( uboBindings.get( program ) !== blockIndex ) {
|
|
1158
|
-
|
|
1159
|
-
// bind shader specific block index to global block point
|
|
1160
|
-
gl.uniformBlockBinding( program, blockIndex, uniformsGroup.__bindingPointIndex );
|
|
1161
|
-
|
|
1162
|
-
uboBindings.set( program, blockIndex );
|
|
1163
|
-
|
|
1164
|
-
}
|
|
1165
|
-
|
|
1166
|
-
}
|
|
1167
|
-
|
|
1168
|
-
//
|
|
1169
|
-
|
|
1170
|
-
function reset() {
|
|
1171
|
-
|
|
1172
|
-
// reset state
|
|
1173
|
-
|
|
1174
|
-
gl.disable( gl.BLEND );
|
|
1175
|
-
gl.disable( gl.CULL_FACE );
|
|
1176
|
-
gl.disable( gl.DEPTH_TEST );
|
|
1177
|
-
gl.disable( gl.POLYGON_OFFSET_FILL );
|
|
1178
|
-
gl.disable( gl.SCISSOR_TEST );
|
|
1179
|
-
gl.disable( gl.STENCIL_TEST );
|
|
1180
|
-
gl.disable( gl.SAMPLE_ALPHA_TO_COVERAGE );
|
|
1181
|
-
|
|
1182
|
-
gl.blendEquation( gl.FUNC_ADD );
|
|
1183
|
-
gl.blendFunc( gl.ONE, gl.ZERO );
|
|
1184
|
-
gl.blendFuncSeparate( gl.ONE, gl.ZERO, gl.ONE, gl.ZERO );
|
|
1185
|
-
gl.blendColor( 0, 0, 0, 0 );
|
|
1186
|
-
|
|
1187
|
-
gl.colorMask( true, true, true, true );
|
|
1188
|
-
gl.clearColor( 0, 0, 0, 0 );
|
|
1189
|
-
|
|
1190
|
-
gl.depthMask( true );
|
|
1191
|
-
gl.depthFunc( gl.LESS );
|
|
1192
|
-
gl.clearDepth( 1 );
|
|
1193
|
-
|
|
1194
|
-
gl.stencilMask( 0xffffffff );
|
|
1195
|
-
gl.stencilFunc( gl.ALWAYS, 0, 0xffffffff );
|
|
1196
|
-
gl.stencilOp( gl.KEEP, gl.KEEP, gl.KEEP );
|
|
1197
|
-
gl.clearStencil( 0 );
|
|
1198
|
-
|
|
1199
|
-
gl.cullFace( gl.BACK );
|
|
1200
|
-
gl.frontFace( gl.CCW );
|
|
1201
|
-
|
|
1202
|
-
gl.polygonOffset( 0, 0 );
|
|
1203
|
-
|
|
1204
|
-
gl.activeTexture( gl.TEXTURE0 );
|
|
1205
|
-
|
|
1206
|
-
gl.bindFramebuffer( gl.FRAMEBUFFER, null );
|
|
1207
|
-
|
|
1208
|
-
if ( isWebGL2 === true ) {
|
|
1209
|
-
|
|
1210
|
-
gl.bindFramebuffer( gl.DRAW_FRAMEBUFFER, null );
|
|
1211
|
-
gl.bindFramebuffer( gl.READ_FRAMEBUFFER, null );
|
|
1212
|
-
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
|
-
gl.useProgram( null );
|
|
1216
|
-
|
|
1217
|
-
gl.lineWidth( 1 );
|
|
1218
|
-
|
|
1219
|
-
gl.scissor( 0, 0, gl.canvas.width, gl.canvas.height );
|
|
1220
|
-
gl.viewport( 0, 0, gl.canvas.width, gl.canvas.height );
|
|
1221
|
-
|
|
1222
|
-
// reset internals
|
|
1223
|
-
|
|
1224
|
-
enabledCapabilities = {};
|
|
1225
|
-
|
|
1226
|
-
currentTextureSlot = null;
|
|
1227
|
-
currentBoundTextures = {};
|
|
1228
|
-
|
|
1229
|
-
currentBoundFramebuffers = {};
|
|
1230
|
-
currentDrawbuffers = new WeakMap();
|
|
1231
|
-
defaultDrawbuffers = [];
|
|
1232
|
-
|
|
1233
|
-
currentProgram = null;
|
|
1234
|
-
|
|
1235
|
-
currentBlendingEnabled = false;
|
|
1236
|
-
currentBlending = null;
|
|
1237
|
-
currentBlendEquation = null;
|
|
1238
|
-
currentBlendSrc = null;
|
|
1239
|
-
currentBlendDst = null;
|
|
1240
|
-
currentBlendEquationAlpha = null;
|
|
1241
|
-
currentBlendSrcAlpha = null;
|
|
1242
|
-
currentBlendDstAlpha = null;
|
|
1243
|
-
currentBlendColor = new Color( 0, 0, 0 );
|
|
1244
|
-
currentBlendAlpha = 0;
|
|
1245
|
-
currentPremultipledAlpha = false;
|
|
1246
|
-
|
|
1247
|
-
currentFlipSided = null;
|
|
1248
|
-
currentCullFace = null;
|
|
1249
|
-
|
|
1250
|
-
currentLineWidth = null;
|
|
1251
|
-
|
|
1252
|
-
currentPolygonOffsetFactor = null;
|
|
1253
|
-
currentPolygonOffsetUnits = null;
|
|
1254
|
-
|
|
1255
|
-
currentScissor.set( 0, 0, gl.canvas.width, gl.canvas.height );
|
|
1256
|
-
currentViewport.set( 0, 0, gl.canvas.width, gl.canvas.height );
|
|
1257
|
-
|
|
1258
|
-
colorBuffer.reset();
|
|
1259
|
-
depthBuffer.reset();
|
|
1260
|
-
stencilBuffer.reset();
|
|
1261
|
-
|
|
1262
|
-
}
|
|
1263
|
-
|
|
1264
|
-
return {
|
|
1265
|
-
|
|
1266
|
-
buffers: {
|
|
1267
|
-
color: colorBuffer,
|
|
1268
|
-
depth: depthBuffer,
|
|
1269
|
-
stencil: stencilBuffer
|
|
1270
|
-
},
|
|
1271
|
-
|
|
1272
|
-
enable: enable,
|
|
1273
|
-
disable: disable,
|
|
1274
|
-
|
|
1275
|
-
bindFramebuffer: bindFramebuffer,
|
|
1276
|
-
drawBuffers: drawBuffers,
|
|
1277
|
-
|
|
1278
|
-
useProgram: useProgram,
|
|
1279
|
-
|
|
1280
|
-
setBlending: setBlending,
|
|
1281
|
-
setMaterial: setMaterial,
|
|
1282
|
-
|
|
1283
|
-
setFlipSided: setFlipSided,
|
|
1284
|
-
setCullFace: setCullFace,
|
|
1285
|
-
|
|
1286
|
-
setLineWidth: setLineWidth,
|
|
1287
|
-
setPolygonOffset: setPolygonOffset,
|
|
1288
|
-
|
|
1289
|
-
setScissorTest: setScissorTest,
|
|
1290
|
-
|
|
1291
|
-
activeTexture: activeTexture,
|
|
1292
|
-
bindTexture: bindTexture,
|
|
1293
|
-
unbindTexture: unbindTexture,
|
|
1294
|
-
compressedTexImage2D: compressedTexImage2D,
|
|
1295
|
-
compressedTexImage3D: compressedTexImage3D,
|
|
1296
|
-
texImage2D: texImage2D,
|
|
1297
|
-
texImage3D: texImage3D,
|
|
1298
|
-
|
|
1299
|
-
updateUBOMapping: updateUBOMapping,
|
|
1300
|
-
uniformBlockBinding: uniformBlockBinding,
|
|
1301
|
-
|
|
1302
|
-
texStorage2D: texStorage2D,
|
|
1303
|
-
texStorage3D: texStorage3D,
|
|
1304
|
-
texSubImage2D: texSubImage2D,
|
|
1305
|
-
texSubImage3D: texSubImage3D,
|
|
1306
|
-
compressedTexSubImage2D: compressedTexSubImage2D,
|
|
1307
|
-
compressedTexSubImage3D: compressedTexSubImage3D,
|
|
1308
|
-
|
|
1309
|
-
scissor: scissor,
|
|
1310
|
-
viewport: viewport,
|
|
1311
|
-
|
|
1312
|
-
reset: reset
|
|
1313
|
-
|
|
1314
|
-
};
|
|
1315
|
-
|
|
1316
|
-
}
|
|
1317
|
-
|
|
1318
|
-
export { WebGLState };
|
|
1
|
+
import { NotEqualDepth, GreaterDepth, GreaterEqualDepth, EqualDepth, LessEqualDepth, LessDepth, AlwaysDepth, NeverDepth, CullFaceFront, CullFaceBack, CullFaceNone, DoubleSide, BackSide, CustomBlending, MultiplyBlending, SubtractiveBlending, AdditiveBlending, NoBlending, NormalBlending, AddEquation, SubtractEquation, ReverseSubtractEquation, MinEquation, MaxEquation, ZeroFactor, OneFactor, SrcColorFactor, SrcAlphaFactor, SrcAlphaSaturateFactor, DstColorFactor, DstAlphaFactor, OneMinusSrcColorFactor, OneMinusSrcAlphaFactor, OneMinusDstColorFactor, OneMinusDstAlphaFactor, ConstantColorFactor, OneMinusConstantColorFactor, ConstantAlphaFactor, OneMinusConstantAlphaFactor } from '../../constants.js';
|
|
2
|
+
import { Color } from '../../math/Color.js';
|
|
3
|
+
import { Vector4 } from '../../math/Vector4.js';
|
|
4
|
+
|
|
5
|
+
function WebGLState( gl, extensions, capabilities ) {
|
|
6
|
+
|
|
7
|
+
const isWebGL2 = capabilities.isWebGL2;
|
|
8
|
+
|
|
9
|
+
function ColorBuffer() {
|
|
10
|
+
|
|
11
|
+
let locked = false;
|
|
12
|
+
|
|
13
|
+
const color = new Vector4();
|
|
14
|
+
let currentColorMask = null;
|
|
15
|
+
const currentColorClear = new Vector4( 0, 0, 0, 0 );
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
|
|
19
|
+
setMask: function ( colorMask ) {
|
|
20
|
+
|
|
21
|
+
if ( currentColorMask !== colorMask && ! locked ) {
|
|
22
|
+
|
|
23
|
+
gl.colorMask( colorMask, colorMask, colorMask, colorMask );
|
|
24
|
+
currentColorMask = colorMask;
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
setLocked: function ( lock ) {
|
|
31
|
+
|
|
32
|
+
locked = lock;
|
|
33
|
+
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
setClear: function ( r, g, b, a, premultipliedAlpha ) {
|
|
37
|
+
|
|
38
|
+
if ( premultipliedAlpha === true ) {
|
|
39
|
+
|
|
40
|
+
r *= a; g *= a; b *= a;
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
color.set( r, g, b, a );
|
|
45
|
+
|
|
46
|
+
if ( currentColorClear.equals( color ) === false ) {
|
|
47
|
+
|
|
48
|
+
gl.clearColor( r, g, b, a );
|
|
49
|
+
currentColorClear.copy( color );
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
reset: function () {
|
|
56
|
+
|
|
57
|
+
locked = false;
|
|
58
|
+
|
|
59
|
+
currentColorMask = null;
|
|
60
|
+
currentColorClear.set( - 1, 0, 0, 0 ); // set to invalid state
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function DepthBuffer() {
|
|
69
|
+
|
|
70
|
+
let locked = false;
|
|
71
|
+
|
|
72
|
+
let currentDepthMask = null;
|
|
73
|
+
let currentDepthFunc = null;
|
|
74
|
+
let currentDepthClear = null;
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
|
|
78
|
+
setTest: function ( depthTest ) {
|
|
79
|
+
|
|
80
|
+
if ( depthTest ) {
|
|
81
|
+
|
|
82
|
+
enable( gl.DEPTH_TEST );
|
|
83
|
+
|
|
84
|
+
} else {
|
|
85
|
+
|
|
86
|
+
disable( gl.DEPTH_TEST );
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
setMask: function ( depthMask ) {
|
|
93
|
+
|
|
94
|
+
if ( currentDepthMask !== depthMask && ! locked ) {
|
|
95
|
+
|
|
96
|
+
gl.depthMask( depthMask );
|
|
97
|
+
currentDepthMask = depthMask;
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
setFunc: function ( depthFunc ) {
|
|
104
|
+
|
|
105
|
+
if ( currentDepthFunc !== depthFunc ) {
|
|
106
|
+
|
|
107
|
+
switch ( depthFunc ) {
|
|
108
|
+
|
|
109
|
+
case NeverDepth:
|
|
110
|
+
|
|
111
|
+
gl.depthFunc( gl.NEVER );
|
|
112
|
+
break;
|
|
113
|
+
|
|
114
|
+
case AlwaysDepth:
|
|
115
|
+
|
|
116
|
+
gl.depthFunc( gl.ALWAYS );
|
|
117
|
+
break;
|
|
118
|
+
|
|
119
|
+
case LessDepth:
|
|
120
|
+
|
|
121
|
+
gl.depthFunc( gl.LESS );
|
|
122
|
+
break;
|
|
123
|
+
|
|
124
|
+
case LessEqualDepth:
|
|
125
|
+
|
|
126
|
+
gl.depthFunc( gl.LEQUAL );
|
|
127
|
+
break;
|
|
128
|
+
|
|
129
|
+
case EqualDepth:
|
|
130
|
+
|
|
131
|
+
gl.depthFunc( gl.EQUAL );
|
|
132
|
+
break;
|
|
133
|
+
|
|
134
|
+
case GreaterEqualDepth:
|
|
135
|
+
|
|
136
|
+
gl.depthFunc( gl.GEQUAL );
|
|
137
|
+
break;
|
|
138
|
+
|
|
139
|
+
case GreaterDepth:
|
|
140
|
+
|
|
141
|
+
gl.depthFunc( gl.GREATER );
|
|
142
|
+
break;
|
|
143
|
+
|
|
144
|
+
case NotEqualDepth:
|
|
145
|
+
|
|
146
|
+
gl.depthFunc( gl.NOTEQUAL );
|
|
147
|
+
break;
|
|
148
|
+
|
|
149
|
+
default:
|
|
150
|
+
|
|
151
|
+
gl.depthFunc( gl.LEQUAL );
|
|
152
|
+
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
currentDepthFunc = depthFunc;
|
|
156
|
+
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
},
|
|
160
|
+
|
|
161
|
+
setLocked: function ( lock ) {
|
|
162
|
+
|
|
163
|
+
locked = lock;
|
|
164
|
+
|
|
165
|
+
},
|
|
166
|
+
|
|
167
|
+
setClear: function ( depth ) {
|
|
168
|
+
|
|
169
|
+
if ( currentDepthClear !== depth ) {
|
|
170
|
+
|
|
171
|
+
gl.clearDepth( depth );
|
|
172
|
+
currentDepthClear = depth;
|
|
173
|
+
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
reset: function () {
|
|
179
|
+
|
|
180
|
+
locked = false;
|
|
181
|
+
|
|
182
|
+
currentDepthMask = null;
|
|
183
|
+
currentDepthFunc = null;
|
|
184
|
+
currentDepthClear = null;
|
|
185
|
+
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function StencilBuffer() {
|
|
193
|
+
|
|
194
|
+
let locked = false;
|
|
195
|
+
|
|
196
|
+
let currentStencilMask = null;
|
|
197
|
+
let currentStencilFunc = null;
|
|
198
|
+
let currentStencilRef = null;
|
|
199
|
+
let currentStencilFuncMask = null;
|
|
200
|
+
let currentStencilFail = null;
|
|
201
|
+
let currentStencilZFail = null;
|
|
202
|
+
let currentStencilZPass = null;
|
|
203
|
+
let currentStencilClear = null;
|
|
204
|
+
|
|
205
|
+
return {
|
|
206
|
+
|
|
207
|
+
setTest: function ( stencilTest ) {
|
|
208
|
+
|
|
209
|
+
if ( ! locked ) {
|
|
210
|
+
|
|
211
|
+
if ( stencilTest ) {
|
|
212
|
+
|
|
213
|
+
enable( gl.STENCIL_TEST );
|
|
214
|
+
|
|
215
|
+
} else {
|
|
216
|
+
|
|
217
|
+
disable( gl.STENCIL_TEST );
|
|
218
|
+
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
},
|
|
224
|
+
|
|
225
|
+
setMask: function ( stencilMask ) {
|
|
226
|
+
|
|
227
|
+
if ( currentStencilMask !== stencilMask && ! locked ) {
|
|
228
|
+
|
|
229
|
+
gl.stencilMask( stencilMask );
|
|
230
|
+
currentStencilMask = stencilMask;
|
|
231
|
+
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
},
|
|
235
|
+
|
|
236
|
+
setFunc: function ( stencilFunc, stencilRef, stencilMask ) {
|
|
237
|
+
|
|
238
|
+
if ( currentStencilFunc !== stencilFunc ||
|
|
239
|
+
currentStencilRef !== stencilRef ||
|
|
240
|
+
currentStencilFuncMask !== stencilMask ) {
|
|
241
|
+
|
|
242
|
+
gl.stencilFunc( stencilFunc, stencilRef, stencilMask );
|
|
243
|
+
|
|
244
|
+
currentStencilFunc = stencilFunc;
|
|
245
|
+
currentStencilRef = stencilRef;
|
|
246
|
+
currentStencilFuncMask = stencilMask;
|
|
247
|
+
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
},
|
|
251
|
+
|
|
252
|
+
setOp: function ( stencilFail, stencilZFail, stencilZPass ) {
|
|
253
|
+
|
|
254
|
+
if ( currentStencilFail !== stencilFail ||
|
|
255
|
+
currentStencilZFail !== stencilZFail ||
|
|
256
|
+
currentStencilZPass !== stencilZPass ) {
|
|
257
|
+
|
|
258
|
+
gl.stencilOp( stencilFail, stencilZFail, stencilZPass );
|
|
259
|
+
|
|
260
|
+
currentStencilFail = stencilFail;
|
|
261
|
+
currentStencilZFail = stencilZFail;
|
|
262
|
+
currentStencilZPass = stencilZPass;
|
|
263
|
+
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
},
|
|
267
|
+
|
|
268
|
+
setLocked: function ( lock ) {
|
|
269
|
+
|
|
270
|
+
locked = lock;
|
|
271
|
+
|
|
272
|
+
},
|
|
273
|
+
|
|
274
|
+
setClear: function ( stencil ) {
|
|
275
|
+
|
|
276
|
+
if ( currentStencilClear !== stencil ) {
|
|
277
|
+
|
|
278
|
+
gl.clearStencil( stencil );
|
|
279
|
+
currentStencilClear = stencil;
|
|
280
|
+
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
},
|
|
284
|
+
|
|
285
|
+
reset: function () {
|
|
286
|
+
|
|
287
|
+
locked = false;
|
|
288
|
+
|
|
289
|
+
currentStencilMask = null;
|
|
290
|
+
currentStencilFunc = null;
|
|
291
|
+
currentStencilRef = null;
|
|
292
|
+
currentStencilFuncMask = null;
|
|
293
|
+
currentStencilFail = null;
|
|
294
|
+
currentStencilZFail = null;
|
|
295
|
+
currentStencilZPass = null;
|
|
296
|
+
currentStencilClear = null;
|
|
297
|
+
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
//
|
|
305
|
+
|
|
306
|
+
const colorBuffer = new ColorBuffer();
|
|
307
|
+
const depthBuffer = new DepthBuffer();
|
|
308
|
+
const stencilBuffer = new StencilBuffer();
|
|
309
|
+
|
|
310
|
+
const uboBindings = new WeakMap();
|
|
311
|
+
const uboProgramMap = new WeakMap();
|
|
312
|
+
|
|
313
|
+
let enabledCapabilities = {};
|
|
314
|
+
|
|
315
|
+
let currentBoundFramebuffers = {};
|
|
316
|
+
let currentDrawbuffers = new WeakMap();
|
|
317
|
+
let defaultDrawbuffers = [];
|
|
318
|
+
|
|
319
|
+
let currentProgram = null;
|
|
320
|
+
|
|
321
|
+
let currentBlendingEnabled = false;
|
|
322
|
+
let currentBlending = null;
|
|
323
|
+
let currentBlendEquation = null;
|
|
324
|
+
let currentBlendSrc = null;
|
|
325
|
+
let currentBlendDst = null;
|
|
326
|
+
let currentBlendEquationAlpha = null;
|
|
327
|
+
let currentBlendSrcAlpha = null;
|
|
328
|
+
let currentBlendDstAlpha = null;
|
|
329
|
+
let currentBlendColor = new Color( 0, 0, 0 );
|
|
330
|
+
let currentBlendAlpha = 0;
|
|
331
|
+
let currentPremultipledAlpha = false;
|
|
332
|
+
|
|
333
|
+
let currentFlipSided = null;
|
|
334
|
+
let currentCullFace = null;
|
|
335
|
+
|
|
336
|
+
let currentLineWidth = null;
|
|
337
|
+
|
|
338
|
+
let currentPolygonOffsetFactor = null;
|
|
339
|
+
let currentPolygonOffsetUnits = null;
|
|
340
|
+
|
|
341
|
+
const maxTextures = gl.getParameter( gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS );
|
|
342
|
+
|
|
343
|
+
let lineWidthAvailable = false;
|
|
344
|
+
let version = 0;
|
|
345
|
+
const glVersion = gl.getParameter( gl.VERSION );
|
|
346
|
+
|
|
347
|
+
if ( glVersion.indexOf( 'WebGL' ) !== - 1 ) {
|
|
348
|
+
|
|
349
|
+
version = parseFloat( /^WebGL (\d)/.exec( glVersion )[ 1 ] );
|
|
350
|
+
lineWidthAvailable = ( version >= 1.0 );
|
|
351
|
+
|
|
352
|
+
} else if ( glVersion.indexOf( 'OpenGL ES' ) !== - 1 ) {
|
|
353
|
+
|
|
354
|
+
version = parseFloat( /^OpenGL ES (\d)/.exec( glVersion )[ 1 ] );
|
|
355
|
+
lineWidthAvailable = ( version >= 2.0 );
|
|
356
|
+
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
let currentTextureSlot = null;
|
|
360
|
+
let currentBoundTextures = {};
|
|
361
|
+
|
|
362
|
+
const scissorParam = gl.getParameter( gl.SCISSOR_BOX );
|
|
363
|
+
const viewportParam = gl.getParameter( gl.VIEWPORT );
|
|
364
|
+
|
|
365
|
+
const currentScissor = new Vector4().fromArray( scissorParam );
|
|
366
|
+
const currentViewport = new Vector4().fromArray( viewportParam );
|
|
367
|
+
|
|
368
|
+
function createTexture( type, target, count, dimensions ) {
|
|
369
|
+
|
|
370
|
+
const data = new Uint8Array( 4 ); // 4 is required to match default unpack alignment of 4.
|
|
371
|
+
const texture = gl.createTexture();
|
|
372
|
+
|
|
373
|
+
gl.bindTexture( type, texture );
|
|
374
|
+
gl.texParameteri( type, gl.TEXTURE_MIN_FILTER, gl.NEAREST );
|
|
375
|
+
gl.texParameteri( type, gl.TEXTURE_MAG_FILTER, gl.NEAREST );
|
|
376
|
+
|
|
377
|
+
for ( let i = 0; i < count; i ++ ) {
|
|
378
|
+
|
|
379
|
+
if ( isWebGL2 && ( type === gl.TEXTURE_3D || type === gl.TEXTURE_2D_ARRAY ) ) {
|
|
380
|
+
|
|
381
|
+
gl.texImage3D( target, 0, gl.RGBA, 1, 1, dimensions, 0, gl.RGBA, gl.UNSIGNED_BYTE, data );
|
|
382
|
+
|
|
383
|
+
} else {
|
|
384
|
+
|
|
385
|
+
gl.texImage2D( target + i, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, data );
|
|
386
|
+
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
return texture;
|
|
392
|
+
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
const emptyTextures = {};
|
|
396
|
+
emptyTextures[ gl.TEXTURE_2D ] = createTexture( gl.TEXTURE_2D, gl.TEXTURE_2D, 1 );
|
|
397
|
+
emptyTextures[ gl.TEXTURE_CUBE_MAP ] = createTexture( gl.TEXTURE_CUBE_MAP, gl.TEXTURE_CUBE_MAP_POSITIVE_X, 6 );
|
|
398
|
+
|
|
399
|
+
if ( isWebGL2 ) {
|
|
400
|
+
|
|
401
|
+
emptyTextures[ gl.TEXTURE_2D_ARRAY ] = createTexture( gl.TEXTURE_2D_ARRAY, gl.TEXTURE_2D_ARRAY, 1, 1 );
|
|
402
|
+
emptyTextures[ gl.TEXTURE_3D ] = createTexture( gl.TEXTURE_3D, gl.TEXTURE_3D, 1, 1 );
|
|
403
|
+
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// init
|
|
407
|
+
|
|
408
|
+
colorBuffer.setClear( 0, 0, 0, 1 );
|
|
409
|
+
depthBuffer.setClear( 1 );
|
|
410
|
+
stencilBuffer.setClear( 0 );
|
|
411
|
+
|
|
412
|
+
enable( gl.DEPTH_TEST );
|
|
413
|
+
depthBuffer.setFunc( LessEqualDepth );
|
|
414
|
+
|
|
415
|
+
setFlipSided( false );
|
|
416
|
+
setCullFace( CullFaceBack );
|
|
417
|
+
enable( gl.CULL_FACE );
|
|
418
|
+
|
|
419
|
+
setBlending( NoBlending );
|
|
420
|
+
|
|
421
|
+
//
|
|
422
|
+
|
|
423
|
+
function enable( id ) {
|
|
424
|
+
|
|
425
|
+
if ( enabledCapabilities[ id ] !== true ) {
|
|
426
|
+
|
|
427
|
+
gl.enable( id );
|
|
428
|
+
enabledCapabilities[ id ] = true;
|
|
429
|
+
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
function disable( id ) {
|
|
435
|
+
|
|
436
|
+
if ( enabledCapabilities[ id ] !== false ) {
|
|
437
|
+
|
|
438
|
+
gl.disable( id );
|
|
439
|
+
enabledCapabilities[ id ] = false;
|
|
440
|
+
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
function bindFramebuffer( target, framebuffer ) {
|
|
446
|
+
|
|
447
|
+
if ( currentBoundFramebuffers[ target ] !== framebuffer ) {
|
|
448
|
+
|
|
449
|
+
gl.bindFramebuffer( target, framebuffer );
|
|
450
|
+
|
|
451
|
+
currentBoundFramebuffers[ target ] = framebuffer;
|
|
452
|
+
|
|
453
|
+
if ( isWebGL2 ) {
|
|
454
|
+
|
|
455
|
+
// gl.DRAW_FRAMEBUFFER is equivalent to gl.FRAMEBUFFER
|
|
456
|
+
|
|
457
|
+
if ( target === gl.DRAW_FRAMEBUFFER ) {
|
|
458
|
+
|
|
459
|
+
currentBoundFramebuffers[ gl.FRAMEBUFFER ] = framebuffer;
|
|
460
|
+
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
if ( target === gl.FRAMEBUFFER ) {
|
|
464
|
+
|
|
465
|
+
currentBoundFramebuffers[ gl.DRAW_FRAMEBUFFER ] = framebuffer;
|
|
466
|
+
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
return true;
|
|
472
|
+
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
return false;
|
|
476
|
+
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
function drawBuffers( renderTarget, framebuffer ) {
|
|
480
|
+
|
|
481
|
+
let drawBuffers = defaultDrawbuffers;
|
|
482
|
+
|
|
483
|
+
let needsUpdate = false;
|
|
484
|
+
|
|
485
|
+
if ( renderTarget ) {
|
|
486
|
+
|
|
487
|
+
drawBuffers = currentDrawbuffers.get( framebuffer );
|
|
488
|
+
|
|
489
|
+
if ( drawBuffers === undefined ) {
|
|
490
|
+
|
|
491
|
+
drawBuffers = [];
|
|
492
|
+
currentDrawbuffers.set( framebuffer, drawBuffers );
|
|
493
|
+
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
const textures = renderTarget.textures;
|
|
497
|
+
|
|
498
|
+
if ( drawBuffers.length !== textures.length || drawBuffers[ 0 ] !== gl.COLOR_ATTACHMENT0 ) {
|
|
499
|
+
|
|
500
|
+
for ( let i = 0, il = textures.length; i < il; i ++ ) {
|
|
501
|
+
|
|
502
|
+
drawBuffers[ i ] = gl.COLOR_ATTACHMENT0 + i;
|
|
503
|
+
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
drawBuffers.length = textures.length;
|
|
507
|
+
|
|
508
|
+
needsUpdate = true;
|
|
509
|
+
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
} else {
|
|
513
|
+
|
|
514
|
+
if ( drawBuffers[ 0 ] !== gl.BACK ) {
|
|
515
|
+
|
|
516
|
+
drawBuffers[ 0 ] = gl.BACK;
|
|
517
|
+
|
|
518
|
+
needsUpdate = true;
|
|
519
|
+
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
if ( needsUpdate ) {
|
|
525
|
+
|
|
526
|
+
if ( capabilities.isWebGL2 ) {
|
|
527
|
+
|
|
528
|
+
gl.drawBuffers( drawBuffers );
|
|
529
|
+
|
|
530
|
+
} else if ( extensions.has( 'WEBGL_draw_buffers' ) === true ) {
|
|
531
|
+
|
|
532
|
+
extensions.get( 'WEBGL_draw_buffers' ).drawBuffersWEBGL( drawBuffers );
|
|
533
|
+
|
|
534
|
+
} else {
|
|
535
|
+
|
|
536
|
+
throw new Error( 'THREE.WebGLState: Usage of gl.drawBuffers() require WebGL2 or WEBGL_draw_buffers extension' );
|
|
537
|
+
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
function useProgram( program ) {
|
|
546
|
+
|
|
547
|
+
if ( currentProgram !== program ) {
|
|
548
|
+
|
|
549
|
+
gl.useProgram( program );
|
|
550
|
+
|
|
551
|
+
currentProgram = program;
|
|
552
|
+
|
|
553
|
+
return true;
|
|
554
|
+
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
return false;
|
|
558
|
+
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
const equationToGL = {
|
|
562
|
+
[ AddEquation ]: gl.FUNC_ADD,
|
|
563
|
+
[ SubtractEquation ]: gl.FUNC_SUBTRACT,
|
|
564
|
+
[ ReverseSubtractEquation ]: gl.FUNC_REVERSE_SUBTRACT
|
|
565
|
+
};
|
|
566
|
+
|
|
567
|
+
if ( isWebGL2 ) {
|
|
568
|
+
|
|
569
|
+
equationToGL[ MinEquation ] = gl.MIN;
|
|
570
|
+
equationToGL[ MaxEquation ] = gl.MAX;
|
|
571
|
+
|
|
572
|
+
} else {
|
|
573
|
+
|
|
574
|
+
const extension = extensions.get( 'EXT_blend_minmax' );
|
|
575
|
+
|
|
576
|
+
if ( extension !== null ) {
|
|
577
|
+
|
|
578
|
+
equationToGL[ MinEquation ] = extension.MIN_EXT;
|
|
579
|
+
equationToGL[ MaxEquation ] = extension.MAX_EXT;
|
|
580
|
+
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
const factorToGL = {
|
|
586
|
+
[ ZeroFactor ]: gl.ZERO,
|
|
587
|
+
[ OneFactor ]: gl.ONE,
|
|
588
|
+
[ SrcColorFactor ]: gl.SRC_COLOR,
|
|
589
|
+
[ SrcAlphaFactor ]: gl.SRC_ALPHA,
|
|
590
|
+
[ SrcAlphaSaturateFactor ]: gl.SRC_ALPHA_SATURATE,
|
|
591
|
+
[ DstColorFactor ]: gl.DST_COLOR,
|
|
592
|
+
[ DstAlphaFactor ]: gl.DST_ALPHA,
|
|
593
|
+
[ OneMinusSrcColorFactor ]: gl.ONE_MINUS_SRC_COLOR,
|
|
594
|
+
[ OneMinusSrcAlphaFactor ]: gl.ONE_MINUS_SRC_ALPHA,
|
|
595
|
+
[ OneMinusDstColorFactor ]: gl.ONE_MINUS_DST_COLOR,
|
|
596
|
+
[ OneMinusDstAlphaFactor ]: gl.ONE_MINUS_DST_ALPHA,
|
|
597
|
+
[ ConstantColorFactor ]: gl.CONSTANT_COLOR,
|
|
598
|
+
[ OneMinusConstantColorFactor ]: gl.ONE_MINUS_CONSTANT_COLOR,
|
|
599
|
+
[ ConstantAlphaFactor ]: gl.CONSTANT_ALPHA,
|
|
600
|
+
[ OneMinusConstantAlphaFactor ]: gl.ONE_MINUS_CONSTANT_ALPHA
|
|
601
|
+
};
|
|
602
|
+
|
|
603
|
+
function setBlending( blending, blendEquation, blendSrc, blendDst, blendEquationAlpha, blendSrcAlpha, blendDstAlpha, blendColor, blendAlpha, premultipliedAlpha ) {
|
|
604
|
+
|
|
605
|
+
if ( blending === NoBlending ) {
|
|
606
|
+
|
|
607
|
+
if ( currentBlendingEnabled === true ) {
|
|
608
|
+
|
|
609
|
+
disable( gl.BLEND );
|
|
610
|
+
currentBlendingEnabled = false;
|
|
611
|
+
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
return;
|
|
615
|
+
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
if ( currentBlendingEnabled === false ) {
|
|
619
|
+
|
|
620
|
+
enable( gl.BLEND );
|
|
621
|
+
currentBlendingEnabled = true;
|
|
622
|
+
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
if ( blending !== CustomBlending ) {
|
|
626
|
+
|
|
627
|
+
if ( blending !== currentBlending || premultipliedAlpha !== currentPremultipledAlpha ) {
|
|
628
|
+
|
|
629
|
+
if ( currentBlendEquation !== AddEquation || currentBlendEquationAlpha !== AddEquation ) {
|
|
630
|
+
|
|
631
|
+
gl.blendEquation( gl.FUNC_ADD );
|
|
632
|
+
|
|
633
|
+
currentBlendEquation = AddEquation;
|
|
634
|
+
currentBlendEquationAlpha = AddEquation;
|
|
635
|
+
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
if ( premultipliedAlpha ) {
|
|
639
|
+
|
|
640
|
+
switch ( blending ) {
|
|
641
|
+
|
|
642
|
+
case NormalBlending:
|
|
643
|
+
gl.blendFuncSeparate( gl.ONE, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA );
|
|
644
|
+
break;
|
|
645
|
+
|
|
646
|
+
case AdditiveBlending:
|
|
647
|
+
gl.blendFunc( gl.ONE, gl.ONE );
|
|
648
|
+
break;
|
|
649
|
+
|
|
650
|
+
case SubtractiveBlending:
|
|
651
|
+
gl.blendFuncSeparate( gl.ZERO, gl.ONE_MINUS_SRC_COLOR, gl.ZERO, gl.ONE );
|
|
652
|
+
break;
|
|
653
|
+
|
|
654
|
+
case MultiplyBlending:
|
|
655
|
+
gl.blendFuncSeparate( gl.ZERO, gl.SRC_COLOR, gl.ZERO, gl.SRC_ALPHA );
|
|
656
|
+
break;
|
|
657
|
+
|
|
658
|
+
default:
|
|
659
|
+
console.error( 'THREE.WebGLState: Invalid blending: ', blending );
|
|
660
|
+
break;
|
|
661
|
+
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
} else {
|
|
665
|
+
|
|
666
|
+
switch ( blending ) {
|
|
667
|
+
|
|
668
|
+
case NormalBlending:
|
|
669
|
+
gl.blendFuncSeparate( gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA );
|
|
670
|
+
break;
|
|
671
|
+
|
|
672
|
+
case AdditiveBlending:
|
|
673
|
+
gl.blendFunc( gl.SRC_ALPHA, gl.ONE );
|
|
674
|
+
break;
|
|
675
|
+
|
|
676
|
+
case SubtractiveBlending:
|
|
677
|
+
gl.blendFuncSeparate( gl.ZERO, gl.ONE_MINUS_SRC_COLOR, gl.ZERO, gl.ONE );
|
|
678
|
+
break;
|
|
679
|
+
|
|
680
|
+
case MultiplyBlending:
|
|
681
|
+
gl.blendFunc( gl.ZERO, gl.SRC_COLOR );
|
|
682
|
+
break;
|
|
683
|
+
|
|
684
|
+
default:
|
|
685
|
+
console.error( 'THREE.WebGLState: Invalid blending: ', blending );
|
|
686
|
+
break;
|
|
687
|
+
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
currentBlendSrc = null;
|
|
693
|
+
currentBlendDst = null;
|
|
694
|
+
currentBlendSrcAlpha = null;
|
|
695
|
+
currentBlendDstAlpha = null;
|
|
696
|
+
currentBlendColor.set( 0, 0, 0 );
|
|
697
|
+
currentBlendAlpha = 0;
|
|
698
|
+
|
|
699
|
+
currentBlending = blending;
|
|
700
|
+
currentPremultipledAlpha = premultipliedAlpha;
|
|
701
|
+
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
return;
|
|
705
|
+
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
// custom blending
|
|
709
|
+
|
|
710
|
+
blendEquationAlpha = blendEquationAlpha || blendEquation;
|
|
711
|
+
blendSrcAlpha = blendSrcAlpha || blendSrc;
|
|
712
|
+
blendDstAlpha = blendDstAlpha || blendDst;
|
|
713
|
+
|
|
714
|
+
if ( blendEquation !== currentBlendEquation || blendEquationAlpha !== currentBlendEquationAlpha ) {
|
|
715
|
+
|
|
716
|
+
gl.blendEquationSeparate( equationToGL[ blendEquation ], equationToGL[ blendEquationAlpha ] );
|
|
717
|
+
|
|
718
|
+
currentBlendEquation = blendEquation;
|
|
719
|
+
currentBlendEquationAlpha = blendEquationAlpha;
|
|
720
|
+
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
if ( blendSrc !== currentBlendSrc || blendDst !== currentBlendDst || blendSrcAlpha !== currentBlendSrcAlpha || blendDstAlpha !== currentBlendDstAlpha ) {
|
|
724
|
+
|
|
725
|
+
gl.blendFuncSeparate( factorToGL[ blendSrc ], factorToGL[ blendDst ], factorToGL[ blendSrcAlpha ], factorToGL[ blendDstAlpha ] );
|
|
726
|
+
|
|
727
|
+
currentBlendSrc = blendSrc;
|
|
728
|
+
currentBlendDst = blendDst;
|
|
729
|
+
currentBlendSrcAlpha = blendSrcAlpha;
|
|
730
|
+
currentBlendDstAlpha = blendDstAlpha;
|
|
731
|
+
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
if ( blendColor.equals( currentBlendColor ) === false || blendAlpha !== currentBlendAlpha ) {
|
|
735
|
+
|
|
736
|
+
gl.blendColor( blendColor.r, blendColor.g, blendColor.b, blendAlpha );
|
|
737
|
+
|
|
738
|
+
currentBlendColor.copy( blendColor );
|
|
739
|
+
currentBlendAlpha = blendAlpha;
|
|
740
|
+
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
currentBlending = blending;
|
|
744
|
+
currentPremultipledAlpha = false;
|
|
745
|
+
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
function setMaterial( material, frontFaceCW ) {
|
|
749
|
+
|
|
750
|
+
material.side === DoubleSide
|
|
751
|
+
? disable( gl.CULL_FACE )
|
|
752
|
+
: enable( gl.CULL_FACE );
|
|
753
|
+
|
|
754
|
+
let flipSided = ( material.side === BackSide );
|
|
755
|
+
if ( frontFaceCW ) flipSided = ! flipSided;
|
|
756
|
+
|
|
757
|
+
setFlipSided( flipSided );
|
|
758
|
+
|
|
759
|
+
( material.blending === NormalBlending && material.transparent === false )
|
|
760
|
+
? setBlending( NoBlending )
|
|
761
|
+
: setBlending( material.blending, material.blendEquation, material.blendSrc, material.blendDst, material.blendEquationAlpha, material.blendSrcAlpha, material.blendDstAlpha, material.blendColor, material.blendAlpha, material.premultipliedAlpha );
|
|
762
|
+
|
|
763
|
+
depthBuffer.setFunc( material.depthFunc );
|
|
764
|
+
depthBuffer.setTest( material.depthTest );
|
|
765
|
+
depthBuffer.setMask( material.depthWrite );
|
|
766
|
+
colorBuffer.setMask( material.colorWrite );
|
|
767
|
+
|
|
768
|
+
const stencilWrite = material.stencilWrite;
|
|
769
|
+
stencilBuffer.setTest( stencilWrite );
|
|
770
|
+
if ( stencilWrite ) {
|
|
771
|
+
|
|
772
|
+
stencilBuffer.setMask( material.stencilWriteMask );
|
|
773
|
+
stencilBuffer.setFunc( material.stencilFunc, material.stencilRef, material.stencilFuncMask );
|
|
774
|
+
stencilBuffer.setOp( material.stencilFail, material.stencilZFail, material.stencilZPass );
|
|
775
|
+
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
setPolygonOffset( material.polygonOffset, material.polygonOffsetFactor, material.polygonOffsetUnits );
|
|
779
|
+
|
|
780
|
+
material.alphaToCoverage === true
|
|
781
|
+
? enable( gl.SAMPLE_ALPHA_TO_COVERAGE )
|
|
782
|
+
: disable( gl.SAMPLE_ALPHA_TO_COVERAGE );
|
|
783
|
+
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
//
|
|
787
|
+
|
|
788
|
+
function setFlipSided( flipSided ) {
|
|
789
|
+
|
|
790
|
+
if ( currentFlipSided !== flipSided ) {
|
|
791
|
+
|
|
792
|
+
if ( flipSided ) {
|
|
793
|
+
|
|
794
|
+
gl.frontFace( gl.CW );
|
|
795
|
+
|
|
796
|
+
} else {
|
|
797
|
+
|
|
798
|
+
gl.frontFace( gl.CCW );
|
|
799
|
+
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
currentFlipSided = flipSided;
|
|
803
|
+
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
function setCullFace( cullFace ) {
|
|
809
|
+
|
|
810
|
+
if ( cullFace !== CullFaceNone ) {
|
|
811
|
+
|
|
812
|
+
enable( gl.CULL_FACE );
|
|
813
|
+
|
|
814
|
+
if ( cullFace !== currentCullFace ) {
|
|
815
|
+
|
|
816
|
+
if ( cullFace === CullFaceBack ) {
|
|
817
|
+
|
|
818
|
+
gl.cullFace( gl.BACK );
|
|
819
|
+
|
|
820
|
+
} else if ( cullFace === CullFaceFront ) {
|
|
821
|
+
|
|
822
|
+
gl.cullFace( gl.FRONT );
|
|
823
|
+
|
|
824
|
+
} else {
|
|
825
|
+
|
|
826
|
+
gl.cullFace( gl.FRONT_AND_BACK );
|
|
827
|
+
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
} else {
|
|
833
|
+
|
|
834
|
+
disable( gl.CULL_FACE );
|
|
835
|
+
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
currentCullFace = cullFace;
|
|
839
|
+
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
function setLineWidth( width ) {
|
|
843
|
+
|
|
844
|
+
if ( width !== currentLineWidth ) {
|
|
845
|
+
|
|
846
|
+
if ( lineWidthAvailable ) gl.lineWidth( width );
|
|
847
|
+
|
|
848
|
+
currentLineWidth = width;
|
|
849
|
+
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
function setPolygonOffset( polygonOffset, factor, units ) {
|
|
855
|
+
|
|
856
|
+
if ( polygonOffset ) {
|
|
857
|
+
|
|
858
|
+
enable( gl.POLYGON_OFFSET_FILL );
|
|
859
|
+
|
|
860
|
+
if ( currentPolygonOffsetFactor !== factor || currentPolygonOffsetUnits !== units ) {
|
|
861
|
+
|
|
862
|
+
gl.polygonOffset( factor, units );
|
|
863
|
+
|
|
864
|
+
currentPolygonOffsetFactor = factor;
|
|
865
|
+
currentPolygonOffsetUnits = units;
|
|
866
|
+
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
} else {
|
|
870
|
+
|
|
871
|
+
disable( gl.POLYGON_OFFSET_FILL );
|
|
872
|
+
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
function setScissorTest( scissorTest ) {
|
|
878
|
+
|
|
879
|
+
if ( scissorTest ) {
|
|
880
|
+
|
|
881
|
+
enable( gl.SCISSOR_TEST );
|
|
882
|
+
|
|
883
|
+
} else {
|
|
884
|
+
|
|
885
|
+
disable( gl.SCISSOR_TEST );
|
|
886
|
+
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
// texture
|
|
892
|
+
|
|
893
|
+
function activeTexture( webglSlot ) {
|
|
894
|
+
|
|
895
|
+
if ( webglSlot === undefined ) webglSlot = gl.TEXTURE0 + maxTextures - 1;
|
|
896
|
+
|
|
897
|
+
if ( currentTextureSlot !== webglSlot ) {
|
|
898
|
+
|
|
899
|
+
gl.activeTexture( webglSlot );
|
|
900
|
+
currentTextureSlot = webglSlot;
|
|
901
|
+
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
function bindTexture( webglType, webglTexture, webglSlot ) {
|
|
907
|
+
|
|
908
|
+
if ( webglSlot === undefined ) {
|
|
909
|
+
|
|
910
|
+
if ( currentTextureSlot === null ) {
|
|
911
|
+
|
|
912
|
+
webglSlot = gl.TEXTURE0 + maxTextures - 1;
|
|
913
|
+
|
|
914
|
+
} else {
|
|
915
|
+
|
|
916
|
+
webglSlot = currentTextureSlot;
|
|
917
|
+
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
let boundTexture = currentBoundTextures[ webglSlot ];
|
|
923
|
+
|
|
924
|
+
if ( boundTexture === undefined ) {
|
|
925
|
+
|
|
926
|
+
boundTexture = { type: undefined, texture: undefined };
|
|
927
|
+
currentBoundTextures[ webglSlot ] = boundTexture;
|
|
928
|
+
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
if ( boundTexture.type !== webglType || boundTexture.texture !== webglTexture ) {
|
|
932
|
+
|
|
933
|
+
if ( currentTextureSlot !== webglSlot ) {
|
|
934
|
+
|
|
935
|
+
gl.activeTexture( webglSlot );
|
|
936
|
+
currentTextureSlot = webglSlot;
|
|
937
|
+
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
gl.bindTexture( webglType, webglTexture || emptyTextures[ webglType ] );
|
|
941
|
+
|
|
942
|
+
boundTexture.type = webglType;
|
|
943
|
+
boundTexture.texture = webglTexture;
|
|
944
|
+
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
function unbindTexture() {
|
|
950
|
+
|
|
951
|
+
const boundTexture = currentBoundTextures[ currentTextureSlot ];
|
|
952
|
+
|
|
953
|
+
if ( boundTexture !== undefined && boundTexture.type !== undefined ) {
|
|
954
|
+
|
|
955
|
+
gl.bindTexture( boundTexture.type, null );
|
|
956
|
+
|
|
957
|
+
boundTexture.type = undefined;
|
|
958
|
+
boundTexture.texture = undefined;
|
|
959
|
+
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
function compressedTexImage2D() {
|
|
965
|
+
|
|
966
|
+
try {
|
|
967
|
+
|
|
968
|
+
gl.compressedTexImage2D.apply( gl, arguments );
|
|
969
|
+
|
|
970
|
+
} catch ( error ) {
|
|
971
|
+
|
|
972
|
+
console.error( 'THREE.WebGLState:', error );
|
|
973
|
+
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
function compressedTexImage3D() {
|
|
979
|
+
|
|
980
|
+
try {
|
|
981
|
+
|
|
982
|
+
gl.compressedTexImage3D.apply( gl, arguments );
|
|
983
|
+
|
|
984
|
+
} catch ( error ) {
|
|
985
|
+
|
|
986
|
+
console.error( 'THREE.WebGLState:', error );
|
|
987
|
+
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
function texSubImage2D() {
|
|
993
|
+
|
|
994
|
+
try {
|
|
995
|
+
|
|
996
|
+
gl.texSubImage2D.apply( gl, arguments );
|
|
997
|
+
|
|
998
|
+
} catch ( error ) {
|
|
999
|
+
|
|
1000
|
+
console.error( 'THREE.WebGLState:', error );
|
|
1001
|
+
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
function texSubImage3D() {
|
|
1007
|
+
|
|
1008
|
+
try {
|
|
1009
|
+
|
|
1010
|
+
gl.texSubImage3D.apply( gl, arguments );
|
|
1011
|
+
|
|
1012
|
+
} catch ( error ) {
|
|
1013
|
+
|
|
1014
|
+
console.error( 'THREE.WebGLState:', error );
|
|
1015
|
+
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
function compressedTexSubImage2D() {
|
|
1021
|
+
|
|
1022
|
+
try {
|
|
1023
|
+
|
|
1024
|
+
gl.compressedTexSubImage2D.apply( gl, arguments );
|
|
1025
|
+
|
|
1026
|
+
} catch ( error ) {
|
|
1027
|
+
|
|
1028
|
+
console.error( 'THREE.WebGLState:', error );
|
|
1029
|
+
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
function compressedTexSubImage3D() {
|
|
1035
|
+
|
|
1036
|
+
try {
|
|
1037
|
+
|
|
1038
|
+
gl.compressedTexSubImage3D.apply( gl, arguments );
|
|
1039
|
+
|
|
1040
|
+
} catch ( error ) {
|
|
1041
|
+
|
|
1042
|
+
console.error( 'THREE.WebGLState:', error );
|
|
1043
|
+
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
function texStorage2D() {
|
|
1049
|
+
|
|
1050
|
+
try {
|
|
1051
|
+
|
|
1052
|
+
gl.texStorage2D.apply( gl, arguments );
|
|
1053
|
+
|
|
1054
|
+
} catch ( error ) {
|
|
1055
|
+
|
|
1056
|
+
console.error( 'THREE.WebGLState:', error );
|
|
1057
|
+
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
function texStorage3D() {
|
|
1063
|
+
|
|
1064
|
+
try {
|
|
1065
|
+
|
|
1066
|
+
gl.texStorage3D.apply( gl, arguments );
|
|
1067
|
+
|
|
1068
|
+
} catch ( error ) {
|
|
1069
|
+
|
|
1070
|
+
console.error( 'THREE.WebGLState:', error );
|
|
1071
|
+
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
function texImage2D() {
|
|
1077
|
+
|
|
1078
|
+
try {
|
|
1079
|
+
|
|
1080
|
+
gl.texImage2D.apply( gl, arguments );
|
|
1081
|
+
|
|
1082
|
+
} catch ( error ) {
|
|
1083
|
+
|
|
1084
|
+
console.error( 'THREE.WebGLState:', error );
|
|
1085
|
+
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
function texImage3D() {
|
|
1091
|
+
|
|
1092
|
+
try {
|
|
1093
|
+
|
|
1094
|
+
gl.texImage3D.apply( gl, arguments );
|
|
1095
|
+
|
|
1096
|
+
} catch ( error ) {
|
|
1097
|
+
|
|
1098
|
+
console.error( 'THREE.WebGLState:', error );
|
|
1099
|
+
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
//
|
|
1105
|
+
|
|
1106
|
+
function scissor( scissor ) {
|
|
1107
|
+
|
|
1108
|
+
if ( currentScissor.equals( scissor ) === false ) {
|
|
1109
|
+
|
|
1110
|
+
gl.scissor( scissor.x, scissor.y, scissor.z, scissor.w );
|
|
1111
|
+
currentScissor.copy( scissor );
|
|
1112
|
+
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
function viewport( viewport ) {
|
|
1118
|
+
|
|
1119
|
+
if ( currentViewport.equals( viewport ) === false ) {
|
|
1120
|
+
|
|
1121
|
+
gl.viewport( viewport.x, viewport.y, viewport.z, viewport.w );
|
|
1122
|
+
currentViewport.copy( viewport );
|
|
1123
|
+
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
function updateUBOMapping( uniformsGroup, program ) {
|
|
1129
|
+
|
|
1130
|
+
let mapping = uboProgramMap.get( program );
|
|
1131
|
+
|
|
1132
|
+
if ( mapping === undefined ) {
|
|
1133
|
+
|
|
1134
|
+
mapping = new WeakMap();
|
|
1135
|
+
|
|
1136
|
+
uboProgramMap.set( program, mapping );
|
|
1137
|
+
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
let blockIndex = mapping.get( uniformsGroup );
|
|
1141
|
+
|
|
1142
|
+
if ( blockIndex === undefined ) {
|
|
1143
|
+
|
|
1144
|
+
blockIndex = gl.getUniformBlockIndex( program, uniformsGroup.name );
|
|
1145
|
+
|
|
1146
|
+
mapping.set( uniformsGroup, blockIndex );
|
|
1147
|
+
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
function uniformBlockBinding( uniformsGroup, program ) {
|
|
1153
|
+
|
|
1154
|
+
const mapping = uboProgramMap.get( program );
|
|
1155
|
+
const blockIndex = mapping.get( uniformsGroup );
|
|
1156
|
+
|
|
1157
|
+
if ( uboBindings.get( program ) !== blockIndex ) {
|
|
1158
|
+
|
|
1159
|
+
// bind shader specific block index to global block point
|
|
1160
|
+
gl.uniformBlockBinding( program, blockIndex, uniformsGroup.__bindingPointIndex );
|
|
1161
|
+
|
|
1162
|
+
uboBindings.set( program, blockIndex );
|
|
1163
|
+
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
//
|
|
1169
|
+
|
|
1170
|
+
function reset() {
|
|
1171
|
+
|
|
1172
|
+
// reset state
|
|
1173
|
+
|
|
1174
|
+
gl.disable( gl.BLEND );
|
|
1175
|
+
gl.disable( gl.CULL_FACE );
|
|
1176
|
+
gl.disable( gl.DEPTH_TEST );
|
|
1177
|
+
gl.disable( gl.POLYGON_OFFSET_FILL );
|
|
1178
|
+
gl.disable( gl.SCISSOR_TEST );
|
|
1179
|
+
gl.disable( gl.STENCIL_TEST );
|
|
1180
|
+
gl.disable( gl.SAMPLE_ALPHA_TO_COVERAGE );
|
|
1181
|
+
|
|
1182
|
+
gl.blendEquation( gl.FUNC_ADD );
|
|
1183
|
+
gl.blendFunc( gl.ONE, gl.ZERO );
|
|
1184
|
+
gl.blendFuncSeparate( gl.ONE, gl.ZERO, gl.ONE, gl.ZERO );
|
|
1185
|
+
gl.blendColor( 0, 0, 0, 0 );
|
|
1186
|
+
|
|
1187
|
+
gl.colorMask( true, true, true, true );
|
|
1188
|
+
gl.clearColor( 0, 0, 0, 0 );
|
|
1189
|
+
|
|
1190
|
+
gl.depthMask( true );
|
|
1191
|
+
gl.depthFunc( gl.LESS );
|
|
1192
|
+
gl.clearDepth( 1 );
|
|
1193
|
+
|
|
1194
|
+
gl.stencilMask( 0xffffffff );
|
|
1195
|
+
gl.stencilFunc( gl.ALWAYS, 0, 0xffffffff );
|
|
1196
|
+
gl.stencilOp( gl.KEEP, gl.KEEP, gl.KEEP );
|
|
1197
|
+
gl.clearStencil( 0 );
|
|
1198
|
+
|
|
1199
|
+
gl.cullFace( gl.BACK );
|
|
1200
|
+
gl.frontFace( gl.CCW );
|
|
1201
|
+
|
|
1202
|
+
gl.polygonOffset( 0, 0 );
|
|
1203
|
+
|
|
1204
|
+
gl.activeTexture( gl.TEXTURE0 );
|
|
1205
|
+
|
|
1206
|
+
gl.bindFramebuffer( gl.FRAMEBUFFER, null );
|
|
1207
|
+
|
|
1208
|
+
if ( isWebGL2 === true ) {
|
|
1209
|
+
|
|
1210
|
+
gl.bindFramebuffer( gl.DRAW_FRAMEBUFFER, null );
|
|
1211
|
+
gl.bindFramebuffer( gl.READ_FRAMEBUFFER, null );
|
|
1212
|
+
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
gl.useProgram( null );
|
|
1216
|
+
|
|
1217
|
+
gl.lineWidth( 1 );
|
|
1218
|
+
|
|
1219
|
+
gl.scissor( 0, 0, gl.canvas.width, gl.canvas.height );
|
|
1220
|
+
gl.viewport( 0, 0, gl.canvas.width, gl.canvas.height );
|
|
1221
|
+
|
|
1222
|
+
// reset internals
|
|
1223
|
+
|
|
1224
|
+
enabledCapabilities = {};
|
|
1225
|
+
|
|
1226
|
+
currentTextureSlot = null;
|
|
1227
|
+
currentBoundTextures = {};
|
|
1228
|
+
|
|
1229
|
+
currentBoundFramebuffers = {};
|
|
1230
|
+
currentDrawbuffers = new WeakMap();
|
|
1231
|
+
defaultDrawbuffers = [];
|
|
1232
|
+
|
|
1233
|
+
currentProgram = null;
|
|
1234
|
+
|
|
1235
|
+
currentBlendingEnabled = false;
|
|
1236
|
+
currentBlending = null;
|
|
1237
|
+
currentBlendEquation = null;
|
|
1238
|
+
currentBlendSrc = null;
|
|
1239
|
+
currentBlendDst = null;
|
|
1240
|
+
currentBlendEquationAlpha = null;
|
|
1241
|
+
currentBlendSrcAlpha = null;
|
|
1242
|
+
currentBlendDstAlpha = null;
|
|
1243
|
+
currentBlendColor = new Color( 0, 0, 0 );
|
|
1244
|
+
currentBlendAlpha = 0;
|
|
1245
|
+
currentPremultipledAlpha = false;
|
|
1246
|
+
|
|
1247
|
+
currentFlipSided = null;
|
|
1248
|
+
currentCullFace = null;
|
|
1249
|
+
|
|
1250
|
+
currentLineWidth = null;
|
|
1251
|
+
|
|
1252
|
+
currentPolygonOffsetFactor = null;
|
|
1253
|
+
currentPolygonOffsetUnits = null;
|
|
1254
|
+
|
|
1255
|
+
currentScissor.set( 0, 0, gl.canvas.width, gl.canvas.height );
|
|
1256
|
+
currentViewport.set( 0, 0, gl.canvas.width, gl.canvas.height );
|
|
1257
|
+
|
|
1258
|
+
colorBuffer.reset();
|
|
1259
|
+
depthBuffer.reset();
|
|
1260
|
+
stencilBuffer.reset();
|
|
1261
|
+
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
return {
|
|
1265
|
+
|
|
1266
|
+
buffers: {
|
|
1267
|
+
color: colorBuffer,
|
|
1268
|
+
depth: depthBuffer,
|
|
1269
|
+
stencil: stencilBuffer
|
|
1270
|
+
},
|
|
1271
|
+
|
|
1272
|
+
enable: enable,
|
|
1273
|
+
disable: disable,
|
|
1274
|
+
|
|
1275
|
+
bindFramebuffer: bindFramebuffer,
|
|
1276
|
+
drawBuffers: drawBuffers,
|
|
1277
|
+
|
|
1278
|
+
useProgram: useProgram,
|
|
1279
|
+
|
|
1280
|
+
setBlending: setBlending,
|
|
1281
|
+
setMaterial: setMaterial,
|
|
1282
|
+
|
|
1283
|
+
setFlipSided: setFlipSided,
|
|
1284
|
+
setCullFace: setCullFace,
|
|
1285
|
+
|
|
1286
|
+
setLineWidth: setLineWidth,
|
|
1287
|
+
setPolygonOffset: setPolygonOffset,
|
|
1288
|
+
|
|
1289
|
+
setScissorTest: setScissorTest,
|
|
1290
|
+
|
|
1291
|
+
activeTexture: activeTexture,
|
|
1292
|
+
bindTexture: bindTexture,
|
|
1293
|
+
unbindTexture: unbindTexture,
|
|
1294
|
+
compressedTexImage2D: compressedTexImage2D,
|
|
1295
|
+
compressedTexImage3D: compressedTexImage3D,
|
|
1296
|
+
texImage2D: texImage2D,
|
|
1297
|
+
texImage3D: texImage3D,
|
|
1298
|
+
|
|
1299
|
+
updateUBOMapping: updateUBOMapping,
|
|
1300
|
+
uniformBlockBinding: uniformBlockBinding,
|
|
1301
|
+
|
|
1302
|
+
texStorage2D: texStorage2D,
|
|
1303
|
+
texStorage3D: texStorage3D,
|
|
1304
|
+
texSubImage2D: texSubImage2D,
|
|
1305
|
+
texSubImage3D: texSubImage3D,
|
|
1306
|
+
compressedTexSubImage2D: compressedTexSubImage2D,
|
|
1307
|
+
compressedTexSubImage3D: compressedTexSubImage3D,
|
|
1308
|
+
|
|
1309
|
+
scissor: scissor,
|
|
1310
|
+
viewport: viewport,
|
|
1311
|
+
|
|
1312
|
+
reset: reset
|
|
1313
|
+
|
|
1314
|
+
};
|
|
1315
|
+
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
export { WebGLState };
|