Ktx2 加载程序:意外的标识符“html”

问题描述 投票:0回答:1

我正在尝试加载 ktx2 纹理,但出现此错误:

未捕获的语法错误:意外的标识符“html”(位于 是60c27b-a185-4e22-a763-bad0f7c717e0:6:11)

错误指向html标签:

/* constants */
let _EngineFormat = {"RGBAFormat":1023,"RGBA_ASTC_4x4_Format":37808,"RGBA_BPTC_Format":36492,"RGBA_ETC2_EAC_Format":37496,"RGBA_PVRTC_4BPPV1_Format":35842,"RGBA_S3TC_DXT5_Format":33779,"RGB_ETC1_Format":36196,"RGB_ETC2_Format":37492,"RGB_PVRTC_4BPPV1_Format":35840,"RGB_S3TC_DXT1_Format":33776}
let _TranscoderFormat = {"ETC1":0,"ETC2":1,"BC1":2,"BC3":3,"BC4":4,"BC5":5,"BC7_M6_OPAQUE_ONLY":6,"BC7_M5":7,"PVRTC1_4_RGB":8,"PVRTC1_4_RGBA":9,"ASTC_4x4":10,"ATC_RGB":11,"ATC_RGBA_INTERPOLATED_ALPHA":12,"RGBA32":13,"RGB565":14,"BGR565":15,"RGBA4444":16}
let _BasisFormat = {"ETC1S":0,"UASTC_4x4":1}
/* basis_transcoder.js */
<!DOCTYPE html>
<html lang="en-US">
<head>

我正在使用 webpack,并且加载纹理如下:

import {KTX2Loader} from 'three/addons/loaders/KTX2Loader.js';
import test from '../../../../assets/models/test.ktx2';

this.ktx2Loader = new KTX2Loader();
this.ktx2Loader.setTranscoderPath('../utils/decoders/basis');
this.ktx2Loader.detectSupport( this.renderer );

const texture = await this.ktx2Loader.loadAsync(test);

对 basic_transcoder 的 js 和 wasm 请求都返回 307 临时重定向。

三个r150

three.js
1个回答
0
投票

在 Yuri Artiukh 视频上找到了解决方案,我只在本地处理此问题,但它解决了我的问题。

import * as THREE from "three"
import { REVISION } from "three"

const THREE_PATH = `https://unpkg.com/three@0.${REVISION}.x`
const ktx2Loader = new KTX2Loader()
ktx2Loader.setTranscoderPath(`${THREE_PATH}/examples/jsm/libs/basis/`)
ktx2Loader.detectSupport(this.renderer)
    
// after you have a mesh and its been added to the scene something like this should now work
    
ktx2Loader.load(tDiffuse, (texture) => {
  material.uniforms.uDiffuse.value = texture
})

© www.soinside.com 2019 - 2024. All rights reserved.