• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

200
Views
Three.js Load local FBX File without uploading

I cannot load files users select in a HTML input because the loader expects a URL linux style URL I guess. I have tried feeding it a blob as a URL object, feeding the raw data to the FBX loader, and most recently feeding the mozilla path to it on my system, but nothing works. How can this be achieved without physically uploading the file to the site and passing an actual URL?

This is my latest attempt:

    $(document).ready(function() {
        
        $('#file').change(function () {
                
            if ( this.value == '' ) {
                console.log( "No valid file selected." );
            }

            var filePath = this.files[0].mozFullPath,
                loader = new THREE.FBXLoader();
                    
            loader.load( filePath, function( object ) {

                object.traverse( function( c ) {

                    if ( c instanceof THREE.Camera ) {              

                        // Debug log
                        console.log( c );

                    }

                } );

            });
            
        });
        
    });
about 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try a combination of a file input HTML element and the FileReader API. Something like:

const fileInput = document.querySelector("#file-input");

fileInput.addEventListener("change", function(event) {

  const reader = new FileReader();

  reader.addEventListener("load", function(event) {

    const contents = event.target.result;

    const loader = new FBXLoader();
    const object = loader.parse(contents);
    scene.add(object);
    
  });

  reader.readAsArrayBuffer(this.files[0]);

});
about 3 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error