Home › Forums › Programming › How to click box to animate some object?
- This topic has 8 replies, 2 voices, and was last updated 6 years, 9 months ago by jay.
-
AuthorPosts
-
2018-03-15 at 6:49 am #2897jayCustomer
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"); } }
});
2018-03-15 at 7:58 am #2902Yuri KovelenovStaffHi 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.2018-03-15 at 8:04 am #2905Yuri KovelenovStaffBTW, 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.
2018-03-15 at 8:09 am #2906jayCustomerOh ok. I try to do some puzzles with code~
Thank you for answer me~!
2018-03-15 at 9:00 am #2917jayCustomeroh it works~! you are amazing
BTW, what if I want to animate html elements by clicking 3D cube?
2018-03-15 at 9:06 am #2918Yuri KovelenovStaffwhat 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”.
2018-03-16 at 4:16 am #2936jayCustomerThank you for answer me Yuri :)
I got 1 more question~!
How can I animate different action in 1 object using puzzle?
2018-03-16 at 7:59 am #2938Yuri KovelenovStaffHow 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.
2018-03-16 at 8:45 am #2945jayCustomerok~ I will try. thank you
-
AuthorPosts
- You must be logged in to reply to this topic.