gpt4 book ai didi

actionscript - Away3D 4.0 从数组中加载图元的动态纹理

转载 作者:行者123 更新时间:2023-12-04 06:16:04 28 4
gpt4 key购买 nike

我有几个数组存储构建基元所需的属性。一个数组存储宽度,另一个存储高度,另一个存储深度,x、y、z 等。我还有一个存储要应用的纹理的远程文件名。从服务器获得响应后,我尝试将纹理应用于基元。当我移动相机看图元时,我看不到它。我的 View 似乎卡住了( View 不会更新)。一旦相机移过基元,它就可以再次看到。有任何想法吗?

private var loadedBuildingTextures:Object = new Object();
private var map_building_count:Number = 0;
private var loadedBuildings:Number = 0;
public var map_building_widths:Array;
public var map_building_heights:Array;
public var map_building_depths:Array;
public var map_building_xs:Array;
public var map_building_ys:Array;
public var map_building_zs:Array;
public var map_building_textures:Array;

// I POPULATE THE ARRAYS BUT LEFT THAT CODE OUT FOR SIMPLICITY

public function placeBuildings():void {
trace('FUNCTION: placeBuildings() fired');
var buildingsPlaced:Number = 0;
for (var a:Number = 0; a < map_building_count; a++ ) {
loadedBuildingTextures['texture_' + a.toString()] = new BitmapFileMaterial(map_building_textures[a]); // ASSIGNS THE BitmapFileMaterials TO AN OBJECT FOR REFERENCING LATER
loadedBuildingTextures['texture_' + a.toString()].loader.contentLoaderInfo.addEventListener(Event.COMPLETE, postBuildingLoad);
buildingsPlaced++;
}
trace('placed ' + buildingsPlaced.toString() + ' of ' + map_building_count.toString() + ' buildings.'); // OUTPUT = "placed 4 of 4 buildings."
trace('FUNCTION: placeBuildings() completed');
}

public function postBuildingLoad(event : Event):void {
loadedBuildings++;
if (int(loadedBuildings) == int(map_building_count)) {
placeBuildingsStep2();
}
}
public function placeBuildingsStep2():void {
trace('RECEIVED ALL RESPONSES FROM SERVER FOR TEXTURES');
for (var a:Number = 0; a < map_building_count; a++ ) {
cube = new Cube(
loadedBuildingTextures['texture_' + a], // <----- THIS SEEMS TO BE THE PROBLEM
map_building_widths[a], // WIDTH
map_building_heights[a], // HEIGHT
map_building_depths[a], // DEPTH
1, // WIDTH UNITS
1, // HEIGHT UNITS
1, // DEPTH UNITS
true);
cube.x = map_building_xs[a];
cube.y = map_building_ys[a];
cube.z = map_building_zs[a];
view.scene.addChild(cube);
}
}

最佳答案

虽然这篇文章很旧,但它确实突出了一个重要问题。 BitmapFileMaterial 与其说是生产就绪方案,不如说是测试的捷径。

我强烈建议为外部 Assets 使用加载队列(如 LoaderMax 或 4.0 中的新 AssetLibrary),然后根据需要实例化 Material 。

关于actionscript - Away3D 4.0 从数组中加载图元的动态纹理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7238298/

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