0

我有两卷不同质量的卷 (.nrrd)。用户可以浏览图层。如果按下某个键,我想以更好的质量加载音量切片。

我的音量和这个类似:第 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();
}

编辑2 :这是我的 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);

它输出“真实主机名/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

4

1 回答 1

1

嗯..

我认为文件设置器(以及注入类的其他设置器)中缺少对 object.modified() 的调用。让我们看看 Haehn 什么时候会来,如果他想改变一些内在的东西,但目前你能试着自己打电话吗?

您可以尝试在修改纹理后添加:

volume.children[2].children[0].children[0].modified();

如果它不起作用,另外:

renderer.render();

编辑: 这很奇怪,我做了一个类似的代码,它做了一些事情。您能否通过打开您的 javascript 控制台(Firefox、Chrome、...有一个)尝试类似的操作并告诉我您遇到的错误?

 renderer.onShowtime = {
   for (var i=0 ; i< volume.children[2].children.length ; i++) {
     volume.children[2].children[i].texture.file="myimage.jpeg";
     volume.children[2].children[i].modified();
   }
 }

在 onShowtime 中调用它很重要,因为在未加载卷之前,slicesX、slicesY... 不存在。

编辑2: 嘿,

感谢您添加的信息,我想我明白了!在我们的 renderer3D 的 render() 方法中,有一个关于 texture._dirty 标志的测试,你不能从框架外部进行更改。此外,带有纹理的第一次渲染使该标志为假,并且加载新纹理似乎不会将该标志设置回当前 XTK 中的真。所以,我认为,我们必须将它添加到 loader.load(texture, object) 方法中。我会在 Github 上做一个 issue,看看 Haehn 是怎么想的!

于 2012-06-19T08:17:19.453 回答