Miorey / wow-model-viewer

A library for displaying interactive 3D models of World of Warcraft characters, items, and NPCs on your website using data from Wowhead. Customize the display with control over camera angles and animation.
https://miorey.github.io/wow-model-viewer/
56 stars 32 forks source link

Render should work with SOD #55

Closed yrodrigez closed 3 months ago

yrodrigez commented 3 months ago

I'm trying to use this with SOD characters but the items are not being displayed image

Miorey commented 3 months ago

@yrodrigez can you send me your code ?

yrodrigez commented 3 months ago

@Miorey Thanks for the quick answer, ofc:

'use client'
import {useEffect, useState} from "react";

export function TDModelViewer() {
    const [isClient, setIsClient] = useState(false);
    const [generateModels, setGenerateModels] = useState<Function | null>(null);

    useEffect(() => {
        const loadGenerateModels = async () => {
            // @ts-ignore
            window.CONTENT_PATH = `${window.location.origin}/api/v1/bypass/`;
            // @ts-ignore
            window.WOTLK_TO_RETAIL_DISPLAY_ID_API=`https://wotlk.murlocvillage.com/api/items`
            const {generateModels} = await import('wow-model-viewer');
            setGenerateModels(() => generateModels);
        };

        if (typeof window !== 'undefined') {
            setIsClient(true);
            loadGenerateModels();
        }
    }, []);

    useEffect(() => {

        if (!isClient || !generateModels) return;

        const character = {
            "race": 4, // 7 is for Gnome, 1 is for Human, 3 is for Dwarf, 4 is for Night Elf
            "gender": 0, // 0 is male, 1 is female
            "skin": 4,
            "face": 0,
            "hairStyle": 2,
            "hairColor": 5,
            "facialStyle": 0,
            "items": [
                [1, 215161], // Head https://www.wowhead.com/classic/item=215161/tempered-interference-negating-helmet
                [3, 220738], // Shoulder
                [5, 220653], // Chest
                [6, 215380], // Waist
                [7, 220654], // Legs
                [8, 220656], // Feet
                [9, 19580], // Wrist
                [10, 220541], // Hands
                [15, 213307], // Cloak
                [21, 220583], // Main hand
                [22, 220600] // Off hand
            ]
        };

        generateModels(1, '#model_3d', character);
    }, [generateModels])

    return null;
}

As you can see i'm trying to use it in a nextJS project

yrodrigez commented 3 months ago

@Miorey closing this one i messed up with the display id

Miorey commented 3 months ago

@yrodrigez I hope it will work well. By the way I will pull a new version to fix an issue on the animations, due to wowhead changes. If you are happy with this lib ⭐ it please !

yrodrigez commented 3 months ago

It is working so and so @Miorey I.E: https://www.everlastingvendetta.com/roster/porco

Using the code from here: https://github.com/yrodrigez/everlasting-vendetta/blob/main/src/app/roster/%5Bname%5D/components/TDModelViewer.tsx https://github.com/yrodrigez/everlasting-vendetta/blob/main/src/app/roster/%5Bname%5D/components/ModelGenerator.ts And getting the displays id's here: https://github.com/yrodrigez/everlasting-vendetta/blob/main/src/app/util/wowhead/getItemDisplayId.ts

Miorey commented 3 months ago

@yrodrigez Is it for a wotlk or older server or retail ? For retail I have to push build the new package version: https://github.com/Miorey/wow-model-viewer/commit/c708506644238c080c1e3a4f3f06640c5dc21b57

yrodrigez commented 3 months ago

@Miorey Its SOD (season of discovery) WoW Classic