当前位置:网站首页>babylon.js高度图
babylon.js高度图
2022-07-13 19:01:00 【紫微前端】

<canvas id="renderCanvas" touch-action="none"></canvas>
<style>
html,
body {
margin: 0;
padding: 0;
}
#renderCanvas {
width: 100%;
height: 56.2vw;
touch-action: none;
display: block;
font-size: 0;
}
</style>
<script src="https://preview.babylonjs.com/babylon.js"></script>
<script src="https://preview.babylonjs.com/loaders/babylonjs.loaders.min.js"></script>
<script src="https://code.jquery.com/pep/0.4.3/pep.js"></script>
<script>
var canvas = document.getElementById("renderCanvas");
var engine = new BABYLON.Engine(canvas, true);
var sunPos = 0;
var radius = 50;
var createScene = function() {
var scene = new BABYLON.Scene(engine);
// Light
var spot = new BABYLON.PointLight("spot", new BABYLON.Vector3(0, 30, 10), scene);
spot.diffuse = new BABYLON.Color3(1, 1, 1);
spot.specular = new BABYLON.Color3(0, 0, 0);
// Camera
var camera = new BABYLON.ArcRotateCamera("Camera", -Math.PI / 2, .8, 100, BABYLON.Vector3.Zero(), scene);
camera.lowerBetaLimit = 0.1;
camera.upperBetaLimit = Math.PI / 2 * 0.9;
camera.lowerRadiusLimit = 30;
camera.upperRadiusLimit = 150;
camera.attachControl(canvas, true);
// Ground
var groundMaterial = new BABYLON.StandardMaterial("ground", scene);
groundMaterial.diffuseTexture = new BABYLON.Texture("https://s3-us-west-2.amazonaws.com/s.cdpn.io/5946/ireland-colormap.jpg", scene);
var ground = BABYLON.Mesh.CreateGroundFromHeightMap("ground", "https://s3-us-west-2.amazonaws.com/s.cdpn.io/5946/ireland-heightmap.jpg", 200, 200, 250, 0, 3, scene, false);
ground.material = groundMaterial;
//Sphere to see the light's position
var sun = BABYLON.Mesh.CreateSphere("sun", 10, 4, scene);
sun.material = new BABYLON.StandardMaterial("sun", scene);
sun.material.emissiveColor = new BABYLON.Color3(1, 1, 0);
// Skybox
var skybox = BABYLON.Mesh.CreateBox("skyBox", 800.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);
skyboxMaterial.disableLighting = true;
skybox.material = skyboxMaterial;
//Sun animation
scene.registerBeforeRender(function() {
sun.position = spot.position;
spot.position.x = radius * Math.cos(sunPos);
spot.position.z = radius * Math.sin(sunPos);
sunPos += 0.01;
});
return scene;
};
var scene = createScene();
engine.runRenderLoop(function() {
scene.render();
});
window.addEventListener("resize", function() {
engine.resize();
});
</script>边栏推荐
猜你喜欢

【服务器数据恢复】某品牌MSA SAN存储RAID5瘫痪,上层LUN无法使用的数据恢复案例

Hcip day 6 notes

集合系列开篇:为什么要学集合?

Where is the win11 uninstaller? Two methods of uninstalling software in win11

Emqx cloud update: add redis and JWT external authentication authorization

二项堆原理与解析

面试诈骗:竟然还有靠面试挣钱的公司

Linear table concept

Record a detailed penetration test of a site

News: JD technology released the "ten billion income plan"; The president of Broadcom software business resigned
随机推荐
Don't underestimate websocket! Long connection, stateful, bidirectional and full duplex are all Wang's skills
Common DOS commands
GPU资源池的虚拟化路径
Various methods of obtaining form handle in VC
Flutter RenderFlex overflowed by pixels on the bottom键盘弹出警告异常
【Day 2】机器阅读理解——常见机器阅读理解模型(上)
[play with FPGA learning 7 in simple terms ----- cross clock domain signal processing based on FPGA]
Development of management
Hongliulin, data gold mine has been dug up in the coal mine!
聚焦数据中心创新,NVIDIA DOCA 1.3带来哪些新力量
Is it difficult to become a hardware engineer?
[day 2] machine reading comprehension -- common machine reading comprehension models (Part 1)
c语言 寄存器技巧 (struct 和 union)
红柳林,煤矿里挖出了数据金矿!
modular
Lesson 3: shortest distance
Could not connect to redis at 192.168.164.118:6379: connection rejected under Linux
Lesson 3: take coins
Hj3 explicit random number hj03
shell语法简单介绍