Benutzer-Werkzeuge

Webseiten-Werkzeuge


api:documentation:grafik3d:licht:start

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen RevisionVorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
api:documentation:grafik3d:licht:start [2025/01/18 08:12] – [PointLight3d] martinapi:documentation:grafik3d:licht:start [2025/01/18 11:22] (aktuell) – [AmbientLight3d] martin
Zeile 22: Zeile 22:
  
 <HTML> <HTML>
-<div class="java-online" style="height: 500px; width: 100%" data-java-online="{'withBottomPanel': true, 'id': '3d-camera1', 'enableFileAccess': true}">+<div class="java-online" style="height: 500px; width: 100%" data-java-online="{'withBottomPanel': true, 'id': 'PointLight3d', 'enableFileAccess': true}">
  
 <script type="text/plain" title="Test1.java"> <script type="text/plain" title="Test1.java">
-Torus3d t = new Torus3d();+new MyActor();
  
 +class MyActor extends Actor {
 +   Torus3d t;
 +   World3d world;
 +   PointLight3d pointLight;
 +   Sprite3d lightSprite;
 +
 +   double angle = 0;
 +   
 +   MyActor() {
 +      t = new Torus3d();
 +      t.scale(0.5);
 +      PhongMaterial3d pm = new PhongMaterial3d(0xffffff, 3);
 +      t.setMaterial(pm);
 +      world = World3d.getWorld3d();
 +      pointLight = new PointLight3d(3, 3, 3);
 +      pointLight.setColor(Color.red);
 +      pointLight.setIntensity(15);
 +      world.removeAllLights();
 +      world.addLight(pointLight);
 +      lightSprite = new Sprite3d(0.5, SpriteLibrary.Particles, 0);
 +   
 +
 +   public void act() {
 +      angle += 1;
 +      double angleRad = Math.toRadians(angle);
 +      double x = 2 * Math.cos(angleRad);
 +      double y = 2 * Math.sin(angleRad);
 +      double z = 2 * Math.sin(angleRad / 3);
 +      pointLight.moveTo(x, y, z);
 +      lightSprite.moveTo(x, y, z);
 +   }
 +
 +}
 +</script>
 +
 +</div>
 +
 +</HTML>
 +
 +
 +===== AmbientLight3d =====
 +
 +<HTML>
 +<div class="java-online" style="height: 500px; width: 100%" data-java-online="{'withBottomPanel': true, 'id': 'AmbientLight3d', 'enableFileAccess': true}">
 +
 +<script type="text/plain" title="Test1.java">
 +new MyActor();
 +
 +class MyActor extends Actor {
 +   Torus3d t;
 +   World3d world;
 +   AmbientLight3d ambientLight;
 +   
 +
 +   double angle = 0;
 +   
 +   MyActor() {
 +      t = new Torus3d();
 +      t.scale(0.5);
 +      PhongMaterial3d pm = new PhongMaterial3d(0xffffff, 3);
 +      t.setMaterial(pm);
 +      world = World3d.getWorld3d();
 +      ambientLight = new AmbientLight3d();
 +      world.removeAllLights();
 +      world.addLight(ambientLight);
 +   
 +
 +   public void act() {
 +      angle += 0.5;
 +      double angleRad = Math.toRadians(angle);
 +      int red = Math.floor(Math.cos(angleRad) * 255);
 +      int blue = Math.floor(Math.sin(3 * angleRad) * 255);
 +      int green = Math.floor(Math.cos(5 * angleRad) * 255);
 +      
 +      int color = 0x10000 * red + 0x100 * green + blue;
 +      ambientLight.setColor(color);
 +   }
 +
 +}
 +</script>
 +
 +</div>
 +
 +</HTML>
 +
 +===== DirectionalLight3d =====
 +
 +<HTML>
 +<div class="java-online" style="height: 500px; width: 100%" data-java-online="{'withBottomPanel': true, 'id': 'DirectionalLight3d', 'enableFileAccess': true}">
 +
 +<script type="text/plain" title="Test1.java">
 +new MyActor();
 +
 +class MyActor extends Actor {
 +   Torus3d t;
 +   World3d world;
 +   DirectionalLight3d directionalLight;
 +   Box3d box = new Box3d();
 +
 +   double angle = 0;
 +   
 +   MyActor() {
 +      t = new Torus3d();
 +      t.scale(0.5);
 +      t.rotateX(45);
 +      box.scale(0.2);
 +      PhongMaterial3d pm = new PhongMaterial3d(0xffffff, 3);
 +      t.setMaterial(pm);
 +      world = World3d.getWorld3d();
 +      directionalLight = new DirectionalLight3d();
 +      directionalLight.moveTo(0, 0, 3);
 +      directionalLight.setTarget(box);
 +      world.removeAllLights();
 +      world.addLight(directionalLight);
 +   
 +
 +   public void act() {
 +      angle += 0.5;
 +      double angleRad = Math.toRadians(angle);
 +
 +      box.moveTo(2 * Math.cos(angleRad), 0, 2 * Math.sin(angleRad));
 +
 +   }
 +
 +}
 </script> </script>
  
api/documentation/grafik3d/licht/start.1737187957.txt.gz · Zuletzt geändert: 2025/01/18 08:12 von martin