Search the Community

Showing results for tags 'ExecuteCodeAction'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Platform
    • Coding and Game Design
  • Frameworks
    • Phaser 3
    • Phaser 2
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 4 results

  1. 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!
  2. Hello first post here. I just started coding with babylon 3 days ago and not being a pro with javascript I'm having trouble trying to wrap my head around the action manager. Specifically what I want to do is trigger a predefined function once a mesh is detected inside another mesh. I have a block that progresses across the screen and once it intersects with another block, I want it to simply throw an alert but I have no clue how to construct the action manager for the intersection and launching the function, tho i got the moving part down. [edit] I figured it out. For anyone else who might stumble across this thread and need it var trigger = {trigger:BABYLON.ActionManager.OnIntersectionEnterTrigger, parameter: OBJECT-BEING-ENTERED};var crash = new BABYLON.ExecuteCodeAction(trigger, function() { alert('CRASH!!!!!! BURRRRRRRR EXPLODIE NOISES'); }); OBJECT-DOING-THE-CRASHING.actionManager.registerAction(crash);
  3. Hi folks, I've been studying and learning Babylon js for a couple of months now, great stuff so far! However I've run into an issue, which seems to be either with OnPointerOverTrigger or ExecuteCodeAction. Basically I want to call a function when you either mouse over/out a mesh, however the function only receives the meshUnderPointer on the OnPointerOutTrigger, not OnPointerOverTrigger. Is this a bug or am i misunderstanding how this is meant to work? I've put an example on the playground, the console log shows no meshUnderPointer for the OnPointerOverTrigger event. http://www.babylonjs.com/playground/#8ULNX#6 Thanks
  4. How do we identify the object whiel trigering a custom action?, See the example below window.onload = function () { // Check support if (!BABYLON.Engine.isSupported()) { window.alert('Browser not supported'); } else { //var canvas = document.getElementById("renderCanvas"); var canvas = document.getElementById("canvas"); var engine = new BABYLON.Engine(canvas, true); var scene = new BABYLON.Scene(engine); var light = new BABYLON.DirectionalLight("dir01", new BABYLON.Vector3(0, -0.5, 1.0), scene); var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0, 10, BABYLON.Vector3.Zero(), scene); camera.setPosition(new BABYLON.Vector3(20, 70, 100)); light.position = new BABYLON.Vector3(0, 25, -50); var y = 0; i=0; var ddd2= BABYLON.Mesh.CreateBox('ddd', 20.0, scene, false); ddd2.position.y = y; y+= 45; ddd2.actionManager = new BABYLON.ActionManager(scene); ddd2.actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger,test)); var ddd3= BABYLON.Mesh.CreateBox('ddd4', 20.0, scene, false); ddd3.position.y = y; y+= 45; ddd3.actionManager = new BABYLON.ActionManager(scene); ddd3.actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger,test)); // Render camera.attachControl(canvas); engine.runRenderLoop(function () { scene.render(); }); } function test(){ console.log(this); }};