Coder Social home page Coder Social logo

shaderbytes / sketchfab-viewer-api-utility Goto Github PK

View Code? Open in Web Editor NEW
35.0 35.0 9.0 143 KB

If you plan to use the Sketchfab Viewer API on your websites I have created a utility that abstracts much of the coding required to do things.

Home Page: https://shaderbytes.co.za/sketchfab/development/api/utility

JavaScript 100.00%

sketchfab-viewer-api-utility's People

Contributors

nehon avatar shaderbytes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

sketchfab-viewer-api-utility's Issues

The structure of the Annotation object

Hi, ty very much for this piece of code, i just want to know the json/javascript object structure of the single Annotation you use to push on the Annotations array.
Ty in advance.

Few questions

Hello,

First, I want to thank you so much for this excellent library. It really made my interaction with Sketchfab API so much easier. Great job!

However, I have a few question since I'm a newbie to Sketchfab.

  1. In your documentation you say that we can use setChannelProperties() to set the values of a channel. For example, to enable RoughnessPBR or set its factor

However, when I try to enable Roughness using the setChannelProperties() nothing actually happens. I can see the new value in the console log but the change isn't being reflected in the viewer.

sketchfabAPIUtilityInstance.setChannelProperties("BODY",sketchfabAPIUtilityInstance.RoughnessPBR,{"enable":false});

Is this the correct way to enable/disable the remaining channels? If not, can you please provide me with the correct way?

  1. Is it possible to run SketchfabAPIUtility along with Sketchfab's native api usage? I've tried every possible way to get them to play together, but they always conflict with each other. Is it better to use one over the other?

HightLight Method & new api version

Could you add a component highlighting method? When I click on a component, the component is highlighted.
Also, do you already have plans to update the api to 1.6 & 1.7

About call setColor and setTexture

Hi shaderbytes:
Do i need to call [resetColor\resetTexture] firstly when i call the [setColor\setTexture]?
i used to call restColor andthen call setColor or texture before in a very old version.
until today i begin to use the new API-Utility

first call resetColor then call setTexture,repeat three times,and the problem happened
image

How can I implement nodeMouseEnter?

I have a small problem and I'm hoping you could help me with.

I'm trying to implement addEventListener('nodeMouseEnter) so that I can highlight the material when the user hovers over it.

I implemented the example code provided by sketchfab and it works except for one small problem.

api.addEventListener(
        'nodeMouseEnter',
        function(event) {
            console.log(event);
            let y = event.material;
            y.channels.EmitColor.factor = 1;
            y.channels.EmitColor.enable = true;
            y.channels.EmitColor.color = [0.5, 0.5, 0.0];
            api.setMaterial(y, function() {
                //console.log('highlighted ' + y.name);
            });
            console.log('nodeMouseEnter', event);
        },
        {
            pick: 'slow'
        }
    );

This work but console.log(event) at the beginning of the function doesn't return firstAncestorOfTypeGroup and firstAncestorOfTypeMatrixTransform, please check screenshot below

nodeMouseEnter

However, if I use Sketchfab Utility API I can access both AncestoryType collections.

function objectClicked(event){
        console.log('MouseClick', event);
        if(event.firstAncestorOfTypeMatrixTransform !== null && event.firstAncestorOfTypeMatrixTransform !== undefined){
            currentObjectKey =  event.firstAncestorOfTypeMatrixTransform.name;
            selected.text(currentObjectKey+" Selected");
            //toggleVisibility(currentObjectKey);
        }

    }

   sketchfabAPIUtilityInstance.addEventListener(sketchfabAPIUtilityInstance.EVENT_CLICK, objectClicked);

Mouseclick

But unfortunately, Sketchfab Utility API doesn't seem to suppose nodeMouseEnter or nodeMouseLeave

I apologize for the long read and looking forward to your answer.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.