canvas3d.canvasDirty |= Canvas3D.AMBIENTLIGHT_DIRTY; canvas3d.sceneAmbient.set(sceneAmbient);
    void updateLightAndFog() {	int enableMask = 0;	int i;	sceneAmbient.x = 0.0f;	sceneAmbient.y = 0.0f;	sceneAmbient.z = 0.0f;	int n = 0;	int nLight = lights.size();;	for (i = 0; i < nLight;i++) {	    LightRetained lt = (LightRetained)((Light)lights.get(i)).retained;	    if (lt instanceof AmbientLightRetained) {		sceneAmbient.x += lt.color.x; 		sceneAmbient.y += lt.color.y; 		sceneAmbient.z += lt.color.z;		continue;	    }	    	    lt.update(canvas3d.ctx, n, 		      canvas3d.canvasViewCache.getVworldToCoexistenceScale());	    if (lt.lightOn)		enableMask |= (1 << n);	    n++;	}	if (sceneAmbient.x > 1.0f) {	    sceneAmbient.x = 1.0f;	}	if (sceneAmbient.y > 1.0f) {	    sceneAmbient.y = 1.0f;	}	if (sceneAmbient.z > 1.0f) {	    sceneAmbient.z = 1.0f;	}		canvas3d.canvasDirty |= Canvas3D.AMBIENTLIGHT_DIRTY;	canvas3d.setSceneAmbient(canvas3d.ctx, sceneAmbient.x,				 sceneAmbient.y, sceneAmbient.z);	if (canvas3d.enableMask != enableMask) {	    canvas3d.canvasDirty |= Canvas3D.LIGHTENABLES_DIRTY;	    // TODO: 32 => renderBin.maxLights	    canvas3d.setLightEnables(canvas3d.ctx, enableMask, 32);	    canvas3d.enableMask = enableMask;	}	canvas3d.lightBin = null;	// Mark the envset as dirty for the canvas for scene graph rendering	canvas3d.environmentSet = null;	if (fog != null) {	    if (fog.retained != canvas3d.fog) {		((FogRetained)fog.retained).update(canvas3d.ctx,			   canvas3d.canvasViewCache.getVworldToCoexistenceScale());		canvas3d.fog = (FogRetained) fog.retained;		canvas3d.canvasDirty |= Canvas3D.FOG_DIRTY;	    }	} else { // Turn off fog	    if (canvas3d.fog != null) {		canvas3d.setFogEnableFlag(canvas3d.ctx, false);		canvas3d.fog = null;		canvas3d.canvasDirty |= Canvas3D.FOG_DIRTY;	    }	}    }