Question

I want to display a Collada model over top of a video stream and dynamically adjust its alpha value. Right now I have it partially working in PaperVision but I can't seem to set the alpha of the model at all. I have tried a few things from google. For non-Collada models the following works fine:

var layer:ViewportLayer = viewport.getChildLayer(myModel, true);
layer.alpha = 0.5;

All the Collada models I have tried have UVW mapped textures. In the end I am hoping to have the model alpha adjust continuously based on some external events. I have googled extensively and had little luck.

Any help would be appreciated!

UPDATE / RESOLVED

So as indicated below, all I needed to do was find the appropriate child and manipulate it directly. My code now looks similar to:

currentModel = new DAE(true, "Model");
currentModel.load("./model/Model.dae");
baseNode.addChild(currentModel);
currentModel.addEventListener(FileLoadEvent.LOAD_COMPLETE, function():void {
    // Assume first child is what we want
    for (var key:String in currentModel.children) {
        currentModelContainer = currentModel.getChildByName(key)
        currentModelContainer.useOwnContainer = true;
        currentModelContainer.alpha = 0.0;
        break;
    }
});

Now, later on all I do is use Tweener to adjust the alpha attribute of currentModelContainer.

Was it helpful?

Solution

One way is by placing the models childnodes inside their own containers.

var target:DisplayObject3D = model.getChildByName("someNode", true);
target.useOwnContainer = true;
target.alpha = 0.5;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top