HemisphereLight
是半球光源,使用半球光光源可以创建出更加贴近自然的效果,并不是所有的光源都来自上方,更多的是来自外部的反射,例如天空的反射,地面的反射,以及其他物体的反射。
示例浏览地址:https://ithanmang.gitee.io/threejs/home/201808/20180801/01-hemisphereLight.html
构造函数
HemisphereLight( skyColor : Integer, groundColor : Integer, intensity : Float )
skyColor - (可选) 从天空发出的光线的颜色 默认0xffffff
.
groundColor - (可选) 从地面发出的光线颜色. 默认0xffffff
.
intensity - (可选) 光线照射的强度. 默认1
.
属性
属性 | 简介 |
---|---|
castShdaw | 默认为undefined ,因为半球光光源不能投射阴影 |
color | 这是构造函数中传递来的天空的天空的颜色skyColor |
groundColor | 地面反射的光的颜色 |
isHemisphereLight | 判断是否为HemisphereLight 光源,默认为true |
position | 光源的照射位置,默认是从上到(0, 1, 0) |
示例代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HemisphereLight 半球光源</title>
<style>
body {
margin: 0;
overflow: hidden;/*溢出隐藏*/
}
</style>
<script src="../../libs/build/three.min.js"></script>
<script src="../../libs/examples/js/controls/OrbitControls.js"></script>
<script src="../../libs/examples/js/libs/dat.gui.min.js"></script>
<script src="../../libs/examples/js/libs/stats.min.js"></script>
<script src="../../libs/examples/js/Detector.js"></script>
</head>
<body>
<script>
let stats = initStats();
let scene, camera, renderer, hemiLight, controls, guiControls;
let hemiLightHelper, directionalLightHelper;
// 场景
function initScene() {
scene = new THREE.Scene();
scene.background = new THREE.Color(0xB0E2FF);
scene.fog = new THREE.Fog(scene.background, 1, 5000);
}
// 相机
function initCamera() {
camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 5000);
camera.position.set(0, 0, 250)