forked from LeenkxTeam/Leenkx_Examples
update
This commit is contained in:
6
world_sun_direction/README.md
Normal file
6
world_sun_direction/README.md
Normal file
@ -0,0 +1,6 @@
|
||||
Sky Texture synchronized with light direction.
|
||||
|
||||
### Keyboard
|
||||
|
||||
- `1` HosekWilkie
|
||||
- `2` Nishita
|
||||
42
world_sun_direction/Sources/lnx/MyTrait.hx
Normal file
42
world_sun_direction/Sources/lnx/MyTrait.hx
Normal file
@ -0,0 +1,42 @@
|
||||
package lnx;
|
||||
|
||||
import leenkx.renderpath.HosekWilkie;
|
||||
import leenkx.renderpath.Nishita;
|
||||
import iron.Scene;
|
||||
import iron.math.Vec4;
|
||||
import iron.system.Input;
|
||||
|
||||
class MyTrait extends iron.Trait {
|
||||
public function new() {
|
||||
super();
|
||||
notifyOnInit(function() {
|
||||
|
||||
var world = Scene.active.world;
|
||||
var center = Scene.active.getEmpty('Center');
|
||||
var light = Scene.active.lights[0];
|
||||
var keyboard = Input.getKeyboard();
|
||||
var model = 'hosekwilkie';
|
||||
notifyOnUpdate(function() {
|
||||
|
||||
if (keyboard.started("1")) Scene.setActive('Scene_'+(model = 'hosekwilkie'));
|
||||
if (keyboard.started("2")) Scene.setActive('Scene_'+(model = 'nishita'));
|
||||
|
||||
center.transform.rotate(Vec4.xAxis(),0.02);
|
||||
|
||||
// Sync sun direction
|
||||
var v = light.look();
|
||||
world.raw.sun_direction[0] = v.x;
|
||||
world.raw.sun_direction[1] = v.y;
|
||||
world.raw.sun_direction[2] = v.z;
|
||||
|
||||
switch model {
|
||||
case 'hosekwilkie': HosekWilkie.recompute(world);
|
||||
case 'nishita': Nishita.recompute(world);
|
||||
}
|
||||
|
||||
// Set world strength
|
||||
// world.getGlobalProbe().raw.strength = 1.0;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
BIN
world_sun_direction/world_sun_direction.blend
Normal file
BIN
world_sun_direction/world_sun_direction.blend
Normal file
Binary file not shown.
Reference in New Issue
Block a user