The model I exported from Clara.io is not showing up on the Three.JS canvas, only a black square is

I recently started using Three.JS and imported an object I exported as a JSON from clara.io. Unfortunately, the object is not appearing in the canvas, instead I see a black square with the dimensions I specified in the variable (400 by 300 pixels).

Below is the code I've been working on:

    var WIDTH = 400,
      HEIGHT = 300;

    // set some camera attributes
    var VIEW_ANGLE = 45,
      ASPECT = WIDTH / HEIGHT,
      NEAR = 1,
      FAR = 100000;


    var $container = $('#wrapper');


    var renderer = new THREE.WebGLRenderer();
    renderer.setSize(window.innerWidth, window.innerHeight);
    var camera =
      new THREE.PerspectiveCamera(
        VIEW_ANGLE,
        ASPECT,
        NEAR,
        FAR);

     scene = new THREE.Scene();
     scene.fog = new THREE.FogExp2(0xcccccc, 0.002);
     camera.position.z = 300;
    scene.add(camera);
    camera.z = 100;


    renderer.setSize(WIDTH, HEIGHT);

    $container.append(renderer.domElement);

    var ambientLight = new THREE.AmbientLight(0x111111);
    scene.add(ambientLight);


    var loader = new THREE.ObjectLoader();
    loader.load("js/suzanne-blender.json", function (obj) {

        scene.add(obj)
    });

    renderer.render(scene, camera);

I am hoping to see the model with the same materials that I used when exporting it from clara.io. Thank you.

Here is the JSON file for the object

Answer №1

After experimenting with the JSON by importing it into the ThreeJS editor available at (simply drag and drop), I decided to include a single light source and positioned it slightly off-center. To my delight, the Suzanne model appeared perfectly in the editor. It seems like the issue lies in the code you are utilizing to render the model. Perhaps integrating a point light positioned to the side can illuminate the object optimally?

Warm regards,

Ben Houston

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

Executing a script within an ASP.NET MVC Project

Currently, I'm in the process of developing a project in MVC that requires using AJAX to fetch XML from an external source. However, I have encountered a challenge where I am unable to directly make the AJAX call due to a XMLHttpRequest same domain po ...

Interfacing with Ajax to dispatch information to a PHP script

Hello, I'm currently working on implementing Ajax in my web application. However, I've encountered a small issue. I'm attempting to check if a username has already been registered by controlling a form. The problem arises when my JavaScript ...

Seeking help with a Javascript regex inquiry

I am currently utilizing JavaScript regex for the following task: I have gathered the HTML content from a page and stored it within a string. Now, I aim to identify all URLs present on this page. For instance, if the document includes-- <script src = ...

Tomcat hosting a dynamic duo: Spring Boot and React!

Exploring the world of Spring Boot application development with a React client using Gradle is an exciting journey for me as I navigate through these new technologies. My current progress includes successfully creating a WAR file that encompasses several i ...

Having trouble with adding an event listener on scroll in React JS. Need assistance in resolving this issue

I'm having trouble adding an event listener for when a user scrolls in my web app. componentDidMount = () => { let scrollPosition = window.scrollY; let header = document.getElementById("topBar"); window.addEventListener(&ap ...

The model fails to bind when JSON is sent to the MVC controller

I've been facing an issue with my JSON payload not getting binded in my controller. I attempted creating a class with List<Models.UpdateChatRequestModel> Chats, but that didn't work for me. I also tried using an array name, but that approac ...

Does the notion of "Execution context and the stack" only pertain to web browsers?

Does the concept of "Execution context and the stack" only apply to browsers, or is it also utilized in other environments such as NodeJS? I've crafted 2 statements but unsure if they are accurate: 1- "The environment for JavaScript is not solely the ...

Error: Google chart for Google Maps is not displaying text every 1 unit as expected

I am looking to display all the hAxis labels in my chart. Due to the extensive length of the code exceeding 4000 lines, I will only include what I consider to be crucial: var data = new google.visualization.DataTable(); data.addColumn('string', & ...

Simple method for implementing a fade effect on a React component with raw JavaScript techniques?

I am seeking a way to have my React component smoothly fade in upon being mounted. The component's outermost DIV starts with inline style display:none. Within the componentDidMount() method, I've written the following code: let el = document.que ...

Safari Browser does not currently offer support for MediaRecorder functionality

[Log] Webcam permission error Error: MediaRecorder is not supported I am facing an issue while trying to record audio. The Chrome browser allows audio recording without any problem, but Safari is throwing an error. global.audioStream = await navigator.m ...

Apollo Server Studio is failing to detect the schema configured in Apollo setup

Here is the stack I'm working with: Apollo Server, graphql, prisma, nextjs I've set up a resolver.ts and schema.ts for my graphql configuration under /graphql resolver.ts export const resolvers = { Query: { books: () => books, } ...

Encountering a 'Cannot Get /' Error while attempting to reach the /about pathway

I attempted to create a new route for my educational website, and it works when the route is set as '/', but when I try to link to the 'about' page, it displays an error saying 'Cannot Get /about' Here is the code from app.js ...

Double-click required to toggle button

Here is the code snippet for controlling an LED using a web page. The script, linked to Python, effectively controls the LED. However, there is an issue where the button toggles to the right side (ON position) only after a double click. Upon first click ...

Having trouble with json_decode in PHP? Learn how to effectively retrieve JSON data in PHP

My attempt to update content using Angular on the front-end and PHP on the server side is encountering some issues. Below is the code snippet being used: In the main js file, a call for update: updateinscription: function($params) { var urlphp = "ht ...

"Obtaining header requests in node.js: A step-by-step guide

Currently, as I work on developing the elasticsearch API application, my task involves retrieving the header request from an AJAX call on the server side. The AJAX request is as follows: $.ajax({ url: 'http://localhost:3002/api/v1/getAutoSu ...

How to detect a click event in any area of an Angular2

Hey there, I'm new to typescript and angular 2 and I've encountered an error in my code. Can someone lend me a hand in fixing this? import { Component, HostListener } from '@angular/core' export class TooltipComponent { public sh ...

Customizing error messages in Joi validationorHow to show custom

Hi there, currently I am utilizing "@hapi/joi": "^15.1.1". Unfortunately, at this moment I am unable to upgrade to the most recent Joi version. This represents my validation schema const schema = { name: Joi.string() .all ...

Get tabular information in xlsx format by utilizing the xlsx npm package for download

I have been attempting to convert my json-like data into an xlsx file format. I utilized the xlsx npm package and followed various code samples available online, however, when trying to open the file in Excel, I encountered the following error: https://i.s ...

Utilize JavaScript to dynamically deactivate hyperlinks during runtime

Utilizing Bootstrap <ul class="nav nav-pills nav-stacked col-sm-2 hidden" id="menu"> <li role="presentation" id="LiNewsFeed"><a href="javascript:GetNewsFeed();">News Feed</a></li> <li role ...

Is there a way to extract specific data from a JSON file and calculate the average in order to generate a line graph using JavaScript

I am working with data in json format and I want to create plots using plotly js. Specifically, I need to generate a plot showing different states by semester. To do this, I first need to filter the data for each state (for example, California), calculate ...