We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

How to click box to animate some object?

Home Forums Programming How to click box to animate some object?

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #2897
    jay
    Customer

    Hi there~ this is very simple question..

    I attached my blender scene screen shot below.

    there is nothing yet on my js file…

    I want to animate my cube by clicking btn(the gray box).

    I want to code does event without using Puzzles.

    For now, my brain is empty and I don’t know how to get started.

    Can you help me to solve this question?

    
    'use strict';
    
    window.addEventListener('load', function() {
    
    var app = new v3d.App('container', null,
        new v3d.SimplePreloader({ container: 'container' }));
    
    var url = 'hw.gltf';
    
    app.load(url, function() {
        app.enableControls();
        runCode();
    });
    
    function runCode() {
        // add your code here, e.g. console.log('Hello, World!');
        window.addEventListener('click', onMouseClick, false);
    
        function onMouseClick( e ) {
            console.log("123123");
        }
    }

    });

    #2902

    Hi jay,

    I’d seriously recommend using Puzzles at least for some parts of your app.
    For example, the click-and-play example that you mentioned can be done with just 4 puzzles. However it requires 200+ lines of code to implement it! (see the attached files).

    Attachments:
    You must be logged in to view attached files.

    Chief 3D Verger | LinkedIn | Twitter

    #2905

    BTW, Puzzles offer a convenient mechanism to connect the visually-scripted logic with rest of a website code, called ExternalInterface. Check the corresponding example inside the Verge3D SDK.

    Anyway, even if you want to try a pure programming approach, Puzzles still can be of use for you. You can use them for fast prototyping and then just copy relevant parts from the generated JavaScript to your app code.

    Chief 3D Verger | LinkedIn | Twitter

    #2906
    jay
    Customer

    Oh ok. I try to do some puzzles with code~

    Thank you for answer me~! :good:

    #2917
    jay
    Customer

    oh it works~! you are amazing :yahoo:

    BTW, what if I want to animate html elements by clicking 3D cube? :unsure:

    #2918

    what if I want to animate html elements by clicking 3D cube?

    Yes, it is possible in both directions. See the same ExternalCall example – the puzzle is “call JS function”.

    Chief 3D Verger | LinkedIn | Twitter

    #2936
    jay
    Customer

    Thank you for answer me Yuri :)

    I got 1 more question~!

    How can I animate different action in 1 object using puzzle?

    #2938

    How can I animate different action in 1 object using puzzle?

    This is a limitation of the glTF format – you can have exactly one animation per object. To overcome this, you can use parenting to empties, parenting to bones and other methods. See for example our e-learning app – material animation is assigned to objects, which in turn are parented to bones.

    Chief 3D Verger | LinkedIn | Twitter

    #2945
    jay
    Customer

    ok~ I will try. thank you

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.