Troubles arising from Maya 2017 export to ThreeJS

I'm facing an issue with exporting from Maya to Three.js

Using Maya 2017 on a Mac and recently downloaded ThreeJS from the site. Initially, I had no problems with the .min version (seems to be Revision 57). I was utilizing

mesh = new THREE.Mesh(geometry, new THREE.MeshFaceMaterial(materials));

However, after learning this method had been deprecated, I switched to using

mesh = new THREE.Mesh(geometry, materials)
. Unfortunately, with Three.js it failed completely - no model rendered and no errors were generated. While it would render the stage in Three.js, nothing else appeared. Models generated outside the JSON loader would render as expected, but that didn't solve my issue. I needed the JSON to load and render.

I attempted to reinstall the Three export, but it seems the version has changed. Now, I can't get any results using either three.min.js or three.js to instantiate a model.

I've explored various solutions, including triangulating the models, but still get an empty stage with no errors. Even a simple triangulated cube model failed to render. I checked the examples on the ThreeJS site for the JSON loader, but they weren't very helpful either. Without diving into the JSONLoader parser to inspect the JSON, does anyone have any suggestions? I'm unsure where to find the correct format for the exported data.

Answer №1

Whenever I mention not feeling any sense of happiness, it's because I couldn't see any model being rendered and there were no apparent errors. I checked the array contents using the console, and everything seemed to be in order, including the materials. I tried simplifying the model to just a single cube with triangulation. The Json file is very brief - should I share it? The main issue remains that the model simply doesn't appear. I've inspected the lighting in case it's hidden, and I've added other objects outside the Json to test visibility, but it seems like the model isn't being created and isn't causing any errors?

My objective is to export a simple Json file from Maya, import it into Three.js, and use mesh (geometry, materials) to create a manipulatable model.

Answer №2

I am going to provide an answer at this moment since I have one.

The issue lies in the ThreeJS JSON export from Maya not functioning properly - there seems to be an error in the output, causing ThreeJS to reject it. However, a workaround is to utilize a conversion tool that transforms an OBJ file into a JS file, which can then be loaded using the same code. To begin, export an OBJ file from Maya, which is a straightforward process. The conversion tool can be located in the threes download folder under utils>converters>obj>convert_obj_three.py. You will need to use the console for this - on a Mac, it is recommended to place a copy of the file in your working folder. Once you have navigated to the appropriate working folder with all your files in the console, use the following line:

python convert_obj_three.py -i myFile.obj -o myfile.js

The resulting JS file can be imported into ThreeJS using the following code:

var jsonLoader = new THREE.JSONLoader();

//load a resource
jsonLoader.load(

//resource URL
'myFile.js',

//Function when resource is loaded
function ( geometry, materials ) {

    var material = materials[ 0 ];
    var object = new THREE.Mesh( geometry, material );
    scene.add( object );

}
);

Another issue that arises is that the object does not display properly - the material appears black. It is only visible if there is something in front of it, or if a grid is used. It took some time to identify the cause by checking the console and realizing that the material was loading but displaying as black. Regardless of the lighting adjustments made, the issue persisted. However, I discovered that specifying a material color resolved the problem. Therefore, include the line material.color.setHex( 0xffffff ); before the scene.add( object ); line.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Do these two JavaScript statements behave the same under the principles of functional programming in a React environment?

Is there a rule in functional programming that states these two approaches are equivalent? When working on a React application, I initially passed a function as an attribute using the second version where the first parameter is also passed. Out of curiosi ...

Display or conceal a div based on the size of the screen using HTML and CSS

Hey there, I recently finished my first React Project and I’m wondering if there’s a way to hide the 'side-menu' section on mobile screens using CSS. Any suggestions? <div className='side-menu'> <SiderComponent /> < ...

Discover additional Atom extensions

I am exploring the possibility of implementing a feature in my Atom package where it can automatically detect whether specific third-party packages have been installed. Currently, my package adds configuration for one such third-party package, but I want t ...

Developing a specialized directive to enhance bootstrap menuItems

I have created a custom directive in AngularJS for the navbar in Bootstrap. This directive uses ng-transclude and handles two types of list items (li) depending on whether it is a dropdown or not. However, I am experiencing issues with the dropdown functio ...

Material design for Angular applications - Angular Material is

