THREE.RGBELoader: unsupported type : 1009

作者: TAIS3 分类: threeJS 发布时间: 2022-05-20 10:41

在参考下面代码使用RGBELoader的时候报这个错误:THREE.RGBELoader: unsupported type : 1009,记录一下.

// import { RGBELoader } from 'three/examples/jsm/loaders/RGBELoader';
const pmremGenerator = new PMREMGenerator(this.renderer); // 使用hdr作为背景色
pmremGenerator.compileEquirectangularShader();

const scene = this.scene;
new RGBELoader()
.setDataType(UnsignedByteType)
.load('/env/railway_bridge_02_1k.hdr', function (texture) {
const envMap = pmremGenerator.fromEquirectangular(texture).texture;
// envMap.isPmremTexture = true;
pmremGenerator.dispose();

scene.environment = envMap; // 给场景添加环境光效果
scene.background = envMap; // 给场景添加背景图
});

 

百度跟谷歌一下的资料都很少.然后看了一下RGBELodaer源代码,看报错那一段

没有发现UnsignedByteType,猜想应该是由于版本的关系,这个type去掉了

switch ( this.type ) {

	case FloatType:

		numElements = image_rgba_data.length / 4;
		const floatArray = new Float32Array( numElements * 4 );

		for ( let j = 0; j < numElements; j ++ ) {

			RGBEByteToRGBFloat( image_rgba_data, j * 4, floatArray, j * 4 );

		}

		data = floatArray;
		type = FloatType;
		break;

	case HalfFloatType:

		numElements = image_rgba_data.length / 4;
		const halfArray = new Uint16Array( numElements * 4 );

		for ( let j = 0; j < numElements; j ++ ) {

			RGBEByteToRGBHalf( image_rgba_data, j * 4, halfArray, j * 4 );

		}

		data = halfArray;
		type = HalfFloatType;
		break;

	default:

		console.error( 'THREE.RGBELoader: unsupported type: ', this.type );
		break;

}

 

发表回复