"Troubleshooting: My Three.js scene is displaying blank, what could

I recently created a simple example using Three.js, but my code was not organized into classes which caused some issues with displaying anything in the view. Here is an example of the code I used:

HTML file

<!DOCTYPE html>
<html>
<head>
    <title> </title>
</head>
<body>

<div id="scenecontainer"></div>

<script src="../js/libs/three.js/three.js"></script>
<script src="../js/libs/Detector.js"></script>
<script src="../js/libs/stats.min.js"></script>
<script src="../js/libs/RequestAnimationFrame.js"></script>

<script src="../js/lab/common/CommonExperiment.js"></script>
<script src="../js/lab/common/commonMain.js"></script>
</body>
</html>

Main.js

var viewport;
var commonExperiment;

function main() {
    viewport = document.getElementById("scenecontainer");
    commonExperiment = new CommonExperiment(viewport);
    commonExperiment.addTestCube();
    commonExperiment.animate();
}

main();

CommonExperiment.js

function CommonExperiment(domElement, renderStatistics) {
    this.testMesh = undefined;

    this.scene = undefined;
    this.renderer = undefined;
    this.stats = undefined;
    this.camera = undefined;
    this.renderStatistics = (renderStatistics != undefined) ? renderStatistics : true;
    this.domElement = domElement;

    this.init();
}

CommonExperiment.prototype.init = function () {
    // Initialization code
};

CommonExperiment.prototype.animate = function () {
    // Animation code
};

CommonExperiment.prototype.addTestCube = function () {
    // Code to add test cube
};

CommonExperiment.prototype.render = function () {
    // Rendering code
};

If anyone can offer advice or assistance, I would greatly appreciate it! 😊

Answer â„–1

My apologies for the oversight - I forgot to include this line:

this.renderer.render(this.scene,this.camera);

at the conclusion of the render loop.

Thank you! :)

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

The route handler is not being invoked

Currently implementing a basic login/logout system using passport.js. Strangely, the router.get('/signout', function(req, res)) is not triggering when attempting to run http://localhost:3000/auth/signout on Advanced Rest Client. Instead, an Inter ...

AngularJS is patiently waiting for the tag to be loaded into the DOM

I am trying to incorporate a Google chart using an Angular directive on a webpage and I want to add an attribute to the element that is created after it has loaded. What is the most effective way to ensure that the element exists before adding the attribut ...

Disable image loading for users who have javascript enabled

I find myself caught in a chicken-egg dilemma. The webpage I created contains numerous images that need to be loaded, and so I implemented a script that loads images as the user scrolls, similar to how Facebook or Google Images functions. When the user rea ...

Using Javascript to dynamically add and remove elements on click

Whenever I click on a link, I am able to generate input, label, and text. However, I want to be able to delete these elements with the next click event on the same link: I've tried updating my code like this: var addAnswer = (function() { var la ...

Store Button and Directory

I'm just starting to learn about Javascript. I want to create an "Add to favorites/remove from favorites" feature on multiple product pages. This function will save the product ID and store it in an array. Additionally, I need help creating a page t ...

ReactAwesome Slider Autoplay Feature

I've been tinkering with a React Awesome Slider that you can find here: https://github.com/rcaferati/react-awesome-slider I've managed to implement it successfully, but I'm struggling to make it autoplay every 10 seconds. I assume I need to ...

I am having trouble unzipping the file

I encountered an issue while attempting to download a .zip file from Discord and extracting it using the decompress package. Despite not returning any errors, the package did not get extracted as expected. (The file was saved and downloaded correctly) co ...

Issue with h2 tag within JQuery's read more feature

How can I modify my jQuery code to wrap the middle text in an h2 tag? I am currently using a code snippet from code-tricks. You can find the original code snippets here: $(document).ready(function() { var showChar = 100; var ellipsestext = "..."; ...

How to Transfer Data from a Dynamic Drop-down Menu to PHP for Processing and Presentation in a Div Element on the Same Web Page

I've scoured various online resources, including StackOverflow, but haven't been able to find a solution for this issue described in the title. On my base page, I have a dynamically generated dropdown list as shown below: <div class="tipfixtu ...

Verify the presence of an image

I have a code snippet that I use to refresh an image in the browser. However, I want to enhance this code so that it first checks if the image exists before displaying it. If the image does not exist, I want to display the previous version of the picture i ...

Set the value obtained from a resolved promise to a mutable reference object in a React component

I am in the process of developing a random movie generator. I am utilizing an external API to retrieve a list of movies and then selecting one randomly from the returned data. The current implementation is as follows: export default function Page() { con ...

Tips for accessing $parent of ng-repeat from ng-include

In my code, I have a nested ng-repeat structure with an ng-include inside the inner ng-repeat. I am trying to access the outer ng-repeat using $parent within the ng-include. Here is an example of what I am working on: index.html <div ng-repeat="popula ...

AngularJS dynamic resources allow for web applications to access and

I have created a directive for a search form that provides a template with a <form> tag, automated messages such as "No results found," and an optional suggestion message like "You can search by name or id." However, I am facing an issue where I nee ...

Tips for achieving functionality with ng-click in an Angular DataTables column creator

Here is the code snippet I am working with: Controller: vm.dtColumns = [ DTColumnBuilder.newColumn('product_code').withTitle('Code'), DTColumnBuilder.newColumn('product_name').withTitle('Name'), ...

What is the best way to retrieve data from Elastic Search using Node.js?

I currently work with NODE JS in conjunction with an elastic search DB. Within this setup, I am utilizing the following package: https://www.npmjs.com/package/@elastic/elasticsearch In my elastic search DB, I have a collection that looks like this: [ { ...

What is the best way to transfer text from a paragraph element to an input field without triggering a page refresh?

I have a challenge where I want to replicate the content of a <p> element into an <input> element's value attribute. The text within the paragraph includes values like .30, .31, .6, .38, which are dynamically updated by a jQuery script wi ...

Analyzing nested HTML for hyperlinks and information

My current project involves parsing a website (files.minecraftforge.net) to extract download links, as well as version and build time information for each download. I've been utilizing the Simple HTML DOM Parser with success so far, but I'm havin ...

Unveiling the Magic of Knockout.js: Extracting the Object Data

I recently started experimenting with knockout and have a query. Here is an excerpt of the code: function Task(data) { var self = this; self.name = ko.observable(data.name); } function ViewModel() { self.taskArr = ko.observableArray([ // ...

Tips on sending error messages to an MVC view during an Ajax call

When using ajax to call a controller action method on an MVC button click event, there may be validation logic in the controller that needs to notify the user of any errors. Is there a way to send an error message to the ajax success event from the control ...

What is the most effective method for declaring callbacks on objects in Typescript?

I am currently working on a sidebar menu component that is connected to a service holding items in the menu. This allows multiple sources to make alterations to the menu as needed. Each item in the menu currently follows the SidebarItem interface: export ...