babylon.js 天空盒报错

babylon.js skybox give errors

我想创建天空盒。

我从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);

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