@needle-tools/three 0.145.4 → 0.146.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/build/three.cjs +32586 -35951
- package/build/three.js +32600 -35965
- package/build/three.min.js +6 -7
- package/build/three.module.js +1547 -1154
- package/examples/js/animation/AnimationClipCreator.js +0 -8
- package/examples/js/animation/CCDIKSolver.js +49 -66
- package/examples/js/animation/MMDAnimationHelper.js +66 -137
- package/examples/js/animation/MMDPhysics.js +70 -134
- package/examples/js/cameras/CinematicCamera.js +33 -22
- package/examples/js/controls/ArcballControls.js +138 -405
- package/examples/js/controls/DragControls.js +8 -33
- package/examples/js/controls/FirstPersonControls.js +32 -54
- package/examples/js/controls/FlyControls.js +29 -55
- package/examples/js/controls/OrbitControls.js +85 -95
- package/examples/js/controls/PointerLockControls.js +5 -14
- package/examples/js/controls/TrackballControls.js +33 -86
- package/examples/js/controls/TransformControls.js +84 -169
- package/examples/js/csm/CSM.js +4 -39
- package/examples/js/csm/CSMFrustum.js +3 -9
- package/examples/js/csm/CSMHelper.js +24 -4
- package/examples/js/csm/CSMShader.js +2 -6
- package/examples/js/curves/CurveExtras.js +27 -27
- package/examples/js/curves/NURBSCurve.js +4 -16
- package/examples/js/curves/NURBSSurface.js +3 -9
- package/examples/js/curves/NURBSUtils.js +8 -45
- package/examples/js/effects/AnaglyphEffect.js +4 -18
- package/examples/js/effects/AsciiEffect.js +32 -31
- package/examples/js/effects/OutlineEffect.js +26 -30
- package/examples/js/effects/ParallaxBarrierEffect.js +0 -13
- package/examples/js/effects/PeppersGhostEffect.js +12 -39
- package/examples/js/effects/StereoEffect.js +0 -4
- package/examples/js/environments/RoomEnvironment.js +12 -10
- package/examples/js/exporters/ColladaExporter.js +48 -65
- package/examples/js/exporters/DRACOExporter.js +22 -22
- package/examples/js/exporters/EXRExporter.js +15 -18
- package/examples/js/exporters/GLTFExporter.js +143 -261
- package/examples/js/exporters/MMDExporter.js +5 -12
- package/examples/js/exporters/OBJExporter.js +42 -33
- package/examples/js/exporters/PLYExporter.js +38 -33
- package/examples/js/exporters/STLExporter.js +5 -7
- package/examples/js/exporters/USDZExporter.js +110 -25
- package/examples/js/geometries/BoxLineGeometry.js +0 -1
- package/examples/js/geometries/ConvexGeometry.js +11 -6
- package/examples/js/geometries/DecalGeometry.js +53 -20
- package/examples/js/geometries/LightningStrike.js +54 -67
- package/examples/js/geometries/ParametricGeometries.js +8 -7
- package/examples/js/geometries/ParametricGeometry.js +25 -12
- package/examples/js/geometries/RoundedBoxGeometry.js +21 -19
- package/examples/js/geometries/TeapotGeometry.js +54 -50
- package/examples/js/geometries/TextGeometry.js +6 -4
- package/examples/js/helpers/LightProbeHelper.js +1 -2
- package/examples/js/helpers/OctreeHelper.js +22 -20
- package/examples/js/helpers/PositionalAudioHelper.js +8 -6
- package/examples/js/helpers/RectAreaLightHelper.js +6 -7
- package/examples/js/helpers/VertexNormalsHelper.js +15 -13
- package/examples/js/helpers/VertexTangentsHelper.js +15 -9
- package/examples/js/helpers/ViewHelper.js +31 -16
- package/examples/js/interactive/HTMLMesh.js +22 -33
- package/examples/js/interactive/InteractiveGroup.js +6 -12
- package/examples/js/interactive/SelectionBox.js +3 -70
- package/examples/js/interactive/SelectionHelper.js +0 -8
- package/examples/js/lights/LightProbeGenerator.js +32 -39
- package/examples/js/lights/RectAreaLightUniformsLib.js +5 -1
- package/examples/js/lines/LineGeometry.js +3 -5
- package/examples/js/lines/LineMaterial.js +4 -11
- package/examples/js/lines/LineSegments2.js +38 -89
- package/examples/js/lines/LineSegmentsGeometry.js +7 -28
- package/examples/js/lines/Wireframe.js +2 -7
- package/examples/js/lines/WireframeGeometry2.js +3 -1
- package/examples/js/loaders/3DMLoader.js +58 -155
- package/examples/js/loaders/3MFLoader.js +72 -106
- package/examples/js/loaders/AMFLoader.js +0 -25
- package/examples/js/loaders/BVHLoader.js +44 -43
- package/examples/js/loaders/BasisTextureLoader.js +16 -46
- package/examples/js/loaders/ColladaLoader.js +201 -359
- package/examples/js/loaders/DDSLoader.js +24 -25
- package/examples/js/loaders/DRACOLoader.js +29 -66
- package/examples/js/loaders/EXRLoader.js +67 -164
- package/examples/js/loaders/FBXLoader.js +286 -441
- package/examples/js/loaders/FontLoader.js +6 -15
- package/examples/js/loaders/GCodeLoader.js +15 -16
- package/examples/js/loaders/GLTFLoader.js +354 -405
- package/examples/js/loaders/HDRCubeTextureLoader.js +0 -6
- package/examples/js/loaders/KMZLoader.js +3 -7
- package/examples/js/loaders/KTXLoader.js +12 -30
- package/examples/js/loaders/LDrawLoader.js +178 -289
- package/examples/js/loaders/LUT3dlLoader.js +7 -11
- package/examples/js/loaders/LUTCubeLoader.js +0 -8
- package/examples/js/loaders/LWOLoader.js +59 -124
- package/examples/js/loaders/LogLuvLoader.js +27 -77
- package/examples/js/loaders/LottieLoader.js +4 -4
- package/examples/js/loaders/MD2Loader.js +26 -27
- package/examples/js/loaders/MDDLoader.js +6 -10
- package/examples/js/loaders/MMDLoader.js +180 -189
- package/examples/js/loaders/MTLLoader.js +18 -47
- package/examples/js/loaders/MaterialXLoader.js +392 -0
- package/examples/js/loaders/NRRDLoader.js +44 -84
- package/examples/js/loaders/OBJLoader.js +50 -65
- package/examples/js/loaders/PCDLoader.js +34 -29
- package/examples/js/loaders/PDBLoader.js +17 -13
- package/examples/js/loaders/PLYLoader.js +9 -39
- package/examples/js/loaders/PRWMLoader.js +11 -22
- package/examples/js/loaders/PVRLoader.js +7 -16
- package/examples/js/loaders/RGBELoader.js +36 -61
- package/examples/js/loaders/RGBMLoader.js +26 -87
- package/examples/js/loaders/STLLoader.js +20 -27
- package/examples/js/loaders/SVGLoader.js +361 -233
- package/examples/js/loaders/TDSLoader.js +81 -118
- package/examples/js/loaders/TGALoader.js +39 -41
- package/examples/js/loaders/TIFFLoader.js +0 -1
- package/examples/js/loaders/TTFLoader.js +0 -8
- package/examples/js/loaders/TiltLoader.js +14 -15
- package/examples/js/loaders/VOXLoader.js +8 -16
- package/examples/js/loaders/VRMLLoader.js +243 -340
- package/examples/js/loaders/VTKLoader.js +101 -118
- package/examples/js/loaders/XYZLoader.js +2 -4
- package/examples/js/loaders/lwo/IFFParser.js +55 -136
- package/examples/js/loaders/lwo/LWO2Parser.js +32 -83
- package/examples/js/loaders/lwo/LWO3Parser.js +31 -73
- package/examples/js/materials/MeshGouraudMaterial.js +15 -13
- package/examples/js/math/Capsule.js +0 -17
- package/examples/js/math/ColorConverter.js +3 -3
- package/examples/js/math/ConvexHull.js +183 -139
- package/examples/js/math/ImprovedNoise.js +1 -1
- package/examples/js/math/Lut.js +8 -15
- package/examples/js/math/MeshSurfaceSampler.js +6 -28
- package/examples/js/math/OBB.js +90 -49
- package/examples/js/math/Octree.js +2 -57
- package/examples/js/math/SimplexNoise.js +74 -88
- package/examples/js/misc/ConvexObjectBreaker.js +37 -48
- package/examples/js/misc/GPUComputationRenderer.js +14 -18
- package/examples/js/misc/Gyroscope.js +5 -9
- package/examples/js/misc/MD2Character.js +14 -23
- package/examples/js/misc/MD2CharacterComplex.js +73 -54
- package/examples/js/misc/MorphAnimMesh.js +0 -6
- package/examples/js/misc/MorphBlendMesh.js +3 -30
- package/examples/js/misc/ProgressiveLightMap.js +47 -43
- package/examples/js/misc/RollerCoaster.js +17 -24
- package/examples/js/misc/TubePainter.js +18 -12
- package/examples/js/misc/Volume.js +16 -45
- package/examples/js/misc/VolumeSlice.js +14 -24
- package/examples/js/modifiers/CurveModifier.js +19 -21
- package/examples/js/modifiers/EdgeSplitModifier.js +0 -30
- package/examples/js/modifiers/SimplifyModifier.js +56 -59
- package/examples/js/modifiers/TessellateModifier.js +2 -9
- package/examples/js/objects/GroundProjectedEnv.js +2 -14
- package/examples/js/objects/Lensflare.js +47 -38
- package/examples/js/objects/LightningStorm.js +10 -13
- package/examples/js/objects/MarchingCubes.js +80 -59
- package/examples/js/objects/Reflector.js +22 -20
- package/examples/js/objects/ReflectorForSSRPass.js +19 -23
- package/examples/js/objects/Refractor.js +52 -30
- package/examples/js/objects/ShadowMesh.js +1 -2
- package/examples/js/objects/Sky.js +2 -7
- package/examples/js/objects/Water.js +23 -18
- package/examples/js/objects/Water2.js +20 -19
- package/examples/js/physics/AmmoPhysics.js +23 -20
- package/examples/js/physics/OimoPhysics.js +19 -17
- package/examples/js/postprocessing/AdaptiveToneMappingPass.js +13 -20
- package/examples/js/postprocessing/AfterimagePass.js +19 -12
- package/examples/js/postprocessing/BloomPass.js +38 -17
- package/examples/js/postprocessing/BokehPass.js +29 -12
- package/examples/js/postprocessing/ClearPass.js +1 -6
- package/examples/js/postprocessing/CubeTexturePass.js +12 -9
- package/examples/js/postprocessing/DotScreenPass.js +7 -5
- package/examples/js/postprocessing/EffectComposer.js +25 -32
- package/examples/js/postprocessing/FilmPass.js +7 -5
- package/examples/js/postprocessing/GlitchPass.js +10 -11
- package/examples/js/postprocessing/HalftonePass.js +9 -9
- package/examples/js/postprocessing/LUTPass.js +2 -15
- package/examples/js/postprocessing/MaskPass.js +20 -17
- package/examples/js/postprocessing/OutlinePass.js +45 -36
- package/examples/js/postprocessing/Pass.js +11 -14
- package/examples/js/postprocessing/RenderPass.js +3 -7
- package/examples/js/postprocessing/SAOPass.js +40 -32
- package/examples/js/postprocessing/SMAAPass.js +34 -17
- package/examples/js/postprocessing/SSAARenderPass.js +14 -14
- package/examples/js/postprocessing/SSAOPass.js +56 -42
- package/examples/js/postprocessing/SSRPass.js +78 -61
- package/examples/js/postprocessing/SavePass.js +14 -6
- package/examples/js/postprocessing/ShaderPass.js +9 -8
- package/examples/js/postprocessing/TAARenderPass.js +11 -9
- package/examples/js/postprocessing/TexturePass.js +7 -4
- package/examples/js/postprocessing/UnrealBloomPass.js +43 -25
- package/examples/js/renderers/CSS2DRenderer.js +2 -21
- package/examples/js/renderers/CSS3DRenderer.js +3 -24
- package/examples/js/renderers/Projector.js +29 -85
- package/examples/js/renderers/SVGRenderer.js +4 -50
- package/examples/js/shaders/ACESFilmicToneMappingShader.js +3 -6
- package/examples/js/shaders/AfterimageShader.js +3 -6
- package/examples/js/shaders/BasicShader.js +3 -6
- package/examples/js/shaders/BleachBypassShader.js +3 -6
- package/examples/js/shaders/BlendShader.js +3 -6
- package/examples/js/shaders/BokehShader.js +3 -6
- package/examples/js/shaders/BokehShader2.js +4 -13
- package/examples/js/shaders/BrightnessContrastShader.js +3 -6
- package/examples/js/shaders/ColorCorrectionShader.js +2 -6
- package/examples/js/shaders/ColorifyShader.js +2 -6
- package/examples/js/shaders/ConvolutionShader.js +5 -10
- package/examples/js/shaders/CopyShader.js +3 -6
- package/examples/js/shaders/DOFMipMapShader.js +3 -6
- package/examples/js/shaders/DepthLimitedBlurShader.js +2 -9
- package/examples/js/shaders/DigitalGlitch.js +3 -6
- package/examples/js/shaders/DotScreenShader.js +2 -6
- package/examples/js/shaders/FXAAShader.js +1 -3
- package/examples/js/shaders/FilmShader.js +3 -6
- package/examples/js/shaders/FocusShader.js +3 -6
- package/examples/js/shaders/FreiChenShader.js +2 -6
- package/examples/js/shaders/GammaCorrectionShader.js +3 -6
- package/examples/js/shaders/GodRaysShader.js +11 -24
- package/examples/js/shaders/HalftoneShader.js +3 -6
- package/examples/js/shaders/HorizontalBlurShader.js +3 -6
- package/examples/js/shaders/HorizontalTiltShiftShader.js +3 -6
- package/examples/js/shaders/HueSaturationShader.js +3 -6
- package/examples/js/shaders/KaleidoShader.js +3 -6
- package/examples/js/shaders/LuminosityHighPassShader.js +2 -6
- package/examples/js/shaders/LuminosityShader.js +3 -6
- package/examples/js/shaders/MMDToonShader.js +2 -6
- package/examples/js/shaders/MirrorShader.js +3 -6
- package/examples/js/shaders/NormalMapShader.js +2 -6
- package/examples/js/shaders/RGBShiftShader.js +3 -6
- package/examples/js/shaders/SAOShader.js +2 -6
- package/examples/js/shaders/SMAAShader.js +6 -18
- package/examples/js/shaders/SSAOShader.js +2 -6
- package/examples/js/shaders/SSRShader.js +6 -18
- package/examples/js/shaders/SepiaShader.js +3 -6
- package/examples/js/shaders/SobelOperatorShader.js +2 -6
- package/examples/js/shaders/TechnicolorShader.js +3 -6
- package/examples/js/shaders/ToneMapShader.js +3 -6
- package/examples/js/shaders/ToonShader.js +8 -24
- package/examples/js/shaders/TriangleBlurShader.js +2 -6
- package/examples/js/shaders/UnpackDepthRGBAShader.js +3 -6
- package/examples/js/shaders/VelocityShader.js +126 -0
- package/examples/js/shaders/VerticalBlurShader.js +3 -6
- package/examples/js/shaders/VerticalTiltShiftShader.js +3 -6
- package/examples/js/shaders/VignetteShader.js +3 -6
- package/examples/js/shaders/VolumeShader.js +2 -6
- package/examples/js/shaders/WaterRefractionShader.js +2 -6
- package/examples/js/textures/FlakesTexture.js +0 -1
- package/examples/js/utils/BufferGeometryUtils.js +234 -168
- package/examples/js/utils/CameraUtils.js +5 -20
- package/examples/js/utils/GPUStatsPanel.js +3 -12
- package/examples/js/utils/GeometryCompressionUtils.js +19 -44
- package/examples/js/utils/GeometryUtils.js +13 -18
- package/examples/js/utils/LDrawUtils.js +8 -11
- package/examples/js/utils/PackedPhongMaterial.js +6 -4
- package/examples/js/utils/SceneUtils.js +117 -6
- package/examples/js/utils/ShadowMapViewer.js +17 -14
- package/examples/js/utils/SkeletonUtils.js +13 -27
- package/examples/js/utils/UVsDebug.js +20 -12
- package/examples/js/utils/WorkerPool.js +1 -11
- package/examples/jsm/animation/CCDIKSolver.js +1 -1
- package/examples/jsm/capabilities/WebGPU.js +3 -1
- package/examples/jsm/controls/OrbitControls.js +44 -4
- package/examples/jsm/exporters/GLTFExporter.js +17 -131
- package/examples/jsm/exporters/USDZExporter.js +75 -19
- package/examples/jsm/interactive/HTMLMesh.js +2 -0
- package/examples/jsm/libs/lottie_canvas.module.js +14844 -0
- package/examples/jsm/loaders/3DMLoader.js +1 -2
- package/examples/jsm/loaders/ColladaLoader.js +28 -0
- package/examples/jsm/loaders/FBXLoader.js +16 -2
- package/examples/jsm/loaders/GLTFLoader.js +204 -377
- package/examples/jsm/loaders/KTX2Loader.js +68 -29
- package/examples/jsm/loaders/LDrawLoader.js +14 -13
- package/examples/jsm/loaders/LottieLoader.js +4 -2
- package/examples/jsm/loaders/MaterialXLoader.js +728 -0
- package/examples/jsm/loaders/PCDLoader.js +1 -1
- package/examples/jsm/loaders/PLYLoader.js +68 -16
- package/examples/jsm/loaders/SVGLoader.js +227 -14
- package/examples/jsm/loaders/USDZLoader.js +31 -16
- package/examples/jsm/nodes/Nodes.js +14 -2
- package/examples/jsm/nodes/accessors/Object3DNode.js +1 -1
- package/examples/jsm/nodes/accessors/PositionNode.js +6 -0
- package/examples/jsm/nodes/accessors/ReferenceNode.js +1 -1
- package/examples/jsm/nodes/accessors/SkinningNode.js +1 -1
- package/examples/jsm/nodes/core/Node.js +1 -1
- package/examples/jsm/nodes/core/NodeBuilder.js +36 -4
- package/examples/jsm/nodes/core/NodeFrame.js +2 -2
- package/examples/jsm/nodes/core/NodeVarying.js +7 -4
- package/examples/jsm/nodes/core/VaryingNode.js +6 -4
- package/examples/jsm/nodes/core/constants.js +13 -13
- package/examples/jsm/nodes/display/PosterizeNode.js +25 -0
- package/examples/jsm/nodes/display/ViewportNode.js +106 -0
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +1 -1
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +1 -1
- package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +3 -1
- package/examples/jsm/nodes/materials/Materials.js +9 -7
- package/examples/jsm/nodes/materials/NodeMaterial.js +9 -1
- package/examples/jsm/nodes/materialx/MaterialXNodes.js +6 -2
- package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +18 -0
- package/examples/jsm/nodes/math/MathNode.js +5 -0
- package/examples/jsm/nodes/math/OperatorNode.js +6 -1
- package/examples/jsm/nodes/shadernode/ShaderNode.js +26 -13
- package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +2 -0
- package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +18 -0
- package/examples/jsm/nodes/utils/EquirectUVNode.js +27 -0
- package/examples/jsm/nodes/utils/JoinNode.js +8 -2
- package/examples/jsm/nodes/utils/MatcapUVNode.js +2 -4
- package/examples/jsm/nodes/utils/MaxMipLevelNode.js +1 -1
- package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +8 -10
- package/examples/jsm/nodes/utils/TimerNode.js +1 -1
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +51 -0
- package/examples/jsm/postprocessing/AfterimagePass.js +17 -4
- package/examples/jsm/postprocessing/BloomPass.js +22 -3
- package/examples/jsm/postprocessing/BokehPass.js +18 -4
- package/examples/jsm/postprocessing/CubeTexturePass.js +12 -5
- package/examples/jsm/postprocessing/DotScreenPass.js +8 -0
- package/examples/jsm/postprocessing/EffectComposer.js +9 -0
- package/examples/jsm/postprocessing/FilmPass.js +8 -0
- package/examples/jsm/postprocessing/GlitchPass.js +13 -1
- package/examples/jsm/postprocessing/HalftonePass.js +8 -0
- package/examples/jsm/postprocessing/OutlinePass.js +10 -0
- package/examples/jsm/postprocessing/Pass.js +2 -0
- package/examples/jsm/postprocessing/RenderPixelatedPass.js +234 -0
- package/examples/jsm/postprocessing/SAOPass.js +20 -0
- package/examples/jsm/postprocessing/SMAAPass.js +16 -0
- package/examples/jsm/postprocessing/SSAARenderPass.js +4 -0
- package/examples/jsm/postprocessing/SavePass.js +17 -1
- package/examples/jsm/postprocessing/ShaderPass.js +8 -0
- package/examples/jsm/postprocessing/TAARenderPass.js +9 -0
- package/examples/jsm/postprocessing/TexturePass.js +8 -0
- package/examples/jsm/postprocessing/UnrealBloomPass.js +16 -0
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +39 -16
- package/examples/jsm/renderers/webgpu/WebGPUAnimation.js +58 -0
- package/examples/jsm/renderers/webgpu/WebGPUAttributes.js +63 -5
- package/examples/jsm/renderers/webgpu/WebGPUBackground.js +36 -7
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +47 -12
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +35 -5
- package/examples/jsm/shaders/MMDToonShader.js +0 -2
- package/examples/jsm/shaders/VelocityShader.js +128 -0
- package/examples/jsm/utils/BufferGeometryUtils.js +130 -6
- package/examples/jsm/utils/SceneUtils.js +129 -4
- package/examples/jsm/utils/TextureUtils.js +85 -0
- package/examples/jsm/webxr/OculusHandModel.js +1 -1
- package/examples/jsm/webxr/XRHandMeshModel.js +6 -3
- package/package.json +11 -12
- package/src/Three.js +1 -0
- package/src/audio/AudioContext.js +5 -5
- package/src/cameras/CubeCamera.js +14 -14
- package/src/constants.js +1 -1
- package/src/core/InstancedBufferGeometry.js +1 -7
- package/src/extras/Earcut.js +67 -67
- package/src/helpers/DirectionalLightHelper.js +5 -1
- package/src/helpers/HemisphereLightHelper.js +4 -1
- package/src/helpers/PointLightHelper.js +2 -1
- package/src/helpers/SpotLightHelper.js +4 -2
- package/src/lights/PointLight.js +2 -2
- package/src/lights/SpotLight.js +2 -2
- package/src/loaders/FileLoader.js +4 -1
- package/src/loaders/ObjectLoader.js +5 -1
- package/src/materials/Material.js +1 -1
- package/src/math/Color.js +5 -5
- package/src/math/Matrix3.js +53 -18
- package/src/math/Ray.js +2 -5
- package/src/math/Sphere.js +19 -26
- package/src/objects/InstancedMesh.js +7 -0
- package/src/objects/LOD.js +25 -6
- package/src/renderers/WebGL3DRenderTarget.js +1 -1
- package/src/renderers/WebGLArrayRenderTarget.js +1 -1
- package/src/renderers/WebGLCubeRenderTarget.js +1 -1
- package/src/renderers/WebGLMultipleRenderTargets.js +1 -1
- package/src/renderers/WebGLRenderTarget.js +1 -1
- package/src/renderers/WebGLRenderer.js +36 -62
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +0 -4
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +0 -2
- package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +0 -2
- package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +0 -2
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk.js +3 -0
- package/src/renderers/shaders/ShaderLib/background.glsl.js +7 -2
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +62 -0
- package/src/renderers/shaders/ShaderLib/cube.glsl.js +4 -6
- package/src/renderers/shaders/ShaderLib.js +20 -6
- package/src/renderers/shaders/UniformsLib.js +1 -1
- package/src/renderers/shaders/UniformsUtils.js +15 -0
- package/src/renderers/webgl/WebGLAttributes.js +2 -0
- package/src/renderers/webgl/WebGLBackground.js +15 -7
- package/src/renderers/webgl/WebGLLights.js +0 -4
- package/src/renderers/webgl/WebGLMaterials.js +2 -1
- package/src/renderers/webgl/WebGLShadowMap.js +3 -1
- package/src/renderers/webgl/WebGLState.js +31 -1
- package/src/renderers/webgl/WebGLTextures.js +71 -18
- package/src/renderers/webgl/WebGLUniforms.js +116 -20
- package/src/renderers/webgl/WebGLUtils.js +1 -1
- package/src/renderers/webxr/WebXRController.js +46 -13
- package/src/renderers/webxr/WebXRManager.js +85 -3
- package/src/scenes/Scene.js +8 -0
- package/src/textures/CompressedArrayTexture.js +18 -0
- package/examples/js/libs/lottie_canvas.js +0 -12751
- package/examples/js/shaders/PixelShader.js +0 -51
- package/examples/jsm/shaders/PixelShader.js +0 -44
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { sRGBEncoding, LinearSRGBColorSpace, SRGBColorSpace } from '../../constants.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Uniform Utilities
|
|
3
5
|
*/
|
|
@@ -73,6 +75,19 @@ export function cloneUniformsGroups( src ) {
|
|
|
73
75
|
|
|
74
76
|
}
|
|
75
77
|
|
|
78
|
+
export function getUnlitUniformColorSpace( renderer ) {
|
|
79
|
+
|
|
80
|
+
if ( renderer.getRenderTarget() === null ) {
|
|
81
|
+
|
|
82
|
+
// https://github.com/mrdoob/three.js/pull/23937#issuecomment-1111067398
|
|
83
|
+
return renderer.outputEncoding === sRGBEncoding ? SRGBColorSpace : LinearSRGBColorSpace;
|
|
84
|
+
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return LinearSRGBColorSpace;
|
|
88
|
+
|
|
89
|
+
}
|
|
90
|
+
|
|
76
91
|
// Legacy
|
|
77
92
|
|
|
78
93
|
const UniformsUtils = { clone: cloneUniforms, merge: mergeUniforms };
|
|
@@ -5,9 +5,11 @@ import { ShaderMaterial } from '../../materials/ShaderMaterial.js';
|
|
|
5
5
|
import { Color } from '../../math/Color.js';
|
|
6
6
|
import { Mesh } from '../../objects/Mesh.js';
|
|
7
7
|
import { ShaderLib } from '../shaders/ShaderLib.js';
|
|
8
|
-
import { cloneUniforms } from '../shaders/UniformsUtils.js';
|
|
8
|
+
import { cloneUniforms, getUnlitUniformColorSpace } from '../shaders/UniformsUtils.js';
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
const _rgb = { r: 0, b: 0, g: 0 };
|
|
11
|
+
|
|
12
|
+
function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha, premultipliedAlpha ) {
|
|
11
13
|
|
|
12
14
|
const clearColor = new Color( 0x000000 );
|
|
13
15
|
let clearAlpha = alpha === true ? 0 : 1;
|
|
@@ -26,7 +28,8 @@ function WebGLBackground( renderer, cubemaps, state, objects, alpha, premultipli
|
|
|
26
28
|
|
|
27
29
|
if ( background && background.isTexture ) {
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
const usePMREM = scene.backgroundBlurriness > 0; // use PMREM if the user wants to blur the background
|
|
32
|
+
background = ( usePMREM ? cubeuvmaps : cubemaps ).get( background );
|
|
30
33
|
|
|
31
34
|
}
|
|
32
35
|
|
|
@@ -67,9 +70,9 @@ function WebGLBackground( renderer, cubemaps, state, objects, alpha, premultipli
|
|
|
67
70
|
new BoxGeometry( 1, 1, 1 ),
|
|
68
71
|
new ShaderMaterial( {
|
|
69
72
|
name: 'BackgroundCubeMaterial',
|
|
70
|
-
uniforms: cloneUniforms( ShaderLib.
|
|
71
|
-
vertexShader: ShaderLib.
|
|
72
|
-
fragmentShader: ShaderLib.
|
|
73
|
+
uniforms: cloneUniforms( ShaderLib.backgroundCube.uniforms ),
|
|
74
|
+
vertexShader: ShaderLib.backgroundCube.vertexShader,
|
|
75
|
+
fragmentShader: ShaderLib.backgroundCube.fragmentShader,
|
|
73
76
|
side: BackSide,
|
|
74
77
|
depthTest: false,
|
|
75
78
|
depthWrite: false,
|
|
@@ -103,6 +106,8 @@ function WebGLBackground( renderer, cubemaps, state, objects, alpha, premultipli
|
|
|
103
106
|
|
|
104
107
|
boxMesh.material.uniforms.envMap.value = background;
|
|
105
108
|
boxMesh.material.uniforms.flipEnvMap.value = ( background.isCubeTexture && background.isRenderTargetTexture === false ) ? - 1 : 1;
|
|
109
|
+
boxMesh.material.uniforms.backgroundBlurriness.value = scene.backgroundBlurriness;
|
|
110
|
+
boxMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;
|
|
106
111
|
|
|
107
112
|
if ( currentBackground !== background ||
|
|
108
113
|
currentBackgroundVersion !== background.version ||
|
|
@@ -157,6 +162,7 @@ function WebGLBackground( renderer, cubemaps, state, objects, alpha, premultipli
|
|
|
157
162
|
}
|
|
158
163
|
|
|
159
164
|
planeMesh.material.uniforms.t2D.value = background;
|
|
165
|
+
planeMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;
|
|
160
166
|
|
|
161
167
|
if ( background.matrixAutoUpdate === true ) {
|
|
162
168
|
|
|
@@ -189,7 +195,9 @@ function WebGLBackground( renderer, cubemaps, state, objects, alpha, premultipli
|
|
|
189
195
|
|
|
190
196
|
function setClear( color, alpha ) {
|
|
191
197
|
|
|
192
|
-
|
|
198
|
+
color.getRGB( _rgb, getUnlitUniformColorSpace( renderer ) );
|
|
199
|
+
|
|
200
|
+
state.buffers.color.setClear( _rgb.r, _rgb.g, _rgb.b, alpha, premultipliedAlpha );
|
|
193
201
|
|
|
194
202
|
}
|
|
195
203
|
|
|
@@ -333,10 +333,6 @@ function WebGLLights( extensions, capabilities ) {
|
|
|
333
333
|
|
|
334
334
|
const uniforms = cache.get( light );
|
|
335
335
|
|
|
336
|
-
// (a) intensity is the total visible light emitted
|
|
337
|
-
//uniforms.color.copy( color ).multiplyScalar( intensity / ( light.width * light.height * Math.PI ) );
|
|
338
|
-
|
|
339
|
-
// (b) intensity is the brightness of the light
|
|
340
336
|
uniforms.color.copy( color ).multiplyScalar( intensity );
|
|
341
337
|
|
|
342
338
|
uniforms.halfWidth.set( light.width * 0.5, 0.0, 0.0 );
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { BackSide } from '../../constants.js';
|
|
2
|
+
import { getUnlitUniformColorSpace } from '../shaders/UniformsUtils.js';
|
|
2
3
|
|
|
3
4
|
function WebGLMaterials( renderer, properties ) {
|
|
4
5
|
|
|
5
6
|
function refreshFogUniforms( uniforms, fog ) {
|
|
6
7
|
|
|
7
|
-
uniforms.fogColor.value
|
|
8
|
+
fog.color.getRGB( uniforms.fogColor.value, getUnlitUniformColorSpace( renderer ) );
|
|
8
9
|
|
|
9
10
|
if ( fog.isFog ) {
|
|
10
11
|
|
|
@@ -244,7 +244,8 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
244
244
|
|
|
245
245
|
if ( ( _renderer.localClippingEnabled && material.clipShadows === true && Array.isArray( material.clippingPlanes ) && material.clippingPlanes.length !== 0 ) ||
|
|
246
246
|
( material.displacementMap && material.displacementScale !== 0 ) ||
|
|
247
|
-
( material.alphaMap && material.alphaTest > 0 )
|
|
247
|
+
( material.alphaMap && material.alphaTest > 0 ) ||
|
|
248
|
+
( material.map && material.alphaTest > 0 ) ) {
|
|
248
249
|
|
|
249
250
|
// in this case we need a unique material instance reflecting the
|
|
250
251
|
// appropriate state
|
|
@@ -288,6 +289,7 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
288
289
|
|
|
289
290
|
result.alphaMap = material.alphaMap;
|
|
290
291
|
result.alphaTest = material.alphaTest;
|
|
292
|
+
result.map = material.map;
|
|
291
293
|
|
|
292
294
|
result.clipShadows = material.clipShadows;
|
|
293
295
|
result.clippingPlanes = material.clippingPlanes;
|
|
@@ -718,7 +718,7 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
718
718
|
}
|
|
719
719
|
|
|
720
720
|
currentBlending = blending;
|
|
721
|
-
currentPremultipledAlpha =
|
|
721
|
+
currentPremultipledAlpha = false;
|
|
722
722
|
|
|
723
723
|
}
|
|
724
724
|
|
|
@@ -952,6 +952,20 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
952
952
|
|
|
953
953
|
}
|
|
954
954
|
|
|
955
|
+
function compressedTexImage3D() {
|
|
956
|
+
|
|
957
|
+
try {
|
|
958
|
+
|
|
959
|
+
gl.compressedTexImage3D.apply( gl, arguments );
|
|
960
|
+
|
|
961
|
+
} catch ( error ) {
|
|
962
|
+
|
|
963
|
+
console.error( 'THREE.WebGLState:', error );
|
|
964
|
+
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
}
|
|
968
|
+
|
|
955
969
|
function texSubImage2D() {
|
|
956
970
|
|
|
957
971
|
try {
|
|
@@ -994,6 +1008,20 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
994
1008
|
|
|
995
1009
|
}
|
|
996
1010
|
|
|
1011
|
+
function compressedTexSubImage3D() {
|
|
1012
|
+
|
|
1013
|
+
try {
|
|
1014
|
+
|
|
1015
|
+
gl.compressedTexSubImage3D.apply( gl, arguments );
|
|
1016
|
+
|
|
1017
|
+
} catch ( error ) {
|
|
1018
|
+
|
|
1019
|
+
console.error( 'THREE.WebGLState:', error );
|
|
1020
|
+
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
}
|
|
1024
|
+
|
|
997
1025
|
function texStorage2D() {
|
|
998
1026
|
|
|
999
1027
|
try {
|
|
@@ -1239,6 +1267,7 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
1239
1267
|
bindTexture: bindTexture,
|
|
1240
1268
|
unbindTexture: unbindTexture,
|
|
1241
1269
|
compressedTexImage2D: compressedTexImage2D,
|
|
1270
|
+
compressedTexImage3D: compressedTexImage3D,
|
|
1242
1271
|
texImage2D: texImage2D,
|
|
1243
1272
|
texImage3D: texImage3D,
|
|
1244
1273
|
|
|
@@ -1250,6 +1279,7 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
1250
1279
|
texSubImage2D: texSubImage2D,
|
|
1251
1280
|
texSubImage3D: texSubImage3D,
|
|
1252
1281
|
compressedTexSubImage2D: compressedTexSubImage2D,
|
|
1282
|
+
compressedTexSubImage3D: compressedTexSubImage3D,
|
|
1253
1283
|
|
|
1254
1284
|
scissor: scissor,
|
|
1255
1285
|
viewport: viewport,
|
|
@@ -11,7 +11,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
11
11
|
const maxTextureSize = capabilities.maxTextureSize;
|
|
12
12
|
const maxSamples = capabilities.maxSamples;
|
|
13
13
|
const multisampledRTTExt = extensions.has( 'WEBGL_multisampled_render_to_texture' ) ? extensions.get( 'WEBGL_multisampled_render_to_texture' ) : null;
|
|
14
|
-
const supportsInvalidateFramebuffer = /OculusBrowser/g.test( navigator.userAgent );
|
|
14
|
+
const supportsInvalidateFramebuffer = typeof navigator === 'undefined' ? false : /OculusBrowser/g.test( navigator.userAgent );
|
|
15
15
|
|
|
16
16
|
const _videoTextures = new WeakMap();
|
|
17
17
|
let _canvas;
|
|
@@ -415,6 +415,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
415
415
|
|
|
416
416
|
array.push( texture.wrapS );
|
|
417
417
|
array.push( texture.wrapT );
|
|
418
|
+
array.push( texture.wrapR || 0 );
|
|
418
419
|
array.push( texture.magFilter );
|
|
419
420
|
array.push( texture.minFilter );
|
|
420
421
|
array.push( texture.anisotropy );
|
|
@@ -671,7 +672,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
671
672
|
|
|
672
673
|
let textureType = _gl.TEXTURE_2D;
|
|
673
674
|
|
|
674
|
-
if ( texture.isDataArrayTexture ) textureType = _gl.TEXTURE_2D_ARRAY;
|
|
675
|
+
if ( texture.isDataArrayTexture || texture.isCompressedArrayTexture ) textureType = _gl.TEXTURE_2D_ARRAY;
|
|
675
676
|
if ( texture.isData3DTexture ) textureType = _gl.TEXTURE_3D;
|
|
676
677
|
|
|
677
678
|
const forceUpload = initTexture( textureProperties, texture );
|
|
@@ -853,45 +854,97 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
853
854
|
|
|
854
855
|
} else if ( texture.isCompressedTexture ) {
|
|
855
856
|
|
|
856
|
-
if (
|
|
857
|
+
if ( texture.isCompressedArrayTexture ) {
|
|
857
858
|
|
|
858
|
-
|
|
859
|
+
if ( useTexStorage && allocateMemory ) {
|
|
859
860
|
|
|
860
|
-
|
|
861
|
+
state.texStorage3D( _gl.TEXTURE_2D_ARRAY, levels, glInternalFormat, mipmaps[ 0 ].width, mipmaps[ 0 ].height, image.depth );
|
|
861
862
|
|
|
862
|
-
|
|
863
|
+
}
|
|
863
864
|
|
|
864
|
-
|
|
865
|
+
for ( let i = 0, il = mipmaps.length; i < il; i ++ ) {
|
|
865
866
|
|
|
866
|
-
|
|
867
|
+
mipmap = mipmaps[ i ];
|
|
867
868
|
|
|
868
|
-
if (
|
|
869
|
+
if ( texture.format !== RGBAFormat ) {
|
|
869
870
|
|
|
870
|
-
if (
|
|
871
|
+
if ( glFormat !== null ) {
|
|
872
|
+
|
|
873
|
+
if ( useTexStorage ) {
|
|
874
|
+
|
|
875
|
+
state.compressedTexSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, 0, mipmap.width, mipmap.height, image.depth, glFormat, mipmap.data, 0, 0 );
|
|
871
876
|
|
|
872
|
-
|
|
877
|
+
} else {
|
|
878
|
+
|
|
879
|
+
state.compressedTexImage3D( _gl.TEXTURE_2D_ARRAY, i, glInternalFormat, mipmap.width, mipmap.height, image.depth, 0, mipmap.data, 0, 0 );
|
|
880
|
+
|
|
881
|
+
}
|
|
873
882
|
|
|
874
883
|
} else {
|
|
875
884
|
|
|
876
|
-
|
|
885
|
+
console.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()' );
|
|
877
886
|
|
|
878
887
|
}
|
|
879
888
|
|
|
880
889
|
} else {
|
|
881
890
|
|
|
882
|
-
|
|
891
|
+
if ( useTexStorage ) {
|
|
892
|
+
|
|
893
|
+
state.texSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, 0, mipmap.width, mipmap.height, image.depth, glFormat, glType, mipmap.data );
|
|
894
|
+
|
|
895
|
+
} else {
|
|
896
|
+
|
|
897
|
+
state.texImage3D( _gl.TEXTURE_2D_ARRAY, i, glInternalFormat, mipmap.width, mipmap.height, image.depth, 0, glFormat, glType, mipmap.data );
|
|
898
|
+
|
|
899
|
+
}
|
|
883
900
|
|
|
884
901
|
}
|
|
885
902
|
|
|
886
|
-
}
|
|
903
|
+
}
|
|
887
904
|
|
|
888
|
-
|
|
905
|
+
} else {
|
|
889
906
|
|
|
890
|
-
|
|
907
|
+
if ( useTexStorage && allocateMemory ) {
|
|
908
|
+
|
|
909
|
+
state.texStorage2D( _gl.TEXTURE_2D, levels, glInternalFormat, mipmaps[ 0 ].width, mipmaps[ 0 ].height );
|
|
910
|
+
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
for ( let i = 0, il = mipmaps.length; i < il; i ++ ) {
|
|
914
|
+
|
|
915
|
+
mipmap = mipmaps[ i ];
|
|
916
|
+
|
|
917
|
+
if ( texture.format !== RGBAFormat ) {
|
|
918
|
+
|
|
919
|
+
if ( glFormat !== null ) {
|
|
920
|
+
|
|
921
|
+
if ( useTexStorage ) {
|
|
922
|
+
|
|
923
|
+
state.compressedTexSubImage2D( _gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, mipmap.data );
|
|
924
|
+
|
|
925
|
+
} else {
|
|
926
|
+
|
|
927
|
+
state.compressedTexImage2D( _gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );
|
|
928
|
+
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
} else {
|
|
932
|
+
|
|
933
|
+
console.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()' );
|
|
934
|
+
|
|
935
|
+
}
|
|
891
936
|
|
|
892
937
|
} else {
|
|
893
938
|
|
|
894
|
-
|
|
939
|
+
if ( useTexStorage ) {
|
|
940
|
+
|
|
941
|
+
state.texSubImage2D( _gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data );
|
|
942
|
+
|
|
943
|
+
} else {
|
|
944
|
+
|
|
945
|
+
state.texImage2D( _gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );
|
|
946
|
+
|
|
947
|
+
}
|
|
895
948
|
|
|
896
949
|
}
|
|
897
950
|
|
|
@@ -1269,7 +1322,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1269
1322
|
|
|
1270
1323
|
multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, attachment, textureTarget, properties.get( texture ).__webglTexture, 0, getRenderTargetSamples( renderTarget ) );
|
|
1271
1324
|
|
|
1272
|
-
} else {
|
|
1325
|
+
} else if ( textureTarget === _gl.TEXTURE_2D || ( textureTarget >= _gl.TEXTURE_CUBE_MAP_POSITIVE_X && textureTarget <= _gl.TEXTURE_CUBE_MAP_NEGATIVE_Z ) ) { // see #24753
|
|
1273
1326
|
|
|
1274
1327
|
_gl.framebufferTexture2D( _gl.FRAMEBUFFER, attachment, textureTarget, properties.get( texture ).__webglTexture, 0 );
|
|
1275
1328
|
|
|
@@ -362,17 +362,32 @@ function setValueV1i( gl, v ) {
|
|
|
362
362
|
|
|
363
363
|
}
|
|
364
364
|
|
|
365
|
-
// Single integer / boolean vector (from flat array)
|
|
365
|
+
// Single integer / boolean vector (from flat array or THREE.VectorN)
|
|
366
366
|
|
|
367
367
|
function setValueV2i( gl, v ) {
|
|
368
368
|
|
|
369
369
|
const cache = this.cache;
|
|
370
370
|
|
|
371
|
-
if (
|
|
371
|
+
if ( v.x !== undefined ) {
|
|
372
372
|
|
|
373
|
-
|
|
373
|
+
if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y ) {
|
|
374
|
+
|
|
375
|
+
gl.uniform2i( this.addr, v.x, v.y );
|
|
376
|
+
|
|
377
|
+
cache[ 0 ] = v.x;
|
|
378
|
+
cache[ 1 ] = v.y;
|
|
374
379
|
|
|
375
|
-
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
} else {
|
|
383
|
+
|
|
384
|
+
if ( arraysEqual( cache, v ) ) return;
|
|
385
|
+
|
|
386
|
+
gl.uniform2iv( this.addr, v );
|
|
387
|
+
|
|
388
|
+
copyArray( cache, v );
|
|
389
|
+
|
|
390
|
+
}
|
|
376
391
|
|
|
377
392
|
}
|
|
378
393
|
|
|
@@ -380,11 +395,27 @@ function setValueV3i( gl, v ) {
|
|
|
380
395
|
|
|
381
396
|
const cache = this.cache;
|
|
382
397
|
|
|
383
|
-
if (
|
|
398
|
+
if ( v.x !== undefined ) {
|
|
384
399
|
|
|
385
|
-
|
|
400
|
+
if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z ) {
|
|
401
|
+
|
|
402
|
+
gl.uniform3i( this.addr, v.x, v.y, v.z );
|
|
403
|
+
|
|
404
|
+
cache[ 0 ] = v.x;
|
|
405
|
+
cache[ 1 ] = v.y;
|
|
406
|
+
cache[ 2 ] = v.z;
|
|
407
|
+
|
|
408
|
+
}
|
|
386
409
|
|
|
387
|
-
|
|
410
|
+
} else {
|
|
411
|
+
|
|
412
|
+
if ( arraysEqual( cache, v ) ) return;
|
|
413
|
+
|
|
414
|
+
gl.uniform3iv( this.addr, v );
|
|
415
|
+
|
|
416
|
+
copyArray( cache, v );
|
|
417
|
+
|
|
418
|
+
}
|
|
388
419
|
|
|
389
420
|
}
|
|
390
421
|
|
|
@@ -392,11 +423,28 @@ function setValueV4i( gl, v ) {
|
|
|
392
423
|
|
|
393
424
|
const cache = this.cache;
|
|
394
425
|
|
|
395
|
-
if (
|
|
426
|
+
if ( v.x !== undefined ) {
|
|
396
427
|
|
|
397
|
-
|
|
428
|
+
if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z || cache[ 3 ] !== v.w ) {
|
|
398
429
|
|
|
399
|
-
|
|
430
|
+
gl.uniform4i( this.addr, v.x, v.y, v.z, v.w );
|
|
431
|
+
|
|
432
|
+
cache[ 0 ] = v.x;
|
|
433
|
+
cache[ 1 ] = v.y;
|
|
434
|
+
cache[ 2 ] = v.z;
|
|
435
|
+
cache[ 3 ] = v.w;
|
|
436
|
+
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
} else {
|
|
440
|
+
|
|
441
|
+
if ( arraysEqual( cache, v ) ) return;
|
|
442
|
+
|
|
443
|
+
gl.uniform4iv( this.addr, v );
|
|
444
|
+
|
|
445
|
+
copyArray( cache, v );
|
|
446
|
+
|
|
447
|
+
}
|
|
400
448
|
|
|
401
449
|
}
|
|
402
450
|
|
|
@@ -414,17 +462,32 @@ function setValueV1ui( gl, v ) {
|
|
|
414
462
|
|
|
415
463
|
}
|
|
416
464
|
|
|
417
|
-
// Single unsigned integer vector (from flat array)
|
|
465
|
+
// Single unsigned integer vector (from flat array or THREE.VectorN)
|
|
418
466
|
|
|
419
467
|
function setValueV2ui( gl, v ) {
|
|
420
468
|
|
|
421
469
|
const cache = this.cache;
|
|
422
470
|
|
|
423
|
-
if (
|
|
471
|
+
if ( v.x !== undefined ) {
|
|
424
472
|
|
|
425
|
-
|
|
473
|
+
if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y ) {
|
|
474
|
+
|
|
475
|
+
gl.uniform2ui( this.addr, v.x, v.y );
|
|
476
|
+
|
|
477
|
+
cache[ 0 ] = v.x;
|
|
478
|
+
cache[ 1 ] = v.y;
|
|
426
479
|
|
|
427
|
-
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
} else {
|
|
483
|
+
|
|
484
|
+
if ( arraysEqual( cache, v ) ) return;
|
|
485
|
+
|
|
486
|
+
gl.uniform2uiv( this.addr, v );
|
|
487
|
+
|
|
488
|
+
copyArray( cache, v );
|
|
489
|
+
|
|
490
|
+
}
|
|
428
491
|
|
|
429
492
|
}
|
|
430
493
|
|
|
@@ -432,11 +495,27 @@ function setValueV3ui( gl, v ) {
|
|
|
432
495
|
|
|
433
496
|
const cache = this.cache;
|
|
434
497
|
|
|
435
|
-
if (
|
|
498
|
+
if ( v.x !== undefined ) {
|
|
436
499
|
|
|
437
|
-
|
|
500
|
+
if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z ) {
|
|
501
|
+
|
|
502
|
+
gl.uniform3ui( this.addr, v.x, v.y, v.z );
|
|
503
|
+
|
|
504
|
+
cache[ 0 ] = v.x;
|
|
505
|
+
cache[ 1 ] = v.y;
|
|
506
|
+
cache[ 2 ] = v.z;
|
|
507
|
+
|
|
508
|
+
}
|
|
438
509
|
|
|
439
|
-
|
|
510
|
+
} else {
|
|
511
|
+
|
|
512
|
+
if ( arraysEqual( cache, v ) ) return;
|
|
513
|
+
|
|
514
|
+
gl.uniform3uiv( this.addr, v );
|
|
515
|
+
|
|
516
|
+
copyArray( cache, v );
|
|
517
|
+
|
|
518
|
+
}
|
|
440
519
|
|
|
441
520
|
}
|
|
442
521
|
|
|
@@ -444,11 +523,28 @@ function setValueV4ui( gl, v ) {
|
|
|
444
523
|
|
|
445
524
|
const cache = this.cache;
|
|
446
525
|
|
|
447
|
-
if (
|
|
526
|
+
if ( v.x !== undefined ) {
|
|
448
527
|
|
|
449
|
-
|
|
528
|
+
if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z || cache[ 3 ] !== v.w ) {
|
|
450
529
|
|
|
451
|
-
|
|
530
|
+
gl.uniform4ui( this.addr, v.x, v.y, v.z, v.w );
|
|
531
|
+
|
|
532
|
+
cache[ 0 ] = v.x;
|
|
533
|
+
cache[ 1 ] = v.y;
|
|
534
|
+
cache[ 2 ] = v.z;
|
|
535
|
+
cache[ 3 ] = v.w;
|
|
536
|
+
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
} else {
|
|
540
|
+
|
|
541
|
+
if ( arraysEqual( cache, v ) ) return;
|
|
542
|
+
|
|
543
|
+
gl.uniform4uiv( this.addr, v );
|
|
544
|
+
|
|
545
|
+
copyArray( cache, v );
|
|
546
|
+
|
|
547
|
+
}
|
|
452
548
|
|
|
453
549
|
}
|
|
454
550
|
|
|
@@ -43,7 +43,6 @@ function WebGLUtils( gl, extensions, capabilities ) {
|
|
|
43
43
|
if ( p === LuminanceAlphaFormat ) return gl.LUMINANCE_ALPHA;
|
|
44
44
|
if ( p === DepthFormat ) return gl.DEPTH_COMPONENT;
|
|
45
45
|
if ( p === DepthStencilFormat ) return gl.DEPTH_STENCIL;
|
|
46
|
-
if ( p === RedFormat ) return gl.RED;
|
|
47
46
|
|
|
48
47
|
// @deprecated since r137
|
|
49
48
|
|
|
@@ -74,6 +73,7 @@ function WebGLUtils( gl, extensions, capabilities ) {
|
|
|
74
73
|
|
|
75
74
|
// WebGL2 formats.
|
|
76
75
|
|
|
76
|
+
if ( p === RedFormat ) return gl.RED;
|
|
77
77
|
if ( p === RedIntegerFormat ) return gl.RED_INTEGER;
|
|
78
78
|
if ( p === RGFormat ) return gl.RG;
|
|
79
79
|
if ( p === RGIntegerFormat ) return gl.RG_INTEGER;
|
|
@@ -90,6 +90,31 @@ class WebXRController {
|
|
|
90
90
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
connect( inputSource ) {
|
|
94
|
+
|
|
95
|
+
if ( inputSource && inputSource.hand ) {
|
|
96
|
+
|
|
97
|
+
const hand = this._hand;
|
|
98
|
+
|
|
99
|
+
if ( hand ) {
|
|
100
|
+
|
|
101
|
+
for ( const inputjoint of inputSource.hand.values() ) {
|
|
102
|
+
|
|
103
|
+
// Initialize hand with joints when connected
|
|
104
|
+
this._getHandJoint( hand, inputjoint );
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
this.dispatchEvent( { type: 'connected', data: inputSource } );
|
|
113
|
+
|
|
114
|
+
return this;
|
|
115
|
+
|
|
116
|
+
}
|
|
117
|
+
|
|
93
118
|
disconnect( inputSource ) {
|
|
94
119
|
|
|
95
120
|
this.dispatchEvent( { type: 'disconnected', data: inputSource } );
|
|
@@ -137,19 +162,8 @@ class WebXRController {
|
|
|
137
162
|
// Update the joints groups with the XRJoint poses
|
|
138
163
|
const jointPose = frame.getJointPose( inputjoint, referenceSpace );
|
|
139
164
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
// The transform of this joint will be updated with the joint pose on each frame
|
|
143
|
-
const joint = new Group();
|
|
144
|
-
joint.matrixAutoUpdate = false;
|
|
145
|
-
joint.visible = false;
|
|
146
|
-
hand.joints[ inputjoint.jointName ] = joint;
|
|
147
|
-
// ??
|
|
148
|
-
hand.add( joint );
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
const joint = hand.joints[ inputjoint.jointName ];
|
|
165
|
+
// The transform of this joint will be updated with the joint pose on each frame
|
|
166
|
+
const joint = this._getHandJoint( hand, inputjoint );
|
|
153
167
|
|
|
154
168
|
if ( jointPose !== null ) {
|
|
155
169
|
|
|
@@ -301,6 +315,25 @@ class WebXRController {
|
|
|
301
315
|
|
|
302
316
|
}
|
|
303
317
|
|
|
318
|
+
// private method
|
|
319
|
+
|
|
320
|
+
_getHandJoint( hand, inputjoint ) {
|
|
321
|
+
|
|
322
|
+
if ( hand.joints[ inputjoint.jointName ] === undefined ) {
|
|
323
|
+
|
|
324
|
+
const joint = new Group();
|
|
325
|
+
joint.matrixAutoUpdate = false;
|
|
326
|
+
joint.visible = false;
|
|
327
|
+
hand.joints[ inputjoint.jointName ] = joint;
|
|
328
|
+
|
|
329
|
+
hand.add( joint );
|
|
330
|
+
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
return hand.joints[ inputjoint.jointName ];
|
|
334
|
+
|
|
335
|
+
}
|
|
336
|
+
|
|
304
337
|
}
|
|
305
338
|
|
|
306
339
|
|