【发布时间】:2022-09-23 16:14:01
【问题描述】:
我的目标是在本地运行一个网站,后端写在flask中,前端使用three.js,一切正常,因为我在控制台(devtools)中看不到任何错误,但由于某种原因它没有显示模型,我有相机,场景和渲染,我还加载了模型并添加到场景中
<body>
<script src=\"https://threejs.org/build/three.js\" >
import * as THREE from \'three\';
let scene, camera, renderer, stats, model;
const loader;
camera = new THREE.PerspectiveCamera(75, window.Width / window.Height, 0.1, 1000);
scene = new THREE.Scene();
renderer = new THREE.WebGLRenderer();
renderer.setSize(window.Width, window.Height);
document.body.appendChild(renderer.domElement);
loader = new GLTFLoader();
loader.load( \"{{ url_for(\'static\', filename=\'free_1975_porsche_911_930_turbo.glb\') }}\",
function ( gltf ) {
scene.add( gltf.scene );
gltf.animations; // Array<THREE.AnimationClip>
gltf.scene; // THREE.Group
gltf.scenes; // Array<THREE.Group>
gltf.cameras; // Array<THREE.Camera>
gltf.asset;
},
function ( xhr ) {
console.log( ( xhr.loaded / xhr.total * 100 ) + \'% loaded\' );
},
function ( error ) {
console.error( error );
}
);
function animate()
{
requestAnimationFrame( animate );
renderer.render( scene, camera );
};
animate();
</script>
</body>
为什么这段代码不在浏览器中显示模型
来自sketchfab的模型
标签: three.js