The JS and CSS navigation menu suddenly ceased to function on the WebGL web page

Having some issues with my navigation menu that uses JS and CSS to create a slide-in style. It was working fine before, but now it's not working properly. Can't figure out if it's due to the webgl on the page or another reason.

Visit: www.explorecanterbury.co.uk

CSS

.photo-menu {
  position: fixed;
  top: 0;
  left: 0;
  width: 370px;
  height: 100%;
  max-height: 700px;
  overflow-x: hidden; 
  display:none;
  background: #ddd;
  text-align: left;
  box-shadow: 1px 4px 4px #999;
}
.nav-toggle-2 {
  width: 24px;
  height: 24px;
  display: block;
 }
.nav-toggle-3 {
  width: 24px;
  height: 24px;
  display: block;
}

.information-menu {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  display:none;
  background: #ddd;
  text-align: left;
  box-shadow: 1px 4px 4px #999;
}

.LocIcon {
  background-image:url(/images/select.png);
  width:24px;
  height:24px;
  display: block;
}

.photosIcon {
  background-image:url(/images/photos.png);
  width:24px;
  height:24px;
  display: block;
}

.infoIcon {
  background-image:url(/images/information.png);
  width:24px;
  height:24px;
  display: block;
}
.searchIcon {
  background-image:url(/images/search.png);
  width:24px;
  height:24px;
  display: block;
}

JS

$(document).ready(function() {

    $(function() {
      $('.nav-toggle-3').on('click', function() {
        $(".information-menu").animate({width:'toggle'},200);
      });

      $('.nav-toggle-2').on('click', function() {
        $(".photo-menu").animate({width:'toggle'},200);
      });
    });
});

HTML

<nav class="navbar navbar-default" style="z-index:6;">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
        <li type="button" class="btn btn-default dropdown-toggle hidden-xs" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="LocIcon"></span></li>
            <ul class="dropdown-menu">
              <li><a href="#" class="small" data-value="option2" tabIndex="-1"><input type="checkbox"/>&nbsp;Museums and Galleries</a></li>
              <li><a href="#" class="small" data-value="option3" tabIndex="-1"><input type="checkbox"/>&nbsp;Landmarks</a></li>
              <li><a href="#" class="small" data-value="option4" tabIndex="-1"><input type="checkbox"/>&nbsp;Shopping</a></li>
              <li><a href="#" class="small" data-value="option5" tabIndex="-1"><input type="checkbox"/>&nbsp;Churches</a></li>
              <li><a href="#" class="small" data-value="option6" tabIndex="-1"><input type="checkbox"/>&nbsp;Tours and Guides</a></li>
            </ul>
            <li><span class="photosIcon nav-toggle-2 hidden-xs"></span></li>
            <li><span class="infoIcon nav-toggle-3 hidden-xs"></span></li>
            <li><span class="searchIcon hidden-xs"></span></li>
            </ul>
          <form class="navbar-form hidden-xs" role="search">
            <div class="input-group">
              <input type="text" class="form-control" placeholder="Search" name="srch-term" id="srch-term">
            </div>
          </form>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>

Answer №1

function detectMouseClick( event ) {

    // create a Ray with starting point at the mouse coordinates
    //   and direction towards the scene (camera direction)
    var vector = new THREE.Vector3( mouseX, mouseY, 1 );
    projector.unprojectVector( vector, camera );
    var ray = new THREE.Raycaster( camera.position, vector.sub( camera.position ).normalize() );

    // create an array containing all objects in the scene that intersect with the ray
    var intersects = ray.intersectObjects( objectList, true);

    if ( intersects[ 0 ].object.name === "Canterbury Tale")
    {
        alert("Canterbury Tale has been clicked!");
    }

    if ( intersects[ 0 ].object.name === "Westgate")
    {
        alert("Westgate has been clicked!");
    }   

    if ( intersects[ 0 ].object.name === "Cathedral")
    {
        document.getElementById('canttaleDiv').style.display = "block"; 
    }   
    }

Your code analysis revealed that the detectMouseClick method is being triggered when clicking on the navbar, leading to errors as it attempts to access intersects[ 0 ].object.name. To resolve this issue, consider binding or placing this method specifically on the container holding the 3D models, rather than the entire document.

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

What's the best way to center and expand a Bootstrap 5.3 dropdown menu to fill the entire width of the page?

I want to recreate the dropdown menu seen on this page, with the full width of the page but without any content. Additionally, I need all the "lorem" links in the menu to be centrally aligned in the navbar. Unfortunately, I am unable to modify the bootstra ...

The AJAX request is lacking a proper reference to the variable

