这个问题的答案: JavaScript函数的原型属性的初始值是多少?
有这句话:
任何新创建的Function实例上的prototype的初始值是Object的新实例
据我所知,Javascript没有类,因此"实例"这个词在我脑海中没有意义.如何解释Javascript中的"实例"?
对不起,我没有足够的代表将我的问题放在答案的评论主题中.
我想设置一个平面的旋转.这需要三个数字来表示x,y和z轴的弧度旋转.
我没有这些数字,但是,我有一个矢量'myVec',它一旦旋转就应该与平面正交.
这个向量让我向前迈进了一步,但并不完全在那里:THREE.Vector3提供了一个函数"setEulerFromRotationMatrix".也许我可以使用它,如果我能弄清楚如何从myVec生成旋转矩阵:
旋转矩阵描述了一个向量如何转换为另一个向量.因此出现了一个问题:哪个向量应该是起始向量?这一个(1,1,1),还是这一个(1,0,0)?
其次,我如何实际制作矩阵?我看过http://en.wikipedia.org/wiki/Rotation_matrix,但只发现了如何从旋转矩阵转换为其他东西.它必须以某种方式逆转矩阵乘法过程.
有什么指针吗?
我有一个程序,其中camera.position.[x | y | z]根据鼠标位置而变化.这个控制台输出验证了这一点:
但是,相机正在查看的对象的渲染不会改变.它静止不动,如下所示:
https://dl.dropbox.com/u/2070405/stackoverflow2/index.html
如何最好地调试此类行为?
该程序包括index.html,js/main.js,js/myLibs/dragPanControls.js*,js/require.js,js/libs/three.js/build/three.js
这是main.js:
// CONFIGURE require.js BEFORE LOADING MODULES:
requirejs.config({
shim: {
'libs/three.js/build/three': {
deps: [],
exports: 'three' //'three' will not be accessible, but any values that three.js writes to the global object will become available to me if I import 'three'.
/*init: function () {
// if I want 'three' to actually refer to something, I can do so by returning whatever I want it to refer to, in this init function …
Run Code Online (Sandbox Code Playgroud) 我在增加一个变量整数时遇到了一些麻烦.这段代码:
variable Integer myInteger = -1;
Integer getInteger () {
myInteger = myInteger + 1;
print("myInteger: " + myInteger.string);
return Integer(myInteger);
}
Array<Integer> integers =
Array.ofSize(
4,
getInteger());
print(integers);
Run Code Online (Sandbox Code Playgroud)
给出这个输出:
myInteger: 0
{ 0, 0, 0, 0 }
Run Code Online (Sandbox Code Playgroud)
而预期的输出是:
myInteger: 0
myInteger: 1
myInteger: 2
myInteger: 3
{ 0, 1, 2, 3 }
Run Code Online (Sandbox Code Playgroud)
那是怎么回事?
是否有任何方法可以初始化一个顺序值而不是一个人?
比如,我可以声明它,然后使用for循环来逐步填充它吗?
由于这可能都发生在类体内,因此一旦类实例构建阶段完成,Sequential值的真正不变性就可以启动.
例:
Sequential<String> strSeq;
for (i in span(0,10)) {
strSeq[i] = "hello";
}
Run Code Online (Sandbox Code Playgroud)
此代码不起作用,因为我收到此错误:
错误:(12,9)ceylon:索引表达式的非法接收类型:'Sequential'不是'KeyedCorrespondenceMutator'或'IndexedCorrespondenceMutator'的子类型
所以我可以得出结论,序列必须在一个语句中分配,对吧?
我对F#很新,我正在尝试创建一个存储多边形的结构,它必须包含一个坐标列表:
type Polygon =
struct
val Coords : list
new(list_of_Coords) = { Coords = list_of_Coords }
end
Run Code Online (Sandbox Code Playgroud)
但Visual Studio说"类型'Microsoft.FSharp.Collections.list <_>'需要1个类型的参数但是给出0"
我想不是因为我不打算初始化结构中的列表 - 只是声明它.
我选择将我的小项目的代码放在'default'模块中(在文件/source/main.ceylon中),但是我在哪里放置模块描述符?目前我在/source/module.ceylon中有它,但是当鼠标悬停在模块名称上时,它会给我一个可怕的警告"在根源目录中遇到的模块描述符".
我需要一个模块描述符,因为我需要依赖一个Ceylon模块(httpd
)
我的任务是在锡兰写一个文件编写者,在这样做的过程中,我遇到了在锡兰写一个if语句的困难,当面对强大的类型正确的向导时,它将被允许通过.在锡兰远处的狭窄的编译桥:
我得到的错误是"错误:(10,1)锡兰:语法不正确:在'if'处缺少EOF"
这是我的if语句(第一行是第10行):
if (is Nil fileResource || is File fileResource) {
File file = createFileIfNil(fileResource);
value writer = file.Overwriter();
//writer.writeLine("Hello, World!");
} else {
print("hello");
}
Run Code Online (Sandbox Code Playgroud)
编辑:根据Bastien Jansens的建议,这是我的if语句更新.但是,错误仍然是相同的:(
Path folderPath = parsePath("""C:\Users\Jon\Auchitect\POSTtoFile""");
Path filePath = folderPath.childPath("BPset.json.txt");
FResource fileResource = filePath.resource;
if (is Nil|File fileResource) {
File file = createFileIfNil(fileResource);
value writer = file.Overwriter();
//writer.writeLine("Hello, World!");
} else {
print("hello");
}
Run Code Online (Sandbox Code Playgroud)
这是我的应用程序的完整源代码:
import ceylon.http.server { newServer, startsWith, Endpoint, Request, Response }
import ceylon.io { SocketAddress }
import ceylon.file { Path, …
Run Code Online (Sandbox Code Playgroud) 在F#我可以这样做:
type coord = float * float //Type for a 2D-float-tupple
let myDepthCurve1 = { coords = [(1., 2.); (3., 4.)]; depth = 9.4 }
Run Code Online (Sandbox Code Playgroud)
但我不能这样做:
type coord = { longitude : float; latitude : float } //Type for a 2D-float-record
let myDepthCurve1 = { coords = [(longitude = 1., latitude = 2.); (longitude = 3., latitude = 4.)]; depth = 9.4 }
Run Code Online (Sandbox Code Playgroud)
当coord类型记录中的字段被标记时,我是否无法一次性创建我的深度?
这是我正在尝试运行的简化版本:
for ( winDoorNo = 0; winDoorNo < aWinDoorSetSpec.no_of_winDoors; winDoorNo ++ ) {
(function (winDoorNo, self) {
self.tangentVectors_azimuth = [];
self.tangentVectors_polar = [];
self.tangentVectors_azimuth[winDoorNo] = tangentPlane.tangentVector_azimuth;
self.tangentVectors_polar[winDoorNo] = tangentPlane.tangentVector_polar;
})(winDoorNo, this);
}
Run Code Online (Sandbox Code Playgroud)
但我发现self.tangentVectors_azimuth
数组只包含for循环索引变量的最后一个值.我发现这篇文章描述了一个类似的问题,我实现了建议的解决方案,即使用闭包.然而,这对我不起作用.执行for循环后,值this.tangentVectors_azimuth
仍为:
[undefined, undefined, Object { x=0.01999999996662183, y=0.01599999957331022, z=0, more...}]
Run Code Online (Sandbox Code Playgroud)