gpt4 book ai didi

javascript - 获取 {"isTrusted":true} error when using GLTFLoader

转载 作者:行者123 更新时间:2023-11-30 20:16:55 28 4
gpt4 key购买 nike

问题:

一切正常:我在/GLTF/子文件夹中将我的 FBX 文件转换为 GLTF。

遗憾的是,一些转换后的文件中缺少一些几何体,所以我尝试再次转换我的 FBX 文件,这次是/TEST/。

突然,模型没有加载,从我的 console.log 语句:

console.log( 'An error happened: '+JSON.stringify(error) );

我得到了这个奇怪的无用错误:

An error happened: {"isTrusted":true}

所以我尝试将我的 FBX 文件转换为 .glb,这次转换为/TEST2/并添加一个额外的 console.log 语句:

console.log( 'An error happened: '+JSON.stringify(error, ["message", "arguments", "type", "name"]) );

我仍然得到同样的错误:

An error happened: {"isTrusted":true}
An error happened: {"type":"error"}

加载第一个转换的 gltf 文件仍然有效(来自/GLTF/的文件),但如前所述,有些文件似乎转换不当:它们的某些几何图形丢失。

这些错误是什么?我该如何加载我的模型?


代码:

<script src="../public/js/3DVisualizer/three.js"></script>
<script src="../public/js/3DVisualizer/inflate.min.js"></script>
<script src="../public/js/3DVisualizer/GLTFLoader.js"></script>
<script src="../public/js/3DVisualizer/DracoLoader.js"></script>

<script src="../public/js/3DVisualizer/OrbitControls.js"></script>
<script src="../public/js/3DVisualizer/Detector.js"></script>
<script src="../public/js/3DVisualizer/stats.min.js"></script>

<script src="../public/js/3DVisualizer/TGALoader.js"></script>

//SOME MORE CODE

<script>

// Instantiate a loader
var loader = new THREE.GLTFLoader();

// Optional: Provide a DRACOLoader instance to decode compressed mesh data
THREE.DRACOLoader.setDecoderPath( '../public/js/3DVisualizer/' );
THREE.DRACOLoader.setDecoderConfig( { type: 'js' } );
loader.setDRACOLoader( new THREE.DRACOLoader() );

// Load a glTF resource
loader.load(
// resource URL
'../public/3D/TEST2/'+name+'.glb',
// called when the resource is loaded
function ( gltf ) {

scene.add( gltf.scene );

gltf.animations; // Array<THREE.AnimationClip>
gltf.scene; // THREE.Scene
gltf.scenes; // Array<THREE.Scene>
gltf.cameras; // Array<THREE.Camera>
gltf.asset; // Object

gltf.scene.traverse(function(node) {
if (node instanceof THREE.Mesh) {
frontObject = node;
node.geometry.computeFaceNormals();
node.geometry.computeVertexNormals();
}
});

if (name.includes("...")) {
backObject = gltf.scene;
}
else {
frontObject = gltf.scene;
}

console.log("LOADED")

frontObject.scale.set(45, 45, 45);
backObject.scale.set(45, 45, 45);


let box = new THREE.Box3().setFromObject(frontObject);
let sphere = box.getBoundingSphere();
let centerPoint = sphere.center;

console.log("CENTER POINT X: " + centerPoint.x);
console.log("CENTER POINT Y: " + centerPoint.y);
console.log("CENTER POINT Z: " + centerPoint.z);

centerPoint.y = 150;

var newCoordinate = shootRay(centerPoint, frontObject);

console.log("NEW POINT X: " + newCoordinate.x);
console.log("NEW POINT Y: " + newCoordinate.y);
console.log("NEW POINT Z: " + newCoordinate.z);

backObject.position.set(newCoordinate.x, newCoordinate.y, (newCoordinate.z - 0));

},
// called while loading is progressing
function ( xhr ) {

},
// called when loading has errors
function ( error ) {
console.log( 'An error happened: '+JSON.stringify(error) );
console.log( 'An error happened: '+JSON.stringify(error, ["message", "arguments", "type", "name"]) );

}
);

</script>

我用来从 FBX 转换为 GLTF 的 NPM 包:

https://www.npmjs.com/package/fbx2gltf


错误:

enter image description here


我看到了什么:

Log shows Error object: {"isTrusted":true} instead of actual error data

.NET Cors isTrusted: true error with Angular 5 app

{"isTrusted":true} exception in core.umd.js


编辑:

enter image description here

最佳答案

要调试它,您可以将模型拖到 my debugging viewer 中你会看到这条消息:

Missing texture: M_Med_Soldier_Body_BLACKKNIGHT_n.tga

glTF 和网络浏览器都不支持 TGA 纹理,因此引用它的事实是用于创建此文件的工具中的错误。我建议在 FBX2glTF 上提交错误。

但是,如果您查看模型文件夹,您会看到相同的图像已经作为 PNG 存在(也许 FBX2glTF 转换了它?)。如果您在文本编辑器(我使用的是 Sublime Text)中打开 .gltf 文件并搜索“图像”,您会发现不正确的 TGA 图像引用。将其重命名为 .png,您将看到我假设的正确结果:

screenshot of working knight model

关于javascript - 获取 {"isTrusted":true} error when using GLTFLoader,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51839039/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com