the display outcome appears fuzzy and lacks sharpness

Currently, I am engaged in prototyping and showcasing data in a 3D format using three.js (version 68). The intended outcome of the entire animation is to have a collection of colored spheres representing protons and neutrons, each colored based on a specific scheme. Although everything seems to be functioning well, the rendered results appear to be pixelated for reasons unknown to me.

The current version of the visualization looks something like this (the image is approximately 400px wide):

I have thoroughly checked for common issues such as incorrect resolution settings, browser scaling problems, and so on.

You can observe this problem on this fiddle, and download the webpage from here.

Additionally, below are the relevant sections of the code:

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <script src="js/jquery.js"></script>
    <script src="js/coffee-script.js"></script>
    <script src="js/three.js"></script>
    <script src="js/OrbitControls.js"></script>
    <script src="js/animtest/load_event.js"></script>
    <style>canvas { width: 100%; height: 100% }</style>
    <title></title>

</head>
<body>
<div id="animation"
    style="width: 1024px; height: 768px; ">

</div>
<script>
    $(function(){
       ctrl = new AnimController("#animation");
       ctrl.set_up_scene();
       ctrl.render();
       ctrl.display_frame(4);
    });
</script>

</body>
</html>

Here is the CoffeeScript code responsible for loading the animation:

class AnimController

  ...

  set_up_scene: () ->
    @scene = new THREE.Scene()
    el = $(@element_name)
    @camera = new THREE.PerspectiveCamera(45
      el.width() / el.height(),
      1, 20000
    )
    @camera.position.set(100, 100, 0)
    @scene.add(new THREE.AmbientLight(0x111111))

    @renderer = new THREE.WebGLRenderer()
    el.html(@renderer.domElement)
    controls = new THREE.OrbitControls(@camera, @renderer.domElement);
    controls.addEventListener('change', () =>
      console.log("Change")
      @render()
    )

  render: () ->
    requestAnimationFrame(() => @render)
    console.log("Render")
    if @update_scene
      material = new THREE.MeshBasicMaterial() #"color": 0xffff00,
      geometry = new THREE.SphereGeometry(5, 50, 50)
      console.log("Update")
      @update_scene = false
      @scene = new THREE.Scene()
      for particle in @curr_event
        p = particle['position']
        sphere = new THREE.Mesh(geometry, material);
        sphere.position.set(p[0], p[1], p[2])
        @scene.add(sphere)
    @renderer.render(@scene, @camera)

Answer №1

It appears that you haven't enabled antialiasing for the renderer in use. While I'm not familiar with coffeescript, in javascript you would typically include the following line of code to enable antialiasing:

 renderer = new THREE.WebGLRenderer({ antialias: true });

Answer №2

