gpt4 book ai didi

actionscript-3 - Away3D 无法加载 AWD

转载 作者:行者123 更新时间:2023-12-02 05:31:26 25 4
gpt4 key购买 nike

我已经按照此链接中的教程进行操作: http://www.adobe.com/devnet/flashplayer/articles/creating-games-away3d.html

但代码似乎有问题,我什至无法加载 3D 花瓶。

代码如下:

package 
{
import away3d.containers.View3D;
import away3d.events.LoaderEvent;
import away3d.loaders.Loader3D;
import away3d.loaders.parsers.Parsers;

import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLRequest;

public class Main extends Sprite
{
private var _view:View3D;
private var _loader:Loader3D;

public function Main()
{
_view = new View3D();
_view.backgroundColor = 0x666666;
_view.antiAlias = 4;

this.addChild(_view);
this.addEventListener(Event.ENTER_FRAME, onEnterFrame);

Parsers.enableAllBundled();

_loader = new Loader3D();
_loader.addEventListener(LoaderEvent.RESOURCE_COMPLETE, onResourceComplete);
_loader.addEventListener(LoaderEvent.LOAD_ERROR, onLoadError);
_loader.load( new URLRequest('vase.awd') );
}

private function onResourceComplete(ev:LoaderEvent):void
{
_loader.removeEventListener(LoaderEvent.RESOURCE_COMPLETE, onResourceComplete);
_loader.removeEventListener(LoaderEvent.LOAD_ERROR, onLoadError);
_view.scene.addChild(_loader);
}

private function onLoadError(ev:LoaderEvent):void
{
trace('Could not find', ev.url);
_loader.removeEventListener(LoaderEvent.RESOURCE_COMPLETE, onResourceComplete);
_loader.removeEventListener(LoaderEvent.LOAD_ERROR, onLoadError);
_loader = null;
}

private function onEnterFrame(ev:Event):void
{
_loader.rotationY = stage.mouseX - stage.stageWidth / 2;
_view.camera.y = 3 * (stage.mouseY - stage.stageHeight/2);
_view.camera.lookAt(_loader.position);
_view.render();
}
}
}

知道错误在哪里吗?或者是否有任何教程教如何将 AWD 文件加载到闪存中?

谢谢。

最佳答案

我建议您使用 AssetLibrary 来加载您的模型,它非常简单且易于处理模型包含的所有内容,

AssetLibrary.addEventListener( AssetEvent.ASSET_COMPLETE, onAssetComplete );
AssetLibrary.addEventListener( LoaderEvent.RESOURCE_COMPLETE, onResourceComplete );
AssetLibrary.addEventListener( LoaderEvent.LOAD_ERROR, onLoadError );

查看详细示例This

希望对你有帮助

关于actionscript-3 - Away3D 无法加载 AWD,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12315277/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com