api:documentation:grafik3d:licht:start
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
api:documentation:grafik3d:licht:start [2025/01/18 08:12] – [PointLight3d] martin | api:documentation:grafik3d:licht:start [2025/01/18 11:22] (aktuell) – [AmbientLight3d] martin | ||
---|---|---|---|
Zeile 25: | Zeile 25: | ||
<script type=" | <script type=" | ||
- | Torus3d t = new Torus3d(); | + | new MyActor(); |
+ | class MyActor extends Actor { | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | |||
+ | | ||
+ | t = new Torus3d(); | ||
+ | t.scale(0.5); | ||
+ | PhongMaterial3d pm = new PhongMaterial3d(0xffffff, | ||
+ | t.setMaterial(pm); | ||
+ | world = World3d.getWorld3d(); | ||
+ | pointLight = new PointLight3d(3, | ||
+ | pointLight.setColor(Color.red); | ||
+ | pointLight.setIntensity(15); | ||
+ | world.removeAllLights(); | ||
+ | world.addLight(pointLight); | ||
+ | lightSprite = new Sprite3d(0.5, | ||
+ | | ||
+ | |||
+ | | ||
+ | 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, | ||
+ | lightSprite.moveTo(x, | ||
+ | } | ||
+ | |||
+ | } | ||
+ | </ | ||
+ | |||
+ | </ | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | ===== AmbientLight3d ===== | ||
+ | |||
+ | < | ||
+ | <div class=" | ||
+ | |||
+ | <script type=" | ||
+ | new MyActor(); | ||
+ | |||
+ | class MyActor extends Actor { | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | |||
+ | | ||
+ | |||
+ | | ||
+ | t = new Torus3d(); | ||
+ | t.scale(0.5); | ||
+ | PhongMaterial3d pm = new PhongMaterial3d(0xffffff, | ||
+ | t.setMaterial(pm); | ||
+ | world = World3d.getWorld3d(); | ||
+ | ambientLight = new AmbientLight3d(); | ||
+ | world.removeAllLights(); | ||
+ | world.addLight(ambientLight); | ||
+ | | ||
+ | |||
+ | | ||
+ | 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); | ||
+ | } | ||
+ | |||
+ | } | ||
+ | </ | ||
+ | |||
+ | </ | ||
+ | |||
+ | </ | ||
+ | |||
+ | ===== DirectionalLight3d ===== | ||
+ | |||
+ | < | ||
+ | <div class=" | ||
+ | |||
+ | <script type=" | ||
+ | new MyActor(); | ||
+ | |||
+ | class MyActor extends Actor { | ||
+ | | ||
+ | | ||
+ | | ||
+ | Box3d box = new Box3d(); | ||
+ | |||
+ | | ||
+ | |||
+ | | ||
+ | t = new Torus3d(); | ||
+ | t.scale(0.5); | ||
+ | t.rotateX(45); | ||
+ | box.scale(0.2); | ||
+ | PhongMaterial3d pm = new PhongMaterial3d(0xffffff, | ||
+ | t.setMaterial(pm); | ||
+ | world = World3d.getWorld3d(); | ||
+ | directionalLight = new DirectionalLight3d(); | ||
+ | directionalLight.moveTo(0, | ||
+ | directionalLight.setTarget(box); | ||
+ | world.removeAllLights(); | ||
+ | world.addLight(directionalLight); | ||
+ | | ||
+ | |||
+ | | ||
+ | angle += 0.5; | ||
+ | double angleRad = Math.toRadians(angle); | ||
+ | |||
+ | box.moveTo(2 * Math.cos(angleRad), | ||
+ | |||
+ | } | ||
+ | |||
+ | } | ||
</ | </ | ||
api/documentation/grafik3d/licht/start.1737187974.txt.gz · Zuletzt geändert: 2025/01/18 08:12 von martin