In addition to anti-aliasing (as mentioned in @gaitat's response), I also overlooked adjusting the resolution of the renderer:

renderer.setResolution(1920, 1080)

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

How can I generate pure JavaScript, without using Typescript modules?

Take this scenario as an example ... index.ts import { x } from "./other-funcs"; function y() { alert("test"); } x(y); other-funcs.ts import { z } from "some-module"; export function x(callback: () => void): void { z(); callback(); } ...

Limiting the usage of a command in Discord.js to one user at a time, rather than all users

I'm in the process of developing a discord.js bot and I need to implement a cooldown for a specific command. After searching several tutorials online, I found that most of them apply the cooldown to all commands (meaning all users have to wait a set ...

What could be causing the images to not display on my HTML page?

My program is designed to display an image based on the result of the random function. Here is my HTML: <div> <h2>Player 0:</h2> <div id="MainPlayer0"></div> </div> Next, in my TypeScript fi ...

Associate text with a color from a predetermined list (JavaScript)

As I work on adding tags to my website for blog posts, I have a specific vision in mind. Each tag should be assigned a unique background color selected from a predefined array of theme colors. My goal is to assign the same background color to tags with id ...

Mapping Form Fields (with Formik)

Currently, the Formik/Yup validation setup in my form is working perfectly: export default function AddUserPage() { const [firstName, setFirstName] = useState(""); const [email, setEmail] = useState(""); return ( <div> <Formik ...

Ensure each list item is directly aligned when swiping on a mobile device

Looking to make a simple horizontal list swipeable on mobile devices with tabs that snap from tab to tab, activating the content for the active tab immediately. The desired effect is to swipe directly from one tab to the next without having to click separ ...

Interactive Content Swapping: How to Use Javascript for Dynamic Link Updates

http://jsfiddle.net/bUjx7/42/ <script type='text/javascript' src='http://code.jquery.com/jquery-1.9.1.js'> </script> <script type='text/javascript'> $(document).ready(function () { $('.fieldreplace ...

Remembering data in a lazy loaded AngularJs list

Encountering an issue with a lazy loaded list of books. Initially, 10 books are loaded and if the user scrolls down, the next 10 books are loaded. For example, if the user is on "page" 4 and clicks on the 35th book to view details, upon returning to the l ...

How can I display the value of a radio button that has been chosen?

Would you mind sharing how to display the selected value of a radio button? I attempted it this way, but unfortunately, it did not work. You can view my code at this link. <mat-radio-group [(ngModel)]="favoriteName"> <mat-radio-button *ngFor="l ...

What exactly does the term "entry point" refer to within the context of npm init?

Starting a new project can be overwhelming, especially when faced with a list of questions during the npm init process. One question that often stumps developers is "entry point." The options provided, like name, version, and description, may seem straig ...

Removing an element from an object using ng-model when its value is empty is a standard practice

Utilizing the $resource service to access and modify resources on my API has been a challenge. An issue arises when the ng-model-bound object's value is set to empty - the bound element is removed from the object. This results in the missing element ...

Is there an issue with loading CSS and JavaScript in mobile view on a website built with CodeIgniter?

My experience with codeigniter has been great so far, but I encountered an issue when trying to view my work on different devices. Here is the problem: Web: Broswer View | Browser (Responsive Design View) Mobile: Screenshot 1 | Screenshot 2 _htaccess: ...

Encountering a PropertyTypeError while attempting to process a payment via Stripe in conjunction with use-shopping-cart on Next.js

Upon reaching the checkout page, I encounter the message: Invalid value with type "undefined" was received for stripe. Valid type for stripe is "string". This issue seems to be related to the redirectToCheckout function. Can someone assist me? The cart-s ...

Is it possible to increase Google+ shares without needing an API key for every single page?

Looking to retrieve the number of Google+ shares for each URL on a search results page using Ajax. Facebook and Twitter share counts have been successfully implemented: $.getJSON('http://urls.api.twitter.com/1/urls/count.json?url=' + url + & ...

Obtain the unique identifier of the chosen option using material-ui's autocomplete feature

I am currently implementing the autocomplete feature using material-ui. The data in the "customerList" displayed in the search field works fine. However, I am facing an issue with retrieving the "ID" number of the selected data. My goal is to obtain the ID ...

Creating interactive touchpoints with pop-up text or interactive text fields is a great way to engage your audience and make your

While developing a game with react-three-fiber, I have successfully integrated touchpoints. Now, I am facing a challenge in creating interactive pop-ups that will provide questions or text for the player to answer. Can anyone lend a hand in accomplishing ...

Encountering a Keycloak Sign In Issue with NextAuth in a Next.js Application [next-auth][error][SIGNIN_OAUTH_ERROR]

Hey there, I'm currently in the process of setting up authentication for my Next.js application using NextAuth and Keycloak. Even though I've followed the documentation closely, I've hit a roadblock when trying to sign in with Keycloak. Her ...

Having trouble with AngularJS not sending form values properly?

I have a code snippet in my app.js file where I am trying to pass the value of email to a file named handler.php. $scope.doForget={email:''}; $scope.doForget = function (customer) { //email = $scope.forget.email; For Testing i am hardcoding ...

Ways to divide a cluster in three.js?

My dilemma involves voxels that require grouping, so I have opted to place them in a container: container.add(e); Next, I integrate the container into the scene. However, I am now faced with the challenge of how to separate the voxels without the need to ...

Errors in production arise from building React applications

I am new to using React and recently built a ToDo web app following a tutorial. Everything seemed fine during development, but when I tried to view the production version locally using serve -s build, two errors popped up that were not present before. reac ...