super-three 0.141.0 → 0.144.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/build/three.cjs +1558 -1034
- package/build/three.js +1558 -1034
- package/build/three.min.js +1 -1
- package/build/three.module.js +2012 -1243
- package/examples/js/animation/MMDPhysics.js +1 -16
- package/examples/js/controls/ArcballControls.js +16 -3
- package/examples/js/controls/FirstPersonControls.js +0 -7
- package/examples/js/controls/FlyControls.js +0 -8
- package/examples/js/controls/OrbitControls.js +0 -4
- package/examples/js/controls/PointerLockControls.js +0 -8
- package/examples/js/controls/TrackballControls.js +0 -2
- package/examples/js/controls/TransformControls.js +20 -16
- package/examples/js/effects/AnaglyphEffect.js +2 -2
- package/examples/js/effects/OutlineEffect.js +4 -24
- package/examples/js/effects/ParallaxBarrierEffect.js +2 -2
- package/examples/js/effects/PeppersGhostEffect.js +2 -2
- package/examples/js/effects/StereoEffect.js +2 -2
- package/examples/js/environments/RoomEnvironment.js +22 -0
- package/examples/js/exporters/ColladaExporter.js +4 -13
- package/examples/js/exporters/DRACOExporter.js +0 -12
- package/examples/js/exporters/GLTFExporter.js +28 -29
- package/examples/js/exporters/OBJExporter.js +2 -23
- package/examples/js/exporters/PLYExporter.js +12 -24
- package/examples/js/exporters/STLExporter.js +0 -7
- package/examples/js/exporters/USDZExporter.js +6 -0
- package/examples/js/geometries/ConvexGeometry.js +1 -1
- package/examples/js/geometries/ParametricGeometry.js +1 -8
- package/examples/js/interactive/SelectionHelper.js +2 -0
- package/examples/js/libs/ktx-parse.umd.js +1 -0
- package/examples/js/libs/meshopt_decoder.js +98 -32
- package/examples/js/loaders/ColladaLoader.js +1 -0
- package/examples/js/loaders/DRACOLoader.js +2 -25
- package/examples/js/loaders/EXRLoader.js +2 -13
- package/examples/js/loaders/FBXLoader.js +10 -3
- package/examples/js/loaders/FontLoader.js +3 -16
- package/examples/js/loaders/GLTFLoader.js +52 -36
- package/examples/js/loaders/HDRCubeTextureLoader.js +0 -11
- package/examples/js/loaders/LDrawLoader.js +139 -74
- package/examples/js/loaders/OBJLoader.js +7 -13
- package/examples/js/loaders/PCDLoader.js +59 -14
- package/examples/js/loaders/PLYLoader.js +3 -3
- package/examples/js/loaders/SVGLoader.js +4 -3
- package/examples/js/loaders/TIFFLoader.js +31 -0
- package/examples/js/loaders/VRMLLoader.js +33 -24
- package/examples/js/loaders/VTKLoader.js +1 -1
- package/examples/js/loaders/lwo/LWO2Parser.js +8 -7
- package/examples/js/loaders/lwo/LWO3Parser.js +8 -7
- package/examples/js/materials/MeshGouraudMaterial.js +385 -0
- package/examples/js/math/ColorConverter.js +0 -50
- package/examples/js/misc/GPUComputationRenderer.js +23 -0
- package/examples/js/misc/Volume.js +198 -190
- package/examples/js/misc/VolumeSlice.js +90 -88
- package/examples/js/modifiers/SimplifyModifier.js +1 -1
- package/examples/js/objects/GroundProjectedEnv.js +193 -0
- package/examples/js/objects/Reflector.js +9 -2
- package/examples/js/objects/ReflectorForSSRPass.js +3 -4
- package/examples/js/objects/Refractor.js +10 -4
- package/examples/js/objects/ShadowMesh.js +5 -1
- package/examples/js/postprocessing/OutlinePass.js +5 -3
- package/examples/js/renderers/CSS2DRenderer.js +2 -2
- package/examples/js/renderers/CSS3DRenderer.js +2 -2
- package/examples/js/renderers/Projector.js +2 -23
- package/examples/js/shaders/LuminosityShader.js +1 -1
- package/examples/js/shaders/MMDToonShader.js +6 -2
- package/examples/js/shaders/ToneMapShader.js +1 -1
- package/examples/js/utils/BufferGeometryUtils.js +1 -1
- package/examples/js/utils/GeometryUtils.js +2 -18
- package/examples/js/utils/PackedPhongMaterial.js +1 -1
- package/examples/js/utils/SceneUtils.js +0 -16
- package/examples/jsm/animation/MMDPhysics.js +3 -22
- package/examples/jsm/controls/ArcballControls.js +17 -2
- package/examples/jsm/controls/FirstPersonControls.js +0 -7
- package/examples/jsm/controls/FlyControls.js +0 -7
- package/examples/jsm/controls/OrbitControls.js +0 -5
- package/examples/jsm/controls/PointerLockControls.js +0 -7
- package/examples/jsm/controls/TrackballControls.js +0 -3
- package/examples/jsm/controls/TransformControls.js +18 -16
- package/examples/jsm/effects/AnaglyphEffect.js +2 -2
- package/examples/jsm/effects/OutlineEffect.js +4 -25
- package/examples/jsm/effects/ParallaxBarrierEffect.js +2 -2
- package/examples/jsm/effects/PeppersGhostEffect.js +2 -2
- package/examples/jsm/effects/StereoEffect.js +2 -2
- package/examples/jsm/environments/RoomEnvironment.js +23 -0
- package/examples/jsm/exporters/ColladaExporter.js +4 -13
- package/examples/jsm/exporters/DRACOExporter.js +0 -13
- package/examples/jsm/exporters/GLTFExporter.js +29 -31
- package/examples/jsm/exporters/KTX2Exporter.js +29 -29
- package/examples/jsm/exporters/OBJExporter.js +0 -18
- package/examples/jsm/exporters/PLYExporter.js +14 -22
- package/examples/jsm/exporters/STLExporter.js +1 -9
- package/examples/jsm/exporters/USDZExporter.js +14 -3
- package/examples/jsm/geometries/ConvexGeometry.js +1 -1
- package/examples/jsm/geometries/ParametricGeometry.js +0 -6
- package/examples/jsm/interactive/HTMLMesh.js +9 -9
- package/examples/jsm/interactive/SelectionHelper.js +5 -3
- package/examples/jsm/libs/meshopt_decoder.module.js +97 -32
- package/examples/jsm/libs/utif.module.js +1579 -0
- package/examples/jsm/libs/zstddec.module.js +1 -0
- package/examples/jsm/loaders/ColladaLoader.js +1 -0
- package/examples/jsm/loaders/DRACOLoader.js +2 -28
- package/examples/jsm/loaders/EXRLoader.js +3 -13
- package/examples/jsm/loaders/FBXLoader.js +10 -3
- package/examples/jsm/loaders/FontLoader.js +3 -16
- package/examples/jsm/loaders/GLTFLoader.js +52 -36
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +0 -13
- package/examples/jsm/loaders/KTX2Loader.js +192 -30
- package/examples/jsm/loaders/LDrawLoader.js +135 -74
- package/examples/jsm/loaders/OBJLoader.js +6 -14
- package/examples/jsm/loaders/PCDLoader.js +59 -13
- package/examples/jsm/loaders/PLYLoader.js +3 -3
- package/examples/jsm/loaders/RGBELoader.js +1 -1
- package/examples/jsm/loaders/SVGLoader.js +4 -3
- package/examples/jsm/loaders/TIFFLoader.js +36 -0
- package/examples/jsm/loaders/USDZLoader.js +393 -0
- package/examples/jsm/loaders/VRMLLoader.js +23 -25
- package/examples/jsm/loaders/VTKLoader.js +1 -1
- package/examples/jsm/loaders/lwo/LWO2Parser.js +6 -8
- package/examples/jsm/loaders/lwo/LWO3Parser.js +6 -8
- package/examples/jsm/materials/MeshGouraudMaterial.js +423 -0
- package/examples/jsm/math/ColorConverter.js +1 -49
- package/examples/jsm/misc/GPUComputationRenderer.js +43 -0
- package/examples/jsm/misc/Volume.js +169 -171
- package/examples/jsm/misc/VolumeSlice.js +78 -80
- package/examples/jsm/modifiers/SimplifyModifier.js +1 -1
- package/examples/jsm/node-editor/accessors/MatcapUVEditor.js +1 -1
- package/examples/jsm/node-editor/accessors/NormalEditor.js +1 -1
- package/examples/jsm/node-editor/accessors/PositionEditor.js +1 -1
- package/examples/jsm/node-editor/accessors/UVEditor.js +1 -1
- package/examples/jsm/node-editor/display/BlendEditor.js +1 -1
- package/examples/jsm/node-editor/display/NormalMapEditor.js +1 -1
- package/examples/jsm/node-editor/inputs/ColorEditor.js +1 -1
- package/examples/jsm/node-editor/inputs/FloatEditor.js +1 -1
- package/examples/jsm/node-editor/inputs/SliderEditor.js +1 -1
- package/examples/jsm/node-editor/inputs/TextureEditor.js +1 -1
- package/examples/jsm/node-editor/inputs/Vector2Editor.js +1 -1
- package/examples/jsm/node-editor/inputs/Vector3Editor.js +1 -1
- package/examples/jsm/node-editor/inputs/Vector4Editor.js +1 -1
- package/examples/jsm/node-editor/materials/BasicMaterialEditor.js +1 -1
- package/examples/jsm/node-editor/materials/PointsMaterialEditor.js +1 -1
- package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +1 -1
- package/examples/jsm/node-editor/math/AngleEditor.js +1 -1
- package/examples/jsm/node-editor/math/DotEditor.js +1 -1
- package/examples/jsm/node-editor/math/InvertEditor.js +1 -1
- package/examples/jsm/node-editor/math/LimiterEditor.js +1 -1
- package/examples/jsm/node-editor/math/NormalizeEditor.js +1 -1
- package/examples/jsm/node-editor/math/OperatorEditor.js +1 -1
- package/examples/jsm/node-editor/math/PowerEditor.js +1 -1
- package/examples/jsm/node-editor/math/TrigonometryEditor.js +1 -1
- package/examples/jsm/node-editor/procedural/CheckerEditor.js +1 -1
- package/examples/jsm/node-editor/utils/JoinEditor.js +1 -1
- package/examples/jsm/node-editor/utils/OscillatorEditor.js +1 -1
- package/examples/jsm/node-editor/utils/PreviewEditor.js +3 -3
- package/examples/jsm/node-editor/utils/SplitEditor.js +1 -1
- package/examples/jsm/node-editor/utils/TimerEditor.js +1 -1
- package/examples/jsm/nodes/Nodes.js +43 -13
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +9 -5
- package/examples/jsm/nodes/accessors/NormalNode.js +4 -4
- package/examples/jsm/nodes/accessors/PositionNode.js +5 -5
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +31 -0
- package/examples/jsm/nodes/core/AttributeNode.js +3 -3
- package/examples/jsm/nodes/core/CodeNode.js +3 -3
- package/examples/jsm/nodes/core/FunctionCallNode.js +20 -5
- package/examples/jsm/nodes/core/FunctionNode.js +2 -2
- package/examples/jsm/nodes/core/Node.js +14 -12
- package/examples/jsm/nodes/core/NodeBuilder.js +12 -12
- package/examples/jsm/nodes/core/NodeUtils.js +23 -1
- package/examples/jsm/nodes/core/{NodeVary.js → NodeVarying.js} +3 -3
- package/examples/jsm/nodes/core/{VaryNode.js → VaryingNode.js} +7 -7
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +94 -0
- package/examples/jsm/nodes/geometry/RangeNode.js +109 -0
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +2 -0
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +8 -7
- package/examples/jsm/nodes/lighting/LightingContextNode.js +4 -4
- package/examples/jsm/nodes/loaders/NodeLoader.js +2 -2
- package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +31 -0
- package/examples/jsm/nodes/materials/Materials.js +13 -25
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +70 -0
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +4 -7
- package/examples/jsm/nodes/materials/NodeMaterial.js +2 -2
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +28 -17
- package/examples/jsm/nodes/materialx/Disclaimer.md +199 -0
- package/examples/jsm/nodes/materialx/functions/lib/mx_hsv.js +56 -0
- package/examples/jsm/nodes/materialx/functions/lib/mx_noise.js +607 -0
- package/examples/jsm/nodes/math/MathNode.js +2 -12
- package/examples/jsm/nodes/parsers/GLSLNodeFunction.js +21 -6
- package/examples/jsm/nodes/procedural/CheckerNode.js +2 -2
- package/examples/jsm/nodes/shadernode/ShaderNode.js +5 -5
- package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +8 -5
- package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +20 -6
- package/examples/jsm/nodes/utils/ConvertNode.js +8 -3
- package/examples/jsm/nodes/utils/JoinNode.js +7 -7
- package/examples/jsm/nodes/utils/MaxMipLevelNode.js +2 -1
- package/examples/jsm/nodes/utils/RotateUVNode.js +32 -0
- package/examples/jsm/nodes/utils/SplitNode.js +21 -5
- package/examples/jsm/nodes/utils/TimerNode.js +2 -2
- package/examples/jsm/objects/GroundProjectedEnv.js +186 -0
- package/examples/jsm/objects/Reflector.js +12 -5
- package/examples/jsm/objects/ReflectorForSSRPass.js +3 -5
- package/examples/jsm/objects/Refractor.js +12 -6
- package/examples/jsm/objects/ShadowMesh.js +8 -2
- package/examples/jsm/postprocessing/OutlinePass.js +5 -3
- package/examples/jsm/renderers/CSS2DRenderer.js +2 -2
- package/examples/jsm/renderers/CSS3DRenderer.js +2 -2
- package/examples/jsm/renderers/Projector.js +2 -24
- package/examples/jsm/renderers/webgl/nodes/SlotNode.js +9 -5
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +329 -218
- package/examples/jsm/renderers/webgl/nodes/WebGLNodes.js +7 -3
- package/examples/jsm/renderers/webgpu/WebGPUBackground.js +39 -3
- package/examples/jsm/renderers/webgpu/WebGPUComputePipelines.js +6 -0
- package/examples/jsm/renderers/webgpu/WebGPUGeometries.js +6 -0
- package/examples/jsm/renderers/webgpu/WebGPUObjects.js +1 -1
- package/examples/jsm/renderers/webgpu/WebGPURenderPipeline.js +17 -19
- package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +16 -14
- package/examples/jsm/renderers/webgpu/WebGPURenderStates.js +2 -2
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +66 -81
- package/examples/jsm/renderers/webgpu/WebGPUTextureUtils.js +5 -3
- package/examples/jsm/renderers/webgpu/WebGPUTextures.js +2 -2
- package/examples/jsm/renderers/webgpu/WebGPUUtils.js +81 -0
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +25 -30
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodes.js +1 -1
- package/examples/jsm/shaders/LuminosityShader.js +1 -1
- package/examples/jsm/shaders/MMDToonShader.js +2 -2
- package/examples/jsm/shaders/ToneMapShader.js +1 -1
- package/examples/jsm/utils/BufferGeometryUtils.js +2 -1
- package/examples/jsm/utils/GeometryUtils.js +17 -25
- package/examples/jsm/utils/PackedPhongMaterial.js +0 -1
- package/examples/jsm/utils/SceneUtils.js +1 -21
- package/examples/jsm/webxr/OculusHandPointerModel.js +6 -1
- package/examples/jsm/webxr/VRButton.js +1 -7
- package/package.json +18 -14
- package/src/Three.Legacy.js +262 -36
- package/src/Three.js +3 -2
- package/src/animation/AnimationAction.js +6 -5
- package/src/animation/AnimationClip.js +1 -1
- package/src/animation/AnimationMixer.js +1 -1
- package/src/animation/AnimationUtils.js +204 -199
- package/src/animation/KeyframeTrack.js +1 -1
- package/src/animation/PropertyBinding.js +24 -5
- package/src/cameras/CubeCamera.js +0 -7
- package/src/constants.js +2 -4
- package/src/core/BufferAttribute.js +81 -111
- package/src/core/BufferGeometry.js +3 -41
- package/src/core/InstancedBufferAttribute.js +0 -10
- package/src/core/InterleavedBuffer.js +1 -1
- package/src/core/InterleavedBufferAttribute.js +56 -7
- package/src/core/Object3D.js +22 -5
- package/src/core/Uniform.js +0 -7
- package/src/core/UniformsGroup.js +92 -0
- package/src/extras/DataUtils.js +104 -88
- package/src/extras/core/Path.js +1 -0
- package/src/extras/core/ShapePath.js +1 -4
- package/src/extras/curves/CatmullRomCurve3.js +4 -2
- package/src/geometries/BoxGeometry.js +1 -1
- package/src/geometries/CapsuleGeometry.js +1 -1
- package/src/geometries/CircleGeometry.js +1 -1
- package/src/geometries/ConeGeometry.js +1 -1
- package/src/geometries/CylinderGeometry.js +2 -1
- package/src/geometries/DodecahedronGeometry.js +1 -1
- package/src/geometries/EdgesGeometry.js +5 -4
- package/src/geometries/ExtrudeGeometry.js +2 -11
- package/src/geometries/IcosahedronGeometry.js +1 -1
- package/src/geometries/LatheGeometry.js +2 -2
- package/src/geometries/OctahedronGeometry.js +1 -1
- package/src/geometries/PlaneGeometry.js +2 -1
- package/src/geometries/PolyhedronGeometry.js +1 -1
- package/src/geometries/RingGeometry.js +1 -1
- package/src/geometries/ShapeGeometry.js +2 -1
- package/src/geometries/SphereGeometry.js +2 -1
- package/src/geometries/TetrahedronGeometry.js +1 -1
- package/src/geometries/TorusGeometry.js +2 -1
- package/src/geometries/TorusKnotGeometry.js +2 -1
- package/src/geometries/TubeGeometry.js +2 -1
- package/src/geometries/WireframeGeometry.js +1 -0
- package/src/helpers/CameraHelper.js +97 -38
- package/src/helpers/DirectionalLightHelper.js +1 -0
- package/src/helpers/HemisphereLightHelper.js +1 -0
- package/src/helpers/PlaneHelper.js +6 -9
- package/src/helpers/PolarGridHelper.js +18 -14
- package/src/helpers/SpotLightHelper.js +1 -0
- package/src/lights/SpotLight.js +2 -0
- package/src/loaders/FileLoader.js +12 -1
- package/src/loaders/LoadingManager.js +1 -1
- package/src/loaders/MaterialLoader.js +49 -7
- package/src/loaders/ObjectLoader.js +4 -41
- package/src/materials/Material.js +1 -33
- package/src/materials/Materials.js +0 -27
- package/src/materials/MeshLambertMaterial.js +28 -1
- package/src/materials/ShaderMaterial.js +3 -7
- package/src/math/Color.js +3 -13
- package/src/math/MathUtils.js +1 -7
- package/src/math/Matrix3.js +1 -7
- package/src/math/Matrix4.js +3 -27
- package/src/math/Quaternion.js +1 -21
- package/src/math/Vector2.js +4 -24
- package/src/math/Vector3.js +7 -46
- package/src/math/Vector4.js +4 -24
- package/src/renderers/WebGLRenderer.js +84 -8
- package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +12 -12
- package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +3 -5
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +6 -5
- package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +24 -24
- package/src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js +2 -1
- package/src/renderers/shaders/ShaderChunk/iridescence_fragment.glsl.js +113 -99
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +34 -12
- package/src/renderers/shaders/ShaderChunk/lights_lambert_fragment.glsl.js +5 -0
- package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +30 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +3 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +13 -1
- package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +2 -4
- package/src/renderers/shaders/ShaderChunk/output_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +18 -7
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +8 -3
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +9 -6
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +14 -10
- package/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +22 -50
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib.js +31 -31
- package/src/renderers/shaders/UniformsLib.js +12 -11
- package/src/renderers/shaders/UniformsUtils.js +14 -0
- package/src/renderers/webgl/WebGLBackground.js +2 -2
- package/src/renderers/webgl/WebGLLights.js +37 -13
- package/src/renderers/webgl/WebGLMorphtargets.js +0 -20
- package/src/renderers/webgl/WebGLProgram.js +6 -11
- package/src/renderers/webgl/WebGLPrograms.js +30 -26
- package/src/renderers/webgl/WebGLRenderLists.js +5 -4
- package/src/renderers/webgl/WebGLRenderStates.js +5 -4
- package/src/renderers/webgl/WebGLShaderCache.js +9 -6
- package/src/renderers/webgl/WebGLShadowMap.js +10 -15
- package/src/renderers/webgl/WebGLState.js +47 -0
- package/src/renderers/webgl/WebGLUniforms.js +4 -4
- package/src/renderers/webgl/WebGLUniformsGroups.js +372 -0
- package/src/renderers/webgl/WebGLUtils.js +2 -0
- package/src/renderers/webvr/WebVRManager.js +42 -9
- package/src/renderers/webvr/WebVRUtils.js +1 -1
- package/src/renderers/webxr/WebXRController.js +45 -37
- package/src/renderers/webxr/WebXRManager.js +58 -33
- package/src/scenes/Scene.js +16 -3
- package/src/textures/Source.js +1 -1
- package/src/utils.js +1 -1
- package/examples/js/controls/experimental/CameraControls.js +0 -1048
- package/examples/js/loaders/KTX2Loader.js +0 -558
- package/examples/jsm/controls/experimental/CameraControls.js +0 -1248
- package/examples/jsm/nodes/accessors/ReflectNode.js +0 -70
- package/examples/jsm/package.json +0 -3
- package/examples/jsm/renderers/webgl/nodes/WebGLPhysicalContextNode.js +0 -45
- package/src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl.js +0 -122
|
@@ -1,558 +0,0 @@
|
|
|
1
|
-
( function () {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* THREE.Loader for KTX 2.0 GPU Texture containers.
|
|
5
|
-
*
|
|
6
|
-
* KTX 2.0 is a container format for various GPU texture formats. The loader
|
|
7
|
-
* supports Basis Universal GPU textures, which can be quickly transcoded to
|
|
8
|
-
* a wide variety of GPU texture compression formats. While KTX 2.0 also allows
|
|
9
|
-
* other hardware-specific formats, this loader does not yet parse them.
|
|
10
|
-
*
|
|
11
|
-
* References:
|
|
12
|
-
* - KTX: http://github.khronos.org/KTX-Specification/
|
|
13
|
-
* - DFD: https://www.khronos.org/registry/DataFormat/specs/1.3/dataformat.1.3.html#basicdescriptor
|
|
14
|
-
*/
|
|
15
|
-
const KTX2TransferSRGB = 2;
|
|
16
|
-
const KTX2_ALPHA_PREMULTIPLIED = 1;
|
|
17
|
-
|
|
18
|
-
const _taskCache = new WeakMap();
|
|
19
|
-
|
|
20
|
-
let _activeLoaders = 0;
|
|
21
|
-
|
|
22
|
-
class KTX2Loader extends THREE.Loader {
|
|
23
|
-
|
|
24
|
-
constructor( manager ) {
|
|
25
|
-
|
|
26
|
-
super( manager );
|
|
27
|
-
this.transcoderPath = '';
|
|
28
|
-
this.transcoderBinary = null;
|
|
29
|
-
this.transcoderPending = null;
|
|
30
|
-
this.workerPool = new THREE.WorkerPool();
|
|
31
|
-
this.workerSourceURL = '';
|
|
32
|
-
this.workerConfig = null;
|
|
33
|
-
|
|
34
|
-
if ( typeof MSC_TRANSCODER !== 'undefined' ) {
|
|
35
|
-
|
|
36
|
-
console.warn( 'THREE.KTX2Loader: Please update to latest "basis_transcoder".' + ' "msc_basis_transcoder" is no longer supported in three.js r125+.' );
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
setTranscoderPath( path ) {
|
|
43
|
-
|
|
44
|
-
this.transcoderPath = path;
|
|
45
|
-
return this;
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
setWorkerLimit( num ) {
|
|
50
|
-
|
|
51
|
-
this.workerPool.setWorkerLimit( num );
|
|
52
|
-
return this;
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
detectSupport( renderer ) {
|
|
57
|
-
|
|
58
|
-
this.workerConfig = {
|
|
59
|
-
astcSupported: renderer.extensions.has( 'WEBGL_compressed_texture_astc' ),
|
|
60
|
-
etc1Supported: renderer.extensions.has( 'WEBGL_compressed_texture_etc1' ),
|
|
61
|
-
etc2Supported: renderer.extensions.has( 'WEBGL_compressed_texture_etc' ),
|
|
62
|
-
dxtSupported: renderer.extensions.has( 'WEBGL_compressed_texture_s3tc' ),
|
|
63
|
-
bptcSupported: renderer.extensions.has( 'EXT_texture_compression_bptc' ),
|
|
64
|
-
pvrtcSupported: renderer.extensions.has( 'WEBGL_compressed_texture_pvrtc' ) || renderer.extensions.has( 'WEBKIT_WEBGL_compressed_texture_pvrtc' )
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
if ( renderer.capabilities.isWebGL2 ) {
|
|
68
|
-
|
|
69
|
-
// https://github.com/mrdoob/three.js/pull/22928
|
|
70
|
-
this.workerConfig.etc1Supported = false;
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return this;
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
init() {
|
|
79
|
-
|
|
80
|
-
if ( ! this.transcoderPending ) {
|
|
81
|
-
|
|
82
|
-
// Load transcoder wrapper.
|
|
83
|
-
const jsLoader = new THREE.FileLoader( this.manager );
|
|
84
|
-
jsLoader.setPath( this.transcoderPath );
|
|
85
|
-
jsLoader.setWithCredentials( this.withCredentials );
|
|
86
|
-
const jsContent = jsLoader.loadAsync( 'basis_transcoder.js' ); // Load transcoder WASM binary.
|
|
87
|
-
|
|
88
|
-
const binaryLoader = new THREE.FileLoader( this.manager );
|
|
89
|
-
binaryLoader.setPath( this.transcoderPath );
|
|
90
|
-
binaryLoader.setResponseType( 'arraybuffer' );
|
|
91
|
-
binaryLoader.setWithCredentials( this.withCredentials );
|
|
92
|
-
const binaryContent = binaryLoader.loadAsync( 'basis_transcoder.wasm' );
|
|
93
|
-
this.transcoderPending = Promise.all( [ jsContent, binaryContent ] ).then( ( [ jsContent, binaryContent ] ) => {
|
|
94
|
-
|
|
95
|
-
const fn = KTX2Loader.BasisWorker.toString();
|
|
96
|
-
const body = [ '/* constants */', 'let _EngineFormat = ' + JSON.stringify( KTX2Loader.EngineFormat ), 'let _TranscoderFormat = ' + JSON.stringify( KTX2Loader.TranscoderFormat ), 'let _BasisFormat = ' + JSON.stringify( KTX2Loader.BasisFormat ), '/* basis_transcoder.js */', jsContent, '/* worker */', fn.substring( fn.indexOf( '{' ) + 1, fn.lastIndexOf( '}' ) ) ].join( '\n' );
|
|
97
|
-
this.workerSourceURL = URL.createObjectURL( new Blob( [ body ] ) );
|
|
98
|
-
this.transcoderBinary = binaryContent;
|
|
99
|
-
this.workerPool.setWorkerCreator( () => {
|
|
100
|
-
|
|
101
|
-
const worker = new Worker( this.workerSourceURL );
|
|
102
|
-
const transcoderBinary = this.transcoderBinary.slice( 0 );
|
|
103
|
-
worker.postMessage( {
|
|
104
|
-
type: 'init',
|
|
105
|
-
config: this.workerConfig,
|
|
106
|
-
transcoderBinary
|
|
107
|
-
}, [ transcoderBinary ] );
|
|
108
|
-
return worker;
|
|
109
|
-
|
|
110
|
-
} );
|
|
111
|
-
|
|
112
|
-
} );
|
|
113
|
-
|
|
114
|
-
if ( _activeLoaders > 0 ) {
|
|
115
|
-
|
|
116
|
-
// Each instance loads a transcoder and allocates workers, increasing network and memory cost.
|
|
117
|
-
console.warn( 'THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues.' + ' Use a single KTX2Loader instance, or call .dispose() on old instances.' );
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
_activeLoaders ++;
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return this.transcoderPending;
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
load( url, onLoad, onProgress, onError ) {
|
|
130
|
-
|
|
131
|
-
if ( this.workerConfig === null ) {
|
|
132
|
-
|
|
133
|
-
throw new Error( 'THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.' );
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const loader = new THREE.FileLoader( this.manager );
|
|
138
|
-
loader.setResponseType( 'arraybuffer' );
|
|
139
|
-
loader.setWithCredentials( this.withCredentials );
|
|
140
|
-
const texture = new THREE.CompressedTexture();
|
|
141
|
-
loader.load( url, buffer => {
|
|
142
|
-
|
|
143
|
-
// Check for an existing task using this buffer. A transferred buffer cannot be transferred
|
|
144
|
-
// again from this thread.
|
|
145
|
-
if ( _taskCache.has( buffer ) ) {
|
|
146
|
-
|
|
147
|
-
const cachedTask = _taskCache.get( buffer );
|
|
148
|
-
|
|
149
|
-
return cachedTask.promise.then( onLoad ).catch( onError );
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
this._createTexture( [ buffer ] ).then( function ( _texture ) {
|
|
154
|
-
|
|
155
|
-
texture.copy( _texture );
|
|
156
|
-
texture.needsUpdate = true;
|
|
157
|
-
if ( onLoad ) onLoad( texture );
|
|
158
|
-
|
|
159
|
-
} ).catch( onError );
|
|
160
|
-
|
|
161
|
-
}, onProgress, onError );
|
|
162
|
-
return texture;
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
_createTextureFrom( transcodeResult ) {
|
|
167
|
-
|
|
168
|
-
const {
|
|
169
|
-
mipmaps,
|
|
170
|
-
width,
|
|
171
|
-
height,
|
|
172
|
-
format,
|
|
173
|
-
type,
|
|
174
|
-
error,
|
|
175
|
-
dfdTransferFn,
|
|
176
|
-
dfdFlags
|
|
177
|
-
} = transcodeResult;
|
|
178
|
-
if ( type === 'error' ) return Promise.reject( error );
|
|
179
|
-
const texture = new THREE.CompressedTexture( mipmaps, width, height, format, THREE.UnsignedByteType );
|
|
180
|
-
texture.minFilter = mipmaps.length === 1 ? THREE.LinearFilter : THREE.LinearMipmapLinearFilter;
|
|
181
|
-
texture.magFilter = THREE.LinearFilter;
|
|
182
|
-
texture.generateMipmaps = false;
|
|
183
|
-
texture.needsUpdate = true;
|
|
184
|
-
texture.encoding = dfdTransferFn === KTX2TransferSRGB ? THREE.sRGBEncoding : THREE.LinearEncoding;
|
|
185
|
-
texture.premultiplyAlpha = !! ( dfdFlags & KTX2_ALPHA_PREMULTIPLIED );
|
|
186
|
-
return texture;
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* @param {ArrayBuffer[]} buffers
|
|
191
|
-
* @param {object?} config
|
|
192
|
-
* @return {Promise<CompressedTexture>}
|
|
193
|
-
*/
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
_createTexture( buffers, config = {} ) {
|
|
197
|
-
|
|
198
|
-
const taskConfig = config;
|
|
199
|
-
const texturePending = this.init().then( () => {
|
|
200
|
-
|
|
201
|
-
return this.workerPool.postMessage( {
|
|
202
|
-
type: 'transcode',
|
|
203
|
-
buffers,
|
|
204
|
-
taskConfig: taskConfig
|
|
205
|
-
}, buffers );
|
|
206
|
-
|
|
207
|
-
} ).then( e => this._createTextureFrom( e.data ) ); // Cache the task result.
|
|
208
|
-
|
|
209
|
-
_taskCache.set( buffers[ 0 ], {
|
|
210
|
-
promise: texturePending
|
|
211
|
-
} );
|
|
212
|
-
|
|
213
|
-
return texturePending;
|
|
214
|
-
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
dispose() {
|
|
218
|
-
|
|
219
|
-
this.workerPool.dispose();
|
|
220
|
-
if ( this.workerSourceURL ) URL.revokeObjectURL( this.workerSourceURL );
|
|
221
|
-
_activeLoaders --;
|
|
222
|
-
return this;
|
|
223
|
-
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
/* CONSTANTS */
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
KTX2Loader.BasisFormat = {
|
|
231
|
-
ETC1S: 0,
|
|
232
|
-
UASTC_4x4: 1
|
|
233
|
-
};
|
|
234
|
-
KTX2Loader.TranscoderFormat = {
|
|
235
|
-
ETC1: 0,
|
|
236
|
-
ETC2: 1,
|
|
237
|
-
BC1: 2,
|
|
238
|
-
BC3: 3,
|
|
239
|
-
BC4: 4,
|
|
240
|
-
BC5: 5,
|
|
241
|
-
BC7_M6_OPAQUE_ONLY: 6,
|
|
242
|
-
BC7_M5: 7,
|
|
243
|
-
PVRTC1_4_RGB: 8,
|
|
244
|
-
PVRTC1_4_RGBA: 9,
|
|
245
|
-
ASTC_4x4: 10,
|
|
246
|
-
ATC_RGB: 11,
|
|
247
|
-
ATC_RGBA_INTERPOLATED_ALPHA: 12,
|
|
248
|
-
RGBA32: 13,
|
|
249
|
-
RGB565: 14,
|
|
250
|
-
BGR565: 15,
|
|
251
|
-
RGBA4444: 16
|
|
252
|
-
};
|
|
253
|
-
KTX2Loader.EngineFormat = {
|
|
254
|
-
RGBAFormat: THREE.RGBAFormat,
|
|
255
|
-
RGBA_ASTC_4x4_Format: THREE.RGBA_ASTC_4x4_Format,
|
|
256
|
-
RGBA_BPTC_Format: THREE.RGBA_BPTC_Format,
|
|
257
|
-
RGBA_ETC2_EAC_Format: THREE.RGBA_ETC2_EAC_Format,
|
|
258
|
-
RGBA_PVRTC_4BPPV1_Format: THREE.RGBA_PVRTC_4BPPV1_Format,
|
|
259
|
-
RGBA_S3TC_DXT5_Format: THREE.RGBA_S3TC_DXT5_Format,
|
|
260
|
-
RGB_ETC1_Format: THREE.RGB_ETC1_Format,
|
|
261
|
-
RGB_ETC2_Format: THREE.RGB_ETC2_Format,
|
|
262
|
-
RGB_PVRTC_4BPPV1_Format: THREE.RGB_PVRTC_4BPPV1_Format,
|
|
263
|
-
RGB_S3TC_DXT1_Format: THREE.RGB_S3TC_DXT1_Format
|
|
264
|
-
};
|
|
265
|
-
/* WEB WORKER */
|
|
266
|
-
|
|
267
|
-
KTX2Loader.BasisWorker = function () {
|
|
268
|
-
|
|
269
|
-
let config;
|
|
270
|
-
let transcoderPending;
|
|
271
|
-
let BasisModule;
|
|
272
|
-
const EngineFormat = _EngineFormat; // eslint-disable-line no-undef
|
|
273
|
-
|
|
274
|
-
const TranscoderFormat = _TranscoderFormat; // eslint-disable-line no-undef
|
|
275
|
-
|
|
276
|
-
const BasisFormat = _BasisFormat; // eslint-disable-line no-undef
|
|
277
|
-
|
|
278
|
-
self.addEventListener( 'message', function ( e ) {
|
|
279
|
-
|
|
280
|
-
const message = e.data;
|
|
281
|
-
|
|
282
|
-
switch ( message.type ) {
|
|
283
|
-
|
|
284
|
-
case 'init':
|
|
285
|
-
config = message.config;
|
|
286
|
-
init( message.transcoderBinary );
|
|
287
|
-
break;
|
|
288
|
-
|
|
289
|
-
case 'transcode':
|
|
290
|
-
transcoderPending.then( () => {
|
|
291
|
-
|
|
292
|
-
try {
|
|
293
|
-
|
|
294
|
-
const {
|
|
295
|
-
width,
|
|
296
|
-
height,
|
|
297
|
-
hasAlpha,
|
|
298
|
-
mipmaps,
|
|
299
|
-
format,
|
|
300
|
-
dfdTransferFn,
|
|
301
|
-
dfdFlags
|
|
302
|
-
} = transcode( message.buffers[ 0 ] );
|
|
303
|
-
const buffers = [];
|
|
304
|
-
|
|
305
|
-
for ( let i = 0; i < mipmaps.length; ++ i ) {
|
|
306
|
-
|
|
307
|
-
buffers.push( mipmaps[ i ].data.buffer );
|
|
308
|
-
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
self.postMessage( {
|
|
312
|
-
type: 'transcode',
|
|
313
|
-
id: message.id,
|
|
314
|
-
width,
|
|
315
|
-
height,
|
|
316
|
-
hasAlpha,
|
|
317
|
-
mipmaps,
|
|
318
|
-
format,
|
|
319
|
-
dfdTransferFn,
|
|
320
|
-
dfdFlags
|
|
321
|
-
}, buffers );
|
|
322
|
-
|
|
323
|
-
} catch ( error ) {
|
|
324
|
-
|
|
325
|
-
console.error( error );
|
|
326
|
-
self.postMessage( {
|
|
327
|
-
type: 'error',
|
|
328
|
-
id: message.id,
|
|
329
|
-
error: error.message
|
|
330
|
-
} );
|
|
331
|
-
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
} );
|
|
335
|
-
break;
|
|
336
|
-
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
} );
|
|
340
|
-
|
|
341
|
-
function init( wasmBinary ) {
|
|
342
|
-
|
|
343
|
-
transcoderPending = new Promise( resolve => {
|
|
344
|
-
|
|
345
|
-
BasisModule = {
|
|
346
|
-
wasmBinary,
|
|
347
|
-
onRuntimeInitialized: resolve
|
|
348
|
-
};
|
|
349
|
-
BASIS( BasisModule ); // eslint-disable-line no-undef
|
|
350
|
-
|
|
351
|
-
} ).then( () => {
|
|
352
|
-
|
|
353
|
-
BasisModule.initializeBasis();
|
|
354
|
-
|
|
355
|
-
if ( BasisModule.KTX2File === undefined ) {
|
|
356
|
-
|
|
357
|
-
console.warn( 'THREE.KTX2Loader: Please update Basis Universal transcoder.' );
|
|
358
|
-
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
} );
|
|
362
|
-
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
function transcode( buffer ) {
|
|
366
|
-
|
|
367
|
-
const ktx2File = new BasisModule.KTX2File( new Uint8Array( buffer ) );
|
|
368
|
-
|
|
369
|
-
function cleanup() {
|
|
370
|
-
|
|
371
|
-
ktx2File.close();
|
|
372
|
-
ktx2File.delete();
|
|
373
|
-
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
if ( ! ktx2File.isValid() ) {
|
|
377
|
-
|
|
378
|
-
cleanup();
|
|
379
|
-
throw new Error( 'THREE.KTX2Loader: Invalid or unsupported .ktx2 file' );
|
|
380
|
-
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
const basisFormat = ktx2File.isUASTC() ? BasisFormat.UASTC_4x4 : BasisFormat.ETC1S;
|
|
384
|
-
const width = ktx2File.getWidth();
|
|
385
|
-
const height = ktx2File.getHeight();
|
|
386
|
-
const levels = ktx2File.getLevels();
|
|
387
|
-
const hasAlpha = ktx2File.getHasAlpha();
|
|
388
|
-
const dfdTransferFn = ktx2File.getDFDTransferFunc();
|
|
389
|
-
const dfdFlags = ktx2File.getDFDFlags();
|
|
390
|
-
const {
|
|
391
|
-
transcoderFormat,
|
|
392
|
-
engineFormat
|
|
393
|
-
} = getTranscoderFormat( basisFormat, width, height, hasAlpha );
|
|
394
|
-
|
|
395
|
-
if ( ! width || ! height || ! levels ) {
|
|
396
|
-
|
|
397
|
-
cleanup();
|
|
398
|
-
throw new Error( 'THREE.KTX2Loader: Invalid texture' );
|
|
399
|
-
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
if ( ! ktx2File.startTranscoding() ) {
|
|
403
|
-
|
|
404
|
-
cleanup();
|
|
405
|
-
throw new Error( 'THREE.KTX2Loader: .startTranscoding failed' );
|
|
406
|
-
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
const mipmaps = [];
|
|
410
|
-
|
|
411
|
-
for ( let mip = 0; mip < levels; mip ++ ) {
|
|
412
|
-
|
|
413
|
-
const levelInfo = ktx2File.getImageLevelInfo( mip, 0, 0 );
|
|
414
|
-
const mipWidth = levelInfo.origWidth;
|
|
415
|
-
const mipHeight = levelInfo.origHeight;
|
|
416
|
-
const dst = new Uint8Array( ktx2File.getImageTranscodedSizeInBytes( mip, 0, 0, transcoderFormat ) );
|
|
417
|
-
const status = ktx2File.transcodeImage( dst, mip, 0, 0, transcoderFormat, 0, - 1, - 1 );
|
|
418
|
-
|
|
419
|
-
if ( ! status ) {
|
|
420
|
-
|
|
421
|
-
cleanup();
|
|
422
|
-
throw new Error( 'THREE.KTX2Loader: .transcodeImage failed.' );
|
|
423
|
-
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
mipmaps.push( {
|
|
427
|
-
data: dst,
|
|
428
|
-
width: mipWidth,
|
|
429
|
-
height: mipHeight
|
|
430
|
-
} );
|
|
431
|
-
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
cleanup();
|
|
435
|
-
return {
|
|
436
|
-
width,
|
|
437
|
-
height,
|
|
438
|
-
hasAlpha,
|
|
439
|
-
mipmaps,
|
|
440
|
-
format: engineFormat,
|
|
441
|
-
dfdTransferFn,
|
|
442
|
-
dfdFlags
|
|
443
|
-
};
|
|
444
|
-
|
|
445
|
-
} //
|
|
446
|
-
// Optimal choice of a transcoder target format depends on the Basis format (ETC1S or UASTC),
|
|
447
|
-
// device capabilities, and texture dimensions. The list below ranks the formats separately
|
|
448
|
-
// for ETC1S and UASTC.
|
|
449
|
-
//
|
|
450
|
-
// In some cases, transcoding UASTC to RGBA32 might be preferred for higher quality (at
|
|
451
|
-
// significant memory cost) compared to ETC1/2, BC1/3, and PVRTC. The transcoder currently
|
|
452
|
-
// chooses RGBA32 only as a last resort and does not expose that option to the caller.
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
const FORMAT_OPTIONS = [ {
|
|
456
|
-
if: 'astcSupported',
|
|
457
|
-
basisFormat: [ BasisFormat.UASTC_4x4 ],
|
|
458
|
-
transcoderFormat: [ TranscoderFormat.ASTC_4x4, TranscoderFormat.ASTC_4x4 ],
|
|
459
|
-
engineFormat: [ EngineFormat.RGBA_ASTC_4x4_Format, EngineFormat.RGBA_ASTC_4x4_Format ],
|
|
460
|
-
priorityETC1S: Infinity,
|
|
461
|
-
priorityUASTC: 1,
|
|
462
|
-
needsPowerOfTwo: false
|
|
463
|
-
}, {
|
|
464
|
-
if: 'bptcSupported',
|
|
465
|
-
basisFormat: [ BasisFormat.ETC1S, BasisFormat.UASTC_4x4 ],
|
|
466
|
-
transcoderFormat: [ TranscoderFormat.BC7_M5, TranscoderFormat.BC7_M5 ],
|
|
467
|
-
engineFormat: [ EngineFormat.RGBA_BPTC_Format, EngineFormat.RGBA_BPTC_Format ],
|
|
468
|
-
priorityETC1S: 3,
|
|
469
|
-
priorityUASTC: 2,
|
|
470
|
-
needsPowerOfTwo: false
|
|
471
|
-
}, {
|
|
472
|
-
if: 'dxtSupported',
|
|
473
|
-
basisFormat: [ BasisFormat.ETC1S, BasisFormat.UASTC_4x4 ],
|
|
474
|
-
transcoderFormat: [ TranscoderFormat.BC1, TranscoderFormat.BC3 ],
|
|
475
|
-
engineFormat: [ EngineFormat.RGB_S3TC_DXT1_Format, EngineFormat.RGBA_S3TC_DXT5_Format ],
|
|
476
|
-
priorityETC1S: 4,
|
|
477
|
-
priorityUASTC: 5,
|
|
478
|
-
needsPowerOfTwo: false
|
|
479
|
-
}, {
|
|
480
|
-
if: 'etc2Supported',
|
|
481
|
-
basisFormat: [ BasisFormat.ETC1S, BasisFormat.UASTC_4x4 ],
|
|
482
|
-
transcoderFormat: [ TranscoderFormat.ETC1, TranscoderFormat.ETC2 ],
|
|
483
|
-
engineFormat: [ EngineFormat.RGB_ETC2_Format, EngineFormat.RGBA_ETC2_EAC_Format ],
|
|
484
|
-
priorityETC1S: 1,
|
|
485
|
-
priorityUASTC: 3,
|
|
486
|
-
needsPowerOfTwo: false
|
|
487
|
-
}, {
|
|
488
|
-
if: 'etc1Supported',
|
|
489
|
-
basisFormat: [ BasisFormat.ETC1S, BasisFormat.UASTC_4x4 ],
|
|
490
|
-
transcoderFormat: [ TranscoderFormat.ETC1 ],
|
|
491
|
-
engineFormat: [ EngineFormat.RGB_ETC1_Format ],
|
|
492
|
-
priorityETC1S: 2,
|
|
493
|
-
priorityUASTC: 4,
|
|
494
|
-
needsPowerOfTwo: false
|
|
495
|
-
}, {
|
|
496
|
-
if: 'pvrtcSupported',
|
|
497
|
-
basisFormat: [ BasisFormat.ETC1S, BasisFormat.UASTC_4x4 ],
|
|
498
|
-
transcoderFormat: [ TranscoderFormat.PVRTC1_4_RGB, TranscoderFormat.PVRTC1_4_RGBA ],
|
|
499
|
-
engineFormat: [ EngineFormat.RGB_PVRTC_4BPPV1_Format, EngineFormat.RGBA_PVRTC_4BPPV1_Format ],
|
|
500
|
-
priorityETC1S: 5,
|
|
501
|
-
priorityUASTC: 6,
|
|
502
|
-
needsPowerOfTwo: true
|
|
503
|
-
} ];
|
|
504
|
-
const ETC1S_OPTIONS = FORMAT_OPTIONS.sort( function ( a, b ) {
|
|
505
|
-
|
|
506
|
-
return a.priorityETC1S - b.priorityETC1S;
|
|
507
|
-
|
|
508
|
-
} );
|
|
509
|
-
const UASTC_OPTIONS = FORMAT_OPTIONS.sort( function ( a, b ) {
|
|
510
|
-
|
|
511
|
-
return a.priorityUASTC - b.priorityUASTC;
|
|
512
|
-
|
|
513
|
-
} );
|
|
514
|
-
|
|
515
|
-
function getTranscoderFormat( basisFormat, width, height, hasAlpha ) {
|
|
516
|
-
|
|
517
|
-
let transcoderFormat;
|
|
518
|
-
let engineFormat;
|
|
519
|
-
const options = basisFormat === BasisFormat.ETC1S ? ETC1S_OPTIONS : UASTC_OPTIONS;
|
|
520
|
-
|
|
521
|
-
for ( let i = 0; i < options.length; i ++ ) {
|
|
522
|
-
|
|
523
|
-
const opt = options[ i ];
|
|
524
|
-
if ( ! config[ opt.if ] ) continue;
|
|
525
|
-
if ( ! opt.basisFormat.includes( basisFormat ) ) continue;
|
|
526
|
-
if ( hasAlpha && opt.transcoderFormat.length < 2 ) continue;
|
|
527
|
-
if ( opt.needsPowerOfTwo && ! ( isPowerOfTwo( width ) && isPowerOfTwo( height ) ) ) continue;
|
|
528
|
-
transcoderFormat = opt.transcoderFormat[ hasAlpha ? 1 : 0 ];
|
|
529
|
-
engineFormat = opt.engineFormat[ hasAlpha ? 1 : 0 ];
|
|
530
|
-
return {
|
|
531
|
-
transcoderFormat,
|
|
532
|
-
engineFormat
|
|
533
|
-
};
|
|
534
|
-
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
console.warn( 'THREE.KTX2Loader: No suitable compressed texture format found. Decoding to RGBA32.' );
|
|
538
|
-
transcoderFormat = TranscoderFormat.RGBA32;
|
|
539
|
-
engineFormat = EngineFormat.RGBAFormat;
|
|
540
|
-
return {
|
|
541
|
-
transcoderFormat,
|
|
542
|
-
engineFormat
|
|
543
|
-
};
|
|
544
|
-
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
function isPowerOfTwo( value ) {
|
|
548
|
-
|
|
549
|
-
if ( value <= 2 ) return true;
|
|
550
|
-
return ( value & value - 1 ) === 0 && value !== 0;
|
|
551
|
-
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
};
|
|
555
|
-
|
|
556
|
-
THREE.KTX2Loader = KTX2Loader;
|
|
557
|
-
|
|
558
|
-
} )();
|