Recently, I decided to explore the world of Angular and its accompanying libraries - angular-material, angular-aria, and angular-animate. I'm eager to experiment with this new styling technique, but it seems like I've hit a roadblock right at the ...

Executing a JavaScript file within the Meteor JS ecosystem

Is there a way to execute a JavaScript file on the server side in a meteor JS environment? Providing some background information: I am looking to automatically insert a document into a mongo database. While I know how to do this in meteor through event-dr ...

Troubles with retrieving native SQL Server JSON data

Trying to retrieve data from a JSON API and insert it into an SQL table in version 15.x of SQL Server has been successful when done manually. However, the process needs to be automated for archival purposes. When attempting to run it as part of a SQL Serve ...

What is the best way to securely store a sensitive Stripe key variable in an Angular application?

When implementing Stripe payment system in my Angular App, I often wonder about the security of storing the key directly in the code as shown below. Is this method secure enough or should I consider a more robust approach? var handler = (<any>windo ...

How to display specific JSON objects that meet particular criteria in HTML cards using Ionic and Angular?

As a beginner in Ionic/Angular, I am attempting to fetch data from a JSON file and display it using cards in the HTML. The JSON contains numerous objects that are either marked as "deTurno == true" or "deTurno == false". Here is what I have so far: publi ...

Dealing with timeout errors when using Puppeteer's page.waitForNavigation()

When using puppeteer, I initiate a page by entering a value and it displays the resulting output. await page.click('button[class="button form-button rs-gcbalance-btn"]') await page.waitForSelector('div[class="small-4 large-4 rs-gcbalance-r ...

The method to eliminate the default active class using AngularJS when clicking on different links

Here is the scenario: The first link is initially active and highlighted with the active class when the page loads. <a class="button active" ng-click="$parent.Filter = ''" ng-class="{ 'active': Filter === '' }"> Test l ...

The elegance of a JSON datetime in the world of ballerinas

My task involves indexing documents to Elasticsearch on an index with a date field mapping. I've been attempting to construct a JSON object with the date value, but Ballerina seems to indicate that it's not possible. I considered storing the ...

I am encountering TypeError issues while attempting to mock/test Vuex store modules

I'm currently in the process of learning how to effectively test components and JavaScript code, but I have hit a roadblock with Vuex modules. Below is the code snippet for the test: import { shallowMount } from '@vue/test-utils' import Wor ...

Encountering a problem when verifying if the data is in JSON format using JavaScript

I'm using JavaScript to determine whether an input value is in JSON format, but I've encountered a problem with a specific value. Below is my code explanation. isJSON = async(str) => { try { return (JSON.parse(str) && !!str); ...

Learn how to efficiently disable or enable a button in Angular depending on the selected radio button

In order to disable the button when the remarks are marked as failed. Here is an example scenario: Imagine there is an array containing two to four items. First example: ITEM 1 -> FAILED -> Remarks (required) ITEM 2 -> FAILED -> Remarks (r ...

Issue encountered with PowerShell 2.0's ConvertFrom-Json and ConvertTo-Json due to a circular reference detection

I am currently utilizing these functions for serializing and deserializing objects in Powershell 2.0, as discussed in the following question: PowerShell 2.0 ConvertFrom-Json and ConvertTo-Json implementation function ConvertTo-Json20([object] $item){ ...

Converting an array of objects to an array of JSON objects in TypeScript

My dilemma lies in the data I have uploaded under the _attachments variable: https://i.sstatic.net/jnFNH.png My aim is to format this data for insertion in the following structure: "_attachments": [ { "container": "string", "fileName": "string" ...

Loading animation reminiscent of a whirlpool, similar to the movement

In my quest for the perfect animation, I have scoured far and wide. Unfortunately, the one I found at http://jsfiddle.net/pedox/yed68/embedded/result/ is created using css, which many browsers do not yet support fully. I also explored , but found it to be ...

What causes the occurrence of "undefined" after multiple iterations of my code?

I've encountered a curious issue with the code snippet below. Everything seems to be running smoothly except for one thing - after a few iterations, I start getting "undefined" as an output. You can test this for yourself by running the code multiple ...

The Implementation of Comet Programming

I'm interested in creating a web application similar to Google Docs where multiple users can edit and view changes in real-time. Would Comet Programming be the best approach for this? As a newcomer to Web Development, I'm currently learning Java ...