Jump to content

Search the Community

Showing results for tags 'piece of shit'.

  • 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 Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

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 1 result

  1. I am kind of tired of people using the inferior SceneLoader.Load() over SceneLoader.Append() and hearing about all their avoidable problems. Every time I mention Append(), I get at most a "well, I'll think about trying it". Append() came about because @Vousk-prod. wanted to have multiple .babylon files, and was doing all these back flips. I looked at the source, and saw all I had to do is change the name of the Load() function to Append, switch the engine arg for a scene arg, then make a 1 line wrapper for Load. public static Load(rootUrl: string, sceneFilename: any, engine: Engine, onsuccess?: (scene: Scene) => void, progressCallBack?: any, onerror?: (scene: Scene) => void): void { SceneLoader.Append(rootUrl, sceneFilename, new Scene(engine), onsuccess, progressCallBack, onerror); } /** * Append a scene * @param rootUrl a string that defines the root url for scene and resources * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene * @param scene is the instance of BABYLON.Scene to append to */ public static Append(rootUrl: string, sceneFilename: any, scene: Scene, onsuccess?: (scene: Scene) => void, progressCallBack?: any, onerror?: (scene: Scene) => void): void { ... } So when you call Load(), you are Appending. Creating a scene outside of the Load call means you do not need to add your render loop in the callback. All the scope problems for your scene variable are also gone. Having more than one .babylon is just 2 simple Appends. Callbacks are also stupid, and do not scale. As soon as you have more than 1 .babylon, they become a nightmare. Just do all your Append()'s & ImportMesh()'s, then have all your post load code below inside a blocking executeWhenReady function. var canvas = document.getElementById("renderCanvas"); var engine = new BABYLON.Engine(canvas, true); var scene = new BABYLON.Scene(engine); BABYLON.SceneLoader.Append("./", "scene.babylon", scene); BABYLON.SceneLoader.ImportMesh(["moe","larry","curly"], "./", "meshes.babylon", scene); scene.executeWhenReady(function () { // Attach camera to canvas inputs scene.activeCamera.attachControl(canvas); // Once the scene is loaded, register a render loop engine.runRenderLoop(function() { scene.render(); }); // any post load code grabbing all stuff using scene lookups var skeleton = scene.getSkeletonByName("myskelname"); var material = scene.getMaterialByName("mymaterial"); var camera = scene.getCameraByName("polaroid"); var bone = scene.getBoneByName("funny"); var light = scene.getLightByName("spot"); var node = scene.getNodeByName("node"); var mesh = scene.getMeshByName("cube"); var sound = scene.getSoundByName("talking"); var flare = scene.getLensFlareSystemByName("flare"); }); Problems with callbacks for ImportMesh that reference the mesh as mesh[0] are also fixed. Usually, the problem is either [0] is the wrong mesh or there wasn't anything actually loaded. Specifying by name in a executeWhenReady should either get the right mesh, or drive home the problem that nothing was done quicker. Might be a good idea to add optional logging capability to Append (and therefore Load) and ImportMesh to list what actually got done. Load must die!
×
×
  • Create New...