从ThreeJS中的Blender导出JSON时丢失纹理

时间:2016-04-12 12:32:45

标签: json three.js blender

从Blender导出到JSON时,模型在所有浏览器中显示为灰色。使用(github.com/mrdoob/three.js/tree/master/utils/exporters/blender)

我在这里附上导出设置,来自Chrome和JS的屏幕截图。 如何解决这个问题?

感谢您的提示!

Screenshot from Chrome

导出设置:

Settings page

JS:

var scene, camera, renderer;

    var WIDTH  = 300;
    var HEIGHT = 300;

    var SPEED = 0.03;

    function init() {
        scene = new THREE.Scene();

        initMesh();
        initCamera();
        initLights();
        initRenderer();

        document.body.appendChild(renderer.domElement);
    }

    function initCamera() {
        camera = new THREE.PerspectiveCamera(70, WIDTH / HEIGHT, 1, 10);
        camera.position.set(0, 3.5, 5);
        camera.lookAt(scene.position);
    }


    function initRenderer() {
        renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
        renderer.setSize(WIDTH, HEIGHT);
    }

    function initLights() {
        var light = new THREE.AmbientLight(0xffffff);
        scene.add(light);
    }

    var mesh = null;
    function initMesh() {
        var loader = new THREE.JSONLoader();
        loader.load('./sp.json', function(geometry, materials) {
                mesh = new THREE.Mesh(geometry, new THREE.MeshFaceMaterial(materials));
                mesh.scale.x = mesh.scale.y = mesh.scale.z = 0.75;
                mesh.translation = THREE.GeometryUtils.center(geometry);
                scene.add(mesh);
        });
    }

    function rotateMesh() {
        if (!mesh) {
                return;
        }

        mesh.rotation.x -= 0;
        mesh.rotation.y -= SPEED;
        mesh.rotation.z -= 0;
    }

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

    init();
    render();

1 个答案:

答案 0 :(得分:-1)

如果您使用节点编辑器创建模型纹理,那么您可能无法看到纹理,UV展开怎么样?