使用GLTFLoader时错误:获取一个{真“isTrusted”}(Getting an {“is

2019-09-27 10:15发布

题:

一切工作正常:我将我/ GLTF /子文件夹内我的FBX文件GLTF。

可悲的是,一些几何形状是从一些转换文件的丢失,所以我试图再次转换我的FBX文件,这个时候/测试/。

突然,该机型不加载,并从我的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>

NPM套餐一用来从FBX转换为GLTF:

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


错误:


我看了看:

日志显示错误对象:{“isTrusted”:真},而不是实际的误差数据

.NET一个Cors isTrusted:有角5应用真正的错误

{ “isTrusted”:真正}例外core.umd.js


编辑:

Answer 1:

要调试这一点,你可以拖动模型为我调试浏览器 ,你会看到这样一条消息:

缺少质地:M_Med_Soldier_Body_BLACKKNIGHT_n.tga

无论glTF也不网页浏览器支持TGA纹理,以便它引用的事实是,在用于创建该文件的工具的错误。 我建议你申请上FBX2glTF的错误。

但是,如果您在模型文件夹的样子,你会看到相同的图像已经存在的PNG(也许FBX2glTF转换呢?)。 如果打开.gltf在文本编辑器文件(我用崇高的文本)并搜索“图片”,你会发现,不正确TGA图像参考。 它重命名为.png ,你就会明白我的假设是正确的结果:



文章来源: Getting an {“isTrusted”:true} error when using GLTFLoader