题:
一切工作正常:我将我/ 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
编辑: