is there any error or wrong formatting that would stop my bot from responding to commands

is there any error or wrong formatting that would stop my bot from responding to commands

has all intents and also full permissions required but still no response to commands
very new to codeing a bot so trying to learn what i can but specific features i need some help to grasp

const Discord = require('discord.js');
const fs = require('fs');
const https = require('https');
const { EmbedBuilder } = require('discord.js');
const { ButtonBuilder } = require('discord.js')
const { ActionRowBuilder } = require('discord.js')
const { Client, IntentsBitField } = require('discord.js');

const client = new Client({
  intents: [
    IntentsBitField.Flags.Guilds,
    IntentsBitField.Flags.GuildMembers,
    IntentsBitField.Flags.GuildMessages,
    IntentsBitField.Flags.MessageContent,
  ],
});

const PREFIX = '%';

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});

client.on('message', async message => {
  if (!message.content.startsWith(prefix) || message.author.bot) return;

  const args = message.content.slice(prefix.length).trim().split(/ +/);
  const command = args.shift().toLowerCase();

  
  if (command === 'upload' && args.length === 2) {
    const [initDataFile, jsonObjectFile] = args;

    // Handle init.data file
    if (!initDataFile.endsWith('.data')) {
      return message.reply('Please upload a DayZ init.data file.');
    }

    const initFile = await message.attachments.find(
      attachment => attachment.name.endsWith('.data')
    );
    if (!initFile) {
      return message.reply('Please upload a DayZ init.data file.');
    }

    // Handle JSON object file
    if (!jsonObjectFile.endsWith('.json')) {
      return message.reply('Please upload a JSON file.');
    }

    const jsonObject = await message.attachments.find(
      attachment => attachment.name.endsWith('.json')
    );
    if (!jsonObject) {
      return message.reply('Please upload a JSON file.');
    }

    try {
      const cleanedInitData = await cleanInitData(initFile);
      const cleanedJsonObject = await cleanJsonObject(jsonObject);
      const objectsJson = await convertToObjectsJson(cleanedInitData, cleanedJsonObject);

      const messageStrings = [
        'Here is your cleaned and converted Objects.json file:',
        '```json',
        objectsJson,
        '```'
      ];
      await message.author.send(messageStrings.join('n'));
    } catch (error) {
      console.error(error);
      await message.reply('An error occurred while processing your files. Please try again later.');
    }
  }
});

// Define a check and replace list
const checkReplaceMap = {
  "bldr_rock_bright_apart2": "DZ\rocks\rock_apart2.p3d"
};

const checkReplaceList = Object.keys(checkReplaceMap);

