我需要在我的应用中使用iPhone Flash灯.但是,当用户打开闪光灯时,相机不会拍照.我怎样才能做到这一点?在这里,我附上了我的代码.但是,当我打开闪光灯时,相机会拍照.
AVCaptureDeviceInput *flashInput = [AVCaptureDeviceInput deviceInputWithDevice:device error: nil];
AVCaptureVideoDataOutput *output = [[AVCaptureVideoDataOutput alloc] init];
AVCaptureSession *session = [[AVCaptureSession alloc] init];
[session beginConfiguration];
[device lockForConfiguration:nil];
[device setTorchMode:AVCaptureTorchModeOn];
[device setFlashMode:AVCaptureFlashModeOn];
[session addInput:flashInput];
[session addOutput:output];
[device unlockForConfiguration];
[output release];
[session commitConfiguration];
[session startRunning];
[self setTorchSession:session];
Run Code Online (Sandbox Code Playgroud)
我在编码时错在哪里?请帮我.提前致谢.
目前,我的OpenGL场景不使用任何灯光,它仅使用具有固定颜色的线框-对我来说效果很好。
现在,我想添加第二种模式,其中线框显示为(半)实体模型。为此,我需要一些照明。照明应该非常容易,只需一些具有固定颜色和方向的全局定向光即可。
有两个问题:据我了解,我可以完全在片段着色器中执行此操作-这正确吗?
并且:我当前的片段着色器非常简单:
#version 130
uniform vec4 inputColor;
out vec4 FragColor;
void main()
{
FragColor=inputColor;
}
Run Code Online (Sandbox Code Playgroud)
在这里必须添加什么以使全局几何光源(而不是其他一些点光源)为我的几何图形照明?
是)我有的
如下图所示,我使用Three.js库创建WEBGL画布,并使用GLTFLoader.js在场景中加载.gltf模型。
我使用的代码
//Add THREE Renderer
renderer_Main = new THREE.WebGLRenderer({ antialias: true });
renderer_Main.setSize(canvasWidth, canvasHeight); //Set Renderer Size
//Add THREE Scene
scene_Main = new THREE.Scene();
//Add First THREE Camera
camera_Main = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.01, 10000);
camera_Main.position.set(-2000, 500, 500); //Set camera position
//Add THREE Grid Helper
var size = 1000; //Value of Each Square Size
var divisions = 60; //Value of Grid Divisions
gridHelper = new THREE.GridHelper(size, divisions);
gridHelper.material.opacity = 0.045;
gridHelper.material.transparent = false;
scene_Main.add(gridHelper); //Add Grid in …Run Code Online (Sandbox Code Playgroud) 我的应用程序需要在其后台服务中具有更新的亮度值(延迟10-15分钟或其他东西)(这不是商业应用程序)....
我知道如何使用SensorEventListener和SensorManager检索灯值,但是在API文档中明确说明如果你不需要它时取消注册监听器,它将在几个小时内耗尽你的电池.
现在我的问题是......我怎样才能使用侦听器和传感器管理器每10-15分钟检索一个亮度值?
我可以使用类似下面的东西,每隔10-15分钟运行一次这个任务吗?
private TimerTask lightSensorTimer = new TimerTask() {
@Override
public void run() {
if (sensorManager != null) {
Sensor lightSensor = sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
if (lightSensor != null) {
sensorManager.registerListener(sensorListener, lightSensor, SensorManager.SENSOR_DELAY_NORMAL);
while (newLightLevel == lightLevel) {
try {
**Thread.sleep(1000);**
} catch (InterruptedException e) {
Log.e(TAG, "Interrupted exception in lightsensor timer: " + e.getMessage());
}
}
PhoneEvents.this.lightLevel = PhoneEvents.this.newLightLevel;
sensorManager.unregisterListener(sensorListener, lightSensor);
}
}
}
};
Run Code Online (Sandbox Code Playgroud)
sensoreventlistener除此之外什么都不做:
private SensorEventListener sensorListener = new SensorEventListener() {
public void onSensorChanged(SensorEvent event) {
if …Run Code Online (Sandbox Code Playgroud) 我(为了练习)创建了一个服务器,以处理客户端连接。主题是关于C编程的,但是我已经做到了。我想再次使用节点js来做。我不需要http服务器,只需一个处理原始cmd的简单模块。该协议是在主题内给出的,我将在我身边实现我的应用程序的逻辑。我只是node js编程的新手,它的主题很浅(大约5-6个命令)。你知道我可以从哪里开始吗?一个简单模块的名称/文档,还是仅用于处理客户端连接/命令读取的简约代码?(Cmd是简单的字符串,后跟\ n)。我已经在npm网站中进行搜索,但是我只是找到http的服务器或更复杂的东西,因此不需要太多功能。只是连接,原始格式的命令以及一些可以很好处理诸如连接丢失,