super-three 0.162.0 → 0.163.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 +407 -1014
- package/build/three.module.js +406 -1013
- package/build/three.module.min.js +1 -1
- package/examples/jsm/controls/TransformControls.js +3 -3
- package/examples/jsm/exporters/GLTFExporter.js +21 -4
- package/examples/jsm/exporters/USDZExporter.js +15 -0
- package/examples/jsm/geometries/TextGeometry.js +10 -2
- package/examples/jsm/interactive/HTMLMesh.js +7 -9
- package/examples/jsm/libs/fflate.module.js +694 -496
- package/examples/jsm/lines/LineMaterial.js +0 -2
- package/examples/jsm/loaders/3MFLoader.js +2 -0
- package/examples/jsm/loaders/EXRLoader.js +89 -19
- package/examples/jsm/loaders/FBXLoader.js +1 -1
- package/examples/jsm/loaders/GLTFLoader.js +6 -0
- package/examples/jsm/loaders/KTX2Loader.js +2 -6
- package/examples/jsm/loaders/LUT3dlLoader.js +0 -15
- package/examples/jsm/loaders/LUTCubeLoader.js +0 -14
- package/examples/jsm/loaders/LUTImageLoader.js +0 -14
- package/examples/jsm/loaders/RGBMLoader.js +16 -0
- package/examples/jsm/misc/GPUComputationRenderer.js +0 -6
- package/examples/jsm/nodes/Nodes.js +6 -1
- package/examples/jsm/nodes/accessors/BatchNode.js +78 -0
- package/examples/jsm/nodes/accessors/InstanceNode.js +25 -2
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +1 -1
- package/examples/jsm/nodes/accessors/MorphNode.js +13 -3
- package/examples/jsm/nodes/accessors/NormalNode.js +12 -2
- package/examples/jsm/nodes/accessors/ReferenceNode.js +1 -1
- package/examples/jsm/nodes/accessors/RendererReferenceNode.js +29 -0
- package/examples/jsm/nodes/accessors/TextureNode.js +30 -7
- package/examples/jsm/nodes/core/Node.js +55 -4
- package/examples/jsm/nodes/core/NodeBuilder.js +21 -16
- package/examples/jsm/nodes/core/NodeFrame.js +10 -10
- package/examples/jsm/nodes/core/NodeUtils.js +2 -2
- package/examples/jsm/nodes/core/UniformNode.js +20 -0
- package/examples/jsm/nodes/display/PassNode.js +17 -1
- package/examples/jsm/nodes/display/ToneMappingNode.js +8 -4
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +6 -0
- package/examples/jsm/nodes/fog/FogExp2Node.js +4 -5
- package/examples/jsm/nodes/fog/FogNode.js +13 -3
- package/examples/jsm/nodes/fog/FogRangeNode.js +4 -3
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +12 -69
- package/examples/jsm/nodes/materials/NodeMaterial.js +33 -11
- package/examples/jsm/nodes/pmrem/PMREMNode.js +193 -0
- package/examples/jsm/nodes/pmrem/PMREMUtils.js +288 -0
- package/examples/jsm/nodes/shadernode/ShaderNode.js +1 -1
- package/examples/jsm/nodes/utils/EquirectUVNode.js +1 -1
- package/examples/jsm/objects/QuadMesh.js +7 -23
- package/examples/jsm/physics/RapierPhysics.js +4 -4
- package/examples/jsm/postprocessing/GlitchPass.js +0 -3
- package/examples/jsm/postprocessing/LUTPass.js +5 -71
- package/examples/jsm/postprocessing/SAOPass.js +0 -1
- package/examples/jsm/postprocessing/SSAOPass.js +0 -3
- package/examples/jsm/renderers/common/Animation.js +3 -0
- package/examples/jsm/renderers/common/Background.js +5 -5
- package/examples/jsm/renderers/common/Info.js +11 -19
- package/examples/jsm/renderers/common/PostProcessing.js +12 -4
- package/examples/jsm/renderers/common/RenderContext.js +1 -1
- package/examples/jsm/renderers/common/RenderObject.js +4 -4
- package/examples/jsm/renderers/common/RenderObjects.js +1 -1
- package/examples/jsm/renderers/common/Renderer.js +25 -8
- package/examples/jsm/renderers/common/extras/PMREMGenerator.js +777 -0
- package/examples/jsm/renderers/common/nodes/Nodes.js +5 -18
- package/examples/jsm/renderers/webgl/WebGLBackend.js +148 -24
- package/examples/jsm/renderers/webgl/WebGLBufferRenderer.js +141 -0
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +3 -3
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +1 -1
- package/examples/jsm/renderers/webgl/utils/WebGLConstants.js +1 -0
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +43 -0
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +3 -2
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +0 -2
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +0 -2
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +54 -25
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +5 -3
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +25 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +18 -4
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +92 -18
- package/examples/jsm/utils/GPUStatsPanel.js +10 -45
- package/examples/jsm/utils/TextureUtils.js +1 -1
- package/package.json +1 -1
- package/src/Three.js +0 -1
- package/src/animation/AnimationClip.js +1 -1
- package/src/constants.js +3 -3
- package/src/core/Object3D.js +10 -7
- package/src/extras/PMREMGenerator.js +9 -0
- package/src/loaders/ObjectLoader.js +2 -0
- package/src/materials/ShaderMaterial.js +0 -4
- package/src/math/Spherical.js +4 -5
- package/src/objects/BatchedMesh.js +4 -3
- package/src/objects/InstancedMesh.js +10 -0
- package/src/renderers/WebGLRenderer.js +55 -114
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +2 -10
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +2 -16
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +32 -22
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib.js +1 -1
- package/src/renderers/shaders/UniformsUtils.js +10 -1
- package/src/renderers/webgl/WebGLAttributes.js +6 -33
- package/src/renderers/webgl/WebGLBindingStates.js +14 -51
- package/src/renderers/webgl/WebGLBufferRenderer.js +3 -25
- package/src/renderers/webgl/WebGLCapabilities.js +2 -12
- package/src/renderers/webgl/WebGLCubeUVMaps.js +10 -6
- package/src/renderers/webgl/WebGLExtensions.js +4 -19
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +3 -25
- package/src/renderers/webgl/WebGLLights.js +6 -32
- package/src/renderers/webgl/WebGLMaterials.js +2 -3
- package/src/renderers/webgl/WebGLMorphtargets.js +79 -217
- package/src/renderers/webgl/WebGLProgram.js +18 -47
- package/src/renderers/webgl/WebGLPrograms.js +20 -32
- package/src/renderers/webgl/WebGLRenderStates.js +8 -6
- package/src/renderers/webgl/WebGLState.js +15 -59
- package/src/renderers/webgl/WebGLTextures.js +75 -237
- package/src/renderers/webgl/WebGLUniformsGroups.js +1 -1
- package/src/renderers/webgl/WebGLUtils.js +6 -57
- package/src/renderers/webxr/WebXRDepthSensing.js +2 -3
- package/src/renderers/webxr/WebXRManager.js +2 -2
- package/src/scenes/Scene.js +7 -1
- package/src/textures/Texture.js +11 -1
- package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +0 -37
- package/src/renderers/WebGL1Renderer.js +0 -7
|
@@ -603,12 +603,10 @@ class LineMaterial extends ShaderMaterial {
|
|
|
603
603
|
if ( value === true ) {
|
|
604
604
|
|
|
605
605
|
this.defines.USE_ALPHA_TO_COVERAGE = '';
|
|
606
|
-
this.extensions.derivatives = true;
|
|
607
606
|
|
|
608
607
|
} else {
|
|
609
608
|
|
|
610
609
|
delete this.defines.USE_ALPHA_TO_COVERAGE;
|
|
611
|
-
this.extensions.derivatives = false;
|
|
612
610
|
|
|
613
611
|
}
|
|
614
612
|
|
|
@@ -1886,10 +1886,10 @@ class EXRLoader extends DataTextureLoader {
|
|
|
1886
1886
|
|
|
1887
1887
|
function parseBox2i( dataView, offset ) {
|
|
1888
1888
|
|
|
1889
|
-
const xMin =
|
|
1890
|
-
const yMin =
|
|
1891
|
-
const xMax =
|
|
1892
|
-
const yMax =
|
|
1889
|
+
const xMin = parseInt32( dataView, offset );
|
|
1890
|
+
const yMin = parseInt32( dataView, offset );
|
|
1891
|
+
const xMax = parseInt32( dataView, offset );
|
|
1892
|
+
const yMax = parseInt32( dataView, offset );
|
|
1893
1893
|
|
|
1894
1894
|
return { xMin: xMin, yMin: yMin, xMax: xMax, yMax: yMax };
|
|
1895
1895
|
|
|
@@ -1898,7 +1898,8 @@ class EXRLoader extends DataTextureLoader {
|
|
|
1898
1898
|
function parseLineOrder( dataView, offset ) {
|
|
1899
1899
|
|
|
1900
1900
|
const lineOrders = [
|
|
1901
|
-
'INCREASING_Y'
|
|
1901
|
+
'INCREASING_Y',
|
|
1902
|
+
'DECREASING_Y'
|
|
1902
1903
|
];
|
|
1903
1904
|
|
|
1904
1905
|
const lineOrder = parseUint8( dataView, offset );
|
|
@@ -2066,10 +2067,12 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2066
2067
|
width: EXRHeader.dataWindow.xMax - EXRHeader.dataWindow.xMin + 1,
|
|
2067
2068
|
height: EXRHeader.dataWindow.yMax - EXRHeader.dataWindow.yMin + 1,
|
|
2068
2069
|
channels: EXRHeader.channels.length,
|
|
2070
|
+
channelLineOffsets: {},
|
|
2071
|
+
scanOrder: null,
|
|
2069
2072
|
bytesPerLine: null,
|
|
2070
2073
|
lines: null,
|
|
2071
2074
|
inputSize: null,
|
|
2072
|
-
type:
|
|
2075
|
+
type: null,
|
|
2073
2076
|
uncompress: null,
|
|
2074
2077
|
getter: null,
|
|
2075
2078
|
format: null,
|
|
@@ -2125,6 +2128,43 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2125
2128
|
|
|
2126
2129
|
EXRDecoder.scanlineBlockSize = EXRDecoder.lines;
|
|
2127
2130
|
|
|
2131
|
+
const channels = {};
|
|
2132
|
+
for ( const channel of EXRHeader.channels ) {
|
|
2133
|
+
|
|
2134
|
+
switch ( channel.name ) {
|
|
2135
|
+
|
|
2136
|
+
case 'Y':
|
|
2137
|
+
case 'R':
|
|
2138
|
+
case 'G':
|
|
2139
|
+
case 'B':
|
|
2140
|
+
case 'A':
|
|
2141
|
+
channels[ channel.name ] = true;
|
|
2142
|
+
EXRDecoder.type = channel.pixelType;
|
|
2143
|
+
|
|
2144
|
+
}
|
|
2145
|
+
|
|
2146
|
+
}
|
|
2147
|
+
|
|
2148
|
+
// RGB images will be converted to RGBA format, preventing software emulation in select devices.
|
|
2149
|
+
let fillAlpha = false;
|
|
2150
|
+
|
|
2151
|
+
if ( channels.R && channels.G && channels.B ) {
|
|
2152
|
+
|
|
2153
|
+
fillAlpha = ! channels.A;
|
|
2154
|
+
EXRDecoder.outputChannels = 4;
|
|
2155
|
+
EXRDecoder.decodeChannels = { R: 0, G: 1, B: 2, A: 3 };
|
|
2156
|
+
|
|
2157
|
+
} else if ( channels.Y ) {
|
|
2158
|
+
|
|
2159
|
+
EXRDecoder.outputChannels = 1;
|
|
2160
|
+
EXRDecoder.decodeChannels = { Y: 0 };
|
|
2161
|
+
|
|
2162
|
+
} else {
|
|
2163
|
+
|
|
2164
|
+
throw new Error( 'EXRLoader.parse: file contains unsupported data channels.' );
|
|
2165
|
+
|
|
2166
|
+
}
|
|
2167
|
+
|
|
2128
2168
|
if ( EXRDecoder.type == 1 ) {
|
|
2129
2169
|
|
|
2130
2170
|
// half
|
|
@@ -2164,15 +2204,13 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2164
2204
|
|
|
2165
2205
|
}
|
|
2166
2206
|
|
|
2167
|
-
EXRDecoder.blockCount =
|
|
2207
|
+
EXRDecoder.blockCount = EXRDecoder.height / EXRDecoder.scanlineBlockSize;
|
|
2168
2208
|
|
|
2169
2209
|
for ( let i = 0; i < EXRDecoder.blockCount; i ++ )
|
|
2170
2210
|
parseInt64( dataView, offset ); // scanlineOffset
|
|
2171
2211
|
|
|
2172
2212
|
// we should be passed the scanline offset table, ready to start reading pixel data.
|
|
2173
2213
|
|
|
2174
|
-
// RGB images will be converted to RGBA format, preventing software emulation in select devices.
|
|
2175
|
-
EXRDecoder.outputChannels = ( ( EXRDecoder.channels == 3 ) ? 4 : EXRDecoder.channels );
|
|
2176
2214
|
const size = EXRDecoder.width * EXRDecoder.height * EXRDecoder.outputChannels;
|
|
2177
2215
|
|
|
2178
2216
|
switch ( outputType ) {
|
|
@@ -2181,7 +2219,7 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2181
2219
|
EXRDecoder.byteArray = new Float32Array( size );
|
|
2182
2220
|
|
|
2183
2221
|
// Fill initially with 1s for the alpha value if the texture is not RGBA, RGB values will be overwritten
|
|
2184
|
-
if (
|
|
2222
|
+
if ( fillAlpha )
|
|
2185
2223
|
EXRDecoder.byteArray.fill( 1, 0, size );
|
|
2186
2224
|
|
|
2187
2225
|
break;
|
|
@@ -2189,7 +2227,7 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2189
2227
|
case HalfFloatType:
|
|
2190
2228
|
EXRDecoder.byteArray = new Uint16Array( size );
|
|
2191
2229
|
|
|
2192
|
-
if (
|
|
2230
|
+
if ( fillAlpha )
|
|
2193
2231
|
EXRDecoder.byteArray.fill( 0x3C00, 0, size ); // Uint16Array holds half float data, 0x3C00 is 1
|
|
2194
2232
|
|
|
2195
2233
|
break;
|
|
@@ -2200,7 +2238,31 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2200
2238
|
|
|
2201
2239
|
}
|
|
2202
2240
|
|
|
2203
|
-
|
|
2241
|
+
let byteOffset = 0;
|
|
2242
|
+
for ( const channel of EXRHeader.channels ) {
|
|
2243
|
+
|
|
2244
|
+
if ( EXRDecoder.decodeChannels[ channel.name ] !== undefined ) {
|
|
2245
|
+
|
|
2246
|
+
EXRDecoder.channelLineOffsets[ channel.name ] = byteOffset * EXRDecoder.width;
|
|
2247
|
+
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2250
|
+
byteOffset += channel.pixelType * 2;
|
|
2251
|
+
|
|
2252
|
+
}
|
|
2253
|
+
|
|
2254
|
+
EXRDecoder.bytesPerLine = EXRDecoder.width * byteOffset;
|
|
2255
|
+
EXRDecoder.outLineWidth = EXRDecoder.width * EXRDecoder.outputChannels;
|
|
2256
|
+
|
|
2257
|
+
if ( EXRHeader.lineOrder === 'INCREASING_Y' ) {
|
|
2258
|
+
|
|
2259
|
+
EXRDecoder.scanOrder = ( y ) => y;
|
|
2260
|
+
|
|
2261
|
+
} else {
|
|
2262
|
+
|
|
2263
|
+
EXRDecoder.scanOrder = ( y ) => EXRDecoder.height - 1 - y;
|
|
2264
|
+
|
|
2265
|
+
}
|
|
2204
2266
|
|
|
2205
2267
|
if ( EXRDecoder.outputChannels == 4 ) {
|
|
2206
2268
|
|
|
@@ -2231,11 +2293,10 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2231
2293
|
const EXRDecoder = setupDecoder( EXRHeader, bufferDataView, uInt8Array, offset, this.type );
|
|
2232
2294
|
|
|
2233
2295
|
const tmpOffset = { value: 0 };
|
|
2234
|
-
const channelOffsets = { R: 0, G: 1, B: 2, A: 3, Y: 0 };
|
|
2235
2296
|
|
|
2236
2297
|
for ( let scanlineBlockIdx = 0; scanlineBlockIdx < EXRDecoder.height / EXRDecoder.scanlineBlockSize; scanlineBlockIdx ++ ) {
|
|
2237
2298
|
|
|
2238
|
-
const line =
|
|
2299
|
+
const line = parseInt32( bufferDataView, offset ) - EXRHeader.dataWindow.yMin; // line_no
|
|
2239
2300
|
EXRDecoder.size = parseUint32( bufferDataView, offset ); // data_len
|
|
2240
2301
|
EXRDecoder.lines = ( ( line + EXRDecoder.scanlineBlockSize > EXRDecoder.height ) ? ( EXRDecoder.height - line ) : EXRDecoder.scanlineBlockSize );
|
|
2241
2302
|
|
|
@@ -2246,17 +2307,26 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2246
2307
|
|
|
2247
2308
|
for ( let line_y = 0; line_y < EXRDecoder.scanlineBlockSize; line_y ++ ) {
|
|
2248
2309
|
|
|
2249
|
-
const
|
|
2250
|
-
|
|
2310
|
+
const scan_y = scanlineBlockIdx * EXRDecoder.scanlineBlockSize;
|
|
2311
|
+
const true_y = line_y + EXRDecoder.scanOrder( scan_y );
|
|
2312
|
+
if ( true_y >= EXRDecoder.height ) continue;
|
|
2313
|
+
|
|
2314
|
+
const lineOffset = line_y * EXRDecoder.bytesPerLine;
|
|
2315
|
+
const outLineOffset = ( EXRDecoder.height - 1 - true_y ) * EXRDecoder.outLineWidth;
|
|
2251
2316
|
|
|
2252
2317
|
for ( let channelID = 0; channelID < EXRDecoder.channels; channelID ++ ) {
|
|
2253
2318
|
|
|
2254
|
-
const
|
|
2319
|
+
const name = EXRHeader.channels[ channelID ].name;
|
|
2320
|
+
const lOff = EXRDecoder.channelLineOffsets[ name ];
|
|
2321
|
+
const cOff = EXRDecoder.decodeChannels[ name ];
|
|
2322
|
+
|
|
2323
|
+
if ( cOff === undefined ) continue;
|
|
2324
|
+
|
|
2325
|
+
tmpOffset.value = lineOffset + lOff;
|
|
2255
2326
|
|
|
2256
2327
|
for ( let x = 0; x < EXRDecoder.width; x ++ ) {
|
|
2257
2328
|
|
|
2258
|
-
|
|
2259
|
-
const outIndex = ( EXRDecoder.height - 1 - true_y ) * ( EXRDecoder.width * EXRDecoder.outputChannels ) + x * EXRDecoder.outputChannels + cOff;
|
|
2329
|
+
const outIndex = outLineOffset + x * EXRDecoder.outputChannels + cOff;
|
|
2260
2330
|
EXRDecoder.byteArray[ outIndex ] = EXRDecoder.getter( viewer, tmpOffset );
|
|
2261
2331
|
|
|
2262
2332
|
}
|
|
@@ -2845,7 +2845,7 @@ class AnimationParser {
|
|
|
2845
2845
|
|
|
2846
2846
|
const quaternionValues = [];
|
|
2847
2847
|
|
|
2848
|
-
if ( ! values || ! times ) return new QuaternionKeyframeTrack( modelName + '.quaternion', [], [] );
|
|
2848
|
+
if ( ! values || ! times ) return new QuaternionKeyframeTrack( modelName + '.quaternion', [ 0 ], [ 0 ] );
|
|
2849
2849
|
|
|
2850
2850
|
for ( let i = 0; i < values.length; i += 3 ) {
|
|
2851
2851
|
|
|
@@ -160,12 +160,8 @@ class KTX2Loader extends Loader {
|
|
|
160
160
|
|| renderer.extensions.has( 'WEBKIT_WEBGL_compressed_texture_pvrtc' )
|
|
161
161
|
};
|
|
162
162
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
// https://github.com/mrdoob/three.js/pull/22928
|
|
166
|
-
this.workerConfig.etc1Supported = false;
|
|
167
|
-
|
|
168
|
-
}
|
|
163
|
+
// https://github.com/mrdoob/three.js/pull/22928
|
|
164
|
+
this.workerConfig.etc1Supported = false;
|
|
169
165
|
|
|
170
166
|
}
|
|
171
167
|
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
ClampToEdgeWrapping,
|
|
6
|
-
DataTexture,
|
|
7
6
|
Data3DTexture,
|
|
8
7
|
FileLoader,
|
|
9
8
|
FloatType,
|
|
@@ -144,19 +143,6 @@ export class LUT3dlLoader extends Loader {
|
|
|
144
143
|
|
|
145
144
|
}
|
|
146
145
|
|
|
147
|
-
const texture = new DataTexture();
|
|
148
|
-
texture.image.data = data;
|
|
149
|
-
texture.image.width = size;
|
|
150
|
-
texture.image.height = size * size;
|
|
151
|
-
texture.format = RGBAFormat;
|
|
152
|
-
texture.type = this.type;
|
|
153
|
-
texture.magFilter = LinearFilter;
|
|
154
|
-
texture.minFilter = LinearFilter;
|
|
155
|
-
texture.wrapS = ClampToEdgeWrapping;
|
|
156
|
-
texture.wrapT = ClampToEdgeWrapping;
|
|
157
|
-
texture.generateMipmaps = false;
|
|
158
|
-
texture.needsUpdate = true;
|
|
159
|
-
|
|
160
146
|
const texture3D = new Data3DTexture();
|
|
161
147
|
texture3D.image.data = data;
|
|
162
148
|
texture3D.image.width = size;
|
|
@@ -174,7 +160,6 @@ export class LUT3dlLoader extends Loader {
|
|
|
174
160
|
|
|
175
161
|
return {
|
|
176
162
|
size,
|
|
177
|
-
texture,
|
|
178
163
|
texture3D,
|
|
179
164
|
};
|
|
180
165
|
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
ClampToEdgeWrapping,
|
|
5
|
-
DataTexture,
|
|
6
5
|
Data3DTexture,
|
|
7
6
|
FileLoader,
|
|
8
7
|
FloatType,
|
|
@@ -127,18 +126,6 @@ export class LUTCubeLoader extends Loader {
|
|
|
127
126
|
|
|
128
127
|
}
|
|
129
128
|
|
|
130
|
-
const texture = new DataTexture();
|
|
131
|
-
texture.image.data = data;
|
|
132
|
-
texture.image.width = size;
|
|
133
|
-
texture.image.height = size * size;
|
|
134
|
-
texture.type = this.type;
|
|
135
|
-
texture.magFilter = LinearFilter;
|
|
136
|
-
texture.minFilter = LinearFilter;
|
|
137
|
-
texture.wrapS = ClampToEdgeWrapping;
|
|
138
|
-
texture.wrapT = ClampToEdgeWrapping;
|
|
139
|
-
texture.generateMipmaps = false;
|
|
140
|
-
texture.needsUpdate = true;
|
|
141
|
-
|
|
142
129
|
const texture3D = new Data3DTexture();
|
|
143
130
|
texture3D.image.data = data;
|
|
144
131
|
texture3D.image.width = size;
|
|
@@ -158,7 +145,6 @@ export class LUTCubeLoader extends Loader {
|
|
|
158
145
|
size,
|
|
159
146
|
domainMin,
|
|
160
147
|
domainMax,
|
|
161
|
-
texture,
|
|
162
148
|
texture3D,
|
|
163
149
|
};
|
|
164
150
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Loader,
|
|
3
3
|
TextureLoader,
|
|
4
|
-
DataTexture,
|
|
5
4
|
Data3DTexture,
|
|
6
5
|
RGBAFormat,
|
|
7
6
|
UnsignedByteType,
|
|
@@ -124,18 +123,6 @@ export class LUTImageLoader extends Loader {
|
|
|
124
123
|
parse( dataArray, size ) {
|
|
125
124
|
|
|
126
125
|
const data = new Uint8Array( dataArray );
|
|
127
|
-
const texture = new DataTexture();
|
|
128
|
-
texture.image.data = data;
|
|
129
|
-
texture.image.width = size;
|
|
130
|
-
texture.image.height = size * size;
|
|
131
|
-
texture.format = RGBAFormat;
|
|
132
|
-
texture.type = UnsignedByteType;
|
|
133
|
-
texture.magFilter = LinearFilter;
|
|
134
|
-
texture.minFilter = LinearFilter;
|
|
135
|
-
texture.wrapS = ClampToEdgeWrapping;
|
|
136
|
-
texture.wrapT = ClampToEdgeWrapping;
|
|
137
|
-
texture.generateMipmaps = false;
|
|
138
|
-
texture.needsUpdate = true;
|
|
139
126
|
|
|
140
127
|
const texture3D = new Data3DTexture();
|
|
141
128
|
texture3D.image.data = data;
|
|
@@ -154,7 +141,6 @@ export class LUTImageLoader extends Loader {
|
|
|
154
141
|
|
|
155
142
|
return {
|
|
156
143
|
size,
|
|
157
|
-
texture,
|
|
158
144
|
texture3D,
|
|
159
145
|
};
|
|
160
146
|
|
|
@@ -36,6 +36,12 @@ class RGBMLoader extends DataTextureLoader {
|
|
|
36
36
|
|
|
37
37
|
const texture = new CubeTexture();
|
|
38
38
|
|
|
39
|
+
for ( let i = 0; i < 6; i ++ ) {
|
|
40
|
+
|
|
41
|
+
texture.images[ i ] = undefined;
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
39
45
|
let loaded = 0;
|
|
40
46
|
|
|
41
47
|
const scope = this;
|
|
@@ -75,6 +81,16 @@ class RGBMLoader extends DataTextureLoader {
|
|
|
75
81
|
|
|
76
82
|
}
|
|
77
83
|
|
|
84
|
+
loadCubemapAsync( urls, onProgress ) {
|
|
85
|
+
|
|
86
|
+
return new Promise( ( resolve, reject ) => {
|
|
87
|
+
|
|
88
|
+
this.loadCubemap( urls, resolve, onProgress, reject );
|
|
89
|
+
|
|
90
|
+
} );
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
|
|
78
94
|
parse( buffer ) {
|
|
79
95
|
|
|
80
96
|
const img = UPNG.decode( buffer );
|
|
@@ -171,12 +171,6 @@ class GPUComputationRenderer {
|
|
|
171
171
|
|
|
172
172
|
this.init = function () {
|
|
173
173
|
|
|
174
|
-
if ( renderer.capabilities.isWebGL2 === false && renderer.extensions.has( 'OES_texture_float' ) === false ) {
|
|
175
|
-
|
|
176
|
-
return 'No OES_texture_float support for float textures.';
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
|
|
180
174
|
if ( renderer.capabilities.maxVertexTextures === 0 ) {
|
|
181
175
|
|
|
182
176
|
return 'No support for vertex shader textures.';
|
|
@@ -64,7 +64,6 @@ export { default as RemapNode, remap, remapClamp } from './utils/RemapNode.js';
|
|
|
64
64
|
export { default as RotateUVNode, rotateUV } from './utils/RotateUVNode.js';
|
|
65
65
|
export { default as RotateNode, rotate } from './utils/RotateNode.js';
|
|
66
66
|
export { default as SetNode } from './utils/SetNode.js';
|
|
67
|
-
export { default as SpecularMIPLevelNode, specularMIPLevel } from './utils/SpecularMIPLevelNode.js';
|
|
68
67
|
export { default as SplitNode } from './utils/SplitNode.js';
|
|
69
68
|
export { default as SpriteSheetUVNode, spritesheetUV } from './utils/SpriteSheetUVNode.js';
|
|
70
69
|
export { default as StorageArrayElementNode } from './utils/StorageArrayElementNode.js';
|
|
@@ -85,8 +84,10 @@ export { default as CameraNode, cameraProjectionMatrix, cameraProjectionMatrixIn
|
|
|
85
84
|
export { default as VertexColorNode, vertexColor } from './accessors/VertexColorNode.js';
|
|
86
85
|
export { default as CubeTextureNode, cubeTexture } from './accessors/CubeTextureNode.js';
|
|
87
86
|
export { default as InstanceNode, instance } from './accessors/InstanceNode.js';
|
|
87
|
+
export { default as BatchNode, batch } from './accessors/BatchNode.js';
|
|
88
88
|
export { default as MaterialNode, materialAlphaTest, materialColor, materialShininess, materialEmissive, materialOpacity, materialSpecularColor, materialSpecularStrength, materialReflectivity, materialRoughness, materialMetalness, materialNormal, materialClearcoat, materialClearcoatRoughness, materialClearcoatNormal, materialRotation, materialSheen, materialSheenRoughness, materialIridescence, materialIridescenceIOR, materialIridescenceThickness, materialLineScale, materialLineDashSize, materialLineGapSize, materialLineWidth, materialLineDashOffset, materialPointWidth } from './accessors/MaterialNode.js';
|
|
89
89
|
export { default as MaterialReferenceNode, materialReference } from './accessors/MaterialReferenceNode.js';
|
|
90
|
+
export { default as RendererReferenceNode, rendererReference } from './accessors/RendererReferenceNode.js';
|
|
90
91
|
export { default as MorphNode, morphReference } from './accessors/MorphNode.js';
|
|
91
92
|
export { default as TextureBicubicNode, textureBicubic } from './accessors/TextureBicubicNode.js';
|
|
92
93
|
export { default as ModelNode, modelDirection, modelViewMatrix, modelNormalMatrix, modelWorldMatrix, modelPosition, modelViewPosition, modelScale } from './accessors/ModelNode.js';
|
|
@@ -160,6 +161,10 @@ export { default as EnvironmentNode } from './lighting/EnvironmentNode.js';
|
|
|
160
161
|
export { default as AONode } from './lighting/AONode.js';
|
|
161
162
|
export { default as AnalyticLightNode } from './lighting/AnalyticLightNode.js';
|
|
162
163
|
|
|
164
|
+
// pmrem
|
|
165
|
+
export { default as PMREMNode, pmremTexture } from './pmrem/PMREMNode.js';
|
|
166
|
+
export * as PMREMUtils from './pmrem/PMREMUtils.js';
|
|
167
|
+
|
|
163
168
|
// procedural
|
|
164
169
|
export { default as CheckerNode, checker } from './procedural/CheckerNode.js';
|
|
165
170
|
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import Node, { addNodeClass } from '../core/Node.js';
|
|
2
|
+
import { normalLocal } from './NormalNode.js';
|
|
3
|
+
import { positionLocal } from './PositionNode.js';
|
|
4
|
+
import { nodeProxy, vec3, mat3, mat4, int, ivec2, float } from '../shadernode/ShaderNode.js';
|
|
5
|
+
import { textureLoad } from './TextureNode.js';
|
|
6
|
+
import { textureSize } from './TextureSizeNode.js';
|
|
7
|
+
import { attribute } from '../core/AttributeNode.js';
|
|
8
|
+
import { tangentLocal } from './TangentNode.js';
|
|
9
|
+
|
|
10
|
+
class BatchNode extends Node {
|
|
11
|
+
|
|
12
|
+
constructor( batchMesh ) {
|
|
13
|
+
|
|
14
|
+
super( 'void' );
|
|
15
|
+
|
|
16
|
+
this.batchMesh = batchMesh;
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
this.instanceColorNode = null;
|
|
20
|
+
|
|
21
|
+
this.batchingIdNode = null;
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
setup( builder ) {
|
|
26
|
+
|
|
27
|
+
// POSITION
|
|
28
|
+
|
|
29
|
+
if ( this.batchingIdNode === null ) {
|
|
30
|
+
|
|
31
|
+
this.batchingIdNode = attribute( 'batchId' );
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const matriceTexture = this.batchMesh._matricesTexture;
|
|
36
|
+
|
|
37
|
+
const size = textureSize( textureLoad( matriceTexture ), 0 );
|
|
38
|
+
const j = float( int( this.batchingIdNode ) ).mul( 4 ).toVar();
|
|
39
|
+
|
|
40
|
+
const x = int( j.mod( size ) );
|
|
41
|
+
const y = int( j ).div( int( size ) );
|
|
42
|
+
const batchingMatrix = mat4(
|
|
43
|
+
textureLoad( matriceTexture, ivec2( x, y ) ),
|
|
44
|
+
textureLoad( matriceTexture, ivec2( x.add( 1 ), y ) ),
|
|
45
|
+
textureLoad( matriceTexture, ivec2( x.add( 2 ), y ) ),
|
|
46
|
+
textureLoad( matriceTexture, ivec2( x.add( 3 ), y ) )
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
const bm = mat3(
|
|
51
|
+
batchingMatrix[ 0 ].xyz,
|
|
52
|
+
batchingMatrix[ 1 ].xyz,
|
|
53
|
+
batchingMatrix[ 2 ].xyz
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
positionLocal.assign( batchingMatrix.mul( positionLocal ) );
|
|
57
|
+
|
|
58
|
+
const transformedNormal = normalLocal.div( vec3( bm[ 0 ].dot( bm[ 0 ] ), bm[ 1 ].dot( bm[ 1 ] ), bm[ 2 ].dot( bm[ 2 ] ) ) );
|
|
59
|
+
|
|
60
|
+
const batchingNormal = bm.mul( transformedNormal ).xyz;
|
|
61
|
+
|
|
62
|
+
normalLocal.assign( batchingNormal );
|
|
63
|
+
|
|
64
|
+
if ( builder.hasGeometryAttribute( 'tangent' ) ) {
|
|
65
|
+
|
|
66
|
+
tangentLocal.mulAssign( bm );
|
|
67
|
+
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export default BatchNode;
|
|
75
|
+
|
|
76
|
+
export const batch = nodeProxy( BatchNode );
|
|
77
|
+
|
|
78
|
+
addNodeClass( 'batch', BatchNode );
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import Node, { addNodeClass } from '../core/Node.js';
|
|
2
|
+
import { varyingProperty } from '../core/PropertyNode.js';
|
|
2
3
|
import { instancedBufferAttribute, instancedDynamicBufferAttribute } from './BufferAttributeNode.js';
|
|
3
4
|
import { normalLocal } from './NormalNode.js';
|
|
4
5
|
import { positionLocal } from './PositionNode.js';
|
|
5
6
|
import { nodeProxy, vec3, mat3, mat4 } from '../shadernode/ShaderNode.js';
|
|
6
|
-
import { DynamicDrawUsage, InstancedInterleavedBuffer } from 'three';
|
|
7
|
+
import { DynamicDrawUsage, InstancedInterleavedBuffer, InstancedBufferAttribute } from 'three';
|
|
7
8
|
|
|
8
9
|
class InstanceNode extends Node {
|
|
9
10
|
|
|
@@ -15,15 +16,18 @@ class InstanceNode extends Node {
|
|
|
15
16
|
|
|
16
17
|
this.instanceMatrixNode = null;
|
|
17
18
|
|
|
19
|
+
this.instanceColorNode = null;
|
|
20
|
+
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
setup( /*builder*/ ) {
|
|
21
24
|
|
|
22
25
|
let instanceMatrixNode = this.instanceMatrixNode;
|
|
23
26
|
|
|
27
|
+
const instanceMesh = this.instanceMesh;
|
|
28
|
+
|
|
24
29
|
if ( instanceMatrixNode === null ) {
|
|
25
30
|
|
|
26
|
-
const instanceMesh = this.instanceMesh;
|
|
27
31
|
const instanceAttribute = instanceMesh.instanceMatrix;
|
|
28
32
|
const buffer = new InstancedInterleavedBuffer( instanceAttribute.array, 16, 1 );
|
|
29
33
|
|
|
@@ -43,6 +47,17 @@ class InstanceNode extends Node {
|
|
|
43
47
|
|
|
44
48
|
}
|
|
45
49
|
|
|
50
|
+
const instanceColorAttribute = instanceMesh.instanceColor;
|
|
51
|
+
|
|
52
|
+
if ( instanceColorAttribute && this.instanceColorNode === null ) {
|
|
53
|
+
|
|
54
|
+
const buffer = new InstancedBufferAttribute( instanceColorAttribute.array, 3 );
|
|
55
|
+
const bufferFn = instanceColorAttribute.usage === DynamicDrawUsage ? instancedDynamicBufferAttribute : instancedBufferAttribute;
|
|
56
|
+
|
|
57
|
+
this.instanceColorNode = vec3( bufferFn( buffer, 'vec3', 3, 0 ) );
|
|
58
|
+
|
|
59
|
+
}
|
|
60
|
+
|
|
46
61
|
// POSITION
|
|
47
62
|
|
|
48
63
|
const instancePosition = instanceMatrixNode.mul( positionLocal ).xyz;
|
|
@@ -60,6 +75,14 @@ class InstanceNode extends Node {
|
|
|
60
75
|
positionLocal.assign( instancePosition );
|
|
61
76
|
normalLocal.assign( instanceNormal );
|
|
62
77
|
|
|
78
|
+
// COLOR
|
|
79
|
+
|
|
80
|
+
if ( this.instanceColorNode !== null ) {
|
|
81
|
+
|
|
82
|
+
varyingProperty( 'vec3', 'vInstanceColor' ).assign( this.instanceColorNode );
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
|
|
63
86
|
}
|
|
64
87
|
|
|
65
88
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import Node, { addNodeClass } from '../core/Node.js';
|
|
2
2
|
import { NodeUpdateType } from '../core/constants.js';
|
|
3
|
-
import { nodeProxy, tslFn } from '../shadernode/ShaderNode.js';
|
|
3
|
+
import { float, nodeProxy, tslFn } from '../shadernode/ShaderNode.js';
|
|
4
4
|
import { uniform } from '../core/UniformNode.js';
|
|
5
5
|
import { reference } from './ReferenceNode.js';
|
|
6
6
|
import { positionLocal } from './PositionNode.js';
|
|
7
7
|
import { normalLocal } from './NormalNode.js';
|
|
8
8
|
import { textureLoad } from './TextureNode.js';
|
|
9
|
-
import { vertexIndex } from '../core/IndexNode.js';
|
|
9
|
+
import { instanceIndex, vertexIndex } from '../core/IndexNode.js';
|
|
10
10
|
import { ivec2, int } from '../shadernode/ShaderNode.js';
|
|
11
11
|
import { DataArrayTexture, Vector2, Vector4, FloatType } from 'three';
|
|
12
12
|
import { loop } from '../utils/LoopNode.js';
|
|
@@ -188,7 +188,17 @@ class MorphNode extends Node {
|
|
|
188
188
|
|
|
189
189
|
loop( morphTargetsCount, ( { i } ) => {
|
|
190
190
|
|
|
191
|
-
const influence =
|
|
191
|
+
const influence = float( 0 ).toVar();
|
|
192
|
+
|
|
193
|
+
if ( this.mesh.isInstancedMesh === true && ( this.mesh.morphTexture !== null && this.mesh.morphTexture !== undefined ) ) {
|
|
194
|
+
|
|
195
|
+
influence.assign( textureLoad( this.mesh.morphTexture, ivec2( int( i ).add( 1 ), int( instanceIndex ) ) ).r );
|
|
196
|
+
|
|
197
|
+
} else {
|
|
198
|
+
|
|
199
|
+
influence.assign( reference( 'morphTargetInfluences', 'float' ).element( i ).toVar() );
|
|
200
|
+
|
|
201
|
+
}
|
|
192
202
|
|
|
193
203
|
if ( hasMorphPosition === true ) {
|
|
194
204
|
|
|
@@ -5,7 +5,7 @@ import { property } from '../core/PropertyNode.js';
|
|
|
5
5
|
import { normalize } from '../math/MathNode.js';
|
|
6
6
|
import { cameraViewMatrix } from './CameraNode.js';
|
|
7
7
|
import { modelNormalMatrix } from './ModelNode.js';
|
|
8
|
-
import { nodeImmutable } from '../shadernode/ShaderNode.js';
|
|
8
|
+
import { nodeImmutable, vec3 } from '../shadernode/ShaderNode.js';
|
|
9
9
|
|
|
10
10
|
class NormalNode extends Node {
|
|
11
11
|
|
|
@@ -37,7 +37,17 @@ class NormalNode extends Node {
|
|
|
37
37
|
|
|
38
38
|
if ( scope === NormalNode.GEOMETRY ) {
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
const geometryAttribute = builder.hasGeometryAttribute( 'normal' );
|
|
41
|
+
|
|
42
|
+
if ( geometryAttribute === false ) {
|
|
43
|
+
|
|
44
|
+
outputNode = vec3( 0, 1, 0 );
|
|
45
|
+
|
|
46
|
+
} else {
|
|
47
|
+
|
|
48
|
+
outputNode = attribute( 'normal', 'vec3' );
|
|
49
|
+
|
|
50
|
+
}
|
|
41
51
|
|
|
42
52
|
} else if ( scope === NormalNode.LOCAL ) {
|
|
43
53
|
|