Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8143393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:06:49+00:00 2026-06-06T13:06:49+00:00

I am trying to create a mesh from an .obj file. I am doing

  • 0

I am trying to create a mesh from an .obj file. I am doing this rather than using the obj loader because I meed to morph the shape using different sliders, select specific faces/vertices and draw a path between vertices.

I am currently getting errors when I try to render the scene and it seems to be something to do with the faces from the obj file. When I manually enter the faces I can create a triangle no problem.

Here is my code

   var camera, scene, renderer,
    geometry, material, mesh;

init();
animate();

function init() {

    var xhr = new XMLHttpRequest();
    xhr.open('GET', '/img/originalMeanModel.obj', false);
    xhr.send(null);
    var text = xhr.responseText;
    var lines = text.split("\n");
    for (i=0; i<19343; i++){
      lines[i] = lines[i].split(" ");
    }

    scene = new THREE.Scene();

    camera = new THREE.PerspectiveCamera( 1, window.innerWidth / window.innerHeight, 1, 2000 );
    camera.position.z = 20;
    scene.add( camera );

    var geometry = new THREE.Geometry()

  /* 
    geometry.vertices.push( new THREE.Vector3( -0.01,  0.01, 0 ) );
    geometry.vertices.push( new THREE.Vector3( -0.01, -0.01, 0 ) );
    geometry.vertices.push( new THREE.Vector3(  0.01, -0.01, 0 ) );
  */
    geometry.faces.push( new THREE.Face3( 0, 1, 2 ) );



    for(i=0; i<6449; i++){
      geometry.vertices.push( 
             new THREE.Vector3( 
              parseFloat(lines[i][1]),   
              parseFloat(lines[i][2]), 
              parseFloat(lines[i][3])) );
    }

    /*
    geometry.faces.push( new THREE.Face3( 0, 1, 2 ) );
    geometry.faces.push( new THREE.Face3( 600, 1, 3000 ) );
    geometry.faces.push( new THREE.Face3( 3000, 6400, 70 ) );
    */


    for(i=6449; i<19343; i++){
      geometry.faces.push( new THREE.Face3( parseInt(lines[i][1]), parseInt(lines[i][2]), parseInt(lines[i][3]) ) );
    }

    console.log(geometry.faces);
    console.log(geometry.vertices);


    material = new THREE.MeshBasicMaterial( { color: 0xff0000, wireframe: false } );
    mesh = new THREE.Mesh( geometry, material );
    scene.add( mesh );

    renderer = new THREE.CanvasRenderer();
    renderer.setSize( window.innerWidth, window.innerHeight );

    document.body.appendChild( renderer.domElement );
}

function animate() {
    // note: three.js includes requestAnimationFrame shim
    requestAnimationFrame( animate );
    render();
}

function render() {
    renderer.render( scene, camera );
}

When I inspect the console the faces and vertices have been printed out as expected. I also have this error printed out 5700+ times

Uncaught TypeError: Cannot read property 'visible' of undefined       Three.js:71
projectScene                                                          Three.js:71
render                                                               Three.js:245
render                                                          threeDemo.php:115
animate                                                         threeDemo.php:106

threeDemo.php:106 is this line of the animate function

render();

threeDemo.php:115 is this line of the render function

renderer.render( scene, camera );

Here is a link the the obj file that I am trying to create a mesh for. https://dl.dropbox.com/u/23384412/originalMeanModel.obj

Is anyone could point me in the right direction it would be really appreciated.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T13:06:51+00:00Added an answer on June 6, 2026 at 1:06 pm

    You can use two OBJLoaders for loading each frame geometry. Then create a third Geometry and create the lines using as reference the vertices from the frame geometries.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying create simple application in C++. This application has to read from file
I'm trying create an immutable object and initialise it from xml config file in
I am trying create alert dailog using glade,but its not working .am i doing
I am trying to create a Mesh object in Python. I am using the
I've been trying create this simple ish to-do list web app using JavaScript &
I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can
Ok so I am trying create a login script, here I am using PHP5
Trying to create Database as follows: USE Master GO IF NOT EXISTS(SELECT [Name] FROM
Trying to create a background-image slideshow and am getting this error... This is the
hi I'm trying create chat using node.js I see example in http://chat.nodejs.org/ I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.