|
@@ -224,21 +224,43 @@
|
|
|
// scene.add(gridHelper);
|
|
|
|
|
|
// 环境光会均匀的照亮场景中的所有物体
|
|
|
- const ambientLight = new THREE.AmbientLight(0xFFEFE0, 2);
|
|
|
+ const ambientLight = new THREE.AmbientLight(0xFFEFE0, 3);
|
|
|
scene.add(ambientLight);
|
|
|
//平行光
|
|
|
- const light = new THREE.DirectionalLight(0xFFF8E5, 2.2);
|
|
|
- light.position.set(-14.8, 9.188, -7.448); //default; light shining from top
|
|
|
+ const light = new THREE.DirectionalLight(0xFFF8E5, 3);
|
|
|
+ light.position.set(-3, 9, 3); //default; light shining from top
|
|
|
+ light.castShadow = true; // default false
|
|
|
+ // 默认情况下光投影相机区域是一个长宽高为10x10x500的长方体区域,光源投射方向为通过坐标原点
|
|
|
+ light.shadow.camera.left = -100; // default
|
|
|
+ light.shadow.camera.right = 100; // default
|
|
|
+ light.shadow.camera.top = 100; // default
|
|
|
+ light.shadow.camera.bottom = -100; // default
|
|
|
+
|
|
|
+ light.shadow.mapSize.width = 8192; // default
|
|
|
+ light.shadow.mapSize.height = 8192; // default
|
|
|
+ // light.shadow.camera.near = 0.1; // default
|
|
|
+ // light.shadow.camera.far = 500; // default
|
|
|
+
|
|
|
+ // light.shadow.bias = -0.01;
|
|
|
+ // light.shadow.radius = 1;
|
|
|
+ // light.shadow.darkness = 1; // 设置阴影强度为0.5
|
|
|
scene.add(light);
|
|
|
+
|
|
|
+ const helper = new THREE.CameraHelper( light.shadow.camera );
|
|
|
+ scene.add(helper);
|
|
|
// 从一个点向各个方向发射的光源。一个常见的例子是模拟一个灯泡发出的光。
|
|
|
// const pointLight = new THREE.PointLight( 0xffffff, 0.3 );
|
|
|
// camera.add( pointLight );
|
|
|
|
|
|
|
|
|
//antialias 这个值得设置为false,不然IOS上截图会失效
|
|
|
- renderer = that.renderer = new THREE.WebGLRenderer( { canvas:canvas3d, alpha: true, antialias:false,
|
|
|
+ renderer = that.renderer = new THREE.WebGLRenderer({
|
|
|
+ canvas:canvas3d,
|
|
|
+ alpha: true,
|
|
|
+ antialias:false,
|
|
|
// 如果想保存three.js canvas画布上的信息,注意设置preserveDrawingBuffer
|
|
|
- preserveDrawingBuffer: true, } );
|
|
|
+ preserveDrawingBuffer: true,
|
|
|
+ });
|
|
|
renderer.shadowMap.enabled = true;//产生阴影
|
|
|
renderer.shadowMap.type = THREE.PCFSoftShadowMap; // 阴影属性
|
|
|
renderer.outputEncoding = THREE.sRGBEncoding;
|
|
@@ -266,11 +288,6 @@
|
|
|
// 检查相机位置是否超出边界框
|
|
|
if (camera.position.y < 0) {
|
|
|
camera.position.y = 0;
|
|
|
- // let clampedPosition = new THREE.Vector3( );
|
|
|
- // boundary.clampPoint(camera.position,clampedPosition);
|
|
|
- // if(clampedPosition){
|
|
|
- // camera.position.copy(clampedPosition);
|
|
|
- // }
|
|
|
}
|
|
|
});
|
|
|
// that.controls = controls;
|