This is the code I am working with: $('.store-card').each(function() { placeid = $(this).data('placeid'); latlng = $(this).data('latlng'); card = this; console.log("1 ", card); $.ajax({ url: '/stores/pl ...

Dynamic elements create an interactive horizontal scrolling experience

I have square elements that will be displayed in a row on the screen extension. These elements are generated dynamically, starting with 2 and going up to 50. Depending on the screen size and number of elements, there may be overflow. In such cases, I want ...

React component with element style declared in module.css file and conditional state

I'm in the process of developing a mobile dropdown feature for a React web application. I am looking for guidance on the proper syntax to use when incorporating multiple classes into a React element. My goal is to apply styles from an imported module ...

Converting Windows paths to Unix paths using PHP

Currently, I am facing an issue with hosting a PHP website that was developed on a Mac on IIS. The problem arises when trying to display images uploaded through a form. The paths of these images are saved in Windows style format (i.e. \images\foo ...

How to create a thumbnail hover effect with CSS3 and javascript, overcoming the z-axis issue

Currently, I am working on creating a set of thumbnails that enlarge when hovered over. The initial setup achieves the zoom effect using CSS3 transform:scale and ease-in-out. However, the issue is that the enlarged images overlap each other due to sharing ...

Searching through an array of objects that contain nested child objects

I am currently trying to find a way to search through an Array that has nested Objects in order to find a specific value and then retrieve the object in which it is found to store it in a new array. This is the code snippet I am working with: var json = ...

Can Express not use await?

Why am I encountering a SyntaxError that says "await is only valid in async function" even though I am using await inside an async function? (async function(){ 'use strict'; const express = require("express"); const bodyParser = ...

I am currently facing a challenge with Bootstrap, as I am trying to design a webpage for small devices using a 1:4:1 format, but I am struggling to get it right

column 1 and column 3(left and right cols) have successfully passed the test case, but not column 2 (the middle one) that I have commented on in the code. Please help. Thank you. The problem has certain conditions that would have been easier to understa ...

Displaying properties of objects in javascript

Just starting with JavaScript and struggling to solve this problem. I attempted using map and filter but couldn't quite implement the if condition correctly. How can I find the records in the given array that have a gender of 0 and color is red? let s ...

Select items from object based on a specified array of IDs

I am facing a challenge with my list of objects that each have an array associated with them. For instance, take a look at this example: "-KpvPH2_SDssxZ573OvM" : { "date" : "2017-07-25T20:21:13.572Z", "description" : "Test", "id" : [ { ...

Cookie Multitree: An Innovative JsTree Solution

Hello everyone, I am currently using jstree and have come across a couple of issues with having multiple trees on the same page. Here are my two problems: 1) I am looking to implement cookies to keep track of which nodes are open in each tree. I attempted ...

Automatically filling out a Pug form using an Express/Node.js web application

My Node.js web app is created with Express and I am attempting to populate a Jade template after querying MongoDB. The goal is to fill the Jade template with the queried values. One thing that puzzles me is that even when I remove everything within the co ...

What is the best method for closing the open portion of an accordion menu?

I'm experimenting with creating a collapsible accordion feature, but I'm facing a challenge in figuring out how to close the currently open accordion pane. The accordion functions smoothly when expanding sections, but I'm stuck on how to col ...

Extract a digit from the database and assign it to the numerical value

Is there a way to extract a specific number from the columns of a given day? I have the date, but I am looking to showcase the records for a particular day (number) The console.log(day.length) doesn't seem to be working as expected Trying to use ...

Jquery back-to-top button instantly teleports to the top instead of smoothly scrolling

I recently tried my hand at creating a simple Back-To-Top button that appears when the page is scrolled past a certain point. I used jQuery $(document).ready(function () { $(window).scroll(function() { if ($(this).scrollTop() > offset) { ...

Browsing through a collection of JSON objects with a user interface

I need a way to filter and display a list of Dogs based on a search query. I initially stored the data in an array within the state, but with an increasing number of entries, I've decided to switch to JSON format for better management. However, I&apo ...

Building a straightforward expandable/collapsible tree view with AngularJS by utilizing a particular data format

Seeking a tree view control that displays as follows: http://plnkr.co/edit/JAIyolmqPqO9KsynSiZp?p=preview +Parent child +Parent child child child child +Parent child child child child child chil ...

Crisp edges and corners casting shadows in Threejs BoxGeometry

I created a structure using BoxGeometry, with a DirectionalLight rotating around it. However, I am facing an issue with aliased light bleed in the corners. I've attempted adjusting the shadow.mapSize, the blur radius, and the renderer.shadowMap.type, ...

Adjust the scrolling behavior of the scroll wheel event to only scroll a single

I am facing an issue with my code that causes the next div to slide into view when scrolling on the mouse wheel, but it scrolls multiple times due to the sensitivity of the scroll. Is there a way to limit the scroll action to only fire once? Take a look a ...