async function cleanInitData(initFile) {
  const dirtyData = await initFile.attachment.download();
  let cleanData = dirtyData
    .replace(/SpawnObject("/g, "")
    .replace(/",/g, " ")
    .replace(/;/g, "")
    .replace(/)/g, "")
    .replace(/"/g, "")
    .replace(/  /g, ' ');

  for (const [key, value] of Object.entries(checkReplaceMap)) {
    const regex = new RegExp(`(^|\s)${key}($|\s)`, 'g');
    cleanData = cleanData.replace(regex, `$1${value}$2`);
  }

  return cleanData;
}

async function cleanJsonObject(jsonObject) {
  const jsonString = await jsonObject.attachment.download();
  let cleanJsonString = jsonString;

  for (const [key, value] of Object.entries(checkReplaceMap)) {
    const regex = new RegExp(`(^|\s)${key}($|\s)`, 'g');
    cleanJsonString = cleanJsonString.replace(regex, `$1${value}$2`);
  }

  return JSON.parse(cleanJsonString);
}

function convertToObjectsJson(initData, jsonObject) {
  const lines = initData.split('n');
  const objects = lines.map(line => {
    const [name, pos, ypr, scale] = line.split(/[(),"]/).slice(1, -1).map(str => str.trim());
    const [x, y, z] = pos.split(/s+/).map(str => Number(str));
    const [pitch, yaw, roll] = ypr.split(/s+/).map(str => Number(str));
    return {
      name,
      pos: [x, y, z],
      ypr: [-pitch, yaw, roll],
      scale: Number(scale)
    };
  });

  jsonObject.Objects = objects;
  return JSON.stringify(jsonObject, null, 2);
}

client.login('TOKEN_HEAR');

is there any error or wrong formatting that would stop my bot from responding to commands

has all intents and also full permissions required but still no response to commands
very new to codeing a bot so trying to learn what i can but specific features i need some help to grasp

the bot will basically use a ckeck replace list of names when a user uploads the init.c or json game file it will search for any match and replace the names in the uploaded file then return the data back to the user in .json set out for dayz objectspawner.json

HTML video tag duration property mismatching with file metadata

I’m currently building a custom player for large ingesting files into a media asset manager system, and as title states, duration of file obtained natively by html video tag does not match with the metadata in the file, thus making the progress bar not match at all with the real progress of the video.

What I’ve done to test this is basically linked the player element to a ref and getting the duration when metadata got preloaded

<video src="my-video.mp4" preload="metadata"></video>

var video = document.querySelector('video');

video.addEventListener('loadedmetadata', function() {
  console.log('Video duration:', video.duration);
});

Although video duration is around 2-3 hours, the video length displayed by video.duration is around 8 hours (28835.47 in seconds)

The video format is mp4.

Next JS – How to modify SVG properties values and add nodes?

I’m using SVGR to load a SVG as a component, in my next js 13 app :

import CvSvg from './../../public/image.svg'

export default function Home() {
    return (
        <div className="flex flex-col min-h-screen">
            <CvSvg />
        </div>
    )
}

Let’s imagine I have this element in the SVG :

<tspan
         sodipodi:role="line"
         style="font-size:4.93889px;fill:#000000;stroke:none;stroke-width:0.264583;stroke-opacity:1"
         x="79.525864"
         y="29.664894"
         id="tspan59991">message
</tspan>

How can I edit the text “message”, or any properties such as its position, color etc from the code ?
Also, how can I add some nodes, to add a line after the “tspan” node for example ?

I’ve tried by many ways, I tried this for example, but it didnt work, the line wasn’t showing up :

import { useEffect, useState } from 'react';
import SVG from './public/image.svg'

function Home() {
  const [svgDoc, setSvgDoc] = useState(null);

  useEffect(() => {
    fetch(SVG)
      .then(response => response.text())
      .then(data => {
        const parser = new DOMParser();
        const svgDoc = parser.parseFromString(data, "image/svg+xml");

        const text = svgDoc.querySelector('#tspan59991');

        const line = svgDoc.createElementNS('http://www.w3.org/2000/svg', 'line');
        line.setAttribute('x1', '79.525864');
        line.setAttribute('y1', '30.664894');
        line.setAttribute('x2', '90');
        line.setAttribute('y2', '30.664894');
        line.setAttribute('style', 'stroke:#000000;stroke-width:1');

        text.parentNode.appendChild(line);
        setSvgDoc(svgDoc.documentElement.outerHTML);
      });
  }, []);

  return (
    <div className="flex flex-col min-h-screen">
      <div dangerouslySetInnerHTML={{ __html: svgDoc }} />
    </div>
  );
}

export default Home;

Creating new objects using values ​in array using the for(of) function

let oll_calc_input_id = ["mass", "mol_mass", "volum", "calculate", "widp"];

class Input_for_calc {
    constructor (id) {
        this.id_obgect = "#" + id;
    }
    document_qs() {
        document.querySelector(`${this.id_obgect}`);
    }
    style_block() {
        document.querySelector(`${this.id_obgect}`).style.display = "block";
    }
    style_none() {
        document.querySelector(`${this.id_obgect}`).style.display = "none";
    }
    value() {
        document.querySelector(`${this.id_obgect}`).value;
    }
};

let mass = new Input_for_calc('mass');

I have an array of values ​​as well as an object constructor and I would like to do new objects automatically, for example, using the “for(of)” function or another. The result should be objects similar to what is shown in the last line of code.
Feel free to say that I’m wrong and it’s impossible to get it this way, but in this case, bring your own implementation options.

I ate directly to take values, overwriting them inside the cycle but it didn’t help. As far as I understand, the weak point in the code options that I ate was to use the name in the line below

let ? = new Input_for_calc('mass');

because in the place marked with a question mark, the javascript took the variables I set as the name for the object.
If you know how to fix this problem please write the answer.

How to fix that. Cannot find name ‘styled’.ts(2304)

import React from "react"
import { BiRegistered } from "react-icons/bi";
import { LoginLabel } from "../../src/components/Account/Login/LoginLabel";

const LabelCOntainer=styled.label``
export default function Register() {
  return (
      <form>
        <label >Nome Completo</label>
        <input/><br/>

        <label> E-mail:</label>
        <input/><br/>

        <input/></form>
  );
}

I don’t know how to fix it, I need help to follow ahead!?

toggling vertical and horizontal div ..and rearranging text fields in side top div

function toggleDivs() {
  var container = document.querySelector(".container");
  var top = document.querySelector(".top");
  var bottom = document.querySelector(".bottom");

  if (container.style.flexDirection === "column") {
    container.style.flexDirection = "row";
    top.style.flex = "3";
    bottom.style.flex = "7";
    top.style.height = "auto";
    bottom.style.height = "auto";
  } else {
    container.style.flexDirection = "column";
    top.style.flex = "3";
    bottom.style.flex = "7";
    top.style.height = "100%";
    bottom.style.height = "100%";
  }
}
.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.top {
  flex: 3;
  background-color: blue;
  border: 1px solid black;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
}

.bottom {
  flex: 7;
  background-color: green;
  border: 1px solid black;
}

input[type="checkbox"] {
  height: 0;
  width: 0;
  visibility: hidden;
}

label {
  cursor: pointer;
  text-indent: -9999px;
  width: 50px;
  height: 25px;
  background-color: grey;
  display: block;
  border-radius: 100px;
  position: relative;
}

label:before {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 23px;
  height: 23px;
  background-color: #fff;
  border-radius: 90px;
  transition: 0.3s;
}

input:checked + label:before {
  left: calc(100% - 1px);
  transform: translateX(-100%);
}

.toggle-button {
  margin-top: 10px;
  padding: 10px;
  background-color: #4caf50;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

.toggle-button:hover {
  background-color: #3e8e41;
}

input[type="text"] {
  margin-bottom: 10px; /* added this */
}

@media screen and (min-width: 768px) {
  .container {
    flex-direction: row;
  }

  input[type="text"] {
    margin-bottom: 0; /* added this */
  }
}
<input type="checkbox" id="toggle-switch" onclick="toggleDivs()" />
<label for="toggle-switch"></label>

<div class="container">
  <div class="top">
    <input type="text" placeholder="Text box 1" />
    <input type="text" placeholder="Text box 2" />
    <input type="text" placeholder="Text box 3" />
    <input type="text" placeholder="Text box 4" />
    <input type="text" placeholder="Text box 5" />
    <input type="text" placeholder="Text box 6" />
    <input type="text" placeholder="Text box 7" />
    <input type="text" placeholder="Text box 8" />
  </div>
  <div class="bottom"></div>
</div>

as we can see in above code we are able to toggle div using toggle switch. Im looking to fix this code in such a way that when top div is vertical I would like to have all the textboxes one below each other and when its horizontal, then we can rearrange first 4 text boxes in single row and then next 4 text boxes and so on..
in short how we can toggle and rearrange text boxes at the same time.

toggling and rearranging fields using toggle switch.

forms error and styling Problem in Angular

Hi I’m relatively new to Angular and I have one major problem and one small styling problem first let’s go to the Major problem:
These are my passwords input I have the code from online and altered it a little bit.

<mat-form-field appearance="fill">
      <mat-label>Passwort</mat-label>
      <input matInput [type]="hidepwd ? 'password' : 'text'" id="passwordInput" [formControl]="password" required>
      <button mat-icon-button matSuffix (click)="hidepwd = !hidepwd" [attr.aria-label]="'Passwort anzeigen/verstecken'"
        [attr.aria-pressed]="hidepwd">
        <mat-icon>{{hidepwd ? 'visibility_off' : 'visibility'}}</mat-icon>
      </button>
      <mat-error *ngIf="password.invalid && (password.dirty || password.touched)">
        {{getPasswordErrorMessage()}}
      </mat-error>
    </mat-form-field>
    <br>
    <mat-form-field appearance="fill">
      <mat-label>Passwort bestätigen</mat-label>
      <input matInput [type]="hidepwdrepeat ? 'password' : 'text'" id="confirmPasswordInput" [formControl]="confirmPassword" (input)="checkPasswordMatch()" required>
      <button mat-icon-button matSuffix (click)="hidepwdrepeat = !hidepwdrepeat" [attr.aria-label]="'Passwort anzeigen/verstecken'"
        [attr.aria-pressed]="hidepwdrepeat">
        <mat-icon>{{hidepwdrepeat ? 'visibility_off' : 'visibility'}}</mat-icon>
      </button>
      <mat-error *ngIf="confirmPassword.invalid && (confirmPassword.dirty || confirmPassword.touched)">
        {{getConfirmPasswordErrorMessage()}}
      </mat-error>
    </mat-form-field>

This is the getConfirmPasswordErrorMessage function where I do the Error handling for the password confirmation in this function:

getConfirmPasswordErrorMessage() {
    if (this.confirmPassword.hasError('required')) {
      console.log("required");
      return 'Pflichtfeld';
    } 
    else if (this.password.value !== this.confirmPassword.value) {
      console.log("passwords dont match");
      return 'Passwörter stimmen nicht überein';
    } 
    else {
      console.log("no error");
      return '';
    }
  }

So now my question I get the error “Pflichtfeld” it’s German for Mandatory field but i don’t get the error that my passwords don’t match why??


my styling question: this is my submit button:

<button mat-raised-button color="primary" (click)="register()">Registrieren</button>

Why does it still look like this?:
enter image description here

I have tried with (input)=”checkPasswordMatch()” like you see but still nothing

generating solvable puzzles for a Double-Choco puzzle game. efficient data structure and algorithm to be used in?

I’m working on a puzzle board game called Double-Choco published by Nikoli magazine

Where the board is a 2-dimensional matrix with cells that are either white or gray. The goal is to divide the grid into blocks by drawing solid lines over the dotted lines. Each block must contain a pair of areas of white cells and gray cells having the same form (size and shape), one area can be rotated or mirror of the opposite area, an area could have a number indicates the number of cells of that color in the block.

I’m looking for help in choosing a data structure and forming an algorithm to automatically generate solvable puzzles for this game.

I am implementing using JavaScript and Here’s the approach I’m currently considering:

  • Start with a blank 2-dimensional matrix with the desired size.
  • Choose a random area size for the white area, between 2 and half of the board size (rounded down to the nearest even number), where cells that form the area is available and not taken
  • Check if a matched opposite area can be acquired on the board with the same shape & size.
  • If not: check if there is a space for a rotated or mirrored area.
  • If not: return to step 2
  • If yes: recheck the whole board for violations (mainly if there is a surrounded odd-size block left
  • If there is a violation: go back to step 2
  • mark the cells of the block (of 2 areas) as taken
  • go to step 2 till board is filled

As for the data-structure I thought of using graph but I couldn’t wrap it around my head. maybe deal with areas as it is as 2-dim matrix?

I’m not sure if this approach is optimal or if there are better data structures and algorithms to use. What data structure and algorithm would you recommend for generating solvable puzzles for this board game? Any help or suggestions would be greatly appreciated.

How to skip labels on the x-axis with ApexCharts

I’m trying to format an Apex Chart like this:

enter image description here

The idea is that there are tick marks every 15 seconds but the label is only displayed every 30 seconds.

Codepen here: https://codepen.io/peterkronenberg/pen/oNaERKP

The problem is that if there are too many labels, it gets too crowded as the Codepen shows (for the purposes of the example, I just made the width smaller)

How can I thin down the number of labels displayed, maybe showing every 2nd or 3rd one?
hideOverlappingLabels doesn’t seem to do anything

enter image description here

Grouping duplicates in order (not your typical filter duplicates)

I have a strange situation for filtering duplicates.

I have to turn this

[
  {name: A, number: 1, order: 1},
  {name: B, number: 1, order: 2},
  {name: C, number: 1, order: 3},
  {name: D, number: 2, order: 4},
  {name: E, number: 2, order: 5},
  {name: F, number: 1, order: 6}
]

Into

[
  [
    {name: A, number: 1, order: 1},
    {name: B, number: 1, order: 2},
    {name: C, number: 1, order: 3},
  ],
  [
    {name: D, number: 2, order: 4},
    {name: E, number: 2, order: 5},
  ],
  [
    {name: F, number: 1, order: 6}
  ]
]

I have been able to put duplicates into their own arrays but this extra step has me scratching my head.

How to get more than on tab gallery on a single pag

I followed a tutorial on W3 schools to create an image gallery. There are small thumb nails and when you click on one it it supposed to open in a larger image. This works well if you only have one gallery, but I want to display multiple. When I have more than one gallary they images all expand in one square instead of under the thumbnail images. I want them to all expand in their own gallery.

here is all of my HTML

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Arryanna Wilson portfolio website</title>
<link rel="stylesheet" type="text/css" href="css/reset.css">
<script src="javascript.js"></script><link href="img/favicon.ico" type="image/x-icon" rel="shortcut icon" />
<link rel="stylesheet" type="text/css" href="css/styles.css">
<meta name="description" content="Arryanna Wilson Portfolio Gallary." />
<meta name="viewport" content="initial-scale=1.0,width=device-width,maximum-scale=1,minimum-scale=1,user-scalable=no" />
</head>
<body>
    
<img src="img/Logo.jpg" alt="Arryanna Wilson Graphic Design Logo" id="logo">
    <hr>
<div id="mySidenav" class="sidenav">
  <a href="javascript:void(0)" class="closebtn" onclick="closeNav()">&times;</a>
    
    <nav id="mobilenav">
        <hr>
    <ul>
        <li><a href="index.html">Home</a></li><hr>
        <li><a href="portfolio.html">portfolio</a></li><hr>
        <li><a href="resume.html">resume</a></li><hr>
        <li><a href="contact.html">contact</a></li>
    </ul> 
        <hr>
    </nav>  
</div>
    
    <span onclick="openNav()">menu</span>
    <hr>
    <div id="main">
        <div class="row">
            <h3> Science Magazine</h3>
  <div class="column">
    <img src="img/Portfolio/magazine/magazine.jpg" alt="Front cover and first two pages of a magazine assignment I created in some of my earlier quarters in college. It is not based on a real company or magazine." onclick="myFunction(this);" class="expandingimgs">
  </div>
  <div class="column">
    <img src="img/Portfolio/magazine/middle pages.jpg" alt="Content in this magazine was reseached and typed out by me. Science is another thing I am passionate about outside of college, so getting the oppertunity to create this was fun for me." onclick="myFunction(this);" class="expandingimgs">
  </div>
  <div class="column">
    <img src="img/Portfolio/magazine/Magazine back.jpg" alt="My images are not original, but still I am proud of this piece." onclick="myFunction(this);" class="expandingimgs">
  </div>
</div>
<hr>
<div class="container">
  <span onclick="this.parentElement.style.display='none'" class="closebtn">&times;</span>

  <img id="expandedImg" style="width:100%" alt="">

  
  <div id="imgtext"></div>
</div>
        
        <div class="row">
            <h3> R&amp;B Electronics inc.</h3>
  <div class="column">
    <img src="img/Portfolio/Templates/Brochure Mockup1.jpg" alt="The inside of a brochures created for a teacher. This is not the typical company I had done assignments with previously. I wanted to get out of my comfort zone." onclick="myFunction(this);" class="expandingimgs">
  </div>
  <div class="column">
    <img src="img/Portfolio/Templates/Brochure Mockup2.jpg" alt="I am still proud of my design." onclick="myFunction(this);" class="expandingimgs">
  </div>
</div>
        <hr>
        <div class="container">
  <span onclick="this.parentElement.style.display='none'" class="closebtn">&times;</span>

  <img id="expandedImg" style="width:100%" alt="">

  
  <div id="imgtext"></div>
</div>
        
<div class="row">
            <h3> Watchtower Hero Comics</h3>
  <div class="column">
    <img src="img/Portfolio/standards manuel/Standardfrontcoverpgs23.jpg" alt="The inside of a brochures created for a teacher. This is not the typical company I had done assignments with previously. I wanted to get out of my comfort zone." onclick="myFunction(this);" class="expandingimgs">
  </div>
  <div class="column">
    <img src="img/Portfolio/standards manuel/Standardsmanuelpgs4+5.jpg" alt="I am still proud of my design." onclick="myFunction(this);" class="expandingimgs">
  </div>
 <div class="column">
    <img src="img/Portfolio/standards manuel/standardsmpgs67.jpg" alt="I am still proud of my design." onclick="myFunction(this);" class="expandingimgs">
  </div>
    <div class="column">
    <img src="img/Portfolio/standards manuel/standardsmpgs8+9.jpg" alt="I am still proud of my design." onclick="myFunction(this);" class="expandingimgs">
  </div>
    <div class="column">
    <img src="img/Portfolio/standards manuel/standardmanuel-back+pg1011.jpg" alt="I am still proud of my design." onclick="myFunction(this);" class="expandingimgs">
  </div>
    <div class="column">
    <img src="img/Portfolio/standards manuel/Untitled-2.jpg" alt="I am still proud of my design." onclick="myFunction(this);" class="expandingimgs">
  </div>
</div>
        <hr>
        <div class="container">
  <span onclick="this.parentElement.style.display='none'" class="closebtn">&times;</span>

  <img id="expandedImg" style="width:100%" alt="">

  
  <div id="imgtext"></div>
</div>
        
<div class="row">
            <h3> Blue mountain Extracts</h3>
  <div class="column">
    <img src="img/Portfolio/Blue mountain/mailer portfolio.jpg" alt="Out of all of the parts I made for this project, this is my favorite one. I wanted to keep the theme with my next piece." onclick="myFunction(this);" class="expandingimgs">
  </div>
  <div class="column">
    <img src="img/Portfolio/Blue mountain/Billboard-linkdin.jpg" alt="This is a Billboard advertising Blue Mountain Extracts. Making the art for these pieces was really fun and calming." onclick="myFunction(this);" class="expandingimgs">
  </div>
     <div class="column">
    <img src="img/Portfolio/Blue mountain/Magazine Ad.jpg" alt="This design is a full page magazine ad. It differs from the themes of my other pages, but I still think it looks nice." onclick="myFunction(this);" class="expandingimgs">
  </div>
</div>
        <hr>
        <div class="container">
  <span onclick="this.parentElement.style.display='none'" class="closebtn">&times;</span>

  <img id="expandedImg" style="width:100%" alt="">

  
  <div id="imgtext"></div>
</div>
        
        <div class="row">
            <h3> Single pieces</h3>
  <div class="column">
    <img src="img/Portfolio/kast iron.jpg" alt="This is a flyer made for Kast Iron Soda Works, my favorite place in the world. This flyer is to allow customers to see events that are going on a" onclick="myFunction(this);" class="expandingimgs">
  </div>
</div>
        <hr>
        <div class="container">
  <span onclick="this.parentElement.style.display='none'" class="closebtn">&times;</span>

  <img id="expandedImg" style="width:100%" alt="">

  
  <div id="imgtext"></div>
</div>
        </div><!--ends main-->
    
<footer>
    <p>330-831-6298</p>
    <p>[email protected]</p>
    <hr>
    <hr>
    <p>All work shown here was done as part of an educational assignment to complete my degree. The work was NOT commissioned or approved by the client or company shown. It does not represent the true identity of the client or company, except where noted.</p>
</footer>
    
</body>
</html>

I tried changing everything into a class, which just stops it from working. I changed all my ids to classes and in java i changed it from get element by id to get elements by class name. Instead of working nothing happened when you clicked on the images.
I also tried giving everything a unique ID and have multiple functions in the java script. Then instead of them all opening in the one spot up top they all opened in the bottom.

here is the javascript that I am working with

function myFunction(imgs) {
  
  var expandImg = document.getElementsByClassName("expandedImg");
 
  var imgText = document.getElementsByClassName("imgtext");
  
  expandImg.src = imgs.src;
  
  imgText.innerHTML = imgs.alt;
 
  expandImg.parentElement.style.display = "block";
}

Problem running PHP in a Django app with Apache

I have a web app running in Django which mainly consists of HTML and JavaScript (which is running with no issues) but recently a colleague created some additional content that is implemented PHP. The web page is served by Apache which is configured to accept .-h- files which it executes correctly. The problem I’m seeing is that there is an HTML file that generates a form with a few fields and a submit button which has the PHP file as it’s action like this:

<form id=“form1” action=“generator.php” method=“post”>
  .
  .
  .
  <input type=“submit” name=“submit” value=“Generate”>
</form>

The .php file can be simplified as:

<!DOCTYPE html>
<html lang=“en”>
<head>
  <meta http-equiv=“Content-Type” content=“text/html”; charset=utf-8” />
</head>
<body>
  <?php
    echo “Generating”
  ?>
</body>
</html>

When the submit (Generate) button is pressed, the network debugging window in the browser shows that generator.php is indeed loaded but the echo statement isn’t executed.

The PHP part of the application is non-negotiable much to my chagrin. If there needs to be more information please let me know.

Flask + React, run without `npm run build` every time

If I have the Flask App.py pointed to the frontend/build folder, the frontend works fine currently, but I have to rebuild with npm run build every time I make changes to frontend code

app = Flask(__name__, static_url_path='', static_folder='frontend/build')

I tried changing this to

app = Flask(__name__, static_url_path='', static_folder='frontend/public') where the source index.html resides, but this did not work

Is there a way I can run the React frontend without building it every time? For debugging purposes, not for release.

Thanks,

Shader error when trying to apply shadows

So I am trying to apply shadows to this shader I have but I get this error:

THREE.WebGLShader: gl.getShaderInfoLog() vertex ERROR: 0:229:
‘transformedNormal’ : undeclared identifier ERROR: 0:229:
‘inverseTransformDirection’ : no matching overloaded function found
ERROR: 0:229: ‘=’ : dimension mismatch ERROR: 0:229: ‘=’ : cannot
convert from ‘const mediump float’ to ‘highp 3-component vector of
float’ ERROR: 0:254: ‘mvPosition’ : redefinition

I assume there’s missing shader chunk for normals but I have no idea how to implement one as I am very very new to webgl and three I will put the code below can anyone guide me on how I can apply a fix for this?

shader module:

import { mergeUniforms } from './three/src/renderers/shaders/UniformsUtils.js'
import { UniformsLib } from './three/src/renderers/shaders/UniformsLib.js'

export default {


  uniforms: mergeUniforms([
    UniformsLib.lights,
    UniformsLib.fog,
  ]),


 

  vertexShader: `
    #include <common>
    #include <fog_pars_vertex>
    #include <shadowmap_pars_vertex>
    varying vec2 vUv;
uniform float time;

float N (vec2 st) { // https://thebookofshaders.com/10/
    return fract( sin( dot( st.xy, vec2(12.9898,78.233 ) ) ) *  43758.5453123);
}

float smoothNoise( vec2 ip ){ // https://www.youtube.com/watch?v=zXsWftRdsvU
  vec2 lv = fract( ip );
  vec2 id = floor( ip );
  
  lv = lv * lv * ( 3. - 2. * lv );
  
  float bl = N( id );
  float br = N( id + vec2( 1, 0 ));
  float b = mix( bl, br, lv.x );
  
  float tl = N( id + vec2( 0, 1 ));
  float tr = N( id + vec2( 1, 1 ));
  float t = mix( tl, tr, lv.x );
  
  return mix( b, t, lv.y );
}

    void main() {
      #include <begin_vertex>
      #include <project_vertex>
      #include <worldpos_vertex>
      #include <shadowmap_vertex>
      #include <fog_vertex>
      
       vUv = uv;
  float t = time * 2.;
  
  // VERTEX POSITION
  
  vec4 mvPosition = vec4( position, 1.0 );
  #ifdef USE_INSTANCING
    mvPosition = instanceMatrix * mvPosition;
  #endif
  
  // DISPLACEMENT
  
  float noise = smoothNoise(mvPosition.xz * 0.5 + vec2(0., t));
  noise = pow(noise * 0.5 + 0.5, 2.) * 2.;
  
  // here the displacement is made stronger on the blades tips.
  float dispPower = 1. - cos( uv.y * 3.1416 * 0.5 );
  
  float displacement = noise * ( 0.3 * dispPower );
  mvPosition.z -= displacement;
  
  //
  
  vec4 modelViewPosition = modelViewMatrix * mvPosition;
  gl_Position = projectionMatrix * modelViewPosition;
    }
  `,

  fragmentShader: `
    #include <common>
    #include <packing>
    #include <fog_pars_fragment>
    #include <bsdfs>
    #include <lights_pars_begin>
    #include <shadowmap_pars_fragment>
    #include <shadowmask_pars_fragment>
    #include <dithering_pars_fragment>
    varying vec2 vUv;
    void main() {
      // CHANGE THAT TO YOUR NEEDS
      // ------------------------------
      
       vec3 baseColor = vec3( 0.41, 1.0, 0.5 );
  float clarity = ( vUv.y * 0.875 ) + 0.125;
     
      vec3 shadowColor = vec3(0, 0, 0);
      float shadowPower = 0.5;
      // ------------------------------
      
      
      // it just mixes the shadow color with the frag color
      gl_FragColor = vec4( mix( (baseColor * clarity, 1), shadowColor, (1.0 - getShadowMask() ) * shadowPower), 1.0);
      
    
      #include <fog_fragment>
      #include <dithering_fragment>
    }
  `
};

and in the main I have this:

const uniforms = {
time: {
  value: 0
}
}

this.leavesMaterial = new THREE.ShaderMaterial({
...BasicCustomShader,
uniforms,
side: THREE.DoubleSide,

fog: true,
lights: true,
dithering: true,
});



const instanceNumber = 50000;
const dummy = new THREE.Object3D();

const geometry = new THREE.PlaneGeometry( 0.1, 1, 1, 4 );
geometry.translate( 0, 0.5, 0 ); // move grass blade geometry lowest point at 0.
geometry.receiveShadow = true;
const instancedMesh = new THREE.InstancedMesh( geometry, this.leavesMaterial, instanceNumber );
geometry.receiveShadow = true;
this.scene_.add( instancedMesh );

// Position and scale the grass blade instances randomly.

for ( let i=0 ; i<instanceNumber ; i++ ) {

dummy.position.set(
  ( Math.random() - 0.3 ) * 300,
  0,
  ( Math.random() - 0.3 ) * 300
);

dummy.scale.setScalar( 1.0 + Math.random() * 2.6 );
dummy.scale.y = 1.0 + Math.random() * 5.5;
dummy.rotation.y = Math.random() * Math.PI;

dummy.updateMatrix();
instancedMesh.setMatrixAt( i, dummy.matrix );

}


// animate loop

this.leavesMaterial.uniforms.time.value = clock.getElapsedTime();
this.leavesMaterial.uniformsNeedUpdate = true;

thank you for any help