【问题标题】:Problems with Papervision3D in as3as3 中 Papervision3D 的问题
【发布时间】:2012-04-19 11:29:22
【问题描述】:

我在 as3 中玩 Papervision3D。我目前被 BitmapEffectLayer 困住了。当我想为对象添加效果时,具有效果的对象将始终呈现在所有内容的前面。这意味着,即使它在 cordinat 系统中的另一个对象后面,它也会被拉到它前面。 这里有一些源代码,不知道有没有帮助。

spherer = new Sphere(shadedMaterial, 120, 20, 14);
        //spherer.x = 0;
        //spherer.y = 0;
        //spherer.z = 0;

        displayEarth = new DisplayObject3D();
        displayEarth.x =0;
        displayEarth.y = 0;
        displayEarth.z = 0;
        displayEarth.addChild(spherer);


        smallSphere = new Sphere(flatMaterial, 10, 10, 10);

        smallSphere.x = 0;
        smallSphere.z = 130;
        smallSphere.y = 00;

        displayEarth.addChild(smallSphere);
        //scene.addChild(smallSphere);
        scene.addChild(light);


        var partMaterial:ParticleMaterial = new ParticleMaterial(0x000000, 1.0, ParticleMaterial.SHAPE_CIRCLE);
        var part:Particle = new Particle(partMaterial, 3, 0, -150, 30);
        var part2:Particle = new Particle(partMaterial, 3, 0,0,135);
        var partsHolder:Particles = new Particles();
        partsHolder.addParticle(part);
        parrr.push(part);
        partsHolder.addParticle(part2);
        parrr.push(part2);

        var effectLayer:BitmapEffectLayer = new BitmapEffectLayer(viewport, stage.stageWidth, stage.stageHeight, true, 0x000000, BitmapClearMode.CLEAR_PRE);
        effectLayer.drawLayer.blendMode = BlendMode.OVERLAY;

        effectLayer.addDisplayObject3D(smallSphere);
        viewport.containerSprite.addLayer(effectLayer);

        displayEarth.addChild(partsHolder);

        scene.addChild(displayEarth);
        effectLayer.addEffect(new BitmapLayerEffect(new BlurFilter(2,2,2)));

现在,附加到 effectLayer 的“smallSphere”将始终呈现在“sphere”的前面。 任何帮助表示赞赏! - 大卫

【问题讨论】:

    标签: actionscript-3 actionscript 3d papervision3d


    【解决方案1】:

    当您将 DisplayObject3D 设置为它自己的图层时(.useOwnContainer = true; 是最简单的选项,本质上您会将该 3D 对象渲染到 2D 典型显示列表上的单独 2D 精灵中。使用 ViewportLayer 可以更容易地控制它堆叠/排序,所以一定要通读Andy Zupko's detailed post on ViewportLayers。这个想法是,如果你将 3D 对象添加到 2D 渲染层,你将不得不处理排序。例如,你可以检查 3D 对象的 z 位置并基于如果对象在 3D 中移动很多,则对图层进行排序。在执行此类操作时,您显然会降低速度,因此最好稍微计划一下(例如,什么在场景中移动,什么不移动,什么是优点和添加效果等的缺点)

    另外,记住 Papervision3D 项目已经有一段时间没有更新可能是个好主意。它目前只提供软件渲染(使用 Flash Player 9,我认为部分使用 Flash Player 10 的新绘图 API,但可能不在稳定分支中)。您可能想看看Away3D,因为它目前仍在开发中。您可以使用 Flash Player 10 软件渲染 API 甚至是轻量级的 Away3DLite 版本(我认为它比 Papervision3D 更快),但还有使用硬件加速的 Away3D 4.0 版本。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-12-24
      • 2023-04-09
      • 2011-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-26
      相关资源
      最近更新 更多