Created
August 19, 2022 17:16
-
-
Save ThomasGorisse/de5b01bb42abdd93ac6710e1044b01a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package io.github.sceneview.components | |
| import com.google.android.filament.EntityInstance | |
| import com.google.android.filament.LightManager | |
| import dev.romainguy.kotlin.math.Quaternion | |
| import io.github.sceneview.light.* | |
| import io.github.sceneview.math.Direction | |
| import io.github.sceneview.math.Position | |
| import io.github.sceneview.utils.Color | |
| import io.github.sceneview.utils.toColor | |
| interface LightComponent : Component { | |
| val lightManager get() = engine.lightManager | |
| val lightInstance: Int @EntityInstance get() = lightManager.getInstance(entity) | |
| /** | |
| * @see LightManager.getType | |
| */ | |
| val type: LightManager.Type get() = lightManager.getType(lightInstance) | |
| /** | |
| * @see LightManager.getDirection | |
| * @see LightManager.setDirection | |
| */ | |
| var position: Position | |
| get() = lightManager.getPosition(lightInstance) | |
| set(value) { | |
| lightManager.setPosition(lightInstance, value) | |
| } | |
| /** | |
| * @see LightManager.getDirection | |
| * @see LightManager.setDirection | |
| */ | |
| var quaternion: Quaternion | |
| get() = lightManager.getQuaternion(lightInstance) | |
| set(value) { | |
| lightManager.setQuaternion(lightInstance, value) | |
| } | |
| /** | |
| * @see LightManager.getDirection | |
| * @see LightManager.setDirection | |
| */ | |
| var direction: Direction | |
| get() = lightManager.getDirection(lightInstance) | |
| set(value) { | |
| lightManager.setDirection(lightInstance, value) | |
| } | |
| /** | |
| * @see LightManager.getIntensity | |
| * @see LightManager.setIntensity | |
| */ | |
| var intensity: Float | |
| get() = lightManager.getIntensity(lightInstance) | |
| set(value) = lightManager.setIntensity(lightInstance, value) | |
| /** | |
| * @see LightManager.getColor | |
| * @see LightManager.setColor | |
| */ | |
| var color: Color | |
| get() = FloatArray(3).apply { | |
| lightManager.getColor(lightInstance, this) | |
| }.toColor() | |
| set(value) = lightManager.setColor(lightInstance, value.r, value.g, value.b) | |
| /** | |
| * @see LightManager.isShadowCaster | |
| * @see LightManager.setShadowCaster | |
| */ | |
| var isShadowCaster: Boolean | |
| get() = lightManager.isShadowCaster(lightInstance) | |
| set(value) = lightManager.setShadowCaster(lightInstance, value) | |
| /** | |
| * @see LightManager.getFalloff | |
| * @see LightManager.setFalloff | |
| */ | |
| var falloff: Float | |
| get() = lightManager.getFalloff(lightInstance) | |
| set(value) = lightManager.setFalloff(lightInstance, value) | |
| /** | |
| * @see LightManager.getSunHaloFalloff | |
| * @see LightManager.setSunHaloFalloff | |
| */ | |
| var sunHaloFalloff: Float | |
| get() = lightManager.getSunHaloFalloff(lightInstance) | |
| set(value) = lightManager.setSunHaloFalloff(lightInstance, value) | |
| /** | |
| * @see LightManager.getSunHaloSize | |
| * @see LightManager.setSunHaloSize | |
| */ | |
| var sunHaloSize: Float | |
| get() = lightManager.getSunHaloSize(lightInstance) | |
| set(value) = lightManager.setSunHaloSize(lightInstance, value) | |
| /** | |
| * @see LightManager.getSunAngularRadius | |
| * @see LightManager.setSunAngularRadius | |
| */ | |
| var sunAngularRadius: Float | |
| get() = lightManager.getSunAngularRadius(lightInstance) | |
| set(value) = lightManager.setSunAngularRadius(lightInstance, value) | |
| /** | |
| * @see LightManager.getInnerConeAngle | |
| * @see LightManager.setSpotLightCone | |
| */ | |
| var innerConeAngle: Float | |
| get() = lightManager.getInnerConeAngle(lightInstance) | |
| set(value) = lightManager.setSpotLightCone(lightInstance, value, outerConeAngle) | |
| /** | |
| * @see LightManager.getOuterConeAngle | |
| * @see LightManager.setSpotLightCone | |
| */ | |
| var outerConeAngle: Float | |
| get() = lightManager.getOuterConeAngle(lightInstance) | |
| set(value) = lightManager.setSpotLightCone(lightInstance, innerConeAngle, value) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment