mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-27 08:00:51 +01:00
Add options to PetImageView
This commit is contained in:
parent
091c7d9f90
commit
b191026ba1
@ -5,7 +5,7 @@ import { PetImageViewProps } from './PetImageView.types';
|
|||||||
|
|
||||||
export const PetImageView: FC<PetImageViewProps> = props =>
|
export const PetImageView: FC<PetImageViewProps> = props =>
|
||||||
{
|
{
|
||||||
const { figure = '', headOnly = false, direction = 0, scale = 1 } = props;
|
const { figure = '', typeId = -1, paletteId = -1, color = 0xFFFFFF, customParts = [], headOnly = false, direction = 0, scale = 1 } = props;
|
||||||
|
|
||||||
const [ petUrl, setPetUrl ] = useState<string>(null);
|
const [ petUrl, setPetUrl ] = useState<string>(null);
|
||||||
|
|
||||||
@ -13,9 +13,22 @@ export const PetImageView: FC<PetImageViewProps> = props =>
|
|||||||
{
|
{
|
||||||
let url = null;
|
let url = null;
|
||||||
|
|
||||||
|
let petTypeId = typeId;
|
||||||
|
let petPaletteId = paletteId;
|
||||||
|
let petColor = color;
|
||||||
|
let petCustomParts = customParts;
|
||||||
|
|
||||||
|
if(figure && figure.length)
|
||||||
|
{
|
||||||
const petFigureData = new PetFigureData(figure);
|
const petFigureData = new PetFigureData(figure);
|
||||||
|
|
||||||
const imageResult = GetRoomEngine().getRoomObjectPetImage(petFigureData.typeId, petFigureData.paletteId, petFigureData.color, new Vector3d((direction * 45)), 64, {
|
petTypeId = petFigureData.typeId;
|
||||||
|
petPaletteId = petFigureData.paletteId;
|
||||||
|
petColor = petFigureData.color;
|
||||||
|
petCustomParts = petFigureData.customParts;
|
||||||
|
}
|
||||||
|
|
||||||
|
const imageResult = GetRoomEngine().getRoomObjectPetImage(petTypeId, petPaletteId, petColor, new Vector3d((direction * 45)), 64, {
|
||||||
imageReady: (id, texture, image) =>
|
imageReady: (id, texture, image) =>
|
||||||
{
|
{
|
||||||
if(image) setPetUrl(image.src);
|
if(image) setPetUrl(image.src);
|
||||||
@ -25,7 +38,7 @@ export const PetImageView: FC<PetImageViewProps> = props =>
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}, headOnly, 0, petFigureData.customParts, 'std');
|
}, headOnly, 0, petCustomParts, 'std');
|
||||||
|
|
||||||
if(imageResult)
|
if(imageResult)
|
||||||
{
|
{
|
||||||
@ -35,7 +48,7 @@ export const PetImageView: FC<PetImageViewProps> = props =>
|
|||||||
}
|
}
|
||||||
|
|
||||||
return url;
|
return url;
|
||||||
}, [ figure, headOnly, direction ]);
|
}, [ figure, typeId, paletteId, color, customParts, headOnly, direction ]);
|
||||||
|
|
||||||
useEffect(() =>
|
useEffect(() =>
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
|
import { PetCustomPart } from 'nitro-renderer';
|
||||||
|
|
||||||
export interface PetImageViewProps
|
export interface PetImageViewProps
|
||||||
{
|
{
|
||||||
figure: string;
|
figure?: string;
|
||||||
|
typeId?: number;
|
||||||
|
paletteId?: number;
|
||||||
|
color?: number;
|
||||||
|
customParts?: PetCustomPart[];
|
||||||
headOnly?: boolean;
|
headOnly?: boolean;
|
||||||
direction?: number;
|
direction?: number;
|
||||||
scale?: number;
|
scale?: number;
|
||||||
|
Loading…
Reference in New Issue
Block a user