mirror of
https://github.com/jiawanlong/Cesium-Examples.git
synced 2025-07-04 15:17:36 +00:00
61 lines
1.7 KiB
HTML
61 lines
1.7 KiB
HTML
<!--********************************************************************
|
|
* by jiawanlong
|
|
*********************************************************************-->
|
|
<!DOCTYPE html>
|
|
<html>
|
|
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<script src="./../../libs/babylon/babylon.js"></script>
|
|
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
overflow: hidden;
|
|
}
|
|
|
|
html,
|
|
body {
|
|
overflow: hidden;
|
|
width: 100%;
|
|
height: 100%;
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
|
|
#renderCanvas {
|
|
width: 100%;
|
|
height: 100%;
|
|
touch-action: none;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<canvas id="renderCanvas" touch-action="none"></canvas>
|
|
<script>
|
|
const createScene = () => {
|
|
const scene = new BABYLON.Scene(engine);
|
|
const camera = new BABYLON.ArcRotateCamera("Camera", -Math.PI / 2, Math.PI / 2.5, 3, new BABYLON.Vector3(0, 0, 0));
|
|
const light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0));
|
|
camera.attachControl(canvas, true);
|
|
const sphere = BABYLON.MeshBuilder.CreateSphere("sphere", { diameter: 2, segments: 32 }, scene);
|
|
sphere.position.y = 1;
|
|
return scene;
|
|
};
|
|
|
|
const engine = new BABYLON.Engine(document.getElementById('renderCanvas') , true);
|
|
const canvas = document.getElementById('renderCanvas') ;
|
|
const scene = createScene();
|
|
engine.runRenderLoop(() => {
|
|
scene.render();
|
|
});
|
|
window.addEventListener('resize', () => {
|
|
engine.resize();
|
|
});
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html> |