我试图像这样做出一些反应
def doAjax = Action { request =>
object MyResult {
val resultCode = 0
val resultTextMessage = "sss"
}
Ok(Json(MyResult)) // It's not working anymore - not compiling in v2.0!
}
Run Code Online (Sandbox Code Playgroud)
但是如何使用Play 2.0将我的对象(MyResult)映射到JSON?在使用scala模块的Play 1.0中,我成功完成了以下操作:
def dosomeaj = {
object MyResult{
val resultCode = 0
val resultTextMessage = "sss"
}
Json(MyResult) // It's working in 1.0
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用gluUnProject将Windows coords转换为世界坐标.我不是试图在模拟器或较旧的Android系统(使用OpenGL ES v1.0)中获取工作样本,这不是关于GL功能可用性的问题.我正在尝试使用OpenGL ES 1.1处理真实设备,glGet函数返回非零结果.
有样品:
public Vector3 translateScreenCoordsToWorld(Vector2 screenCoords) {
gl.glLoadIdentity();
final Matrix4x4 modelViewMatrix = new Matrix4x4();
final Matrix4x4 projectMatrix = new Matrix4x4();
int[] viewVectorParams = new int[4];
gl.glGetIntegerv(GL11.GL_VIEWPORT,viewVectorParams,0);
gl.glGetFloatv(GL11.GL_MODELVIEW_MATRIX,modelViewMatrix.buffer,0);
gl.glGetFloatv(GL11.GL_PROJECTION_MATRIX,projectMatrix.buffer,0);
float[] output = new float[4];
GLU.gluUnProject(
screenCoords.x, screenCoords.y, 0,
modelViewMatrix.buffer, 0,
projectMatrix.buffer, 0,
viewVectorParams, 0,
output, 0);
return new Vector3(output[0],output[1],output[2]);
}
Run Code Online (Sandbox Code Playgroud)
Matrix4x4只是float []缓冲区的包装器;
有了这个功能,我正在尝试创建一个平面来填充所有屏幕或检测当前投影矩阵的最大世界坐标,但它根本不起作用,因为我不确定我正确使用这些功能.
例如,当我尝试运行translateScreenCoordsToWorld(new Vector2(480,800))时,它返回非常小的坐标值Vector3(0.27f,0.42f,-1.0f).
任何人都可以通过一个定位相机为GL_PROJECTION模式提供良好的样品用量gluUnProject.
更新 感谢您的良好链接.但它仍然不适合我:(现在我的功能看起来像:
public Vector3 translateScreenCoordsToWorld(Vector2 screenCoords) {
float winX = screenCoords.x, winY = screenCoords.y, winZ = 0;
winY …Run Code Online (Sandbox Code Playgroud) 假设我们有以下类型定义:
data P = PA | PB
Run Code Online (Sandbox Code Playgroud)
(与PA或PB的结构无关)
然后,我们可以像这样定义其他一些记录类型(案例 1):
data C1 = C1 { field :: P } -- this is fine
Run Code Online (Sandbox Code Playgroud)
但有时您需要定义更受约束的字段类型(案例 2):
data C2 = C2 { field :: PA } -- won't compile because PA is a data constructor
Run Code Online (Sandbox Code Playgroud)
Haskell 中解决此类案例的最自然和惯用的方法是什么?我试图避免过于复杂或样板的解决方案。
实际上我知道Apache Cassandra的好的Java高级API和ORM - Hector.但是找不到任何原生的Scala解决方案.有人知道SuperColumns的质量,活动和ORM支持的任何实际项目吗?
我想禁用fullOptJS(生产模式)的源映射生成。拥有有关原始 Scala 源文件的所有信息并不总是合适的。
我没有找到任何合适的选项来完全禁用输出或类似的东西?是否有任何指向文档的链接,其中包含 scalajs sbt 插件可用的所有选项?
谢谢你的帮助