我有一个非常愚蠢的问题,我不是html开发人员,但我需要一个简单的帮助。
<script>
var canvas = document.getElementById("renderCanvas"); // Get the canvas element
var engine = new BABYLON.Engine(canvas, true); // Generate the BABYLON 3D engine
/******* Add the create scene function ******/
var createScene = function () {
// Create the scene space
var scene = new BABYLON.Scene(engine);
// Add a camera to the scene and attach it to the canvas
var camera = new BABYLON.ArcRotateCamera("Camera", Math.PI / 2, Math.PI / 2, 2, BABYLON.Vector3.Zero(), scene);
camera.attachControl(canvas, true);
// Add lights to the scene
var light1 = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(1, 1, 0), scene);
var light2 = new BABYLON.PointLight("light2", new BABYLON.Vector3(0, 1, -1), scene);
// Add and manipulate meshes in the scene
var sphere = BABYLON.MeshBuilder.CreateSphere("sphere", { diameter: 2 }, scene);
return scene;
};
/******* End of the create scene function ******/
var scene = createScene(); //Call the createScene function
engine.runRenderLoop(function () { // Register a render loop to repeatedly render the scene
scene.render();
});
window.addEventListener("resize", function () { // Watch for browser/canvas resize events
engine.resize();
});
</script>
我想将脚本部分放在一个外部js文件中,但如果我什么都不尝试,它将在屏幕上呈现。 你能帮我吗
谢谢