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 9051387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T12:53:35+00:00 2026-06-16T12:53:35+00:00

I have been doing some experiments with three.js. However, when I try to do

  • 0

I have been doing some experiments with three.js. However, when I try to do a simple test, I can’t get it to display anything. Here’s my code. If someone could tell me what I’m missing it would be really helpful.

//Constant declaration
var RENDER_DIST = 1000,
    FOV = 75;

var WIDTH = window.innerWidth,
    HEIGHT= window.innerHeight;

//Create the scene
var scene = new THREE.Scene();

//Create the camera
var camera = new THREE.PerspectiveCamera(FOV, WIDTH / HEIGHT, 0.1, RENDER_DIST);

//Pull the camera back a bit
camera.z = 100;
//Then add it to the scene
scene.add(camera);

//Create a renderer
renderer = new THREE.WebGLRenderer();
renderer.setSize(WIDTH,HEIGHT);
renderer.domElement.className = "glMain";

//Container is a div
$("#container").html(renderer.domElement);

//Boilerplate done! Celebrate!
(function init() {
    var geometry = new THREE.SphereGeometry(50); 
    var material = new THREE.MeshBasicMaterial({color: 0xff0000}); 
    var sphere = new THREE.Mesh(geometry, material); 
    scene.add(sphere);

    //debugging
    console.log("Sphere at " + sphere.position.x + " " + sphere.position.y + " " + sphere.position.z);


})();

//Our main function
(function loopRun() {
    requestAnimationFrame(loopRun);

    console.log("rendered");
    renderer.render(scene, camera);
})();

On the console log I am getting all the "rendered" messages but nothing is displaying. I have checked that the canvas is the right size and it is, so I have no idea what is wrong. I have tried a few different geometries.

EDIT: I am using Chrome, and online three.js examples work fine. There are no errors on the console log.

  • 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-16T12:53:36+00:00Added an answer on June 16, 2026 at 12:53 pm
    //Pull the camera back a bit
    camera.position.z = 100;
    
    //Container is a div
    document.body.appendChild(renderer.domElement);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been doing some research on test driven development and find it pretty
I love my GUID. However, lately I have been doing some research to understand
I have been doing some research and still can't find a solution to my
I have been doing some customization to this jQuery paging script I found here
I have been using cvx for doing some experiments with my SDPs. Although it
I'm getting started with Zend Framework. I have been doing some tutorials here and
I have been doing some research on what the easiest way to get phone
I have been doing some URL rewriting for a customer in a test environment
I have been doing some searching for a regex that can be used as
I have been doing some research for using MSMQ. Following 2 gave me fundamental

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.