mirror of
https://github.com/billsonnn/nitro-converter.git
synced 2024-11-26 09:20:51 +01:00
Fix layer order
This commit is contained in:
parent
e2cad3b9fe
commit
3f09425622
@ -6,6 +6,5 @@ export interface IAssetPlaneVisualization
|
||||
size?: number;
|
||||
horizontalAngle?: number;
|
||||
verticalAngle?: number;
|
||||
layers?: IAssetPlaneVisualizationLayer[];
|
||||
animatedLayers?: IAssetPlaneVisualizationAnimatedLayer[];
|
||||
allLayers?: (IAssetPlaneVisualizationLayer | IAssetPlaneVisualizationAnimatedLayer)[];
|
||||
}
|
||||
|
@ -155,6 +155,8 @@ export class RoomVisualizationMapper extends Mapper
|
||||
|
||||
for (const planeVisualizationXML of xml)
|
||||
{
|
||||
if (planeVisualizationXML.size === 32) continue;
|
||||
|
||||
const visualization: IAssetPlaneVisualization = {};
|
||||
|
||||
if (planeVisualizationXML.size !== undefined) visualization.size = planeVisualizationXML.size;
|
||||
@ -162,23 +164,24 @@ export class RoomVisualizationMapper extends Mapper
|
||||
if (planeVisualizationXML.horizontalAngle !== undefined) visualization.horizontalAngle = planeVisualizationXML.horizontalAngle;
|
||||
if (planeVisualizationXML.verticalAngle !== undefined) visualization.verticalAngle = planeVisualizationXML.verticalAngle;
|
||||
|
||||
if (planeVisualizationXML.layers !== undefined)
|
||||
if (planeVisualizationXML.allLayers !== undefined)
|
||||
{
|
||||
if (planeVisualizationXML.layers.length)
|
||||
if (planeVisualizationXML.allLayers.length)
|
||||
{
|
||||
visualization.layers = [];
|
||||
visualization.allLayers = [];
|
||||
|
||||
RoomVisualizationMapper.mapPlaneVisualizationLayers(planeVisualizationXML.layers, visualization.layers);
|
||||
}
|
||||
}
|
||||
for (const layer of planeVisualizationXML.allLayers)
|
||||
{
|
||||
if (layer instanceof PlaneVisualizationLayerXML)
|
||||
{
|
||||
RoomVisualizationMapper.mapPlaneVisualizationLayers([layer], visualization.allLayers);
|
||||
}
|
||||
|
||||
if (planeVisualizationXML.animatedLayers !== undefined)
|
||||
{
|
||||
if (planeVisualizationXML.animatedLayers.length)
|
||||
{
|
||||
visualization.animatedLayers = [];
|
||||
|
||||
RoomVisualizationMapper.mapPlaneVisualizationAnimatedLayers(planeVisualizationXML.animatedLayers, visualization.animatedLayers);
|
||||
else if (layer instanceof PlaneVisualizationAnimatedLayerXML)
|
||||
{
|
||||
RoomVisualizationMapper.mapPlaneVisualizationAnimatedLayers([layer], visualization.allLayers);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,7 +189,7 @@ export class RoomVisualizationMapper extends Mapper
|
||||
}
|
||||
}
|
||||
|
||||
private static mapPlaneVisualizationLayers(xml: PlaneVisualizationLayerXML[], output: IAssetPlaneVisualizationLayer[]): void
|
||||
private static mapPlaneVisualizationLayers(xml: PlaneVisualizationLayerXML[], output: (IAssetPlaneVisualizationLayer | IAssetPlaneVisualizationAnimatedLayer)[]): void
|
||||
{
|
||||
if (!xml || !output) return;
|
||||
|
||||
@ -203,7 +206,7 @@ export class RoomVisualizationMapper extends Mapper
|
||||
}
|
||||
}
|
||||
|
||||
private static mapPlaneVisualizationAnimatedLayers(xml: PlaneVisualizationAnimatedLayerXML[], output: IAssetPlaneVisualizationAnimatedLayer[]): void
|
||||
private static mapPlaneVisualizationAnimatedLayers(xml: PlaneVisualizationAnimatedLayerXML[], output: (IAssetPlaneVisualizationLayer | IAssetPlaneVisualizationAnimatedLayer)[]): void
|
||||
{
|
||||
if (!xml || !output) return;
|
||||
|
||||
@ -252,6 +255,8 @@ export class RoomVisualizationMapper extends Mapper
|
||||
|
||||
for (const planeMaterialXML of xml)
|
||||
{
|
||||
if (planeMaterialXML.id.startsWith('floor_32_') || planeMaterialXML.id.startsWith('wall_32_') || planeMaterialXML.id.startsWith('landscape_32_')) continue;
|
||||
|
||||
const planeMaterial: IAssetPlaneMaterial = {};
|
||||
|
||||
if (planeMaterialXML.id !== undefined) planeMaterial.id = planeMaterialXML.id;
|
||||
@ -353,6 +358,8 @@ export class RoomVisualizationMapper extends Mapper
|
||||
|
||||
for (const planeTextureXML of xml)
|
||||
{
|
||||
if (planeTextureXML.id.startsWith('floor_32_') || planeTextureXML.id.startsWith('wall_32_') || planeTextureXML.id.startsWith('landscape_32_')) continue;
|
||||
|
||||
const planeTexture: IAssetPlaneTexture = {};
|
||||
|
||||
if (planeTextureXML.id !== undefined) planeTexture.id = planeTextureXML.id;
|
||||
@ -409,6 +416,8 @@ export class RoomVisualizationMapper extends Mapper
|
||||
|
||||
for (const planeMaskVisualizationXML of planeMaskXML.visualizations)
|
||||
{
|
||||
if (planeMaskVisualizationXML.size === 32) continue;
|
||||
|
||||
const planeMaskVisualization: IAssetPlaneMaskVisualization = {};
|
||||
|
||||
if (planeMaskVisualizationXML.size !== undefined) planeMaskVisualization.size = planeMaskVisualizationXML.size;
|
||||
|
@ -6,6 +6,7 @@ export class PlaneVisualizationXML
|
||||
private readonly _size: number;
|
||||
private readonly _horizontalAngle: number;
|
||||
private readonly _verticalAngle: number;
|
||||
private readonly _allLayers: (PlaneVisualizationLayerXML | PlaneVisualizationAnimatedLayerXML)[];
|
||||
private readonly _layers: PlaneVisualizationLayerXML[];
|
||||
private readonly _animatedLayers: PlaneVisualizationAnimatedLayerXML[];
|
||||
|
||||
@ -20,7 +21,25 @@ export class PlaneVisualizationXML
|
||||
if (attributes.verticalAngle !== undefined) this._verticalAngle = parseFloat(attributes.verticalAngle);
|
||||
}
|
||||
|
||||
if ((xml.visualizationLayer !== undefined) && Array.isArray(xml.visualizationLayer))
|
||||
if ((xml.$$ !== undefined) && Array.isArray(xml.$$))
|
||||
{
|
||||
this._allLayers = [];
|
||||
|
||||
for (const layer of xml.$$)
|
||||
{
|
||||
switch (layer['#name'])
|
||||
{
|
||||
case 'visualizationLayer':
|
||||
this._allLayers.push(new PlaneVisualizationLayerXML(layer));
|
||||
break;
|
||||
case 'animationLayer':
|
||||
this._allLayers.push(new PlaneVisualizationAnimatedLayerXML(layer));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* if ((xml.visualizationLayer !== undefined) && Array.isArray(xml.visualizationLayer))
|
||||
{
|
||||
this._layers = [];
|
||||
|
||||
@ -32,7 +51,7 @@ export class PlaneVisualizationXML
|
||||
this._animatedLayers = [];
|
||||
|
||||
for (const layer of xml.animationLayer) this._animatedLayers.push(new PlaneVisualizationAnimatedLayerXML(layer));
|
||||
}
|
||||
} */
|
||||
}
|
||||
|
||||
public get size(): number
|
||||
@ -50,6 +69,11 @@ export class PlaneVisualizationXML
|
||||
return this._verticalAngle;
|
||||
}
|
||||
|
||||
public get allLayers(): (PlaneVisualizationLayerXML | PlaneVisualizationAnimatedLayerXML)[]
|
||||
{
|
||||
return this._allLayers;
|
||||
}
|
||||
|
||||
public get layers(): PlaneVisualizationLayerXML[]
|
||||
{
|
||||
return this._layers;
|
||||
|
@ -3,11 +3,11 @@ import { UncompressSWF } from './UncompressSWF';
|
||||
|
||||
export const ReadSWF = async (buffer: Buffer) =>
|
||||
{
|
||||
if(Buffer.isBuffer(buffer)) return await UncompressSWF(buffer);
|
||||
if (Buffer.isBuffer(buffer)) return await UncompressSWF(buffer);
|
||||
|
||||
buffer = await readFile(buffer);
|
||||
|
||||
if(!buffer) return null;
|
||||
if (!buffer) return null;
|
||||
|
||||
return await UncompressSWF(buffer);
|
||||
};
|
||||
|
@ -101,7 +101,10 @@ export class SWFUtilities
|
||||
|
||||
if (!binaryData) return null;
|
||||
|
||||
return await parseStringPromise(this.removeComments(binaryData.binaryData));
|
||||
return await parseStringPromise(this.removeComments(binaryData.binaryData), {
|
||||
explicitChildren: true,
|
||||
preserveChildrenOrder: true
|
||||
});
|
||||
}
|
||||
|
||||
public static async getAnimationXML(habboAssetSWF: HabboAssetSWF, snakeCase: boolean = false): Promise<any>
|
||||
|
Loading…
Reference in New Issue
Block a user