<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de">
	<id>https://wiki.stephanschlegel.de/index.php?action=history&amp;feed=atom&amp;title=Three.js_-_Shadows</id>
	<title>Three.js - Shadows - Versionsgeschichte</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.stephanschlegel.de/index.php?action=history&amp;feed=atom&amp;title=Three.js_-_Shadows"/>
	<link rel="alternate" type="text/html" href="https://wiki.stephanschlegel.de/index.php?title=Three.js_-_Shadows&amp;action=history"/>
	<updated>2026-05-06T18:31:39Z</updated>
	<subtitle>Versionsgeschichte dieser Seite in Wikizone</subtitle>
	<generator>MediaWiki 1.35.14</generator>
	<entry>
		<id>https://wiki.stephanschlegel.de/index.php?title=Three.js_-_Shadows&amp;diff=25666&amp;oldid=prev</id>
		<title>Steff am 30. Dezember 2021 um 19:02 Uhr</title>
		<link rel="alternate" type="text/html" href="https://wiki.stephanschlegel.de/index.php?title=Three.js_-_Shadows&amp;diff=25666&amp;oldid=prev"/>
		<updated>2021-12-30T19:02:51Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;de&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Nächstältere Version&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Version vom 30. Dezember 2021, 19:02 Uhr&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Zeile 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  [[&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Threejs &lt;/del&gt;- Snippets]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  [[&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;ThreeJS &lt;/ins&gt;- Snippets]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== Schatten einschalten ===&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== Schatten einschalten ===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Steff</name></author>
	</entry>
	<entry>
		<id>https://wiki.stephanschlegel.de/index.php?title=Three.js_-_Shadows&amp;diff=25665&amp;oldid=prev</id>
		<title>Steff am 30. Dezember 2021 um 19:02 Uhr</title>
		<link rel="alternate" type="text/html" href="https://wiki.stephanschlegel.de/index.php?title=Three.js_-_Shadows&amp;diff=25665&amp;oldid=prev"/>
		<updated>2021-12-30T19:02:23Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;de&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Nächstältere Version&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Version vom 30. Dezember 2021, 19:02 Uhr&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Zeile 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; [[Threejs - Snippets]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== Schatten einschalten ===&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== Schatten einschalten ===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Steff</name></author>
	</entry>
	<entry>
		<id>https://wiki.stephanschlegel.de/index.php?title=Three.js_-_Shadows&amp;diff=25664&amp;oldid=prev</id>
		<title>Steff: Die Seite wurde neu angelegt: „ === Schatten einschalten === &lt;syntaxhighlight lang=&quot;javascript&quot;&gt; // Decide for every object if it casts and/or receives shadows sphere.castShadow = true plane…“</title>
		<link rel="alternate" type="text/html" href="https://wiki.stephanschlegel.de/index.php?title=Three.js_-_Shadows&amp;diff=25664&amp;oldid=prev"/>
		<updated>2021-12-30T19:01:45Z</updated>

		<summary type="html">&lt;p&gt;Die Seite wurde neu angelegt: „ === Schatten einschalten === &amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt; // Decide for every object if it casts and/or receives shadows sphere.castShadow = true plane…“&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Neue Seite&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
=== Schatten einschalten ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// Decide for every object if it casts and/or receives shadows&lt;br /&gt;
sphere.castShadow = true&lt;br /&gt;
plane.receiveShadow = true&lt;br /&gt;
&lt;br /&gt;
// Decide for every light if it casts shadows&lt;br /&gt;
directionalLight.castShadow = true&lt;br /&gt;
&lt;br /&gt;
// Enable shadowmap in renderer&lt;br /&gt;
renderer.shadowMap.enabled = true&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Shadowmap optimieren ===&lt;br /&gt;
Jedes Licht nutzt eine Shadowmap mit einer Default Tilegröße von 512x512px. Über die shadowmap-Property kann man die Größe beeinflussen. Wegen dem Mipmapping solltest du eine Zweierpotenz nutzen (siehe Mipmapping). Vorsicht - Schatten kosten viel Performance.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
directionalLight.shadow.mapSize.x = 1024&lt;br /&gt;
directionalLight.shadow.mapSize.y = 1024&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Schattenkamera einstellen. ===&lt;br /&gt;
Lichter benutzen ein eigenes Camera Objekt (OrthoCamera) um die Schatten zu berechnen. &lt;br /&gt;
&lt;br /&gt;
==== CameraHelper ====&lt;br /&gt;
Für genaue Tweaks erstellen wie einen &amp;#039;&amp;#039;&amp;#039;CameraHelper&amp;#039;&amp;#039;&amp;#039; und übergeben diesem die Schattenkamera.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// Shadow camera helper&lt;br /&gt;
const directionalLightCameraHelper = new THREE.CameraHelper(directionalLight.shadow.camera)&lt;br /&gt;
scene.add(directionalLightCameraHelper)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Renderbereich einstellen ====&lt;br /&gt;
Mit den near, far, left, right, top, bottom Werten lassen sich die Grenzen der Kamera und damit auch für die Schattenerzeugung einstellen. Der Camerahelper hilft dabei. near und far helfen nicht die Qualität der Schatten zu verbessern. Falsche Werte können aber für verbuggte Schatten verantwortlich sein.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Schmale Kameraausschnitte verbessern das Ergebnis&amp;#039;&amp;#039;&amp;#039;, da die Mipmaps effektiver verwendet werden. Sind sie &amp;#039;&amp;#039;&amp;#039;zu schmal können aber Schatten abgeschnitten werden&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
directionalLight.shadow.camera.near = 1&lt;br /&gt;
directionalLight.shadow.camera.far = 6&lt;br /&gt;
&lt;br /&gt;
directionalLight.shadow.camera.left = -2&lt;br /&gt;
directionalLight.shadow.camera.right = 2&lt;br /&gt;
directionalLight.shadow.camera.top = 2&lt;br /&gt;
directionalLight.shadow.camera.bottom = -2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Renderer - Shadow map algorithm ===&lt;br /&gt;
Es gibt verschiedene Algorythmen für die Berechnung der ShadowMap:&lt;br /&gt;
&lt;br /&gt;
 THREE.BasicShadowMap Very performant but lousy quality&lt;br /&gt;
 THREE.PCFShadowMap Less performant but smoother edges - DEFAULT&lt;br /&gt;
 THREE.PCFSoftShadowMap Less performant but even softer edges&lt;br /&gt;
 THREE.VSMShadowMap Less performant, more constraints, can have unexpected results&lt;br /&gt;
&lt;br /&gt;
 renderer.shadowMap.type = THREE.PCFSoftShadowMap&lt;br /&gt;
&lt;br /&gt;
=== Komplettes Beispiel ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
//...&lt;br /&gt;
/**&lt;br /&gt;
 * Lights&lt;br /&gt;
 */&lt;br /&gt;
// Ambient light&lt;br /&gt;
const ambientLight = new THREE.AmbientLight(0xffffff, 0.5)&lt;br /&gt;
gui.add(ambientLight, &amp;#039;intensity&amp;#039;).min(0).max(1).step(0.001)&lt;br /&gt;
scene.add(ambientLight)&lt;br /&gt;
&lt;br /&gt;
// Directional light&lt;br /&gt;
const directionalLight = new THREE.DirectionalLight(0xffffff, 0.5)&lt;br /&gt;
directionalLight.position.set(2, 2, - 1)&lt;br /&gt;
gui.add(directionalLight, &amp;#039;intensity&amp;#039;).min(0).max(1).step(0.001)&lt;br /&gt;
gui.add(directionalLight.position, &amp;#039;x&amp;#039;).min(- 5).max(5).step(0.001)&lt;br /&gt;
gui.add(directionalLight.position, &amp;#039;y&amp;#039;).min(- 5).max(5).step(0.001)&lt;br /&gt;
gui.add(directionalLight.position, &amp;#039;z&amp;#039;).min(- 5).max(5).step(0.001)&lt;br /&gt;
&lt;br /&gt;
// Add Shadow and mapsize&lt;br /&gt;
directionalLight.castShadow = true&lt;br /&gt;
directionalLight.shadow.mapSize.x = 1024&lt;br /&gt;
directionalLight.shadow.mapSize.y = 1024&lt;br /&gt;
// Shadow camera settings...&lt;br /&gt;
directionalLight.shadow.camera.near = 1&lt;br /&gt;
directionalLight.shadow.camera.far = 6&lt;br /&gt;
// ...important for quality&lt;br /&gt;
directionalLight.shadow.camera.left = -2&lt;br /&gt;
directionalLight.shadow.camera.right = 2&lt;br /&gt;
directionalLight.shadow.camera.top = 2&lt;br /&gt;
directionalLight.shadow.camera.bottom = -2&lt;br /&gt;
// adding a bit of a cheap blur&lt;br /&gt;
// directionalLight.shadow.radius = 4&lt;br /&gt;
&lt;br /&gt;
scene.add(directionalLight)&lt;br /&gt;
&lt;br /&gt;
// Shadow camera helper&lt;br /&gt;
const directionalLightCameraHelper = new THREE.CameraHelper(directionalLight.shadow.camera)&lt;br /&gt;
scene.add(directionalLightCameraHelper)&lt;br /&gt;
&lt;br /&gt;
// ...&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Objects&lt;br /&gt;
 */&lt;br /&gt;
sphere.castShadow = true&lt;br /&gt;
// ...&lt;br /&gt;
plane.receiveShadow = true&lt;br /&gt;
// ...&lt;br /&gt;
scene.add(sphere, plane)&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Renderer&lt;br /&gt;
 */&lt;br /&gt;
const renderer = new THREE.WebGLRenderer({&lt;br /&gt;
    canvas: canvas&lt;br /&gt;
})&lt;br /&gt;
renderer.setSize(sizes.width, sizes.height)&lt;br /&gt;
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2))&lt;br /&gt;
&lt;br /&gt;
// Renderer Shadowmap settings&lt;br /&gt;
renderer.shadowMap.enabled = true &lt;br /&gt;
renderer.shadowMap.type = THREE.PCFSoftShadowMap; // default THREE.PCFShadowMap&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Spotlight Schatten ===&lt;br /&gt;
Die Spotlightkamera nutzt - passend zum Kegelförmigen Licht - eine PerspectiveCamera zum Berechnen der Shadowmap. Daher gibt es hier keine left, right, top, bottom Werte sondern eine Field of view Einstellung:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
spotLight.shadow.camera.fov = 30&lt;br /&gt;
spotLight.shadow.camera.near = 1&lt;br /&gt;
spotLight.shadow.camera.far = 5&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Pointlight Schatten ===&lt;br /&gt;
Auch hier wird eine  PerspectiveCamera genutzt. Aber da das PointLight in jede Richtung geht muss Three.je eine Cube ShadowMap berechnen - also 6 Renderings für jede Seite des Cubs. Daher ist aus Performance Sicht ein PointLight die schlechteste Variante.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
pointLight.shadow.mapSize.width = 1024&lt;br /&gt;
pointLight.shadow.mapSize.height = 1024&lt;br /&gt;
pointLight.shadow.camera.near = 0.1&lt;br /&gt;
pointLight.shadow.camera.far = 5&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Die einzigen Eigenschaften hier sind mapSize, near and far:&lt;br /&gt;
=== Techniken für bessere Schatten ===&lt;br /&gt;
Vor allem wenn mehrere Schatten übereinanderfallen erzeugt der Renderer keine überzeugenden Ergebnisse. Aber es gibt noch ein paar Tricks um Schatten zu erzeugen und trotzdem die Performance zu erhalten&lt;br /&gt;
==== Shadow Baking ====&lt;br /&gt;
Wie Texturen kann man auch Schatten baken. Nachteil. Bei Bewegung des Objekts bewegt sich der&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * Textures&lt;br /&gt;
 */&lt;br /&gt;
const textureLoader = new THREE.TextureLoader()&lt;br /&gt;
const bakedShadow = textureLoader.load(&amp;#039;/textures/bakedShadow.jpg&amp;#039;)&lt;br /&gt;
//...&lt;br /&gt;
const plane = new THREE.Mesh(&lt;br /&gt;
    new THREE.PlaneGeometry(5, 5),&lt;br /&gt;
    new THREE.MeshBasicMaterial({&lt;br /&gt;
        map: bakedShadow&lt;br /&gt;
    })&lt;br /&gt;
)&lt;br /&gt;
// we don&amp;#039;t need the rendered shadows in this case&lt;br /&gt;
renderer.shadowMap.enabled = false&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Dynamic Shadow Baking ====&lt;br /&gt;
Alternativ können wir einen einfachen Schatten unter dem Objekt, knapp über dem Boden platzieren und passend zum Objekt animieren. Dies ist nicht ganz so realistisch aber performant und auch bei Animationen möglich &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Schattenobjekt&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Die Textur ist ein einfaches Halo. Sie wird im Alphakanal genutzt, so dass der weiße Teil sichtbar und der schwarze unsichtbar ist. &lt;br /&gt;
&lt;br /&gt;
[[Datei:SimpleShadow.jpg|miniatur|ohne]]&lt;br /&gt;
Die Textur setzen wir auf eine schwarze Plane (Ebene), diese wirkt dann wie ein Schatten.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Animation&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Wir bewegen den Schatten passend zum Objekt über dem Boden. Entfernt sich das Objekt verstärken wir einfach die Transparenz.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Beispiel Kugel mit animiertem Fake-Schatten&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
const textureLoader = new THREE.TextureLoader()&lt;br /&gt;
const simpleShadow = textureLoader.load(&amp;#039;/textures/simpleShadow.jpg&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
// Sphere Shadow&lt;br /&gt;
const sphereShadow = new THREE.Mesh(&lt;br /&gt;
    new THREE.PlaneGeometry(1.5, 1.5),&lt;br /&gt;
    new THREE.MeshBasicMaterial({&lt;br /&gt;
        color: 0x000000,&lt;br /&gt;
        transparent: true,&lt;br /&gt;
        alphaMap: simpleShadow&lt;br /&gt;
    })&lt;br /&gt;
)&lt;br /&gt;
sphereShadow.rotation.x = - Math.PI * 0.5&lt;br /&gt;
sphereShadow.position.y = plane.position.y + 0.01&lt;br /&gt;
&lt;br /&gt;
scene.add(sphere, sphereShadow, plane)&lt;br /&gt;
&lt;br /&gt;
//...&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Animate&lt;br /&gt;
 */&lt;br /&gt;
const clock = new THREE.Clock()&lt;br /&gt;
&lt;br /&gt;
const tick = () =&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    const elapsedTime = clock.getElapsedTime()&lt;br /&gt;
&lt;br /&gt;
    // Update the sphere&lt;br /&gt;
    sphere.position.x = Math.cos(elapsedTime) * 1.5&lt;br /&gt;
    sphere.position.z = Math.sin(elapsedTime) * 1.5&lt;br /&gt;
    sphere.position.y = Math.abs(Math.sin(elapsedTime * 3))&lt;br /&gt;
&lt;br /&gt;
    // Update the shadow accordingly&lt;br /&gt;
    sphereShadow.position.x = sphere.position.x&lt;br /&gt;
    sphereShadow.position.z = sphere.position.z&lt;br /&gt;
    sphereShadow.material.opacity = (1 - sphere.position.y) * 0.3&lt;br /&gt;
&lt;br /&gt;
    // Update controls&lt;br /&gt;
    controls.update()&lt;br /&gt;
&lt;br /&gt;
    // Render&lt;br /&gt;
    renderer.render(scene, camera)&lt;br /&gt;
&lt;br /&gt;
    // Call tick again on the next frame&lt;br /&gt;
    window.requestAnimationFrame(tick)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
tick()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Steff</name></author>
	</entry>
</feed>