From 9156b9172a9267400aa81ae3d2a7b03f08962354 Mon Sep 17 00:00:00 2001 From: kovacsv Date: Sun, 14 Jan 2024 07:59:43 +0100 Subject: [PATCH] Fix distance calculation. --- sandbox/three_shadow3.html | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/sandbox/three_shadow3.html b/sandbox/three_shadow3.html index 166e38fc..854a4cab 100644 --- a/sandbox/three_shadow3.html +++ b/sandbox/three_shadow3.html @@ -24,9 +24,11 @@ { let size = new THREE.Vector2 (10.0, 5.0); - this.shadowCamera = new THREE.OrthographicCamera (-size.x / 2.0, size.x / 2.0, size.y / 2.0, -size.y / 2.0, 0.0, 10.0); - this.shadowCamera.position.z = -5; - this.shadowCamera.scale.z *= -1; + this.shadowCamera = new THREE.OrthographicCamera (-size.x / 2.0, size.x / 2.0, size.y / 2.0, -size.y / 2.0, 0.0, 8.0); + //this.shadowCamera.scale.z *= -1; + //this.shadowCamera.position.z = 6; + this.shadowCamera.rotation.y = Math.PI; + //this.shadowCamera.rotation.z = Math.PI; shadowGroup.add (this.shadowCamera); this.shadowRenderTarget = new THREE.WebGLRenderTarget (1024, 1024); @@ -56,6 +58,7 @@ }; this.shadowPlaneMesh = new THREE.Mesh (planeGeometry, planeMaterial); + this.shadowPlaneMesh.scale.x *= -1.0; shadowGroup.add (this.shadowPlaneMesh); } @@ -132,10 +135,12 @@ }); let boxMesh1 = new THREE.Mesh (box1, boxMaterial); let boxMesh2 = new THREE.Mesh (box2, boxMaterial); - boxMesh1.position.z = 4; + + boxMesh1.position.z = 3; + boxMesh2.position.x = 1; boxMesh2.position.y = 1; - boxMesh2.position.z = 2; + boxMesh2.position.z = 1; boxMesh1.updateMatrixWorld (true); boxMesh2.updateMatrixWorld (true);