babylon.js天空盒给出错误

时间:2018-12-02 12:34:12

标签: javascript babylonjs

我要创建天空盒。

我从https://www.babylonjs-playground.com/#UU7RQ#240复制示例。当我想看结果时。我在检查错误中看到:这是错误的屏幕截图。

errors screenshot

这是代码:

let canvas = document.getElementById("renderCanvas");

let engine = new BABYLON.Engine(canvas, true);


var createScene = function () {
    var scene = new BABYLON.Scene(engine);
    var camera = new BABYLON.ArcRotateCamera("Camera", -Math.PI / 2, Math.PI / 2, 5, BABYLON.Vector3.Zero(), scene);
    camera.attachControl(canvas, true);

    var light = new BABYLON.HemisphericLight("hemiLight", new BABYLON.Vector3(-1, 1, 0), scene);
    light.diffuse = new BABYLON.Color3(1, 0, 0);

    // Skybox
    var skybox = BABYLON.MeshBuilder.CreateBox("skyBox", {size:1000.0}, scene);
    var skyboxMaterial = new BABYLON.StandardMaterial("skyBox", scene);
    skyboxMaterial.backFaceCulling = false;
    skyboxMaterial.reflectionTexture = new BABYLON.CubeTexture("textures/skybox", scene);
    skyboxMaterial.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
   skyboxMaterial.diffuseColor = new BABYLON.Color3(0, 0, 0);
   skyboxMaterial.specularColor = new BABYLON.Color3(0, 0, 0);
   skybox.material = skyboxMaterial;

   return scene;

};

// activate scene
let scene = createScene();

// show scene
engine.runRenderLoop(function() {
    scene.render();
});

scene.activeCamera.attachControl(canvas);

1 个答案:

答案 0 :(得分:0)

很遗憾,您不能直接从磁盘加载图像。它们必须由本地网络服务器(Apache,IIS等)托管