Unable to bring in Blender 2.79 JSON files using THREE.js

Working on a 3D graph visualization within an Angular project using the 3D Force Graph library. I'm attempting to incorporate 3D models created in Blender as nodes in the graph. However, when trying to import the object using three.js, it returns undefined and generates multiple warning messages, such as:

Offscreen-For-WebGL-0000014E33B8D990]RENDER WARNING: Render count or primcount is 0.

The code snippet I've used thus far looks like this:

var self = this;
var loader = new THREE.JSONLoader();
var house = loader.load("assets/model/house.json",
    function ( obj ) {
      // Upon successful loading of the object      
      console.log("house -- "+house);     // returns undefined
      self.showGraph(gData,house,themeNum);
      console.log("graph drawn");
    },
    // onProgress callback
    function ( xhr ) {
      console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
    },
    // onError callback
    function ( err ) {
      console.error( 'An error occurred -- '+err );
    }
);
    
// Function to render the graph - triggered upon model load
showGraph(gData:any, house:any, themeNum: any){
    const Graph = ForceGraph3D()
      (document.getElementById('3d-graph'))
      .nodeThreeObject(({ group }) => new THREE.Mesh(
        [
          new THREE.BoxGeometry(Math.random() * 20, Math.random() * 20, Math.random() * 20),          
          house,
          new THREE.CylinderGeometry(Math.random() * 10, Math.random() * 10, Math.random() * 20),
          new THREE.DodecahedronGeometry(Math.random() * 10),
          new THREE.SphereGeometry(Math.random() * 10),
          new THREE.TorusGeometry(Math.random() * 10, Math.random() * 2),
          new THREE.TorusKnotGeometry(Math.random() * 10, Math.random() * 2)
        ][group],
        new THREE.MeshLambertMaterial({
          color: this.themes[themeNum][group],
          transparent: true,
          opacity: 0.75
        })
      ))
        .nodeAutoColorBy('group')  
        .onNodeClick(node => {    
          this.attach3DNodeClickEvent(node);
        })      
        .graphData(gData); 
  }

The graph display works with other available shapes from three.js but encounters issues specifically with the imported 3D model showing as undefined in the graph (visible by links without shape). Each shape is assigned based on node group.

https://i.sstatic.net/EaAXH.png

I have Blender version 2.79 installed along with the latest Blender JSON exporter and "three.min.js" from Github.

The exported house.json file content is shown below. The "Face Materials" option was selected during export.

{
    "geometries":[{
        "data":{ ... long data string here }
        ],
        "name":"CubeGeometry.2",
        "uuid":"1D367B89-D7FF-406F-90CF-EAEE8DFD2C3F",
        "materials":[{...}],
        "type":"Geometry"
    }],
    "materials":[{...},{...},{...}],
    "animations":[{...}],
    "metadata":{...},
    "textures":[],
    "images":[],
    "object":{
        "matrix":[...], 
        "children":[{...},{...}]}
}

Your insights on what could be amiss are greatly welcome.

Please excuse the lengthy query.

Answer №1

In the upcoming year, it has been decided that the Blender exporter will no longer be supported. I highly recommend giving the glTF Blender Exporter a try as an alternative option. You can also explore using three.js's excellent GLTFLoader to replace JSONLoader.

This approach is more reliable and forward-looking for your projects.

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

Enhancing Angular 5 with CustomEvent Polyfill for JavaScript

After implementing the code snippet in main.ts file, I encountered an issue with CustomEvent not being added to the window object correctly. Strangely, when I manually add CustomEvent using the JavaScript console, it works fine. This problem arises specifi ...

Altering the color upon repetition and utilizing JQuery coordinates for the dynamic movement of elements

I've been working on recreating some JQuery tutorials by myself, but I've hit a roadblock. My goal is to create an object that moves from one position to another while changing color when it repeats. I attempted to achieve this by using an array ...

Transforming button properties into a JSON format

I am currently in the process of developing a web application using node.js and mongodb. Within my app, there is a table that dynamically populates data from the database using a loop. I encountered an issue with a delete function that I implemented base ...

Why isn't the Angular Google Maps Displaying in my Template View?

