lightSphere.setModelBound(new BoundingSphere());
lightSphere.getSceneHints().setLightCombineMode(LightCombineMode.Off);
lightSphere.setDefaultColor(lightColor);
// Create a new point light and fill out the properties
final PointLight pointLight = new PointLight();
pointLight.setAttenuate(true);
pointLight.setConstant(.01f);
pointLight.setLinear(.001f);
pointLight.setQuadratic(.1f);
pointLight.setEnabled(true);
pointLight.setDiffuse(lightColor);
pointLight.setAmbient(new ColorRGBA(.1f, .1f, .1f, .1f));
_lightState.attach(pointLight);
lightSphere.addController(new SpatialController<Spatial>() {
double timeX = rand.nextDouble() * Math.PI * 8;
double timeY = rand.nextDouble() * Math.PI * 8;
double timeZ = rand.nextDouble() * Math.PI * 8;
double speed = MathUtils.nextRandomDouble();
public void update(final double tpf, final Spatial caller) {
timeX += tpf * speed;
timeY += tpf * speed;
timeZ += tpf * speed;
final double xPos = Math.sin(timeX * 0.4) * worldsize;
final double yPos = Math.cos(timeY * 0.5) * worldsize;
final double zPos = Math.sin(timeZ * 0.6) * worldsize;
caller.setTranslation(xPos, yPos, zPos);
pointLight.setLocation(xPos, yPos, zPos);
}
});
// Add the light to the world part 2.
colornode.attachChild(lightSphere);