0

我正在尝试创建一个,clone()但它从不渲染。MeshBABYLON.Mesh.CreateGroundFromHeightMap()

// Ground
var groundMaterial = new BABYLON.StandardMaterial("ground", scene);
groundMaterial.emissiveTexture = new BABYLON.Texture("textures/earth.jpg", scene);

var ground = BABYLON.Mesh.CreateGroundFromHeightMap("ground", "textures/worldHeightMap.jpg", 200, 200, 250, 0, 10, scene, false);
ground.material = groundMaterial;

// Cloned Ground
var groundMaterial2 = new BABYLON.StandardMaterial("ground2", scene);
groundMaterial2.emissiveColor = new BABYLON.Color3(1, 0, 0);
groundMaterial2.alpha = 0.5;

var ground2 = ground.clone("ground2");
ground2.position = new BABYLON.Vector3(0, 1, 0);
ground2.material = groundMaterial2;

http://babylonjs-playground.azurewebsites.net/#YA6VT#1

4

1 回答 1

0

由于从图像CreateGroundFromHeightMap() 加载它VertexDataMesh因此在加载之前还没有准备好被克隆。通过使用CreateGroundFromHeightMap's 可选onReady参数,我们可以延迟clone()直到一切准备就绪。

// Ground
var groundMaterial = new BABYLON.StandardMaterial("ground", scene);
groundMaterial.emissiveTexture = new BABYLON.Texture("textures/earth.jpg", scene);

var ground = BABYLON.Mesh.CreateGroundFromHeightMap("ground", "textures/worldHeightMap.jpg", 200, 200, 250, 0, 10, scene, false,
    mesh => {
        // Cloned Ground
        var groundMaterial2 = new BABYLON.StandardMaterial("ground2", scene);
        groundMaterial2.emissiveColor = new BABYLON.Color3(1, 0, 0);
        groundMaterial2.alpha = 0.5;

        var ground2 = mesh.clone("ground2");
        ground2.position = new BABYLON.Vector3(0, 1, 0);
        ground2.material = groundMaterial2;
    });
ground.material = groundMaterial;

http://babylonjs-playground.azurewebsites.net/#YA6VT#2

于 2016-02-03T05:18:59.210 回答