After configuring Angular Google Maps and following the provided steps, I am facing an issue where the map is not loading on the directive without any error. Below is the code snippet: Controller app.controller('MapCtrl', [ '$scope&apo ...

What is the best way to utilize the data being returned from PHP in JQuery or JavaScript?

There's an AJAX request hitting a php file to fetch some data, which looks like this: 21-12-12:::visits;45;;pageviews;344---22-10-10:::visits;71;;pageviews;34---15-01-11:::visits;4;;pageviews;30 Do you see the pattern? It resembles a multidimensiona ...

Navigating the world of cryptocurrency can be daunting, but with the right tools

Hello fellow developers, I've encountered some difficulties with cryptocurrency in my Nativescript project. I am attempting to incorporate the NPM package ripple-lib into my code, but I have been unsuccessful using nativescript-nodeify. How can I suc ...

Implementing a vertical tabindex change in Material UI Dialogue table

My material UI dialogue contains a table: <Dialog open={open} onClose={handleClose} maxWidth={'xl'} aria-labelledby='scroll-dialog-title' aria-describedby='scroll-dialog-description' disa ...

Ways to add values to a database through modal window

There are two buttons on the interface: login and register. Clicking the login button opens the login modal, while clicking the register button should open the register modal. My objective is to validate the form and insert the values into a database aft ...

Is there a more efficient alternative to using JavaScript JSON?

Is there a quicker method for writing this code efficiently? view = + data.items[ 0 ].statistics.viewCount view1 = + data.items[ 1 ].statistics.viewCount view2 = + data.items[ 2 ].statistics.viewCount document.getElementById("views").innerHTML = view ...

Rails offers a unique hybrid approach that falls between Ember and traditional JavaScript responses

My current project is a standard rails application that has primarily utilized HTML without any AJAX. However, I am planning to gradually incorporate "remote" links and support for JS responses to improve the user experience. While I acknowledge that gener ...

Changing a single variable into an array that holds the variable in JavaScript

Is there a way to change 5 into [5] using JavaScript? I need this functionality for a method that utilizes jQuery's $.inArray. It should be able to handle both scalar variables and arrays, converting scalars into arrays with a single element. ...

The translation of popups using ngx-translate in Javascript is not functioning properly

When I click on my request, the content "Are you sure?" is not changing to the required language. This issue is located in list.component.html <button type="button" (click)="myrequest(item.Id)">Request View</button> The fu ...

What could be causing the sudden disappearance of the button?

There is an element with the ID "alpha" that contains the text "Now I'm here...". When the button is clicked, only the text should be removed, not the button itself. <div id="alpha">Now I'm here...</div> <button type="button" oncl ...

The benefits of using Node.js for asynchronous calls

Each time a new data is added or existing data is updated, the variables new_data and updated_data will increment accordingly. However, when attempting to output the total count of new_data and updated_data at the end of the code, it always shows as 0. H ...

Problem: In Django, Ajax requests using HttpResponse do not return the expected json data

Version: Django 1.7.2, Python 3.4 In this code snippet, the functionality is related to implementing a 'like' feature. When a user clicks the 'like' button, an AJAX call is made to trigger the 'pushLike' action. If the user h ...

Submitting MongoDB ObjectIDs using Postman

I am currently using MongoDb.Driver within my C# project, and I have a model structured like this: public class MyClass { [BsonId] public ObjectId Id { get; set; } public ObjectId UserId { get; set; } } The UserId field is of type ObjectId ...

JS: Best way to transfer selected information to the following page?

Within our SharePoint list, users often need to add very similar items. To streamline this process, I am exploring the possibility of adding a new column that includes a button or turning one of the existing columns into a clickable link. When clicked: ...

Each div in prevAlll() will have its own unique CSS background

In continuation of my initial query, which has now been resolved, you can find the original question here. JS: $(function() { var scaletext = { 1: 'SA', 2: 'A', 3: 'N', 4: 'Da', 5: 'SDa' } $(&a ...

Using jqGrid to load additional JSON data after the initial local data has already been populated in the

I encountered a specific issue: I have a compact form with four choices. Users can choose to fill them out or not, and upon clicking 'Ok', a jqGrid is loaded with data based on those selections. To accommodate dynamic column formatting, my servle ...

What is the best way to swap out the css selector using jQuery?

Looking to switch the height attribute to min-height This is how I usually update the value, but uncertain about changing the attribute $('.mySelector').css('height','650px') <div class="mySelector" style="cursor: -moz-g ...