将新图层应用于卷webgl的切片

时间:2012-06-18 14:38:50

标签: webgl volume slice xtk

我有两卷不同质量的卷(.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"

当我用firebug检查 console.log(volume.children [2] .children [0]);

.texture.file设置为hostname / 112.jpg

当我去"网络" .jpg已成功转移

enter image description here

enter image description here


enter image description here

请注意112.jpg和level.jpg是一样的。第一个是在r.onShowtime中加载而另一个是在一个按键事件中加载的。


编辑3: volume.children [2] .children [0]属于" X.slice",不是吗?

这是我的方法:jsFiddle

这是我的实际问题,但仍无效:jsFiddle

1 个答案:

答案 0 :(得分:1)

MHH ..

我认为文件setter(以及其他来自注入类的setter)中缺少对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中调用它很重要,因为在未加载卷之前,sliceX,slicesY ...不存在。

编辑2: 哎,

感谢您添加的信息,我想我已经明白了!在我们的renderer3D的render()方法中,对texture._dirty标志进行了测试,您无法从框架外部进行更改。此外,第一次使用纹理渲染使该标志为false,并且加载新纹理似乎并未在当前XTK中将该标志设置为true。所以,我认为,我们必须在loader.load(texture,object)方法中添加它。我会在Github上发一个问题,看看Haehn对它的看法!