如何修复“未捕获的ReferenceError:未定义MouseInteract”?

时间:2019-01-18 04:49:26

标签: javascript three.js

当我尝试合并多个网格时,无法成功合并这些网格的材质。

当我更换

let mesh = new THREE.Mesh(singleGeometry, materialArr);

作者

let mesh = new THREE.Mesh(singleGeometry, new THREE.MeshPhongMaterial());

我完全没有错误。

updateWorld() {
    let singleGeometry = new THREE.Geometry();
    let materialArr = [];

    this.game.worlds.getWorld(OverWorld).world.forEach((block, pos) => {
        // console.log(this.renderRegister);
        // console.log(pos);
        // console.log(block.constructor.name);

        let modelClass = this.renderRegister.getRender(block.constructor.name);
        // console.log(modelClass);
        let model = new modelClass();

        //for(let i=0; i<model.parts.length; i++) {
        model.parts.forEach((part, i) => {
            //let part = model.parts[i];

            part.mesh.position.x = pos.x;
            part.mesh.position.y = pos.y;
            part.mesh.position.z = pos.z;
            //this.scene.add(part.mesh);

            part.mesh.updateMatrix(); // as needed
            singleGeometry.merge(part.mesh.geometry, part.mesh.matrix, i);

            materialArr.push(part.mesh.material);
        });
    });

    let mesh = new THREE.Mesh(singleGeometry, materialArr);

    mesh.geometry.computeFaceNormals();
    mesh.geometry.computeVertexNormals();

    this.scene.add(mesh);
}

我希望不会有任何错误,但是仍然会出现错误。

Image of the stacktrace

0 个答案:

没有答案