@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
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
FrontSide,
|
|
14
14
|
Group,
|
|
15
15
|
ImageBitmapLoader,
|
|
16
|
+
InstancedMesh,
|
|
16
17
|
InterleavedBuffer,
|
|
17
18
|
InterleavedBufferAttribute,
|
|
18
19
|
Interpolant,
|
|
@@ -53,7 +54,6 @@ import {
|
|
|
53
54
|
SkinnedMesh,
|
|
54
55
|
Sphere,
|
|
55
56
|
SpotLight,
|
|
56
|
-
TangentSpaceNormalMap,
|
|
57
57
|
Texture,
|
|
58
58
|
TextureLoader,
|
|
59
59
|
TriangleFanDrawMode,
|
|
@@ -149,6 +149,12 @@ class GLTFLoader extends Loader {
|
|
|
149
149
|
|
|
150
150
|
} );
|
|
151
151
|
|
|
152
|
+
this.register( function ( parser ) {
|
|
153
|
+
|
|
154
|
+
return new GLTFMeshGpuInstancing( parser );
|
|
155
|
+
|
|
156
|
+
} );
|
|
157
|
+
|
|
152
158
|
this.register( function ( parser ) {
|
|
153
159
|
|
|
154
160
|
return new GLTFAnimationPointerExtension( parser );
|
|
@@ -292,15 +298,15 @@ class GLTFLoader extends Loader {
|
|
|
292
298
|
|
|
293
299
|
parse( data, path, onLoad, onError ) {
|
|
294
300
|
|
|
295
|
-
let
|
|
301
|
+
let json;
|
|
296
302
|
const extensions = {};
|
|
297
303
|
const plugins = {};
|
|
298
304
|
|
|
299
305
|
if ( typeof data === 'string' ) {
|
|
300
306
|
|
|
301
|
-
|
|
307
|
+
json = JSON.parse( data );
|
|
302
308
|
|
|
303
|
-
} else {
|
|
309
|
+
} else if ( data instanceof ArrayBuffer ) {
|
|
304
310
|
|
|
305
311
|
const magic = LoaderUtils.decodeText( new Uint8Array( data, 0, 4 ) );
|
|
306
312
|
|
|
@@ -317,17 +323,19 @@ class GLTFLoader extends Loader {
|
|
|
317
323
|
|
|
318
324
|
}
|
|
319
325
|
|
|
320
|
-
|
|
326
|
+
json = JSON.parse( extensions[ EXTENSIONS.KHR_BINARY_GLTF ].content );
|
|
321
327
|
|
|
322
328
|
} else {
|
|
323
329
|
|
|
324
|
-
|
|
330
|
+
json = JSON.parse( LoaderUtils.decodeText( new Uint8Array( data ) ) );
|
|
325
331
|
|
|
326
332
|
}
|
|
327
333
|
|
|
328
|
-
}
|
|
334
|
+
} else {
|
|
329
335
|
|
|
330
|
-
|
|
336
|
+
json = data;
|
|
337
|
+
|
|
338
|
+
}
|
|
331
339
|
|
|
332
340
|
if ( json.asset === undefined || json.asset.version[ 0 ] < 2 ) {
|
|
333
341
|
|
|
@@ -376,10 +384,6 @@ class GLTFLoader extends Loader {
|
|
|
376
384
|
extensions[ extensionName ] = new GLTFMaterialsUnlitExtension();
|
|
377
385
|
break;
|
|
378
386
|
|
|
379
|
-
case EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:
|
|
380
|
-
extensions[ extensionName ] = new GLTFMaterialsPbrSpecularGlossinessExtension();
|
|
381
|
-
break;
|
|
382
|
-
|
|
383
387
|
case EXTENSIONS.KHR_DRACO_MESH_COMPRESSION:
|
|
384
388
|
extensions[ extensionName ] = new GLTFDracoMeshCompressionExtension( json, this.dracoLoader );
|
|
385
389
|
break;
|
|
@@ -472,7 +476,6 @@ const EXTENSIONS = {
|
|
|
472
476
|
KHR_LIGHTS_PUNCTUAL: 'KHR_lights_punctual',
|
|
473
477
|
KHR_MATERIALS_CLEARCOAT: 'KHR_materials_clearcoat',
|
|
474
478
|
KHR_MATERIALS_IOR: 'KHR_materials_ior',
|
|
475
|
-
KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS: 'KHR_materials_pbrSpecularGlossiness',
|
|
476
479
|
KHR_MATERIALS_SHEEN: 'KHR_materials_sheen',
|
|
477
480
|
KHR_MATERIALS_SPECULAR: 'KHR_materials_specular',
|
|
478
481
|
KHR_MATERIALS_TRANSMISSION: 'KHR_materials_transmission',
|
|
@@ -485,7 +488,8 @@ const EXTENSIONS = {
|
|
|
485
488
|
KHR_MATERIALS_EMISSIVE_STRENGTH: 'KHR_materials_emissive_strength',
|
|
486
489
|
KHR_ANIMATION_POINTER: 'KHR_animation_pointer',
|
|
487
490
|
EXT_TEXTURE_WEBP: 'EXT_texture_webp',
|
|
488
|
-
EXT_MESHOPT_COMPRESSION: 'EXT_meshopt_compression'
|
|
491
|
+
EXT_MESHOPT_COMPRESSION: 'EXT_meshopt_compression',
|
|
492
|
+
EXT_MESH_GPU_INSTANCING: 'EXT_mesh_gpu_instancing'
|
|
489
493
|
};
|
|
490
494
|
|
|
491
495
|
/**
|
|
@@ -583,6 +587,8 @@ class GLTFLightsExtension {
|
|
|
583
587
|
|
|
584
588
|
lightNode.decay = 2;
|
|
585
589
|
|
|
590
|
+
assignExtrasToUserData( lightNode, lightDef );
|
|
591
|
+
|
|
586
592
|
if ( lightDef.intensity !== undefined ) lightNode.intensity = lightDef.intensity;
|
|
587
593
|
|
|
588
594
|
lightNode.name = parser.createUniqueName( lightDef.name || ( 'light_' + lightIndex ) );
|
|
@@ -1214,12 +1220,6 @@ class GLTFAnimationPointerExtension {
|
|
|
1214
1220
|
|
|
1215
1221
|
return depPromise;
|
|
1216
1222
|
|
|
1217
|
-
}
|
|
1218
|
-
|
|
1219
|
-
getDependency( type, index ) {
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
1223
|
}
|
|
1224
1224
|
|
|
1225
1225
|
createAnimationTracks( node, inputAccessor, outputAccessor, sampler, target ) {
|
|
@@ -1963,6 +1963,160 @@ class GLTFMeshoptCompression {
|
|
|
1963
1963
|
|
|
1964
1964
|
}
|
|
1965
1965
|
|
|
1966
|
+
/**
|
|
1967
|
+
* GPU Instancing Extension
|
|
1968
|
+
*
|
|
1969
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_mesh_gpu_instancing
|
|
1970
|
+
*
|
|
1971
|
+
*/
|
|
1972
|
+
class GLTFMeshGpuInstancing {
|
|
1973
|
+
|
|
1974
|
+
constructor( parser ) {
|
|
1975
|
+
|
|
1976
|
+
this.name = EXTENSIONS.EXT_MESH_GPU_INSTANCING;
|
|
1977
|
+
this.parser = parser;
|
|
1978
|
+
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1981
|
+
createNodeMesh( nodeIndex ) {
|
|
1982
|
+
|
|
1983
|
+
const json = this.parser.json;
|
|
1984
|
+
const nodeDef = json.nodes[ nodeIndex ];
|
|
1985
|
+
|
|
1986
|
+
if ( ! nodeDef.extensions || ! nodeDef.extensions[ this.name ] ||
|
|
1987
|
+
nodeDef.mesh === undefined ) {
|
|
1988
|
+
|
|
1989
|
+
return null;
|
|
1990
|
+
|
|
1991
|
+
}
|
|
1992
|
+
|
|
1993
|
+
const meshDef = json.meshes[ nodeDef.mesh ];
|
|
1994
|
+
|
|
1995
|
+
// No Points or Lines + Instancing support yet
|
|
1996
|
+
|
|
1997
|
+
for ( const primitive of meshDef.primitives ) {
|
|
1998
|
+
|
|
1999
|
+
if ( primitive.mode !== WEBGL_CONSTANTS.TRIANGLES &&
|
|
2000
|
+
primitive.mode !== WEBGL_CONSTANTS.TRIANGLE_STRIP &&
|
|
2001
|
+
primitive.mode !== WEBGL_CONSTANTS.TRIANGLE_FAN &&
|
|
2002
|
+
primitive.mode !== undefined ) {
|
|
2003
|
+
|
|
2004
|
+
return null;
|
|
2005
|
+
|
|
2006
|
+
}
|
|
2007
|
+
|
|
2008
|
+
}
|
|
2009
|
+
|
|
2010
|
+
const extensionDef = nodeDef.extensions[ this.name ];
|
|
2011
|
+
const attributesDef = extensionDef.attributes;
|
|
2012
|
+
|
|
2013
|
+
// @TODO: Can we support InstancedMesh + SkinnedMesh?
|
|
2014
|
+
|
|
2015
|
+
const pending = [];
|
|
2016
|
+
const attributes = {};
|
|
2017
|
+
|
|
2018
|
+
for ( const key in attributesDef ) {
|
|
2019
|
+
|
|
2020
|
+
pending.push( this.parser.getDependency( 'accessor', attributesDef[ key ] ).then( accessor => {
|
|
2021
|
+
|
|
2022
|
+
attributes[ key ] = accessor;
|
|
2023
|
+
return attributes[ key ];
|
|
2024
|
+
|
|
2025
|
+
} ) );
|
|
2026
|
+
|
|
2027
|
+
}
|
|
2028
|
+
|
|
2029
|
+
if ( pending.length < 1 ) {
|
|
2030
|
+
|
|
2031
|
+
return null;
|
|
2032
|
+
|
|
2033
|
+
}
|
|
2034
|
+
|
|
2035
|
+
pending.push( this.parser.createNodeMesh( nodeIndex ) );
|
|
2036
|
+
|
|
2037
|
+
return Promise.all( pending ).then( results => {
|
|
2038
|
+
|
|
2039
|
+
const nodeObject = results.pop();
|
|
2040
|
+
const meshes = nodeObject.isGroup ? nodeObject.children : [ nodeObject ];
|
|
2041
|
+
const count = results[ 0 ].count; // All attribute counts should be same
|
|
2042
|
+
const instancedMeshes = [];
|
|
2043
|
+
|
|
2044
|
+
for ( const mesh of meshes ) {
|
|
2045
|
+
|
|
2046
|
+
// Temporal variables
|
|
2047
|
+
const m = new Matrix4();
|
|
2048
|
+
const p = new Vector3();
|
|
2049
|
+
const q = new Quaternion();
|
|
2050
|
+
const s = new Vector3( 1, 1, 1 );
|
|
2051
|
+
|
|
2052
|
+
const instancedMesh = new InstancedMesh( mesh.geometry, mesh.material, count );
|
|
2053
|
+
|
|
2054
|
+
for ( let i = 0; i < count; i ++ ) {
|
|
2055
|
+
|
|
2056
|
+
if ( attributes.TRANSLATION ) {
|
|
2057
|
+
|
|
2058
|
+
p.fromBufferAttribute( attributes.TRANSLATION, i );
|
|
2059
|
+
|
|
2060
|
+
}
|
|
2061
|
+
|
|
2062
|
+
if ( attributes.ROTATION ) {
|
|
2063
|
+
|
|
2064
|
+
q.fromBufferAttribute( attributes.ROTATION, i );
|
|
2065
|
+
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2068
|
+
if ( attributes.SCALE ) {
|
|
2069
|
+
|
|
2070
|
+
s.fromBufferAttribute( attributes.SCALE, i );
|
|
2071
|
+
|
|
2072
|
+
}
|
|
2073
|
+
|
|
2074
|
+
instancedMesh.setMatrixAt( i, m.compose( p, q, s ) );
|
|
2075
|
+
|
|
2076
|
+
}
|
|
2077
|
+
|
|
2078
|
+
// Add instance attributes to the geometry, excluding TRS.
|
|
2079
|
+
for ( const attributeName in attributes ) {
|
|
2080
|
+
|
|
2081
|
+
if ( attributeName !== 'TRANSLATION' &&
|
|
2082
|
+
attributeName !== 'ROTATION' &&
|
|
2083
|
+
attributeName !== 'SCALE' ) {
|
|
2084
|
+
|
|
2085
|
+
mesh.geometry.setAttribute( attributeName, attributes[ attributeName ] );
|
|
2086
|
+
|
|
2087
|
+
}
|
|
2088
|
+
|
|
2089
|
+
}
|
|
2090
|
+
|
|
2091
|
+
// Just in case
|
|
2092
|
+
Object3D.prototype.copy.call( instancedMesh, mesh );
|
|
2093
|
+
|
|
2094
|
+
// https://github.com/mrdoob/three.js/issues/18334
|
|
2095
|
+
instancedMesh.frustumCulled = false;
|
|
2096
|
+
this.parser.assignFinalMaterial( instancedMesh );
|
|
2097
|
+
|
|
2098
|
+
instancedMeshes.push( instancedMesh );
|
|
2099
|
+
|
|
2100
|
+
}
|
|
2101
|
+
|
|
2102
|
+
if ( nodeObject.isGroup ) {
|
|
2103
|
+
|
|
2104
|
+
nodeObject.clear();
|
|
2105
|
+
|
|
2106
|
+
nodeObject.add( ... instancedMeshes );
|
|
2107
|
+
|
|
2108
|
+
return nodeObject;
|
|
2109
|
+
|
|
2110
|
+
}
|
|
2111
|
+
|
|
2112
|
+
return instancedMeshes[ 0 ];
|
|
2113
|
+
|
|
2114
|
+
} );
|
|
2115
|
+
|
|
2116
|
+
}
|
|
2117
|
+
|
|
2118
|
+
}
|
|
2119
|
+
|
|
1966
2120
|
/* BINARY EXTENSION */
|
|
1967
2121
|
const BINARY_EXTENSION_HEADER_MAGIC = 'glTF';
|
|
1968
2122
|
const BINARY_EXTENSION_HEADER_LENGTH = 12;
|
|
@@ -2173,335 +2327,6 @@ class GLTFTextureTransformExtension {
|
|
|
2173
2327
|
|
|
2174
2328
|
}
|
|
2175
2329
|
|
|
2176
|
-
/**
|
|
2177
|
-
* Specular-Glossiness Extension
|
|
2178
|
-
*
|
|
2179
|
-
* Specification: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Archived/KHR_materials_pbrSpecularGlossiness
|
|
2180
|
-
*/
|
|
2181
|
-
|
|
2182
|
-
/**
|
|
2183
|
-
* A sub class of StandardMaterial with some of the functionality
|
|
2184
|
-
* changed via the `onBeforeCompile` callback
|
|
2185
|
-
* @pailhead
|
|
2186
|
-
*/
|
|
2187
|
-
class GLTFMeshStandardSGMaterial extends MeshStandardMaterial {
|
|
2188
|
-
|
|
2189
|
-
constructor( params ) {
|
|
2190
|
-
|
|
2191
|
-
super();
|
|
2192
|
-
|
|
2193
|
-
this.isGLTFSpecularGlossinessMaterial = true;
|
|
2194
|
-
|
|
2195
|
-
//various chunks that need replacing
|
|
2196
|
-
const specularMapParsFragmentChunk = [
|
|
2197
|
-
'#ifdef USE_SPECULARMAP',
|
|
2198
|
-
' uniform sampler2D specularMap;',
|
|
2199
|
-
'#endif'
|
|
2200
|
-
].join( '\n' );
|
|
2201
|
-
|
|
2202
|
-
const glossinessMapParsFragmentChunk = [
|
|
2203
|
-
'#ifdef USE_GLOSSINESSMAP',
|
|
2204
|
-
' uniform sampler2D glossinessMap;',
|
|
2205
|
-
'#endif'
|
|
2206
|
-
].join( '\n' );
|
|
2207
|
-
|
|
2208
|
-
const specularMapFragmentChunk = [
|
|
2209
|
-
'vec3 specularFactor = specular;',
|
|
2210
|
-
'#ifdef USE_SPECULARMAP',
|
|
2211
|
-
' vec4 texelSpecular = texture2D( specularMap, vUv );',
|
|
2212
|
-
' // reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture',
|
|
2213
|
-
' specularFactor *= texelSpecular.rgb;',
|
|
2214
|
-
'#endif'
|
|
2215
|
-
].join( '\n' );
|
|
2216
|
-
|
|
2217
|
-
const glossinessMapFragmentChunk = [
|
|
2218
|
-
'float glossinessFactor = glossiness;',
|
|
2219
|
-
'#ifdef USE_GLOSSINESSMAP',
|
|
2220
|
-
' vec4 texelGlossiness = texture2D( glossinessMap, vUv );',
|
|
2221
|
-
' // reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture',
|
|
2222
|
-
' glossinessFactor *= texelGlossiness.a;',
|
|
2223
|
-
'#endif'
|
|
2224
|
-
].join( '\n' );
|
|
2225
|
-
|
|
2226
|
-
const lightPhysicalFragmentChunk = [
|
|
2227
|
-
'PhysicalMaterial material;',
|
|
2228
|
-
'material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );',
|
|
2229
|
-
'vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );',
|
|
2230
|
-
'float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );',
|
|
2231
|
-
'material.roughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.',
|
|
2232
|
-
'material.roughness += geometryRoughness;',
|
|
2233
|
-
'material.roughness = min( material.roughness, 1.0 );',
|
|
2234
|
-
'material.specularColor = specularFactor;',
|
|
2235
|
-
].join( '\n' );
|
|
2236
|
-
|
|
2237
|
-
const uniforms = {
|
|
2238
|
-
specular: { value: new Color().setHex( 0xffffff ) },
|
|
2239
|
-
glossiness: { value: 1 },
|
|
2240
|
-
specularMap: { value: null },
|
|
2241
|
-
glossinessMap: { value: null }
|
|
2242
|
-
};
|
|
2243
|
-
|
|
2244
|
-
this._extraUniforms = uniforms;
|
|
2245
|
-
|
|
2246
|
-
this.onBeforeCompile = function ( shader ) {
|
|
2247
|
-
|
|
2248
|
-
for ( const uniformName in uniforms ) {
|
|
2249
|
-
|
|
2250
|
-
shader.uniforms[ uniformName ] = uniforms[ uniformName ];
|
|
2251
|
-
|
|
2252
|
-
}
|
|
2253
|
-
|
|
2254
|
-
shader.fragmentShader = shader.fragmentShader
|
|
2255
|
-
.replace( 'uniform float roughness;', 'uniform vec3 specular;' )
|
|
2256
|
-
.replace( 'uniform float metalness;', 'uniform float glossiness;' )
|
|
2257
|
-
.replace( '#include <roughnessmap_pars_fragment>', specularMapParsFragmentChunk )
|
|
2258
|
-
.replace( '#include <metalnessmap_pars_fragment>', glossinessMapParsFragmentChunk )
|
|
2259
|
-
.replace( '#include <roughnessmap_fragment>', specularMapFragmentChunk )
|
|
2260
|
-
.replace( '#include <metalnessmap_fragment>', glossinessMapFragmentChunk )
|
|
2261
|
-
.replace( '#include <lights_physical_fragment>', lightPhysicalFragmentChunk );
|
|
2262
|
-
|
|
2263
|
-
};
|
|
2264
|
-
|
|
2265
|
-
Object.defineProperties( this, {
|
|
2266
|
-
|
|
2267
|
-
specular: {
|
|
2268
|
-
get: function () {
|
|
2269
|
-
|
|
2270
|
-
return uniforms.specular.value;
|
|
2271
|
-
|
|
2272
|
-
},
|
|
2273
|
-
set: function ( v ) {
|
|
2274
|
-
|
|
2275
|
-
uniforms.specular.value = v;
|
|
2276
|
-
|
|
2277
|
-
}
|
|
2278
|
-
},
|
|
2279
|
-
|
|
2280
|
-
specularMap: {
|
|
2281
|
-
get: function () {
|
|
2282
|
-
|
|
2283
|
-
return uniforms.specularMap.value;
|
|
2284
|
-
|
|
2285
|
-
},
|
|
2286
|
-
set: function ( v ) {
|
|
2287
|
-
|
|
2288
|
-
uniforms.specularMap.value = v;
|
|
2289
|
-
|
|
2290
|
-
if ( v ) {
|
|
2291
|
-
|
|
2292
|
-
this.defines.USE_SPECULARMAP = ''; // USE_UV is set by the renderer for specular maps
|
|
2293
|
-
|
|
2294
|
-
} else {
|
|
2295
|
-
|
|
2296
|
-
delete this.defines.USE_SPECULARMAP;
|
|
2297
|
-
|
|
2298
|
-
}
|
|
2299
|
-
|
|
2300
|
-
}
|
|
2301
|
-
},
|
|
2302
|
-
|
|
2303
|
-
glossiness: {
|
|
2304
|
-
get: function () {
|
|
2305
|
-
|
|
2306
|
-
return uniforms.glossiness.value;
|
|
2307
|
-
|
|
2308
|
-
},
|
|
2309
|
-
set: function ( v ) {
|
|
2310
|
-
|
|
2311
|
-
uniforms.glossiness.value = v;
|
|
2312
|
-
|
|
2313
|
-
}
|
|
2314
|
-
},
|
|
2315
|
-
|
|
2316
|
-
glossinessMap: {
|
|
2317
|
-
get: function () {
|
|
2318
|
-
|
|
2319
|
-
return uniforms.glossinessMap.value;
|
|
2320
|
-
|
|
2321
|
-
},
|
|
2322
|
-
set: function ( v ) {
|
|
2323
|
-
|
|
2324
|
-
uniforms.glossinessMap.value = v;
|
|
2325
|
-
|
|
2326
|
-
if ( v ) {
|
|
2327
|
-
|
|
2328
|
-
this.defines.USE_GLOSSINESSMAP = '';
|
|
2329
|
-
this.defines.USE_UV = '';
|
|
2330
|
-
|
|
2331
|
-
} else {
|
|
2332
|
-
|
|
2333
|
-
delete this.defines.USE_GLOSSINESSMAP;
|
|
2334
|
-
delete this.defines.USE_UV;
|
|
2335
|
-
|
|
2336
|
-
}
|
|
2337
|
-
|
|
2338
|
-
}
|
|
2339
|
-
}
|
|
2340
|
-
|
|
2341
|
-
} );
|
|
2342
|
-
|
|
2343
|
-
delete this.metalness;
|
|
2344
|
-
delete this.roughness;
|
|
2345
|
-
delete this.metalnessMap;
|
|
2346
|
-
delete this.roughnessMap;
|
|
2347
|
-
|
|
2348
|
-
this.setValues( params );
|
|
2349
|
-
|
|
2350
|
-
}
|
|
2351
|
-
|
|
2352
|
-
copy( source ) {
|
|
2353
|
-
|
|
2354
|
-
super.copy( source );
|
|
2355
|
-
|
|
2356
|
-
this.specularMap = source.specularMap;
|
|
2357
|
-
this.specular.copy( source.specular );
|
|
2358
|
-
this.glossinessMap = source.glossinessMap;
|
|
2359
|
-
this.glossiness = source.glossiness;
|
|
2360
|
-
delete this.metalness;
|
|
2361
|
-
delete this.roughness;
|
|
2362
|
-
delete this.metalnessMap;
|
|
2363
|
-
delete this.roughnessMap;
|
|
2364
|
-
return this;
|
|
2365
|
-
|
|
2366
|
-
}
|
|
2367
|
-
|
|
2368
|
-
}
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
class GLTFMaterialsPbrSpecularGlossinessExtension {
|
|
2372
|
-
|
|
2373
|
-
constructor() {
|
|
2374
|
-
|
|
2375
|
-
this.name = EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS;
|
|
2376
|
-
|
|
2377
|
-
this.specularGlossinessParams = [
|
|
2378
|
-
'color',
|
|
2379
|
-
'map',
|
|
2380
|
-
'lightMap',
|
|
2381
|
-
'lightMapIntensity',
|
|
2382
|
-
'aoMap',
|
|
2383
|
-
'aoMapIntensity',
|
|
2384
|
-
'emissive',
|
|
2385
|
-
'emissiveIntensity',
|
|
2386
|
-
'emissiveMap',
|
|
2387
|
-
'bumpMap',
|
|
2388
|
-
'bumpScale',
|
|
2389
|
-
'normalMap',
|
|
2390
|
-
'normalMapType',
|
|
2391
|
-
'displacementMap',
|
|
2392
|
-
'displacementScale',
|
|
2393
|
-
'displacementBias',
|
|
2394
|
-
'specularMap',
|
|
2395
|
-
'specular',
|
|
2396
|
-
'glossinessMap',
|
|
2397
|
-
'glossiness',
|
|
2398
|
-
'alphaMap',
|
|
2399
|
-
'envMap',
|
|
2400
|
-
'envMapIntensity'
|
|
2401
|
-
];
|
|
2402
|
-
|
|
2403
|
-
}
|
|
2404
|
-
|
|
2405
|
-
getMaterialType() {
|
|
2406
|
-
|
|
2407
|
-
return GLTFMeshStandardSGMaterial;
|
|
2408
|
-
|
|
2409
|
-
}
|
|
2410
|
-
|
|
2411
|
-
extendParams( materialParams, materialDef, parser ) {
|
|
2412
|
-
|
|
2413
|
-
const pbrSpecularGlossiness = materialDef.extensions[ this.name ];
|
|
2414
|
-
|
|
2415
|
-
materialParams.color = new Color( 1.0, 1.0, 1.0 );
|
|
2416
|
-
materialParams.opacity = 1.0;
|
|
2417
|
-
|
|
2418
|
-
const pending = [];
|
|
2419
|
-
|
|
2420
|
-
if ( Array.isArray( pbrSpecularGlossiness.diffuseFactor ) ) {
|
|
2421
|
-
|
|
2422
|
-
const array = pbrSpecularGlossiness.diffuseFactor;
|
|
2423
|
-
|
|
2424
|
-
materialParams.color.fromArray( array );
|
|
2425
|
-
materialParams.opacity = array[ 3 ];
|
|
2426
|
-
|
|
2427
|
-
}
|
|
2428
|
-
|
|
2429
|
-
if ( pbrSpecularGlossiness.diffuseTexture !== undefined ) {
|
|
2430
|
-
|
|
2431
|
-
pending.push( parser.assignTexture( materialParams, 'map', pbrSpecularGlossiness.diffuseTexture, sRGBEncoding ) );
|
|
2432
|
-
|
|
2433
|
-
}
|
|
2434
|
-
|
|
2435
|
-
materialParams.emissive = new Color( 0.0, 0.0, 0.0 );
|
|
2436
|
-
materialParams.glossiness = pbrSpecularGlossiness.glossinessFactor !== undefined ? pbrSpecularGlossiness.glossinessFactor : 1.0;
|
|
2437
|
-
materialParams.specular = new Color( 1.0, 1.0, 1.0 );
|
|
2438
|
-
|
|
2439
|
-
if ( Array.isArray( pbrSpecularGlossiness.specularFactor ) ) {
|
|
2440
|
-
|
|
2441
|
-
materialParams.specular.fromArray( pbrSpecularGlossiness.specularFactor );
|
|
2442
|
-
|
|
2443
|
-
}
|
|
2444
|
-
|
|
2445
|
-
if ( pbrSpecularGlossiness.specularGlossinessTexture !== undefined ) {
|
|
2446
|
-
|
|
2447
|
-
const specGlossMapDef = pbrSpecularGlossiness.specularGlossinessTexture;
|
|
2448
|
-
pending.push( parser.assignTexture( materialParams, 'glossinessMap', specGlossMapDef ) );
|
|
2449
|
-
pending.push( parser.assignTexture( materialParams, 'specularMap', specGlossMapDef, sRGBEncoding ) );
|
|
2450
|
-
|
|
2451
|
-
}
|
|
2452
|
-
|
|
2453
|
-
return Promise.all( pending );
|
|
2454
|
-
|
|
2455
|
-
}
|
|
2456
|
-
|
|
2457
|
-
createMaterial( materialParams ) {
|
|
2458
|
-
|
|
2459
|
-
const material = new GLTFMeshStandardSGMaterial( materialParams );
|
|
2460
|
-
material.fog = true;
|
|
2461
|
-
|
|
2462
|
-
material.color = materialParams.color;
|
|
2463
|
-
|
|
2464
|
-
material.map = materialParams.map === undefined ? null : materialParams.map;
|
|
2465
|
-
|
|
2466
|
-
material.lightMap = null;
|
|
2467
|
-
material.lightMapIntensity = 1.0;
|
|
2468
|
-
|
|
2469
|
-
material.aoMap = materialParams.aoMap === undefined ? null : materialParams.aoMap;
|
|
2470
|
-
material.aoMapIntensity = 1.0;
|
|
2471
|
-
|
|
2472
|
-
material.emissive = materialParams.emissive;
|
|
2473
|
-
material.emissiveIntensity = materialParams.emissiveIntensity === undefined ? 1.0 : materialParams.emissiveIntensity;
|
|
2474
|
-
material.emissiveMap = materialParams.emissiveMap === undefined ? null : materialParams.emissiveMap;
|
|
2475
|
-
|
|
2476
|
-
material.bumpMap = materialParams.bumpMap === undefined ? null : materialParams.bumpMap;
|
|
2477
|
-
material.bumpScale = 1;
|
|
2478
|
-
|
|
2479
|
-
material.normalMap = materialParams.normalMap === undefined ? null : materialParams.normalMap;
|
|
2480
|
-
material.normalMapType = TangentSpaceNormalMap;
|
|
2481
|
-
|
|
2482
|
-
if ( materialParams.normalScale ) material.normalScale = materialParams.normalScale;
|
|
2483
|
-
|
|
2484
|
-
material.displacementMap = null;
|
|
2485
|
-
material.displacementScale = 1;
|
|
2486
|
-
material.displacementBias = 0;
|
|
2487
|
-
|
|
2488
|
-
material.specularMap = materialParams.specularMap === undefined ? null : materialParams.specularMap;
|
|
2489
|
-
material.specular = materialParams.specular;
|
|
2490
|
-
|
|
2491
|
-
material.glossinessMap = materialParams.glossinessMap === undefined ? null : materialParams.glossinessMap;
|
|
2492
|
-
material.glossiness = materialParams.glossiness;
|
|
2493
|
-
|
|
2494
|
-
material.alphaMap = null;
|
|
2495
|
-
|
|
2496
|
-
material.envMap = materialParams.envMap === undefined ? null : materialParams.envMap;
|
|
2497
|
-
material.envMapIntensity = 1.0;
|
|
2498
|
-
|
|
2499
|
-
return material;
|
|
2500
|
-
|
|
2501
|
-
}
|
|
2502
|
-
|
|
2503
|
-
}
|
|
2504
|
-
|
|
2505
2330
|
/**
|
|
2506
2331
|
* Mesh Quantization Extension
|
|
2507
2332
|
*
|
|
@@ -3044,10 +2869,18 @@ class GLTFParser {
|
|
|
3044
2869
|
|
|
3045
2870
|
// Use an ImageBitmapLoader if imageBitmaps are supported. Moves much of the
|
|
3046
2871
|
// expensive work of uploading a texture to the GPU off the main thread.
|
|
2872
|
+
|
|
2873
|
+
let isSafari = false;
|
|
2874
|
+
let isFirefox = false;
|
|
2875
|
+
let firefoxVersion = - 1;
|
|
2876
|
+
|
|
2877
|
+
if ( typeof navigator !== 'undefined' ) {
|
|
2878
|
+
|
|
2879
|
+
isSafari = /^((?!chrome|android).)*safari/i.test( navigator.userAgent ) === true;
|
|
2880
|
+
isFirefox = navigator.userAgent.indexOf( 'Firefox' ) > - 1;
|
|
2881
|
+
firefoxVersion = isFirefox ? navigator.userAgent.match( /Firefox\/([0-9]+)\./ )[ 1 ] : - 1;
|
|
3047
2882
|
|
|
3048
|
-
|
|
3049
|
-
const isFirefox = navigator.userAgent.indexOf( 'Firefox' ) > - 1;
|
|
3050
|
-
const firefoxVersion = isFirefox ? navigator.userAgent.match( /Firefox\/([0-9]+)\./ )[ 1 ] : - 1;
|
|
2883
|
+
}
|
|
3051
2884
|
|
|
3052
2885
|
if ( typeof createImageBitmap === 'undefined' || isSafari || ( isFirefox && firefoxVersion < 98 ) ) {
|
|
3053
2886
|
|
|
@@ -3371,6 +3204,14 @@ class GLTFParser {
|
|
|
3371
3204
|
dependency = this.loadCamera( index );
|
|
3372
3205
|
break;
|
|
3373
3206
|
|
|
3207
|
+
case 'light':
|
|
3208
|
+
dependency = this._invokeOne( function ( ext ) {
|
|
3209
|
+
|
|
3210
|
+
return ext._loadLight && ext._loadLight( index );
|
|
3211
|
+
|
|
3212
|
+
} );
|
|
3213
|
+
break;
|
|
3214
|
+
|
|
3374
3215
|
default:
|
|
3375
3216
|
dependency = this._invokeOne( function ( ext ) {
|
|
3376
3217
|
|
|
@@ -3494,10 +3335,12 @@ class GLTFParser {
|
|
|
3494
3335
|
|
|
3495
3336
|
if ( accessorDef.bufferView === undefined && accessorDef.sparse === undefined ) {
|
|
3496
3337
|
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3338
|
+
const itemSize = WEBGL_TYPE_SIZES[ accessorDef.type ];
|
|
3339
|
+
const TypedArray = WEBGL_COMPONENT_TYPES[ accessorDef.componentType ];
|
|
3340
|
+
const normalized = accessorDef.normalized === true;
|
|
3341
|
+
|
|
3342
|
+
const array = new TypedArray( accessorDef.count * itemSize );
|
|
3343
|
+
return Promise.resolve( new BufferAttribute( array, itemSize, normalized ) );
|
|
3501
3344
|
|
|
3502
3345
|
}
|
|
3503
3346
|
|
|
@@ -3659,7 +3502,7 @@ class GLTFParser {
|
|
|
3659
3502
|
|
|
3660
3503
|
texture.flipY = false;
|
|
3661
3504
|
|
|
3662
|
-
|
|
3505
|
+
texture.name = textureDef.name || sourceDef.name || '';
|
|
3663
3506
|
|
|
3664
3507
|
const samplers = json.samplers || {};
|
|
3665
3508
|
const sampler = samplers[ textureDef.sampler ] || {};
|
|
@@ -3668,6 +3511,7 @@ class GLTFParser {
|
|
|
3668
3511
|
texture.minFilter = WEBGL_FILTERS[ sampler.minFilter ] || LinearMipmapLinearFilter;
|
|
3669
3512
|
texture.wrapS = WEBGL_WRAPPINGS[ sampler.wrapS ] || RepeatWrapping;
|
|
3670
3513
|
texture.wrapT = WEBGL_WRAPPINGS[ sampler.wrapT ] || RepeatWrapping;
|
|
3514
|
+
texture.anisotropy = 4;
|
|
3671
3515
|
|
|
3672
3516
|
parser.associations.set( texture, { textures: textureIndex } );
|
|
3673
3517
|
|
|
@@ -3807,7 +3651,7 @@ class GLTFParser {
|
|
|
3807
3651
|
|
|
3808
3652
|
}
|
|
3809
3653
|
|
|
3810
|
-
if ( encoding !== undefined ) {
|
|
3654
|
+
if ( encoding !== undefined && texture ) {
|
|
3811
3655
|
|
|
3812
3656
|
texture.encoding = encoding;
|
|
3813
3657
|
|
|
@@ -3883,7 +3727,6 @@ class GLTFParser {
|
|
|
3883
3727
|
|
|
3884
3728
|
let cacheKey = 'ClonedMaterial:' + material.uuid + ':';
|
|
3885
3729
|
|
|
3886
|
-
if ( material.isGLTFSpecularGlossinessMaterial ) cacheKey += 'specular-glossiness:';
|
|
3887
3730
|
if ( useDerivativeTangents ) cacheKey += 'derivative-tangents:';
|
|
3888
3731
|
if ( useVertexColors ) cacheKey += 'vertex-colors:';
|
|
3889
3732
|
if ( useFlatShading ) cacheKey += 'flat-shading:';
|
|
@@ -3951,13 +3794,7 @@ class GLTFParser {
|
|
|
3951
3794
|
|
|
3952
3795
|
const pending = [];
|
|
3953
3796
|
|
|
3954
|
-
if ( materialExtensions[ EXTENSIONS.
|
|
3955
|
-
|
|
3956
|
-
const sgExtension = extensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ];
|
|
3957
|
-
materialType = sgExtension.getMaterialType();
|
|
3958
|
-
pending.push( sgExtension.extendParams( materialParams, materialDef, parser ) );
|
|
3959
|
-
|
|
3960
|
-
} else if ( materialExtensions[ EXTENSIONS.KHR_MATERIALS_UNLIT ] ) {
|
|
3797
|
+
if ( materialExtensions[ EXTENSIONS.KHR_MATERIALS_UNLIT ] ) {
|
|
3961
3798
|
|
|
3962
3799
|
const kmuExtension = extensions[ EXTENSIONS.KHR_MATERIALS_UNLIT ];
|
|
3963
3800
|
materialType = kmuExtension.getMaterialType();
|
|
@@ -4081,17 +3918,7 @@ class GLTFParser {
|
|
|
4081
3918
|
|
|
4082
3919
|
return Promise.all( pending ).then( function () {
|
|
4083
3920
|
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
if ( materialType === GLTFMeshStandardSGMaterial ) {
|
|
4087
|
-
|
|
4088
|
-
material = extensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ].createMaterial( materialParams );
|
|
4089
|
-
|
|
4090
|
-
} else {
|
|
4091
|
-
|
|
4092
|
-
material = new materialType( materialParams );
|
|
4093
|
-
|
|
4094
|
-
}
|
|
3921
|
+
const material = new materialType( materialParams );
|
|
4095
3922
|
|
|
4096
3923
|
if ( materialDef.name ) material.name = materialDef.name;
|
|
4097
3924
|
|