我正在阅读 babylonjs 的教程,我一直在为很多事情努力。我在第一个环境教程中,我正在尝试让我的天空盒渲染。假设文件路径正确,问题可能是什么?
var canvas,
createScene,
engine;
// Get the canvas element from our HTML below
canvas = document.querySelector("#renderCanvas");
// Load the BABYLON 3D engine
engine = new BABYLON.Engine( canvas, true );
// Here begins a function that we will 'call' just after it's built
createScene = function () {
var scene = new BABYLON.Scene( engine );
// this is how to set or change the background color
// the .clearColor method is used with the new BABYLON.Color3();
scene.clearColor = new BABYLON.Color3( 0.5, 0.8, 0.5 );
// there are also preset colors like blue, red, yellow you can add by saying BABYLON.Color3.Blue();
// ambient color is used to help determine what things will ultimately look like.
scene.ambientColor = new BABYLON.Color3( 0.3, 0.3, 0.3 );
// when there is no ambient color on the scene, ambient colors on textures and ambient colors of your objects will have no effect.
var camera = new BABYLON.ArcRotateCamera("Camera", 0.4, 1.2, 20, new BABYLON.Vector3(-10, 0, 0), scene);
var light0 = new BABYLON.HemisphericLight("Hemi0", new BABYLON.Vector3.Zero(), scene);
light0.diffuse = new BABYLON.Color3(1, 1, 1);
light0.specular = new BABYLON.Color3(1, 1, 1);
light0.groundColor = new BABYLON.Color3(0, 0, 0);
// skybox
var skybox = BABYLON.Mesh.CreateBox( 'skyBox', 100.0, scene );
console.log( skybox );
var skyboxMaterial = new BABYLON.StandardMaterial('skyBox', scene);
skyboxMaterial.backFaceCulling = false;
skybox.material = skyboxMaterial;
// infanite distance makes the sky box follow the camera's position
skybox.infiniteDistance = true;
// here, we remove all light relection from the shape
skyboxMaterial.diffuseColor = new BABYLON.Color3( 0, 0, 0 );
skyboxMaterial.specularColor = new BABYLON.Color3( 0, 0, 0 );
// now we apply the texture to the box
skyboxMaterial.reflectionTexture = new BABYLON.CubeTexture( 'data/images/skybox', scene );
skyboxMaterial.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
scene.activeCamera = camera;
scene.activeCamera.attachControl( canvas );
return scene;
}; // End of createScene function
// -------------------------------------------------------------
// Now, call the createScene function that you just finished creating
var scene;
scene = createScene();
// Register a render loop to repeatedly render the scene
engine.runRenderLoop( function () {
scene.render();
});
// Watch for browser/canvas resize events
window.addEventListener( 'resize', function () {
engine.resize();
});