1

我是 ThreeJS 的初学者。我想从 Blender 中导入 gLTF 格式的基本立方体...这是我的代码。

它缺少什么?

  var canvas = document.getElementById('canvas');
        var camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
        var scene = new THREE.Scene();
        var renderer = new THREE.WebGLRenderer();
        renderer.setClearColor(rosa, 1);
        renderer.setSize(window.innerWidth, window.innerHeight);
        var controls = new THREE.OrbitControls(camera, renderer.domElement);
        canvas.appendChild(renderer.domElement);

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

        function renderingScene() {
            renderer.render(scene, camera);
        }

        function cargarGLTF() {
            // Load a glTF resource
            loader.load('./glTF/resources/cube/untitled.gltf', function (gltf) {
                scene.add(gltf.scene);
            });
           // renderingScene();
        }
        cargarGLTF();
        controlMouse();
        renderingScene();

输出控制台

输出控制台

4

0 回答 0