Search the Community

Showing results for tags 'file reading'.



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

  1. Hi, I'm working on a project, where the user is supposed to be able to upload his own images as a texture for an object. Now I'm able to get the image like this: <table id="fileForm"> <tr> <td> <input type="file" id="files" name="file[]"> </td> </tr></table>var handleFileSelect = function(evt){ var files = evt.target.files; var reader = new FileReader(); reader.readAsDataURL(files[0]); var boarding = scene.getMeshByName("Boarding"); reader.onload = function(e) { console.log(e.target.result); //$("#fileForm").append('<img src="'+e.target.result+'"/>'); var mat = new BABYLON.StandardMaterial("mat",scene); mat.diffuseTexture = new BABYLON.Texture(e.target.result,scene); boarding.material = mat; }}$("#files").on("change",handleFileSelect);Now with the commented line: $("#fileForm").append('<img src="'+e.target.result+'"/>'); I can attach the texture to my form, that works like a charm, however I cannot figure out how I can use the loaded image as a texture. As I tried above I just get the error message: "Uncaught TypeError: Cannot read property 'replace' of null" Which is probably because the constructor of BABYLON.Texture expects a URL and instead gets a data stream... But how can I solve this in a way that will work? Thanks for any hints or clues. Dinkelborg