trecool

Members
  • Content Count

    4
  • Joined

  • Last visited

  1. Ah, thanks! That actually gets me a little closer... However, when I try the following.... function loadingComplete() { LIBRARY['kubus'].actionManager = new BABYLON.ActionManager(scene); LIBRARY['kubus'].actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger, function () { LIBRARY['kubus'].material.diffuseColor = new BABYLON.Color3(1.00, 0.00, 1.00); console.log("test"); })); console.log("wow"); } it logs the "wow" but click events are not registered. I take it that the registerAction() function has to be outside other funtions in order to work? But then I'm back to my original problem, that I can't add the registerAction() to an undefined object. I'm sorry if this is a really stupid question but my brain is mush at this point :/
  2. Hey! I'm struggling really hard trying to get anything to work - I checked to Playgrounds, forums and documentation but I can not find anything helpful about working with imported meshes. Am I blind? Most of the playground examples I can find work with simple meshes like cubes and spheres, but that is not helpful for me. var frame = new BABYLON.Mesh.CreateBox("box", 100, scene); frame.isVisible = false; var loader = new BABYLON.AssetsManager(scene); var meshTask = loader.addMeshTask("FW", "", "assets/", "groups.babylon"); meshTask.onSuccess = function (task) { LIBRARY['kubus'] = task.loadedMeshes[0]; LIBRARY['kubus'].parent = frame; } And then I can scale the frame without destroying my object. This seems rather complex for such a simple task, is there a better way? But how do I access the object now? Anything outside the onSuccess function happens before so everytime I try to reference LIBRARY['kubus'] outside this function, I just get an "undefined" error. I tried it with onFinish and put it after loader.load(). Next big problem: How do I access groups I set up in 3dsmax - is it even possible? Is there a better way than looking at the parent object of every mesh and comparing them? For example, this imported object consists of 70 meshes but I have models with up to 200 meshes and this approach seems rather counter intuitive. And for further reading, are there any further ressources I could check out? I don't find the Playground search to be too helpful and the documentation is great when needing assistance in rendering and other engine stuff but I find it lacking in the "importing and working with meshes and objects"-department. And what exactly is the difference between the name of an object and the name of the variable? I really don't understand this approach, is the name used internally for reference? Can I access the objects like this? Is there a way to get an overview of all objects in a scene? Thanks for all the help!
  3. Hey! So I'm trying to re-use a function because it can easily be done but it doesn't seem to work for me. I've got an array filled with cubes and I'm trying to call a function with an id as parameter to reference the objects within the array. cubes.push(cube, cube1, cube2, cube3); function lightFader (id) { if (!clicked) { cubes[id].material.diffuseColor = new BABYLON.Color3(1.00, 0.00, 0.00); document.getElementById("p1").innerHTML = "Text 1!"; clicked = true; } else { cubes[id].material.diffuseColor = new BABYLON.Color3(1.00, 1.00, 0.00); document.getElementById("p1").innerHTML = "Text 2!"; clicked = false; } } cube.actionManager = new BABYLON.ActionManager(scene); cube1.actionManager = new BABYLON.ActionManager(scene); cube2.actionManager = new BABYLON.ActionManager(scene); cube3.actionManager = new BABYLON.ActionManager(scene); cube.actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger, lightFader(0))); cube1.actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger, lightFader(1))); cube2.actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger, lightFader(2))); cube3.actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger, lightFader(3))); I have two major issues with this code: Firstly, I know that functions with parentheses are called on start and functions without them are called, when they are referenced in code. Meaning lightFader; only gets called on the trigger event while lightFader() gets called as soon as I launch the whole thing. But I don't want to do that, I do not want it to run on start up. How do I do that if I do require the parentheses to call the function with the right parameter? Secondly, it does not seem to be possible to change the material using my approach. What is wrong here? Is this approach completely wrong? Thank you!
  4. Hey! As a student of UX design I have no real deeper knowledge of 3D development but have got about two-ish years of Unity under my belt. For a project as part of my intership I wanted to develop an application WebGL but as the Unity WebGL export is far from great and takes ages to load the simplest scenes, I made the transition to "real" WebGL using ThreeJS. I did have great sucess with it but when I dug a little deeper I ran into a few brickwalls I can't seem to find a satisfying answer to - so I hope some of you may shed some light on my problems From what I gathered, ThreeJS is great for just displaying and rendering things but severly lacks in the anmiation and simulation department, where BabylonJS enters the room. Does this hold true? Coming from Unity, I don't quite understand the renderloop. A scene is created and then this scene is continously rendered in the renderloop. Correct? So why are not all objects and imported meshes loaded and created every frame but just once? Or is my view on the whole system totally scewed to begin with? Again, I'm used to Start() and Update() in Unity and finally, I need to create some simple dynmaic animations in 2D and 3D space. Those animations are quite simple, one is for instance just two sliders controlling values and based on those values, something happens, nothing fancy or highly computing intensive. Basically a "if I push a button then a door opens" kind of thing. In Unity this is done really fast in an almost drag and drop manner, but I have no experience in creating such scenes by code alone. Is it more "difficult?" Or is just the transition period a little difficult and once I got a understanding of the mechanics its just smooth sailing? Would you recommend BabylonJS or is it more a "of course you could use it, buuuuut...."? I do hope someone can enlighten me and support my decision to move to Babylon. Cheers!