Unable to view the scene as seen by the OrthographicCamera

My objective is to create a simple HUD by overlaying a 2D scene on top of a 3D scene. However, in the example provided in this jsFiddle, only the perspective camera appears to render.

var camera, scene, renderer, geometry, material, mesh, sprite, rtcamera, rtscene, texture, spmaterial;

init();
update();

function init() {
    var width = window.innerWidth - 80,
        height = window.innerHeight - 80;

    scene = new THREE.Scene();
    rtscene = new THREE.Scene();

    camera = new THREE.PerspectiveCamera(50, width/height, 1, 10000);
    camera.position.z = 500;
    scene.add(camera);
    rtcamera = new THREE.OrthographicCamera(-width/2, width/2, height/2, -height/2, 0.1, 1000);

    geometry = new THREE.BoxGeometry(200, 200, 200);
    material = new THREE.MeshNormalMaterial();
    mesh = new THREE.Mesh(geometry, material);
    scene.add(mesh);

    var texture = THREE.ImageUtils.loadTexture('../img/logo.png');
    var spmaterial = new THREE.SpriteMaterial({
        map: texture
    });
    sprite = new THREE.Sprite(spmaterial);
    sprite.scale.set(50, 200, 1);
    rtscene.add(sprite);

    renderer = new THREE.WebGLRenderer();
    renderer.setSize(width, height);
    renderer.autoClear = false;

    document.body.appendChild(renderer.domElement);

}

function update() {

    requestAnimationFrame(update);
    render();

}

function render() {

    mesh.rotation.x += 0.01;
    mesh.rotation.y += 0.02;

    renderer.clear();
    renderer.render(scene, camera);
    renderer.clearDepth();
    renderer.render(rtscene, rtcamera);

}

I am utilizing three.js r71 and WebGLRenderer. When I attempt to render a perspective scene on top of another perspective scene, both are visible.

Is there an important element that I might be overlooking?
Thank you in advance.

Answer №1

The URL for the image you're trying to load in three.js doesn't seem to be working as expected. Looking at the console, we can see:

jshell.net/7Leazzja/img/logo.png 
Failed to load resource: the server responded with a status of 404 (Not Found)

It appears that the image is not found - possibly due to how JSFiddle isolates the application.

You'll need to use a different image. However, this might be challenging due to CORS restrictions. I recommend checking out the suggestions provided here: How to make JSFiddle of sprites using THREE.JS source and image files from Github?

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

Browse through different states by clicking on the <a> </a> tag

Is there a way to switch between states defined by $stateProvider when clicking on the <a> </a> tag? Below are the states I have set up: $stateProvider //region page States .state('page1', { url: "/pg1", ...

How can I utilize an exported function in a separate HTML component with Angular?

I have a function that I exported in a separate file. export function sum(population): string { return population.toString().replace(/\B(?=(\d{3})+(?!\d))/g, "."); } I imported this function in my component like this: import { ...

Google Sheets displaying blank values after submission via an AJAX call

I have been working on transferring data from my web app to a Google spreadsheet and I am encountering some issues. I followed the script provided by Martin Hawksey, which can be found here: https://gist.github.com/mhawksey/1276293 Despite setting everyth ...

Complicated "as-label" for understanding expressions in Angular

Is it possible to set a complex label in a comprehension expression in Angular? I've searched everywhere for a solution, but I can't seem to find one. The workaround I found involves pre-populating the 'as' label attribute with the des ...

Live CSS editing tool

Are there any Javascript libraries or plugins available that enable real-time modification of CSS classes/styles on a webpage? ...

Issue with managing cursor location using readline in Node.js

Currently, I am developing a console application in Node.js utilizing the readline module to manage cursor positions and obtain user input. Below is a custom library I have created for this purpose: // ReadLine.js const readline = require("readline&qu ...

The XMLHttpRequest function consistently comes back as undefined

Currently, I am working on the MDN tutorial about 'XMLHttpRequest'. Unfortunately, when trying to use request.open('GET', url) with a txt file from my local directory, it is returning undefined. I have checked both the url and request i ...

I'm struggling to find the perfect configuration for Vite, JSconfig, and Aliases in Visual Studio Code to optimize Intellisense and Autocomplete features

After exclusively using PHPStorm/Webstorm for years, I recently made the switch back to Visual Studio Code. The main reason behind this decision was the lightweight nature of VSCode and its widespread availability as a free tool, unlike paid services. I s ...

execute a setTimeout function in ReactJs to render a component after a specified amount of time

Is there a way to render a component inside my App.Js after a certain amount of time using setTimeout? I've tried, but nothing seems to be happening... This is my code: function App() { return ( <Router> <GlobalStyle /> ...

Implementing Adaptive Images in Bootstrap 5 for a Specified Design

I am currently working on a website layout that involves displaying one image per section. My goal is to have the images positioned on either side of the text when viewed on a larger screen, as shown in the example below: https://i.sstatic.net/bms6S.png ...

Using the Map Function in React JS to Dynamically Render Radio Buttons with Material-UI

Hey everyone, I'm looking for some assistance in replacing the old classic radio button with a new one using material-ui. I've been trying but haven't been successful so far. Any suggestions would be greatly appreciated. Thanks in advance. Y ...

Is it possible to generate a dynamic multiplication function by utilizing nested attributes together with the selected option in a combobox

I have a unique question that may seem strange or confusing, but I have not been able to find an example similar to my situation. I created a nested form where each new row has a long name structure like this: <input id="shopping_document_shopping_prod ...

Searching for text within a PDF document using the Internet Explorer version 9 browser by

When a link is clicked in our application, it opens a new window with a secure PDF file. We are looking to validate this using Selenium in Ruby. However, we encountered an issue in IE9 where there is no HTML/DOM element for validation. We were able to suc ...

Is it possible to access the $pristine property of an input element in Angular without using a form?

Imagine having the following HTML... <div class="row"> <div class="col-xs-3 align-right"> <p>Name</p> </div> <div class="col-xs-7"> <input type="text" class="form-control" ng-model="registrati ...

Adding the tasksMap to the dependency array in the React useEffect hook will result in an endless loop

I'm facing an issue with adding tasksMap to the useEffect dependency array, as it causes an infinite loop. Can someone guide me on how to resolve this? To ensure that the user sees an updated view of tasks that are added or modified, I need the app to ...

Possible issue with accurate indexing causing caption error with API images in React

Continuing from: Implementing a lightbox feature in react-multi-carousel for my ReactJS app My application utilizes react-images for the lightbox functionality and react-carousel-images for the carousel. The API provides a title and image data. The issue ...

Alter the border line's color based on the specific section or div it overlays

I am attempting to utilize jQuery in order to change the color of my border line depending on its position within the divs. I have set the position to absolute and it is positioned on both divs. My goal is to make the line on the top div appear as grey, wh ...

What could be the reason for the malfunctioning of the where feature in Cloud Firestore?

Looking to create a warning system using discord.js and utilizing Cloud Firestore as the database. The goal is to have a system where when an admin triggers a command, it utilizes the where function to locate all documents containing the userid of the user ...

Guide to dividing a URL in reactjs/nextjs

Here is the complete URL: /search-results?query=home+floor&categories=All+Categories. I am looking to separate it into two sections - /search-results and query=home+floor&categories=All+Categories. My objective is to extract the second part of t ...

Tips for adjusting the height and width of rows and columns in an HTML table with jQuery

Currently, I am utilizing both the colResizable plugin for adjusting columns and the Resizable function for adjusting rows. While this setup works perfectly fine in Mozilla Firefox, it seems to encounter issues when used in Chrome. For column resizing, we ...