super-three 0.154.1 → 0.156.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/build/three.cjs +360 -160
- package/build/three.js +360 -160
- package/build/three.min.js +1 -1
- package/build/three.module.js +355 -161
- package/build/three.module.min.js +1 -1
- package/examples/jsm/controls/OrbitControls.js +155 -25
- package/examples/jsm/csm/CSMShader.js +35 -1
- package/examples/jsm/environments/RoomEnvironment.js +1 -1
- package/examples/jsm/exporters/USDZExporter.js +1 -0
- package/examples/jsm/interactive/SelectionHelper.js +7 -0
- package/examples/jsm/libs/tween.module.js +790 -735
- package/examples/jsm/libs/utif.module.js +1644 -1558
- package/examples/jsm/loaders/DDSLoader.js +46 -3
- package/examples/jsm/loaders/EXRLoader.js +4 -4
- package/examples/jsm/loaders/FBXLoader.js +3 -1
- package/examples/jsm/loaders/GLTFLoader.js +25 -10
- package/examples/jsm/loaders/KTX2Loader.js +128 -79
- package/examples/jsm/loaders/LDrawLoader.js +1 -1
- package/examples/jsm/loaders/LogLuvLoader.js +2 -2
- package/examples/jsm/loaders/MMDLoader.js +10 -7
- package/examples/jsm/loaders/NRRDLoader.js +3 -3
- package/examples/jsm/loaders/PLYLoader.js +1 -1
- package/examples/jsm/loaders/RGBELoader.js +48 -66
- package/examples/jsm/loaders/STLLoader.js +7 -0
- package/examples/jsm/loaders/TGALoader.js +10 -10
- package/examples/jsm/loaders/VRMLLoader.js +1 -1
- package/examples/jsm/misc/GPUComputationRenderer.js +0 -9
- package/examples/jsm/misc/Volume.js +4 -6
- package/examples/jsm/nodes/Nodes.js +8 -6
- package/examples/jsm/nodes/accessors/BufferAttributeNode.js +29 -3
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +20 -3
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +15 -4
- package/examples/jsm/nodes/accessors/InstanceNode.js +8 -8
- package/examples/jsm/nodes/accessors/LineMaterialNode.js +31 -0
- package/examples/jsm/nodes/accessors/MaterialNode.js +73 -61
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +3 -0
- package/examples/jsm/nodes/accessors/Object3DNode.js +2 -2
- package/examples/jsm/nodes/accessors/SceneNode.js +6 -0
- package/examples/jsm/nodes/accessors/TextureNode.js +54 -9
- package/examples/jsm/nodes/accessors/TextureStoreNode.js +29 -0
- package/examples/jsm/nodes/core/AttributeNode.js +2 -2
- package/examples/jsm/nodes/core/LightingModel.js +7 -9
- package/examples/jsm/nodes/core/Node.js +28 -3
- package/examples/jsm/nodes/core/NodeBuilder.js +94 -12
- package/examples/jsm/nodes/core/NodeUniform.js +1 -1
- package/examples/jsm/nodes/core/OutputStructNode.js +58 -0
- package/examples/jsm/nodes/core/PropertyNode.js +6 -0
- package/examples/jsm/nodes/core/StackNode.js +4 -4
- package/examples/jsm/nodes/core/StructTypeNode.js +24 -0
- package/examples/jsm/nodes/display/BumpMapNode.js +77 -0
- package/examples/jsm/nodes/display/NormalMapNode.js +2 -2
- package/examples/jsm/nodes/display/ViewportNode.js +19 -5
- package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +10 -2
- package/examples/jsm/nodes/functions/BSDF/Schlick_to_F0.js +13 -0
- package/examples/jsm/nodes/functions/PhongLightingModel.js +53 -14
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +236 -97
- package/examples/jsm/nodes/geometry/RangeNode.js +2 -2
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +13 -0
- package/examples/jsm/nodes/lighting/AONode.js +1 -1
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +58 -20
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +7 -10
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +22 -12
- package/examples/jsm/nodes/lighting/HemisphereLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/LightingContextNode.js +12 -9
- package/examples/jsm/nodes/lighting/PointLightNode.js +7 -10
- package/examples/jsm/nodes/lighting/SpotLightNode.js +7 -10
- package/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +54 -0
- package/examples/jsm/nodes/materials/Materials.js +2 -0
- package/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +34 -0
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +2 -0
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +2 -2
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +19 -2
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +2 -2
- package/examples/jsm/nodes/materials/NodeMaterial.js +61 -26
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +2 -2
- package/examples/jsm/nodes/math/HashNode.js +35 -0
- package/examples/jsm/nodes/shadernode/ShaderNode.js +6 -2
- package/examples/jsm/nodes/utils/SplitNode.js +1 -1
- package/examples/jsm/objects/Reflector.js +1 -9
- package/examples/jsm/objects/Refractor.js +0 -8
- package/examples/jsm/offscreen/scene.js +0 -1
- package/examples/jsm/postprocessing/FilmPass.js +3 -5
- package/examples/jsm/postprocessing/MaskPass.js +4 -1
- package/examples/jsm/postprocessing/OutputPass.js +33 -14
- package/examples/jsm/postprocessing/RenderPass.js +30 -12
- package/examples/jsm/postprocessing/SAOPass.js +23 -98
- package/examples/jsm/postprocessing/SSAOPass.js +10 -30
- package/examples/jsm/postprocessing/UnrealBloomPass.js +21 -17
- package/examples/jsm/renderers/common/Backend.js +11 -8
- package/examples/jsm/renderers/common/Background.js +22 -20
- package/examples/jsm/renderers/common/Binding.js +14 -0
- package/examples/jsm/renderers/common/Bindings.js +7 -10
- package/examples/jsm/renderers/common/Geometries.js +1 -1
- package/examples/jsm/renderers/common/Pipelines.js +96 -47
- package/examples/jsm/renderers/common/RenderContext.js +1 -0
- package/examples/jsm/renderers/common/RenderContexts.js +41 -5
- package/examples/jsm/renderers/common/RenderList.js +12 -4
- package/examples/jsm/renderers/common/RenderObject.js +26 -6
- package/examples/jsm/renderers/common/RenderObjects.js +10 -7
- package/examples/jsm/renderers/common/Renderer.js +82 -42
- package/examples/jsm/renderers/common/SampledTexture.js +2 -1
- package/examples/jsm/renderers/common/Sampler.js +1 -1
- package/examples/jsm/renderers/common/StorageBuffer.js +1 -1
- package/examples/jsm/renderers/common/Textures.js +172 -20
- package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +2 -2
- package/examples/jsm/renderers/common/nodes/NodeSampler.js +1 -1
- package/examples/jsm/renderers/common/nodes/Nodes.js +58 -13
- package/examples/jsm/renderers/webgl/WebGLBackend.js +607 -0
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +118 -17
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +84 -0
- package/examples/jsm/renderers/webgl/utils/WebGLExtensions.js +26 -0
- package/examples/jsm/renderers/webgl/utils/WebGLState.js +529 -0
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +199 -0
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +242 -0
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +340 -0
- package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodeBuilder.js +1 -1
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +320 -84
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +18 -2
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +120 -66
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +2 -2
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +55 -36
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +96 -5
- package/examples/jsm/renderers/webgpu/utils/WebGPUConstants.js +24 -22
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +117 -139
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +60 -142
- package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +7 -6
- package/examples/jsm/shaders/FilmShader.js +11 -54
- package/examples/jsm/shaders/OutputShader.js +19 -2
- package/examples/jsm/shaders/SAOShader.js +0 -13
- package/examples/jsm/shaders/SSAOShader.js +33 -26
- package/examples/jsm/utils/BufferGeometryUtils.js +13 -4
- package/examples/jsm/webxr/OculusHandPointerModel.js +2 -2
- package/package.json +2 -2
- package/src/Three.js +3 -0
- package/src/animation/PropertyBinding.js +1 -1
- package/src/audio/Audio.js +6 -0
- package/src/cameras/CubeCamera.js +1 -4
- package/src/constants.js +4 -1
- package/src/core/BufferAttribute.js +20 -0
- package/src/core/Object3D.js +2 -15
- package/src/core/RenderTarget.js +122 -0
- package/src/core/UniformsGroup.js +2 -2
- package/src/geometries/CapsuleGeometry.js +1 -1
- package/src/loaders/DataTextureLoader.js +19 -2
- package/src/materials/Material.js +2 -2
- package/src/math/Vector2.js +2 -2
- package/src/math/Vector3.js +3 -3
- package/src/math/Vector4.js +4 -4
- package/src/objects/Line.js +1 -1
- package/src/objects/Mesh.js +1 -1
- package/src/objects/Points.js +1 -1
- package/src/renderers/WebGLMultipleRenderTargets.js +0 -2
- package/src/renderers/WebGLRenderTarget.js +3 -110
- package/src/renderers/WebGLRenderer.js +83 -57
- package/src/renderers/shaders/ShaderChunk/iridescence_fragment.glsl.js +1 -2
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +11 -1
- package/src/renderers/shaders/ShaderLib/background.glsl.js +8 -0
- package/src/renderers/webgl/WebGLBackground.js +5 -14
- package/src/renderers/webgl/WebGLGeometries.js +5 -1
- package/src/renderers/webgl/WebGLMaterials.js +1 -1
- package/src/renderers/webgl/WebGLProgram.js +2 -0
- package/src/renderers/webgl/WebGLPrograms.js +19 -3
- package/src/renderers/webgl/WebGLTextures.js +101 -16
- package/src/renderers/webgl/WebGLUtils.js +27 -20
- package/src/textures/CompressedCubeTexture.js +19 -0
- package/src/textures/Texture.js +2 -2
- package/src/utils.js +9 -1
- package/examples/jsm/nodes/functions/BSDF/BRDF_BlinnPhong.js +0 -30
- package/examples/jsm/renderers/common/RenderTarget.js +0 -15
- package/examples/jsm/renderers/common/nodes/NodeRender.js +0 -302
- /package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/SlotNode.js +0 -0
- /package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodes.js +0 -0
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT5_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT1_Format, RGB_S3TC_DXT1_Format, DepthFormat, DepthStencilFormat, LuminanceAlphaFormat, LuminanceFormat, RedFormat, RGBAFormat, AlphaFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBAIntegerFormat, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType, RGBA_BPTC_Format, _SRGBAFormat, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format, SRGBColorSpace, NoColorSpace } from '../../constants.js';
|
|
1
|
+
import { RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT5_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT1_Format, RGB_S3TC_DXT1_Format, DepthFormat, DepthStencilFormat, LuminanceAlphaFormat, LuminanceFormat, RedFormat, RGBAFormat, AlphaFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBAIntegerFormat, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType, RGBA_BPTC_Format, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, _SRGBAFormat, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format, SRGBColorSpace, NoColorSpace, DisplayP3ColorSpace } from '../../constants.js';
|
|
2
|
+
|
|
3
|
+
const LinearTransferFunction = 0;
|
|
4
|
+
const SRGBTransferFunction = 1;
|
|
2
5
|
|
|
3
6
|
function WebGLUtils( gl, extensions, capabilities ) {
|
|
4
7
|
|
|
@@ -8,6 +11,8 @@ function WebGLUtils( gl, extensions, capabilities ) {
|
|
|
8
11
|
|
|
9
12
|
let extension;
|
|
10
13
|
|
|
14
|
+
const transferFunction = ( colorSpace === SRGBColorSpace || colorSpace === DisplayP3ColorSpace ) ? SRGBTransferFunction : LinearTransferFunction;
|
|
15
|
+
|
|
11
16
|
if ( p === UnsignedByteType ) return gl.UNSIGNED_BYTE;
|
|
12
17
|
if ( p === UnsignedShort4444Type ) return gl.UNSIGNED_SHORT_4_4_4_4;
|
|
13
18
|
if ( p === UnsignedShort5551Type ) return gl.UNSIGNED_SHORT_5_5_5_1;
|
|
@@ -74,7 +79,7 @@ function WebGLUtils( gl, extensions, capabilities ) {
|
|
|
74
79
|
|
|
75
80
|
if ( p === RGB_S3TC_DXT1_Format || p === RGBA_S3TC_DXT1_Format || p === RGBA_S3TC_DXT3_Format || p === RGBA_S3TC_DXT5_Format ) {
|
|
76
81
|
|
|
77
|
-
if (
|
|
82
|
+
if ( transferFunction === SRGBTransferFunction ) {
|
|
78
83
|
|
|
79
84
|
extension = extensions.get( 'WEBGL_compressed_texture_s3tc_srgb' );
|
|
80
85
|
|
|
@@ -159,8 +164,8 @@ function WebGLUtils( gl, extensions, capabilities ) {
|
|
|
159
164
|
|
|
160
165
|
if ( extension !== null ) {
|
|
161
166
|
|
|
162
|
-
if ( p === RGB_ETC2_Format ) return (
|
|
163
|
-
if ( p === RGBA_ETC2_EAC_Format ) return (
|
|
167
|
+
if ( p === RGB_ETC2_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2;
|
|
168
|
+
if ( p === RGBA_ETC2_EAC_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : extension.COMPRESSED_RGBA8_ETC2_EAC;
|
|
164
169
|
|
|
165
170
|
} else {
|
|
166
171
|
|
|
@@ -182,20 +187,20 @@ function WebGLUtils( gl, extensions, capabilities ) {
|
|
|
182
187
|
|
|
183
188
|
if ( extension !== null ) {
|
|
184
189
|
|
|
185
|
-
if ( p === RGBA_ASTC_4x4_Format ) return (
|
|
186
|
-
if ( p === RGBA_ASTC_5x4_Format ) return (
|
|
187
|
-
if ( p === RGBA_ASTC_5x5_Format ) return (
|
|
188
|
-
if ( p === RGBA_ASTC_6x5_Format ) return (
|
|
189
|
-
if ( p === RGBA_ASTC_6x6_Format ) return (
|
|
190
|
-
if ( p === RGBA_ASTC_8x5_Format ) return (
|
|
191
|
-
if ( p === RGBA_ASTC_8x6_Format ) return (
|
|
192
|
-
if ( p === RGBA_ASTC_8x8_Format ) return (
|
|
193
|
-
if ( p === RGBA_ASTC_10x5_Format ) return (
|
|
194
|
-
if ( p === RGBA_ASTC_10x6_Format ) return (
|
|
195
|
-
if ( p === RGBA_ASTC_10x8_Format ) return (
|
|
196
|
-
if ( p === RGBA_ASTC_10x10_Format ) return (
|
|
197
|
-
if ( p === RGBA_ASTC_12x10_Format ) return (
|
|
198
|
-
if ( p === RGBA_ASTC_12x12_Format ) return (
|
|
190
|
+
if ( p === RGBA_ASTC_4x4_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : extension.COMPRESSED_RGBA_ASTC_4x4_KHR;
|
|
191
|
+
if ( p === RGBA_ASTC_5x4_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : extension.COMPRESSED_RGBA_ASTC_5x4_KHR;
|
|
192
|
+
if ( p === RGBA_ASTC_5x5_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : extension.COMPRESSED_RGBA_ASTC_5x5_KHR;
|
|
193
|
+
if ( p === RGBA_ASTC_6x5_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : extension.COMPRESSED_RGBA_ASTC_6x5_KHR;
|
|
194
|
+
if ( p === RGBA_ASTC_6x6_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : extension.COMPRESSED_RGBA_ASTC_6x6_KHR;
|
|
195
|
+
if ( p === RGBA_ASTC_8x5_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : extension.COMPRESSED_RGBA_ASTC_8x5_KHR;
|
|
196
|
+
if ( p === RGBA_ASTC_8x6_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : extension.COMPRESSED_RGBA_ASTC_8x6_KHR;
|
|
197
|
+
if ( p === RGBA_ASTC_8x8_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : extension.COMPRESSED_RGBA_ASTC_8x8_KHR;
|
|
198
|
+
if ( p === RGBA_ASTC_10x5_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : extension.COMPRESSED_RGBA_ASTC_10x5_KHR;
|
|
199
|
+
if ( p === RGBA_ASTC_10x6_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : extension.COMPRESSED_RGBA_ASTC_10x6_KHR;
|
|
200
|
+
if ( p === RGBA_ASTC_10x8_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : extension.COMPRESSED_RGBA_ASTC_10x8_KHR;
|
|
201
|
+
if ( p === RGBA_ASTC_10x10_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : extension.COMPRESSED_RGBA_ASTC_10x10_KHR;
|
|
202
|
+
if ( p === RGBA_ASTC_12x10_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : extension.COMPRESSED_RGBA_ASTC_12x10_KHR;
|
|
203
|
+
if ( p === RGBA_ASTC_12x12_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : extension.COMPRESSED_RGBA_ASTC_12x12_KHR;
|
|
199
204
|
|
|
200
205
|
} else {
|
|
201
206
|
|
|
@@ -207,13 +212,15 @@ function WebGLUtils( gl, extensions, capabilities ) {
|
|
|
207
212
|
|
|
208
213
|
// BPTC
|
|
209
214
|
|
|
210
|
-
if ( p === RGBA_BPTC_Format ) {
|
|
215
|
+
if ( p === RGBA_BPTC_Format || p === RGB_BPTC_SIGNED_Format || p === RGB_BPTC_UNSIGNED_Format ) {
|
|
211
216
|
|
|
212
217
|
extension = extensions.get( 'EXT_texture_compression_bptc' );
|
|
213
218
|
|
|
214
219
|
if ( extension !== null ) {
|
|
215
220
|
|
|
216
|
-
if ( p === RGBA_BPTC_Format ) return (
|
|
221
|
+
if ( p === RGBA_BPTC_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : extension.COMPRESSED_RGBA_BPTC_UNORM_EXT;
|
|
222
|
+
if ( p === RGB_BPTC_SIGNED_Format ) return extension.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;
|
|
223
|
+
if ( p === RGB_BPTC_UNSIGNED_Format ) return extension.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT;
|
|
217
224
|
|
|
218
225
|
} else {
|
|
219
226
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CubeReflectionMapping } from '../constants.js';
|
|
2
|
+
import { CompressedTexture } from './CompressedTexture.js';
|
|
3
|
+
|
|
4
|
+
class CompressedCubeTexture extends CompressedTexture {
|
|
5
|
+
|
|
6
|
+
constructor( images, format, type ) {
|
|
7
|
+
|
|
8
|
+
super( undefined, images[ 0 ].width, images[ 0 ].height, format, type, CubeReflectionMapping );
|
|
9
|
+
|
|
10
|
+
this.isCompressedCubeTexture = true;
|
|
11
|
+
this.isCubeTexture = true;
|
|
12
|
+
|
|
13
|
+
this.image = images;
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { CompressedCubeTexture };
|
package/src/textures/Texture.js
CHANGED
|
@@ -19,7 +19,7 @@ import { Matrix3 } from '../math/Matrix3.js';
|
|
|
19
19
|
import { Source } from './Source.js';
|
|
20
20
|
import { warnOnce } from '../utils.js';
|
|
21
21
|
|
|
22
|
-
let
|
|
22
|
+
let _textureId = 0;
|
|
23
23
|
|
|
24
24
|
class Texture extends EventDispatcher {
|
|
25
25
|
|
|
@@ -29,7 +29,7 @@ class Texture extends EventDispatcher {
|
|
|
29
29
|
|
|
30
30
|
this.isTexture = true;
|
|
31
31
|
|
|
32
|
-
Object.defineProperty( this, 'id', { value:
|
|
32
|
+
Object.defineProperty( this, 'id', { value: _textureId ++ } );
|
|
33
33
|
|
|
34
34
|
this.uuid = MathUtils.generateUUID();
|
|
35
35
|
|
package/src/utils.js
CHANGED
|
@@ -68,6 +68,14 @@ function createElementNS( name ) {
|
|
|
68
68
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
function createCanvasElement() {
|
|
72
|
+
|
|
73
|
+
const canvas = createElementNS( 'canvas' );
|
|
74
|
+
canvas.style.display = 'block';
|
|
75
|
+
return canvas;
|
|
76
|
+
|
|
77
|
+
}
|
|
78
|
+
|
|
71
79
|
const _cache = {};
|
|
72
80
|
|
|
73
81
|
function warnOnce( message ) {
|
|
@@ -80,4 +88,4 @@ function warnOnce( message ) {
|
|
|
80
88
|
|
|
81
89
|
}
|
|
82
90
|
|
|
83
|
-
export { arrayMin, arrayMax, arrayNeedsUint32, getTypedArray, createElementNS, warnOnce };
|
|
91
|
+
export { arrayMin, arrayMax, arrayNeedsUint32, getTypedArray, createElementNS, createCanvasElement, warnOnce };
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import F_Schlick from './F_Schlick.js';
|
|
2
|
-
import { shininess, specularColor } from '../../core/PropertyNode.js';
|
|
3
|
-
import { transformedNormalView } from '../../accessors/NormalNode.js';
|
|
4
|
-
import { positionViewDirection } from '../../accessors/PositionNode.js';
|
|
5
|
-
import { tslFn, float } from '../../shadernode/ShaderNode.js';
|
|
6
|
-
|
|
7
|
-
const G_BlinnPhong_Implicit = () => float( 0.25 );
|
|
8
|
-
|
|
9
|
-
const D_BlinnPhong = tslFn( ( { dotNH } ) => {
|
|
10
|
-
|
|
11
|
-
return shininess.mul( 0.5 / Math.PI ).add( 1.0 ).mul( dotNH.pow( shininess ) );
|
|
12
|
-
|
|
13
|
-
} );
|
|
14
|
-
|
|
15
|
-
const BRDF_BlinnPhong = tslFn( ( { lightDirection } ) => {
|
|
16
|
-
|
|
17
|
-
const halfDir = lightDirection.add( positionViewDirection ).normalize();
|
|
18
|
-
|
|
19
|
-
const dotNH = transformedNormalView.dot( halfDir ).clamp();
|
|
20
|
-
const dotVH = positionViewDirection.dot( halfDir ).clamp();
|
|
21
|
-
|
|
22
|
-
const F = F_Schlick( { f0: specularColor, f90: 1.0, dotVH } );
|
|
23
|
-
const G = G_BlinnPhong_Implicit();
|
|
24
|
-
const D = D_BlinnPhong( { dotNH } );
|
|
25
|
-
|
|
26
|
-
return F.mul( G ).mul( D );
|
|
27
|
-
|
|
28
|
-
} );
|
|
29
|
-
|
|
30
|
-
export default BRDF_BlinnPhong;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { WebGLRenderTarget } from 'three';
|
|
2
|
-
|
|
3
|
-
// @TODO: Consider rename WebGLRenderTarget to just RenderTarget
|
|
4
|
-
|
|
5
|
-
class RenderTarget extends WebGLRenderTarget {
|
|
6
|
-
|
|
7
|
-
constructor( width, height, options = {} ) {
|
|
8
|
-
|
|
9
|
-
super( width, height, options );
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export default RenderTarget;
|
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
import WebGPUNodeBuilder from '../../webgpu/backends/webgpu/builder/WGSLNodeBuilder.js';
|
|
2
|
-
import { NoToneMapping, EquirectangularReflectionMapping, EquirectangularRefractionMapping } from 'three';
|
|
3
|
-
import { NodeFrame, cubeTexture, texture, rangeFog, densityFog, reference, toneMapping, positionWorld, modelWorldMatrix, transformDirection, equirectUV, viewportBottomLeft } from '../../../nodes/Nodes.js';
|
|
4
|
-
|
|
5
|
-
class NodeRender {
|
|
6
|
-
|
|
7
|
-
constructor( renderer, properties ) {
|
|
8
|
-
|
|
9
|
-
this.renderer = renderer;
|
|
10
|
-
this.properties = properties;
|
|
11
|
-
|
|
12
|
-
this.nodeFrame = new NodeFrame();
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
get( renderObject ) {
|
|
17
|
-
|
|
18
|
-
const renderObjectProperties = this.properties.get( renderObject );
|
|
19
|
-
|
|
20
|
-
let nodeBuilder = renderObjectProperties.nodeBuilder;
|
|
21
|
-
|
|
22
|
-
if ( nodeBuilder === undefined ) {
|
|
23
|
-
|
|
24
|
-
nodeBuilder = new WebGPUNodeBuilder( renderObject.object, this.renderer );
|
|
25
|
-
nodeBuilder.material = renderObject.material;
|
|
26
|
-
nodeBuilder.lightsNode = renderObject.lightsNode;
|
|
27
|
-
nodeBuilder.environmentNode = this.getEnvironmentNode( renderObject.scene );
|
|
28
|
-
nodeBuilder.fogNode = this.getFogNode( renderObject.scene );
|
|
29
|
-
nodeBuilder.toneMappingNode = this.getToneMappingNode();
|
|
30
|
-
nodeBuilder.build();
|
|
31
|
-
|
|
32
|
-
renderObjectProperties.nodeBuilder = nodeBuilder;
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return nodeBuilder;
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
getForCompute( computeNode ) {
|
|
41
|
-
|
|
42
|
-
const computeProperties = this.properties.get( computeNode );
|
|
43
|
-
|
|
44
|
-
let nodeBuilder = computeProperties.nodeBuilder;
|
|
45
|
-
|
|
46
|
-
if ( nodeBuilder === undefined ) {
|
|
47
|
-
|
|
48
|
-
nodeBuilder = new WebGPUNodeBuilder( computeNode, this.renderer );
|
|
49
|
-
nodeBuilder.build();
|
|
50
|
-
|
|
51
|
-
computeProperties.nodeBuilder = nodeBuilder;
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return nodeBuilder;
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
remove( renderObject ) {
|
|
60
|
-
|
|
61
|
-
const objectProperties = this.properties.get( renderObject );
|
|
62
|
-
|
|
63
|
-
delete objectProperties.nodeBuilder;
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
getEnvironmentNode( scene ) {
|
|
68
|
-
|
|
69
|
-
return scene.environmentNode || this.properties.get( scene ).environmentNode || null;
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
getFogNode( scene ) {
|
|
74
|
-
|
|
75
|
-
return scene.fogNode || this.properties.get( scene ).fogNode || null;
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
getToneMappingNode() {
|
|
80
|
-
|
|
81
|
-
return this.renderer.toneMappingNode || this.properties.get( this.renderer ).toneMappingNode || null;
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
getCacheKey( scene, lightsNode ) {
|
|
86
|
-
|
|
87
|
-
const environmentNode = this.getEnvironmentNode( scene );
|
|
88
|
-
const fogNode = this.getFogNode( scene );
|
|
89
|
-
const toneMappingNode = this.getToneMappingNode();
|
|
90
|
-
|
|
91
|
-
const cacheKey = [];
|
|
92
|
-
|
|
93
|
-
if ( lightsNode ) cacheKey.push( 'lightsNode:' + lightsNode.getCacheKey() );
|
|
94
|
-
if ( environmentNode ) cacheKey.push( 'environmentNode:' + environmentNode.getCacheKey() );
|
|
95
|
-
if ( fogNode ) cacheKey.push( 'fogNode:' + fogNode.getCacheKey() );
|
|
96
|
-
if ( toneMappingNode ) cacheKey.push( 'toneMappingNode:' + toneMappingNode.getCacheKey() );
|
|
97
|
-
|
|
98
|
-
return '{' + cacheKey.join( ',' ) + '}';
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
updateToneMapping() {
|
|
103
|
-
|
|
104
|
-
const renderer = this.renderer;
|
|
105
|
-
const rendererProperties = this.properties.get( renderer );
|
|
106
|
-
const rendererToneMapping = renderer.toneMapping;
|
|
107
|
-
|
|
108
|
-
if ( rendererToneMapping !== NoToneMapping ) {
|
|
109
|
-
|
|
110
|
-
if ( rendererProperties.toneMapping !== rendererToneMapping ) {
|
|
111
|
-
|
|
112
|
-
rendererProperties.toneMappingNode = toneMapping( rendererToneMapping, reference( 'toneMappingExposure', 'float', renderer ) );
|
|
113
|
-
rendererProperties.toneMapping = rendererToneMapping;
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
} else {
|
|
118
|
-
|
|
119
|
-
delete rendererProperties.toneMappingNode;
|
|
120
|
-
delete rendererProperties.toneMapping;
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
updateBackground( scene ) {
|
|
127
|
-
|
|
128
|
-
const sceneProperties = this.properties.get( scene );
|
|
129
|
-
const background = scene.background;
|
|
130
|
-
|
|
131
|
-
if ( background ) {
|
|
132
|
-
|
|
133
|
-
if ( sceneProperties.background !== background ) {
|
|
134
|
-
|
|
135
|
-
let backgroundNode = null;
|
|
136
|
-
|
|
137
|
-
if ( background.isCubeTexture === true ) {
|
|
138
|
-
|
|
139
|
-
backgroundNode = cubeTexture( background, transformDirection( positionWorld, modelWorldMatrix ) );
|
|
140
|
-
|
|
141
|
-
} else if ( background.isTexture === true ) {
|
|
142
|
-
|
|
143
|
-
let nodeUV = null;
|
|
144
|
-
|
|
145
|
-
if ( background.mapping === EquirectangularReflectionMapping || background.mapping === EquirectangularRefractionMapping ) {
|
|
146
|
-
|
|
147
|
-
nodeUV = equirectUV();
|
|
148
|
-
|
|
149
|
-
} else {
|
|
150
|
-
|
|
151
|
-
nodeUV = viewportBottomLeft;
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
backgroundNode = texture( background, nodeUV );
|
|
156
|
-
|
|
157
|
-
} else if ( background.isColor !== true ) {
|
|
158
|
-
|
|
159
|
-
console.error( 'WebGPUNodes: Unsupported background configuration.', background );
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
sceneProperties.backgroundNode = backgroundNode;
|
|
164
|
-
sceneProperties.background = background;
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
} else if ( sceneProperties.backgroundNode ) {
|
|
169
|
-
|
|
170
|
-
delete sceneProperties.backgroundNode;
|
|
171
|
-
delete sceneProperties.background;
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
updateFog( scene ) {
|
|
178
|
-
|
|
179
|
-
const sceneProperties = this.properties.get( scene );
|
|
180
|
-
const fog = scene.fog;
|
|
181
|
-
|
|
182
|
-
if ( fog ) {
|
|
183
|
-
|
|
184
|
-
if ( sceneProperties.fog !== fog ) {
|
|
185
|
-
|
|
186
|
-
let fogNode = null;
|
|
187
|
-
|
|
188
|
-
if ( fog.isFogExp2 ) {
|
|
189
|
-
|
|
190
|
-
fogNode = densityFog( reference( 'color', 'color', fog ), reference( 'density', 'float', fog ) );
|
|
191
|
-
|
|
192
|
-
} else if ( fog.isFog ) {
|
|
193
|
-
|
|
194
|
-
fogNode = rangeFog( reference( 'color', 'color', fog ), reference( 'near', 'float', fog ), reference( 'far', 'float', fog ) );
|
|
195
|
-
|
|
196
|
-
} else {
|
|
197
|
-
|
|
198
|
-
console.error( 'WebGPUNodes: Unsupported fog configuration.', fog );
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
sceneProperties.fogNode = fogNode;
|
|
203
|
-
sceneProperties.fog = fog;
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
} else {
|
|
208
|
-
|
|
209
|
-
delete sceneProperties.fogNode;
|
|
210
|
-
delete sceneProperties.fog;
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
updateEnvironment( scene ) {
|
|
217
|
-
|
|
218
|
-
const sceneProperties = this.properties.get( scene );
|
|
219
|
-
const environment = scene.environment;
|
|
220
|
-
|
|
221
|
-
if ( environment ) {
|
|
222
|
-
|
|
223
|
-
if ( sceneProperties.environment !== environment ) {
|
|
224
|
-
|
|
225
|
-
let environmentNode = null;
|
|
226
|
-
|
|
227
|
-
if ( environment.isCubeTexture === true ) {
|
|
228
|
-
|
|
229
|
-
environmentNode = cubeTexture( environment );
|
|
230
|
-
|
|
231
|
-
} else if ( environment.isTexture === true ) {
|
|
232
|
-
|
|
233
|
-
environmentNode = texture( environment );
|
|
234
|
-
|
|
235
|
-
} else {
|
|
236
|
-
|
|
237
|
-
console.error( 'WebGPUNodes: Unsupported environment configuration.', environment );
|
|
238
|
-
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
sceneProperties.environmentNode = environmentNode;
|
|
242
|
-
sceneProperties.environment = environment;
|
|
243
|
-
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
} else if ( sceneProperties.environmentNode ) {
|
|
247
|
-
|
|
248
|
-
delete sceneProperties.environmentNode;
|
|
249
|
-
delete sceneProperties.environment;
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
getNodeFrame( renderObject ) {
|
|
256
|
-
|
|
257
|
-
const nodeFrame = this.nodeFrame;
|
|
258
|
-
nodeFrame.scene = renderObject.scene;
|
|
259
|
-
nodeFrame.object = renderObject.object;
|
|
260
|
-
nodeFrame.camera = renderObject.camera;
|
|
261
|
-
nodeFrame.renderer = renderObject.renderer;
|
|
262
|
-
nodeFrame.material = renderObject.material;
|
|
263
|
-
|
|
264
|
-
return nodeFrame;
|
|
265
|
-
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
updateBefore( renderObject ) {
|
|
269
|
-
|
|
270
|
-
const nodeFrame = this.getNodeFrame( renderObject );
|
|
271
|
-
const nodeBuilder = this.get( renderObject );
|
|
272
|
-
|
|
273
|
-
for ( const node of nodeBuilder.updateBeforeNodes ) {
|
|
274
|
-
|
|
275
|
-
nodeFrame.updateBeforeNode( node );
|
|
276
|
-
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
update( renderObject ) {
|
|
282
|
-
|
|
283
|
-
const nodeFrame = this.getNodeFrame( renderObject );
|
|
284
|
-
const nodeBuilder = this.get( renderObject );
|
|
285
|
-
|
|
286
|
-
for ( const node of nodeBuilder.updateNodes ) {
|
|
287
|
-
|
|
288
|
-
nodeFrame.updateNode( node );
|
|
289
|
-
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
dispose() {
|
|
295
|
-
|
|
296
|
-
this.nodeFrame = new NodeFrame();
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
export default NodeRender;
|
|
File without changes
|
|
File without changes
|