0

Trying out http://www.goxtk.com, great stuff! Is there a quick way to get the bounding box for a model or some other point that could be used as the center of rotation of the camera? Worst case, what's the best way to loop over the points? Thanks for any replies!

4

1 に答える 1

1

次のように、各 X.object() の重心をクエリできます。

...
r = new X.renderer('r');
r.init();

o = new X.object();
o.load('test.vtk');

r.add(o);
r.render();

r.onShowtime = function() {

    // print the centroid
    console.log(o.points().centroid());

};
...

X.renderer の onShowtime 関数をオーバーロードして、X.object が適切にセットアップされていること (.vtk ファイルがロードされていることなど) を確認する必要があります。

カメラを構成するには、次の操作を実行できます。

...
r.camera().setPosition(-400,0,0); // set the position
r.camera().setFocus(-10,-10,-10); // set the focus point
r.camera().setUp(1,0,0); // set the (normalized) up vector
r.render();
...

とにかく、ポイントをループするには:

...
// o is an X.object
var numberOfPoints = o.points().count();
var pointArrayLength = o.points().length(); // equals numberOfPoints * 3
var allPoints = o.points().all(); // as a flat 1D array optimized for WebGL

// just loop it :)
...
于 2012-02-06T14:49:50.760 に答える