From b191026ba10b17d1ec9e4e606602460abcfd4245 Mon Sep 17 00:00:00 2001 From: Bill Date: Mon, 17 May 2021 00:50:27 -0400 Subject: [PATCH] Add options to PetImageView --- src/views/pet-image/PetImageView.tsx | 23 ++++++++++++++++++----- src/views/pet-image/PetImageView.types.ts | 8 +++++++- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/views/pet-image/PetImageView.tsx b/src/views/pet-image/PetImageView.tsx index b8eae232..ec281a3e 100644 --- a/src/views/pet-image/PetImageView.tsx +++ b/src/views/pet-image/PetImageView.tsx @@ -5,7 +5,7 @@ import { PetImageViewProps } from './PetImageView.types'; export const PetImageView: FC = 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(null); @@ -13,9 +13,22 @@ export const PetImageView: FC = props => { let url = null; - const petFigureData = new PetFigureData(figure); + let petTypeId = typeId; + let petPaletteId = paletteId; + let petColor = color; + let petCustomParts = customParts; - const imageResult = GetRoomEngine().getRoomObjectPetImage(petFigureData.typeId, petFigureData.paletteId, petFigureData.color, new Vector3d((direction * 45)), 64, { + if(figure && figure.length) + { + const petFigureData = new PetFigureData(figure); + + 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) => { if(image) setPetUrl(image.src); @@ -25,7 +38,7 @@ export const PetImageView: FC = props => { } - }, headOnly, 0, petFigureData.customParts, 'std'); + }, headOnly, 0, petCustomParts, 'std'); if(imageResult) { @@ -35,7 +48,7 @@ export const PetImageView: FC = props => } return url; - }, [ figure, headOnly, direction ]); + }, [ figure, typeId, paletteId, color, customParts, headOnly, direction ]); useEffect(() => { diff --git a/src/views/pet-image/PetImageView.types.ts b/src/views/pet-image/PetImageView.types.ts index abe49e57..f86d32a3 100644 --- a/src/views/pet-image/PetImageView.types.ts +++ b/src/views/pet-image/PetImageView.types.ts @@ -1,6 +1,12 @@ +import { PetCustomPart } from 'nitro-renderer'; + export interface PetImageViewProps { - figure: string; + figure?: string; + typeId?: number; + paletteId?: number; + color?: number; + customParts?: PetCustomPart[]; headOnly?: boolean; direction?: number; scale?: number;