@plastic-software/three 0.178.0 → 0.179.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 +1 -1
- package/build/three.cjs +856 -196
- package/build/three.core.js +647 -123
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +211 -76
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +70 -21
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +1796 -557
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +1754 -557
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +1 -2
- package/examples/jsm/capabilities/WebGPU.js +1 -1
- package/examples/jsm/csm/CSMShadowNode.js +4 -4
- package/examples/jsm/environments/RoomEnvironment.js +8 -3
- package/examples/jsm/exporters/USDZExporter.js +676 -299
- package/examples/jsm/geometries/RoundedBoxGeometry.js +47 -8
- package/examples/jsm/interactive/HTMLMesh.js +5 -3
- package/examples/jsm/libs/meshopt_decoder.module.js +75 -58
- package/examples/jsm/lights/LightProbeGenerator.js +14 -3
- package/examples/jsm/loaders/EXRLoader.js +210 -22
- package/examples/jsm/loaders/FBXLoader.js +1 -1
- package/examples/jsm/loaders/MaterialXLoader.js +212 -30
- package/examples/jsm/loaders/TTFLoader.js +13 -1
- package/examples/jsm/loaders/USDLoader.js +219 -0
- package/examples/jsm/loaders/USDZLoader.js +4 -892
- package/examples/jsm/loaders/usd/USDAParser.js +741 -0
- package/examples/jsm/loaders/usd/USDCParser.js +17 -0
- package/examples/jsm/objects/LensflareMesh.js +3 -3
- package/examples/jsm/objects/SkyMesh.js +2 -2
- package/examples/jsm/physics/RapierPhysics.js +14 -5
- package/examples/jsm/postprocessing/GTAOPass.js +10 -9
- package/examples/jsm/postprocessing/OutlinePass.js +17 -17
- package/examples/jsm/postprocessing/SSAOPass.js +10 -9
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +11 -2
- package/examples/jsm/transpiler/GLSLDecoder.js +2 -2
- package/examples/jsm/tsl/display/BloomNode.js +8 -7
- package/examples/jsm/tsl/display/GaussianBlurNode.js +6 -8
- package/examples/jsm/tsl/display/{TRAAPassNode.js → TRAANode.js} +181 -172
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +1 -1
- package/package.json +1 -1
- package/src/Three.Core.js +1 -0
- package/src/Three.TSL.js +69 -20
- package/src/animation/KeyframeTrack.js +1 -1
- package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
- package/src/animation/tracks/StringKeyframeTrack.js +1 -1
- package/src/cameras/Camera.js +14 -0
- package/src/cameras/OrthographicCamera.js +1 -1
- package/src/cameras/PerspectiveCamera.js +1 -1
- package/src/constants.js +1 -1
- package/{examples/jsm/misc → src/core}/Timer.js +4 -42
- package/src/extras/PMREMGenerator.js +11 -0
- package/src/helpers/CameraHelper.js +41 -11
- package/src/helpers/SkeletonHelper.js +35 -6
- package/src/lights/LightShadow.js +21 -8
- package/src/lights/PointLightShadow.js +1 -1
- package/src/loaders/FileLoader.js +25 -2
- package/src/loaders/ImageBitmapLoader.js +23 -0
- package/src/loaders/Loader.js +14 -0
- package/src/loaders/LoadingManager.js +23 -0
- package/src/materials/MeshBasicMaterial.js +1 -1
- package/src/materials/nodes/Line2NodeMaterial.js +0 -8
- package/src/materials/nodes/NodeMaterial.js +1 -1
- package/src/materials/nodes/PointsNodeMaterial.js +5 -0
- package/src/materials/nodes/manager/NodeMaterialObserver.js +87 -2
- package/src/math/Frustum.js +19 -8
- package/src/math/FrustumArray.js +10 -5
- package/src/math/Line3.js +129 -2
- package/src/math/Matrix4.js +48 -27
- package/src/math/Spherical.js +2 -2
- package/src/nodes/Nodes.js +1 -0
- package/src/nodes/TSL.js +1 -0
- package/src/nodes/accessors/Camera.js +12 -12
- package/src/nodes/accessors/Normal.js +11 -11
- package/src/nodes/accessors/ReferenceNode.js +18 -3
- package/src/nodes/accessors/SceneNode.js +1 -1
- package/src/nodes/accessors/StorageTextureNode.js +1 -1
- package/src/nodes/accessors/TextureNode.js +12 -0
- package/src/nodes/core/ArrayNode.js +12 -0
- package/src/nodes/core/AssignNode.js +3 -0
- package/src/nodes/core/ContextNode.js +20 -1
- package/src/nodes/core/Node.js +14 -2
- package/src/nodes/core/NodeBuilder.js +25 -20
- package/src/nodes/core/NodeUtils.js +4 -1
- package/src/nodes/core/StackNode.js +42 -0
- package/src/nodes/core/UniformNode.js +63 -5
- package/src/nodes/core/VarNode.js +91 -2
- package/src/nodes/display/PassNode.js +148 -2
- package/src/nodes/display/ViewportTextureNode.js +67 -7
- package/src/nodes/functions/PhysicalLightingModel.js +2 -2
- package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
- package/src/nodes/gpgpu/ComputeNode.js +67 -23
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +28 -3
- package/src/nodes/lighting/ProjectorLightNode.js +19 -6
- package/src/nodes/lighting/ShadowFilterNode.js +1 -1
- package/src/nodes/materialx/MaterialXNodes.js +131 -2
- package/src/nodes/materialx/lib/mx_noise.js +165 -1
- package/src/nodes/math/ConditionalNode.js +1 -1
- package/src/nodes/math/MathNode.js +78 -54
- package/src/nodes/math/OperatorNode.js +22 -22
- package/src/nodes/tsl/TSLCore.js +64 -9
- package/src/nodes/utils/DebugNode.js +1 -1
- package/src/nodes/utils/EventNode.js +83 -0
- package/src/nodes/utils/RTTNode.js +9 -0
- package/src/objects/BatchedMesh.js +4 -2
- package/src/renderers/WebGLRenderer.js +21 -22
- package/src/renderers/common/Bindings.js +19 -18
- package/src/renderers/common/Color4.js +2 -2
- package/src/renderers/common/PostProcessing.js +60 -5
- package/src/renderers/common/Renderer.js +18 -15
- package/src/renderers/common/SampledTexture.js +3 -71
- package/src/renderers/common/Sampler.js +79 -0
- package/src/renderers/common/Storage3DTexture.js +21 -0
- package/src/renderers/common/StorageArrayTexture.js +21 -0
- package/src/renderers/common/StorageTexture.js +19 -0
- package/src/renderers/common/Textures.js +19 -3
- package/src/renderers/common/XRManager.js +26 -8
- package/src/renderers/common/nodes/NodeSampledTexture.js +0 -12
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +20 -2
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +11 -2
- package/src/renderers/webgl/WebGLCapabilities.js +2 -2
- package/src/renderers/webgl/WebGLMaterials.js +6 -6
- package/src/renderers/webgl/WebGLProgram.js +22 -16
- package/src/renderers/webgl/WebGLPrograms.js +4 -4
- package/src/renderers/webgl/WebGLShadowMap.js +11 -1
- package/src/renderers/webgl/WebGLTextures.js +19 -7
- package/src/renderers/webgl-fallback/WebGLBackend.js +22 -12
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +2 -2
- package/src/renderers/webgpu/WebGPUBackend.js +54 -15
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +53 -73
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +35 -31
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +11 -64
- package/src/renderers/webgpu/utils/WebGPUUtils.js +2 -17
- package/src/renderers/webxr/WebXRDepthSensing.js +6 -10
- package/src/renderers/webxr/WebXRManager.js +68 -8
- package/src/textures/ExternalTexture.js +45 -0
- package/src/textures/FramebufferTexture.js +2 -2
- package/src/textures/Source.js +11 -1
- package/src/textures/VideoTexture.js +30 -2
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
DataUtils,
|
|
4
4
|
FloatType,
|
|
5
5
|
HalfFloatType,
|
|
6
|
-
NoColorSpace,
|
|
7
6
|
LinearFilter,
|
|
8
7
|
LinearSRGBColorSpace,
|
|
9
8
|
RedFormat,
|
|
9
|
+
RGFormat,
|
|
10
10
|
RGBAFormat
|
|
11
11
|
} from 'three';
|
|
12
12
|
import * as fflate from '../libs/fflate.module.js';
|
|
@@ -113,6 +113,14 @@ class EXRLoader extends DataTextureLoader {
|
|
|
113
113
|
*/
|
|
114
114
|
this.type = HalfFloatType;
|
|
115
115
|
|
|
116
|
+
/**
|
|
117
|
+
* Texture output format.
|
|
118
|
+
*
|
|
119
|
+
* @type {(RGBAFormat|RGFormat|RedFormat)}
|
|
120
|
+
* @default RGBAFormat
|
|
121
|
+
*/
|
|
122
|
+
this.outputFormat = RGBAFormat;
|
|
123
|
+
|
|
116
124
|
}
|
|
117
125
|
|
|
118
126
|
/**
|
|
@@ -1022,6 +1030,81 @@ class EXRLoader extends DataTextureLoader {
|
|
|
1022
1030
|
|
|
1023
1031
|
}
|
|
1024
1032
|
|
|
1033
|
+
function lossyDctChannelDecode( channelIndex, rowPtrs, channelData, acBuffer, dcBuffer, outBuffer ) {
|
|
1034
|
+
|
|
1035
|
+
const dataView = new DataView( outBuffer.buffer );
|
|
1036
|
+
const cd = channelData[ channelIndex ];
|
|
1037
|
+
const width = cd.width;
|
|
1038
|
+
const height = cd.height;
|
|
1039
|
+
|
|
1040
|
+
const numBlocksX = Math.ceil( width / 8.0 );
|
|
1041
|
+
const numBlocksY = Math.ceil( height / 8.0 );
|
|
1042
|
+
const numFullBlocksX = Math.floor( width / 8.0 );
|
|
1043
|
+
const leftoverX = width - ( numBlocksX - 1 ) * 8;
|
|
1044
|
+
const leftoverY = height - ( numBlocksY - 1 ) * 8;
|
|
1045
|
+
|
|
1046
|
+
const currAcComp = { value: 0 };
|
|
1047
|
+
let currDcComp = 0;
|
|
1048
|
+
const dctData = new Float32Array( 64 );
|
|
1049
|
+
const halfZigBlock = new Uint16Array( 64 );
|
|
1050
|
+
const rowBlock = new Uint16Array( numBlocksX * 64 );
|
|
1051
|
+
|
|
1052
|
+
for ( let blocky = 0; blocky < numBlocksY; ++ blocky ) {
|
|
1053
|
+
|
|
1054
|
+
let maxY = 8;
|
|
1055
|
+
|
|
1056
|
+
if ( blocky == numBlocksY - 1 ) maxY = leftoverY;
|
|
1057
|
+
|
|
1058
|
+
for ( let blockx = 0; blockx < numBlocksX; ++ blockx ) {
|
|
1059
|
+
|
|
1060
|
+
halfZigBlock.fill( 0 );
|
|
1061
|
+
halfZigBlock[ 0 ] = dcBuffer[ currDcComp ++ ];
|
|
1062
|
+
unRleAC( currAcComp, acBuffer, halfZigBlock );
|
|
1063
|
+
unZigZag( halfZigBlock, dctData );
|
|
1064
|
+
dctInverse( dctData );
|
|
1065
|
+
convertToHalf( dctData, rowBlock, blockx * 64 );
|
|
1066
|
+
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
// Write decoded data to output buffer
|
|
1070
|
+
for ( let y = 8 * blocky; y < 8 * blocky + maxY; ++ y ) {
|
|
1071
|
+
|
|
1072
|
+
let offset = rowPtrs[ channelIndex ][ y ];
|
|
1073
|
+
|
|
1074
|
+
for ( let blockx = 0; blockx < numFullBlocksX; ++ blockx ) {
|
|
1075
|
+
|
|
1076
|
+
const src = blockx * 64 + ( ( y & 0x7 ) * 8 );
|
|
1077
|
+
|
|
1078
|
+
for ( let x = 0; x < 8; ++ x ) {
|
|
1079
|
+
|
|
1080
|
+
dataView.setUint16( offset + x * INT16_SIZE * cd.type, rowBlock[ src + x ], true );
|
|
1081
|
+
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
offset += 8 * INT16_SIZE * cd.type;
|
|
1085
|
+
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
if ( numBlocksX != numFullBlocksX ) {
|
|
1089
|
+
|
|
1090
|
+
const src = numFullBlocksX * 64 + ( ( y & 0x7 ) * 8 );
|
|
1091
|
+
|
|
1092
|
+
for ( let x = 0; x < leftoverX; ++ x ) {
|
|
1093
|
+
|
|
1094
|
+
dataView.setUint16( offset + x * INT16_SIZE * cd.type, rowBlock[ src + x ], true );
|
|
1095
|
+
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
cd.decoded = true;
|
|
1105
|
+
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1025
1108
|
function unRleAC( currAcComp, acBuffer, halfZigBlock ) {
|
|
1026
1109
|
|
|
1027
1110
|
let acValue;
|
|
@@ -1634,8 +1717,12 @@ class EXRLoader extends DataTextureLoader {
|
|
|
1634
1717
|
|
|
1635
1718
|
}
|
|
1636
1719
|
|
|
1637
|
-
//
|
|
1638
|
-
|
|
1720
|
+
// Decode lossy DCT data if we have a valid color space conversion set with the first RGB channel present
|
|
1721
|
+
if ( cscSet.idx[ 0 ] !== undefined && channelData[ cscSet.idx[ 0 ] ] ) {
|
|
1722
|
+
|
|
1723
|
+
lossyDctDecode( cscSet, rowOffsets, channelData, acBuffer, dcBuffer, outBuffer );
|
|
1724
|
+
|
|
1725
|
+
}
|
|
1639
1726
|
|
|
1640
1727
|
// Decode other channels
|
|
1641
1728
|
for ( let i = 0; i < channelData.length; ++ i ) {
|
|
@@ -1673,7 +1760,11 @@ class EXRLoader extends DataTextureLoader {
|
|
|
1673
1760
|
|
|
1674
1761
|
break;
|
|
1675
1762
|
|
|
1676
|
-
case LOSSY_DCT:
|
|
1763
|
+
case LOSSY_DCT:
|
|
1764
|
+
|
|
1765
|
+
lossyDctChannelDecode( i, rowOffsets, channelData, acBuffer, dcBuffer, outBuffer );
|
|
1766
|
+
|
|
1767
|
+
break;
|
|
1677
1768
|
|
|
1678
1769
|
default:
|
|
1679
1770
|
throw new Error( 'EXRLoader.parse: unsupported channel compression' );
|
|
@@ -2291,7 +2382,7 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2291
2382
|
|
|
2292
2383
|
}
|
|
2293
2384
|
|
|
2294
|
-
function setupDecoder( EXRHeader, dataView, uInt8Array, offset, outputType ) {
|
|
2385
|
+
function setupDecoder( EXRHeader, dataView, uInt8Array, offset, outputType, outputFormat ) {
|
|
2295
2386
|
|
|
2296
2387
|
const EXRDecoder = {
|
|
2297
2388
|
size: 0,
|
|
@@ -2302,6 +2393,7 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2302
2393
|
height: EXRHeader.dataWindow.yMax - EXRHeader.dataWindow.yMin + 1,
|
|
2303
2394
|
inputChannels: EXRHeader.channels,
|
|
2304
2395
|
channelByteOffsets: {},
|
|
2396
|
+
shouldExpand: false,
|
|
2305
2397
|
scanOrder: null,
|
|
2306
2398
|
totalBytes: null,
|
|
2307
2399
|
columns: null,
|
|
@@ -2379,17 +2471,16 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2379
2471
|
|
|
2380
2472
|
// RGB images will be converted to RGBA format, preventing software emulation in select devices.
|
|
2381
2473
|
let fillAlpha = false;
|
|
2474
|
+
let invalidOutput = false;
|
|
2382
2475
|
|
|
2476
|
+
// Validate if input texture contain supported channels
|
|
2383
2477
|
if ( channels.R && channels.G && channels.B ) {
|
|
2384
2478
|
|
|
2385
|
-
fillAlpha = ! channels.A;
|
|
2386
2479
|
EXRDecoder.outputChannels = 4;
|
|
2387
|
-
EXRDecoder.decodeChannels = { R: 0, G: 1, B: 2, A: 3 };
|
|
2388
2480
|
|
|
2389
2481
|
} else if ( channels.Y ) {
|
|
2390
2482
|
|
|
2391
2483
|
EXRDecoder.outputChannels = 1;
|
|
2392
|
-
EXRDecoder.decodeChannels = { Y: 0 };
|
|
2393
2484
|
|
|
2394
2485
|
} else {
|
|
2395
2486
|
|
|
@@ -2397,6 +2488,83 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2397
2488
|
|
|
2398
2489
|
}
|
|
2399
2490
|
|
|
2491
|
+
// Setup output texture configuration
|
|
2492
|
+
switch ( EXRDecoder.outputChannels ) {
|
|
2493
|
+
|
|
2494
|
+
case 4:
|
|
2495
|
+
|
|
2496
|
+
if ( outputFormat == RGBAFormat ) {
|
|
2497
|
+
|
|
2498
|
+
fillAlpha = ! channels.A;
|
|
2499
|
+
EXRDecoder.format = RGBAFormat;
|
|
2500
|
+
EXRDecoder.colorSpace = LinearSRGBColorSpace;
|
|
2501
|
+
EXRDecoder.outputChannels = 4;
|
|
2502
|
+
EXRDecoder.decodeChannels = { R: 0, G: 1, B: 2, A: 3 };
|
|
2503
|
+
|
|
2504
|
+
} else if ( outputFormat == RGFormat ) {
|
|
2505
|
+
|
|
2506
|
+
EXRDecoder.format = RGFormat;
|
|
2507
|
+
EXRDecoder.colorSpace = LinearSRGBColorSpace;
|
|
2508
|
+
EXRDecoder.outputChannels = 2;
|
|
2509
|
+
EXRDecoder.decodeChannels = { R: 0, G: 1 };
|
|
2510
|
+
|
|
2511
|
+
} else if ( outputFormat == RedFormat ) {
|
|
2512
|
+
|
|
2513
|
+
EXRDecoder.format = RedFormat;
|
|
2514
|
+
EXRDecoder.colorSpace = LinearSRGBColorSpace;
|
|
2515
|
+
EXRDecoder.outputChannels = 1;
|
|
2516
|
+
EXRDecoder.decodeChannels = { R: 0 };
|
|
2517
|
+
|
|
2518
|
+
} else {
|
|
2519
|
+
|
|
2520
|
+
invalidOutput = true;
|
|
2521
|
+
|
|
2522
|
+
}
|
|
2523
|
+
|
|
2524
|
+
break;
|
|
2525
|
+
|
|
2526
|
+
case 1:
|
|
2527
|
+
|
|
2528
|
+
if ( outputFormat == RGBAFormat ) {
|
|
2529
|
+
|
|
2530
|
+
fillAlpha = true;
|
|
2531
|
+
EXRDecoder.format = RGBAFormat;
|
|
2532
|
+
EXRDecoder.colorSpace = LinearSRGBColorSpace;
|
|
2533
|
+
EXRDecoder.outputChannels = 4;
|
|
2534
|
+
EXRDecoder.shouldExpand = true;
|
|
2535
|
+
EXRDecoder.decodeChannels = { Y: 0 };
|
|
2536
|
+
|
|
2537
|
+
} else if ( outputFormat == RGFormat ) {
|
|
2538
|
+
|
|
2539
|
+
EXRDecoder.format = RGFormat;
|
|
2540
|
+
EXRDecoder.colorSpace = LinearSRGBColorSpace;
|
|
2541
|
+
EXRDecoder.outputChannels = 2;
|
|
2542
|
+
EXRDecoder.shouldExpand = true;
|
|
2543
|
+
EXRDecoder.decodeChannels = { Y: 0 };
|
|
2544
|
+
|
|
2545
|
+
} else if ( outputFormat == RedFormat ) {
|
|
2546
|
+
|
|
2547
|
+
EXRDecoder.format = RedFormat;
|
|
2548
|
+
EXRDecoder.colorSpace = LinearSRGBColorSpace;
|
|
2549
|
+
EXRDecoder.outputChannels = 1;
|
|
2550
|
+
EXRDecoder.decodeChannels = { Y: 0 };
|
|
2551
|
+
|
|
2552
|
+
} else {
|
|
2553
|
+
|
|
2554
|
+
invalidOutput = true;
|
|
2555
|
+
|
|
2556
|
+
}
|
|
2557
|
+
|
|
2558
|
+
break;
|
|
2559
|
+
|
|
2560
|
+
default:
|
|
2561
|
+
|
|
2562
|
+
invalidOutput = true;
|
|
2563
|
+
|
|
2564
|
+
}
|
|
2565
|
+
|
|
2566
|
+
if (invalidOutput) throw new Error( 'EXRLoader.parse: invalid output format for specified file.' );
|
|
2567
|
+
|
|
2400
2568
|
if ( EXRDecoder.type == 1 ) {
|
|
2401
2569
|
|
|
2402
2570
|
// half
|
|
@@ -2486,18 +2654,6 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2486
2654
|
|
|
2487
2655
|
}
|
|
2488
2656
|
|
|
2489
|
-
if ( EXRDecoder.outputChannels == 4 ) {
|
|
2490
|
-
|
|
2491
|
-
EXRDecoder.format = RGBAFormat;
|
|
2492
|
-
EXRDecoder.colorSpace = LinearSRGBColorSpace;
|
|
2493
|
-
|
|
2494
|
-
} else {
|
|
2495
|
-
|
|
2496
|
-
EXRDecoder.format = RedFormat;
|
|
2497
|
-
EXRDecoder.colorSpace = NoColorSpace;
|
|
2498
|
-
|
|
2499
|
-
}
|
|
2500
|
-
|
|
2501
2657
|
if ( EXRHeader.spec.singleTile ) {
|
|
2502
2658
|
|
|
2503
2659
|
EXRDecoder.blockHeight = EXRHeader.tiles.ySize;
|
|
@@ -2543,11 +2699,30 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2543
2699
|
const EXRHeader = parseHeader( bufferDataView, buffer, offset );
|
|
2544
2700
|
|
|
2545
2701
|
// get input compression information and prepare decoding.
|
|
2546
|
-
const EXRDecoder = setupDecoder( EXRHeader, bufferDataView, uInt8Array, offset, this.type );
|
|
2702
|
+
const EXRDecoder = setupDecoder( EXRHeader, bufferDataView, uInt8Array, offset, this.type, this.outputFormat );
|
|
2547
2703
|
|
|
2548
2704
|
// parse input data
|
|
2549
2705
|
EXRDecoder.decode();
|
|
2550
2706
|
|
|
2707
|
+
// output texture post-processing
|
|
2708
|
+
if ( EXRDecoder.shouldExpand ) {
|
|
2709
|
+
|
|
2710
|
+
const byteArray = EXRDecoder.byteArray;
|
|
2711
|
+
|
|
2712
|
+
if ( this.outputFormat == RGBAFormat ) {
|
|
2713
|
+
|
|
2714
|
+
for ( let i = 0; i < byteArray.length; i += 4 )
|
|
2715
|
+
byteArray [i + 2 ] = ( byteArray [ i + 1 ] = byteArray[ i ] );
|
|
2716
|
+
|
|
2717
|
+
} else if ( this.outputFormat == RGFormat ) {
|
|
2718
|
+
|
|
2719
|
+
for ( let i = 0; i < byteArray.length; i += 2 )
|
|
2720
|
+
byteArray [ i + 1 ] = byteArray[ i ] ;
|
|
2721
|
+
|
|
2722
|
+
}
|
|
2723
|
+
|
|
2724
|
+
}
|
|
2725
|
+
|
|
2551
2726
|
return {
|
|
2552
2727
|
header: EXRHeader,
|
|
2553
2728
|
width: EXRDecoder.width,
|
|
@@ -2564,7 +2739,7 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2564
2739
|
* Sets the texture type.
|
|
2565
2740
|
*
|
|
2566
2741
|
* @param {(HalfFloatType|FloatType)} value - The texture type to set.
|
|
2567
|
-
* @return {
|
|
2742
|
+
* @return {EXRLoader} A reference to this loader.
|
|
2568
2743
|
*/
|
|
2569
2744
|
setDataType( value ) {
|
|
2570
2745
|
|
|
@@ -2573,6 +2748,19 @@ class EXRLoader extends DataTextureLoader {
|
|
|
2573
2748
|
|
|
2574
2749
|
}
|
|
2575
2750
|
|
|
2751
|
+
/**
|
|
2752
|
+
* Sets texture output format. Defaults to `RGBAFormat`.
|
|
2753
|
+
*
|
|
2754
|
+
* @param {(RGBAFormat|RGFormat|RedFormat)} value - Texture output format.
|
|
2755
|
+
* @return {EXRLoader} A reference to this loader.
|
|
2756
|
+
*/
|
|
2757
|
+
setOutputFormat( value ) {
|
|
2758
|
+
|
|
2759
|
+
this.outputFormat = value;
|
|
2760
|
+
return this;
|
|
2761
|
+
|
|
2762
|
+
}
|
|
2763
|
+
|
|
2576
2764
|
load( url, onLoad, onProgress, onError ) {
|
|
2577
2765
|
|
|
2578
2766
|
function onLoadCallback( texture, texData ) {
|
|
@@ -1784,7 +1784,7 @@ class GeometryParser {
|
|
|
1784
1784
|
geoInfo.vertexPositions = ( geoNode.Vertices !== undefined ) ? geoNode.Vertices.a : [];
|
|
1785
1785
|
geoInfo.vertexIndices = ( geoNode.PolygonVertexIndex !== undefined ) ? geoNode.PolygonVertexIndex.a : [];
|
|
1786
1786
|
|
|
1787
|
-
if ( geoNode.LayerElementColor && geoNode.LayerElementColor.
|
|
1787
|
+
if ( geoNode.LayerElementColor && geoNode.LayerElementColor[ 0 ].Colors ) {
|
|
1788
1788
|
|
|
1789
1789
|
geoInfo.color = this.parseVertexColors( geoNode.LayerElementColor[ 0 ] );
|
|
1790
1790
|
|