mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-26 15:40:51 +01:00
Fixes
This commit is contained in:
parent
0df421e20c
commit
382cb665d8
11
src/App.tsx
11
src/App.tsx
@ -1,4 +1,4 @@
|
|||||||
import { GetAssetManager, GetAvatarRenderManager, GetCommunication, GetConfiguration, GetLocalizationManager, GetRoomEngine, GetRoomSessionManager, GetSessionDataManager, GetSoundManager, GetStage, GetTicker, HabboWebTools, LegacyExternalInterface, LoadGameUrlEvent, NitroLogger, NitroVersion, PrepareRenderer } from '@nitrots/nitro-renderer';
|
import { GetAssetManager, GetAvatarRenderManager, GetCommunication, GetConfiguration, GetLocalizationManager, GetRoomCameraWidgetManager, GetRoomEngine, GetRoomSessionManager, GetSessionDataManager, GetSoundManager, GetStage, GetTexturePool, GetTicker, HabboWebTools, LegacyExternalInterface, LoadGameUrlEvent, NitroLogger, NitroVersion, PrepareRenderer } from '@nitrots/nitro-renderer';
|
||||||
import { FC, useEffect, useState } from 'react';
|
import { FC, useEffect, useState } from 'react';
|
||||||
import { GetUIVersion } from './api';
|
import { GetUIVersion } from './api';
|
||||||
import { Base } from './common';
|
import { Base } from './common';
|
||||||
@ -38,8 +38,6 @@ export const App: FC<{}> = props =>
|
|||||||
resolution: window.devicePixelRatio
|
resolution: window.devicePixelRatio
|
||||||
});
|
});
|
||||||
|
|
||||||
GetTicker().add(ticker => renderer.render(GetStage()));
|
|
||||||
|
|
||||||
await GetConfiguration().init();
|
await GetConfiguration().init();
|
||||||
|
|
||||||
GetTicker().maxFPS = GetConfiguration().getValue<number>('system.fps.max', 24);
|
GetTicker().maxFPS = GetConfiguration().getValue<number>('system.fps.max', 24);
|
||||||
@ -58,7 +56,8 @@ export const App: FC<{}> = props =>
|
|||||||
GetAvatarRenderManager().init(),
|
GetAvatarRenderManager().init(),
|
||||||
GetSoundManager().init(),
|
GetSoundManager().init(),
|
||||||
GetSessionDataManager().init(),
|
GetSessionDataManager().init(),
|
||||||
GetRoomSessionManager().init()
|
GetRoomSessionManager().init(),
|
||||||
|
GetRoomCameraWidgetManager().init()
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -73,6 +72,10 @@ export const App: FC<{}> = props =>
|
|||||||
|
|
||||||
setInterval(() => HabboWebTools.sendHeartBeat(), 10000);
|
setInterval(() => HabboWebTools.sendHeartBeat(), 10000);
|
||||||
|
|
||||||
|
GetTicker().add(ticker => GetRoomEngine().update(ticker));
|
||||||
|
GetTicker().add(ticker => renderer.render(GetStage()));
|
||||||
|
GetTicker().add(ticker => GetTexturePool().run());
|
||||||
|
|
||||||
setIsReady(true);
|
setIsReady(true);
|
||||||
|
|
||||||
// handle socket close
|
// handle socket close
|
||||||
|
@ -47,7 +47,7 @@ export class BodyModel extends CategoryBaseModel
|
|||||||
const figureString = AvatarEditorUtilities.CURRENT_FIGURE.getFigureStringWithFace(part.id);
|
const figureString = AvatarEditorUtilities.CURRENT_FIGURE.getFigureStringWithFace(part.id);
|
||||||
const avatarImage = GetAvatarRenderManager().createAvatarImage(figureString, AvatarScaleType.LARGE, null, { resetFigure, dispose: null, disposed: false });
|
const avatarImage = GetAvatarRenderManager().createAvatarImage(figureString, AvatarScaleType.LARGE, null, { resetFigure, dispose: null, disposed: false });
|
||||||
|
|
||||||
const sprite = avatarImage.getImageAsSprite(AvatarSetType.HEAD);
|
const sprite = avatarImage.processAsContainer(AvatarSetType.HEAD);
|
||||||
|
|
||||||
if(sprite)
|
if(sprite)
|
||||||
{
|
{
|
||||||
|
@ -25,7 +25,7 @@ export class ChatBubbleUtilities
|
|||||||
|
|
||||||
figure = avatarImage.getFigure().getFigureString();
|
figure = avatarImage.getFigure().getFigureString();
|
||||||
|
|
||||||
const imageUrl = await avatarImage.getCroppedImageUrl(AvatarSetType.HEAD);
|
const imageUrl = avatarImage.processAsImageUrl(AvatarSetType.HEAD);
|
||||||
const color = avatarImage.getPartColor(AvatarFigurePartType.CHEST);
|
const color = avatarImage.getPartColor(AvatarFigurePartType.CHEST);
|
||||||
|
|
||||||
if(isPlaceholder) this.placeHolderImageUrl = imageUrl;
|
if(isPlaceholder) this.placeHolderImageUrl = imageUrl;
|
||||||
|
@ -2,6 +2,8 @@ import { AvatarScaleType, AvatarSetType, GetAvatarRenderManager } from '@nitrots
|
|||||||
import { CSSProperties, FC, useEffect, useMemo, useRef, useState } from 'react';
|
import { CSSProperties, FC, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { Base, BaseProps } from '../Base';
|
import { Base, BaseProps } from '../Base';
|
||||||
|
|
||||||
|
const AVATAR_IMAGE_CACHE: Map<string, string> = new Map();
|
||||||
|
|
||||||
export interface LayoutAvatarImageViewProps extends BaseProps<HTMLDivElement>
|
export interface LayoutAvatarImageViewProps extends BaseProps<HTMLDivElement>
|
||||||
{
|
{
|
||||||
figure: string;
|
figure: string;
|
||||||
@ -49,31 +51,40 @@ export const LayoutAvatarImageView: FC<LayoutAvatarImageViewProps> = props =>
|
|||||||
{
|
{
|
||||||
if(!isReady) return;
|
if(!isReady) return;
|
||||||
|
|
||||||
const resetFigure = (_figure: string) =>
|
const figureKey = [ figure, gender, direction, headOnly ].join('-');
|
||||||
|
|
||||||
|
if(AVATAR_IMAGE_CACHE.has(figureKey))
|
||||||
{
|
{
|
||||||
if(isDisposed.current) return;
|
setAvatarUrl(AVATAR_IMAGE_CACHE.get(figureKey));
|
||||||
|
}
|
||||||
const avatarImage = GetAvatarRenderManager().createAvatarImage(_figure, AvatarScaleType.LARGE, gender, { resetFigure: (figure: string) => resetFigure(figure), dispose: null, disposed: false });
|
else
|
||||||
|
{
|
||||||
let setType = AvatarSetType.FULL;
|
const resetFigure = (_figure: string) =>
|
||||||
|
|
||||||
if(headOnly) setType = AvatarSetType.HEAD;
|
|
||||||
|
|
||||||
avatarImage.setDirection(setType, direction);
|
|
||||||
|
|
||||||
const loadImage = async () =>
|
|
||||||
{
|
{
|
||||||
const imageUrl = await avatarImage.getCroppedImageUrl(setType);
|
if(isDisposed.current) return;
|
||||||
|
|
||||||
|
const avatarImage = GetAvatarRenderManager().createAvatarImage(_figure, AvatarScaleType.LARGE, gender, { resetFigure: (figure: string) => resetFigure(figure), dispose: null, disposed: false });
|
||||||
|
|
||||||
if(imageUrl && !isDisposed.current) setAvatarUrl(imageUrl);
|
let setType = AvatarSetType.FULL;
|
||||||
|
|
||||||
avatarImage.dispose();
|
if(headOnly) setType = AvatarSetType.HEAD;
|
||||||
|
|
||||||
|
avatarImage.setDirection(setType, direction);
|
||||||
|
|
||||||
|
const imageUrl = avatarImage.processAsImageUrl(setType);
|
||||||
|
|
||||||
|
if(imageUrl && !isDisposed.current)
|
||||||
|
{
|
||||||
|
if(!avatarImage.isPlaceholder()) AVATAR_IMAGE_CACHE.set(figureKey, imageUrl);
|
||||||
|
|
||||||
|
setAvatarUrl(imageUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
avatarImage.dispose(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
loadImage();
|
resetFigure(figure);
|
||||||
}
|
}
|
||||||
|
|
||||||
resetFigure(figure);
|
|
||||||
}, [ figure, gender, direction, headOnly, isReady ]);
|
}, [ figure, gender, direction, headOnly, isReady ]);
|
||||||
|
|
||||||
useEffect(() =>
|
useEffect(() =>
|
||||||
|
@ -256,14 +256,13 @@ const useRoomState = () =>
|
|||||||
const width = Math.floor(window.innerWidth);
|
const width = Math.floor(window.innerWidth);
|
||||||
const height = Math.floor(window.innerHeight);
|
const height = Math.floor(window.innerHeight);
|
||||||
|
|
||||||
|
renderer.resolution = window.devicePixelRatio;
|
||||||
renderer.resize(width, height);
|
renderer.resize(width, height);
|
||||||
|
|
||||||
background.width = width;
|
background.width = width;
|
||||||
background.height = height;
|
background.height = height;
|
||||||
|
|
||||||
InitializeRoomInstanceRenderingCanvas(width, height, 1);
|
InitializeRoomInstanceRenderingCanvas(width, height, 1);
|
||||||
|
|
||||||
renderer.render(GetStage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('resize', resize);
|
window.addEventListener('resize', resize);
|
||||||
|
Loading…
Reference in New Issue
Block a user