【发布时间】:2012-07-05 20:14:20
【问题描述】:
我有两卷不同质量的卷 (.nrrd)。用户可以浏览图层。如果某个键被按下 我想以更好的质量加载卷的切片。
我的音量和这个差不多:lesson 10 xtk
我找到了:
volume.children[2].children[0].children[0].texture.file = "http://path/to/file.ext";
但如果我应用某种文件(.jpg、.dcm),则不会发生任何事情。
这是将切片更改为进入子级并更改纹理的正确方法吗?
或者我应该将选定的切片作为一个对象单独加载并以某种方式将其应用于“低质量体积”?
编辑: 这是我迄今为止尝试过的(我在 dcms 上遇到错误,但在 jpgs 上没有):
if (event.keyCode == 83) { // "s"-button
volume.children[2].children[0].children[0].texture.file = "http://localhost:3000/112.jpg";
volume.children[2].children[0].children[0].modified();
r.render();
}
edit2: 这是我的 r.onShowtime = function() {}
volume.children[2].children[0].texture.file = 'http://localhost:3000/112.jpg';
volume.children[2].children[0].visible = true; // to activate the first layer
volume.children[2].children[0].modified();
console.log(volume.children[2].children[0].visible +" "+ volume.children[2].children[0].texture.file);
它输出 "true hostname/112.jpg"
当我在 firebug 中检查 .jpg 时,标题是好的,但答案是“null”
当我用萤火虫检查 console.log(volume.children[2].children[0]);
.texture.file 设置为 hostname/112.jpg
当我进入“网络”时,.jpg 已成功传输
请注意 112.jpg 和 level.jpg 是一样的。第一个在 r.onShowtime 中加载,另一个在按键事件中加载。
编辑 3:volume.children[2].children[0] 属于“X.slice”类型,不是吗?
这是我的方法:jsFiddle
这是我的实际问题,但仍然无法正常工作:jsFiddle
【问题讨论】:
-
为什么答案是“null”?我可以单击链接并显示图像。我必须等待图像加载事件吗?
-
好吧,我尝试将它绑定到一个 image.onload,如下所示:stackoverflow.com/questions/5933230/javascript-image-onload 但它并没有改变行为