Files
alternativa3d-archive/Alternativa3D5/5.4.1/alternativa/engine3d/display/Skin.as
2024-10-05 12:11:16 +01:00

66 lines
1.8 KiB
ActionScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package alternativa.engine3d.display {
import alternativa.engine3d.*;
import alternativa.engine3d.core.PolyPrimitive;
import alternativa.engine3d.materials.SurfaceMaterial;
import flash.display.Graphics;
import flash.display.Sprite;
use namespace alternativa3d;
/**
* @private
* Контейнер, исползуемый материалами для отрисовки примитивов. Каждый примитив BSP-дерева рисуется в своём контейнере.
*/
public class Skin extends Sprite {
/**
* @private
* Графика скина (для быстрого доступа)
*/
alternativa3d var gfx:Graphics = graphics;
/**
* @private
* Ссылка на следующий скин
*/
alternativa3d var nextSkin:Skin;
/**
* @private
* Примитив
*/
alternativa3d var primitive:PolyPrimitive;
/**
* @private
* Материал, связанный со скином.
*/
alternativa3d var material:SurfaceMaterial;
// Хранилище неиспользуемых скинов
static private var collector:Array = new Array();
/**
* @private
* Создание скина.
*/
static alternativa3d function createSkin():Skin {
// Достаём скин из коллектора
var skin:Skin = collector.pop();
// Если коллектор пуст, создаём новый скин
if (skin == null) {
skin = new Skin();
}
return skin;
}
/**
* @private
* Удаление скина, все ссылки должны быть почищены.
*/
static alternativa3d function destroySkin(skin:Skin):void {
collector.push(skin);
}
}
}