I have a environment map in my scene
sceneTarget.environment = envMap;
sceneTarget.background = envMap;
so my question is : how to turn off the environment ?
also I don’t want to condition my RGBELoader() with a if(loadAnEnvMap){// ... ...}
Blancer.com Tutorials and projects
Freelance Projects, Design and Programming Tutorials
Category Added in a WPeMatico Campaign
I have a environment map in my scene
sceneTarget.environment = envMap;
sceneTarget.background = envMap;
so my question is : how to turn off the environment ?
also I don’t want to condition my RGBELoader() with a if(loadAnEnvMap){// ... ...}
regardless of knowledge about Kofax, please say anything wrong part of code you can find.
I’m beginner at javascript, so I really glad if I cat get some advice about this problem.
function callKofaxRoboRestApi() {
var endpointUrl = '**rest api url**';
var requestParams = {
'username': 'my user name',
'password': 'my password'
};
const accessToken = "**my token**";
var headers = {
'Authorization': 'Bearer ' + accessToken,
'Content-Type': 'application/json',
};
var options = {
'method': 'post',
'headers': headers,
'payload': JSON.stringify(requestParams)
};
var data = {
'entry': {
'group': {
'name': '**robot name**',
'type': 'robot'
}
}
};
var payload = JSON.stringify(data);
var response = UrlFetchApp.fetch(endpointUrl, options);
var responseData = JSON.parse(response.getContentText());
if (response.getResponseCode() == 200) {
Logger.log('success');
} else {
Logger.log('looser');
}
this code return with ‘Exeption: Address unavailable:rest api url/callkofaxRoboRestApi @kofax.documatation gs:38
Is there something wrong? or skipped code?
I am using Node.js 18.16.0 x64 on Windows 10 Pro 22H2 x64, I just encountered a strange bug that prevents me from using Node.js after importing readline.
I needed a way to get user input using only built-in and absolutely not any library that needs to be installed.
Any code that requires readline will trigger the bug.
I copy-pasted code from this answer:
const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout,
});
readline.question(`What's your name?`, name => {
console.log(`Hi ${name}!`);
readline.close();
});
I get this:
Welcome to Node.js v18.16.0.
Type ".help" for more information.
> const readline = require('readline').createInterface({
... input: process.stdin,
... output: process.stdout,
... });
undefined
>
>
rreeaaddlliinnee..qquueessttiioonn((``WWhhaatt''ss yyoouurr nnaammee??``,, nnaammee ==>> {{
...
ccoonnssoollee..lloogg((``HHii $${{nnaammee}}!!``));;
...
rreeaaddlliinnee..cclloossee(());;
...
}}));;
Then after I press Enter node.exe immediately closes itself.
I also tried this
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
function readLineAsync(message) {
return new Promise((resolve, reject) => {
rl.question(message, (answer) => {
resolve(answer);
});
});
}
// Leverages Node.js' awesome async/await functionality
async function demoSynchronousPrompt() {
var promptInput = await readLineAsync("Give me some input >");
console.log("Won't be executed until promptInput is received", promptInput);
rl.close();
}
Welcome to Node.js v18.16.0.
Type ".help" for more information.
> const readline = require('readline');
solve(answer);
undefined
>
> const rl = readline.createInterface({
... input: process.stdin,
... output: process.stdout
... });
undefined
>
>
ffuunnccttiioonn rreeaaddLLiinneeAAssyynncc((mmeessssaaggee)) {{
...
rreettuurrnn nneeww PPrroommiissee((((rreessoollvvee,, rreejjeecctt)) ==>> {{
...
rrll..qquueessttiioonn((mmeessssaaggee,, ((aannsswweerr)) ==>> {{
...
rree }}));;
...
}}));;
...
}}
undefined
>
>
//// LLeevveerraaggeess NNooddee..jjss'' aawweessoommee aassyynncc//aawwaaiitt ffuunnccttiioonnaalliittyy
undefined
>
aassyynncc ffuunnccttiioonn ddeemmooSSyynncchhrroonnoouussPPrroommpptt(()) {{
...
vvaarr pprroommppttIInnppuutt == aawwaaiitt rreeaaddLLiinneeAAssyynncc((""GGiivvee mmee ssoommee iinnppuutt >>""));;
...
ccoonnssoollee..lloogg((""WWoonn''tt bbee eexxeeccuutteedd uunnttiill pprroommppttIInnppuutt iiss rreecceeiivveedd"",, pprroommppttIInnppuutt));;
...
rrll..cclloossee(());;
...
}}
Same thing happens.
What is going on?
there is a way to add new keywords to javascript ؟. I want to create own version of js to make do a specific things in a few words
add new words to javascript
I have created a User in which I have used a hook and gives it component “id” This is my User component And here I have imported it in App.js This is my App.js and This is part of Navbar.js This is Navbar part I have tried so many times but no result has camehere you can see that I have written “id” in URL but nothing is happened
When adding components inside my page components i keep getting this error: “Failed to resolve import {url} from {url} Does this file exits”
page component
import Header from "~src/ui/components/organisms/Header/Header";
import $ from "./HomePage.module.scss";
const HomePage: React.FunctionComponent = () => {
document.title = "Home";
return (
<>
<div className={$.wrapper}>
<Header type="home" />
</div>
</>
);
};
export default HomePage;
component
import Navbar from "../../molecules/Navbar/Navbar";
import HeaderMainContent from "../../molecules/HeaderMainContent/HeaderMainContent";
import HeaderDetailContent from "../../molecules/HeaderDetailContent/HeaderDetailContent";
import $ from "./Header.module.scss";
type Props = {
type: "home" | "detail";
};
const Header = ({ type }: Props) => {
return (
<header className={`${type === "home" ? $.header_long : $.header_short}`}>
<div className={$.wrapper}>
<Navbar type={type === "home" ? "home" : "detail"} />
{type === "home" && <HeaderMainContent />}
{type === "detail" && <HeaderDetailContent />}
</div>
</header>
);
};
export default Header;
Folder structure
Screenshot
I also tried adding a different component to the page, but this gave the same error.
Uncaught TypeError: Cannot read properties of null (reading 'style') at HTMLAnchorElement.animateit animateit @
This is my code:
`(function () {
const aLink = document.querySelectorAll('a');
const cursor = document.querySelector('.cursor');
const animateit = function (e) {
const span = this.querySelector('span');
const { offsetX: x, offsetY: y } = e,
{ offsetWidth: width, offsetHeight: height } = this,
move = 35,
xMove = x / width * (move * 2) - move,
yMove = y / height * (move * 2) - move;
span.style.transform = `translate(${xMove}px, ${yMove}px)`;
if (e.type === 'mouseleave') span.style.transform = '';
};
aLink.forEach(b => b.addEventListener('mousemove', animateit));
aLink.forEach(b => b.addEventListener('mouseleave', animateit));
})();`
I was expectiong to just work normally… But it work sbut I dont now what has happened but it shows that style is null.
I am creating a React site that retrieves web-scraping data from a third-party site. My puppeteer script runs fine as a .js file, but when I add it to my server using Express & Axios, it seemingly does not go to the page and cannot execute the following lines of code. (My code is a lot longer so I put a shorter example here:)
puppeteer.js // works fine
const puppeter = require('puppeteer');
(async () => {
const browser = await puppeter.launch({headless: true});
const page = await browser.newPage();
await page.goto(`https://www.scrapethissite.com/lessons/`);
let header = "";
header = await page.$eval( "#header", el => el.textContent.trim());
console.log(header)
await browser.close();
})();
index.js // does not work
const puppeteer = require('puppeteer');
app.get('/', async (req, res) => {
const browser = await puppeter.launch({headless: true});
const page = await browser.newPage();
await page.goto(`https://www.scrapethissite.com/lessons/`);
let header = "";
header = await page.$eval( "#header", el => el.textContent.trim());
console.log(header)
await browser.close();
});
The server code either outputs the header in the console as ” ” or when I modify it slightly to remove the initialization of the variable “header” and just have the line: let header = await page.$eval( "#header", el => el.textContent.trim());
I get an “UnhandledPromiseRejectionWarning.” The script works fine by itself, but when I use it in the server I start to get errors. Is this a problem with using Puppeteer in Axios or do I need to modify my code so it can handle the promises better?
My vue production build (built with npm run build
) delivers a styled (the background color from my css is applied) blank page.
If I check the page source I see that the js code is properly loaded, but my app
div is still empty.
What can be the source of that?
I am using React
and socket.io
to transmit a message to all the connected devices. Please find the mistake. Any help is appreciated.
App.js
import { useRef } from "react";
import { io } from "socket.io-client";
const socket = io("http://localhost:4000");
const App = () => {
const messege = useRef(null);
//socket functions
socket.on("connect", () => {
console.log("connected: " + socket.id);
});
socket.on("recieve", (msg) => {
console.log(msg);
});
const send = () => {
const message = messege.current.value;
socket.emit("message", message);
};
return (
<div>
<input type="text" placeholder="Message" ref={messege} />
<button onClick={send}>Send</button>
</div>
);
};
export default App;
Server.js
const { Server } = require("socket.io");
const io = new Server(4000, {
cors: {
origin: ["http://localhost:5173"],
},
});
io.on("connection", (socket) => {
console.log(`connected with id: ${socket.id}`);
socket.on("message", (msg) => {
console.log(msg);
socket.emit("recieve", msg);
});
});
It only prints the message only to the emitter client(not other connected client).
I have an email component that uses a form and rich text editor. All the data is stored in a state variable formData. I want to access this for the purpose of dispatching an RTK action. Basically, when the user leaves the component without submitting the form, I dispatch an action that creates a draft email with the latest form data.
useEffect(() => {
return () => {
dispatch(draftCampaign(formData));
};
}, []);
This creates a draft email, however, all the fields are empty since the formData I’m passing is only the initial one, not the submitted one.
My formData:
const [smsCount, setSmsCount] = useState(0);
const [formData, setFormData] = useState({
type: "SMS",
threadName: "",
from: "Qmeter or 2354",
customerName: "",
dropdownOption: "QNP-102 Template",
to: [],
startSending: new Date().toLocaleDateString(),
smsCount: smsCount,
});
const {
threadName,
from,
customerName,
dropdownOption,
startSending,
editorContent,
} = formData;
const onChange = (e) => {
setFormData((prevState) => ({
...prevState,
[e.target.name]: e.target.value,
smsCount: smsCount,
}));
};
const onEditorChange = (content, delta, source, editor) => {
setFormData((prevState) => ({
...prevState,
editorContent: content,
}));
I have component TopPage
and ImagePreview
and FileUploader
At first FileUploader
is shown,
FileUploader changed the fileObj state of TopPage.
then,FileUploader disappeared and ImagePreview appreas, and at the same time useEffect() is called, but at this time, there is no ImagePreviewRef
.
When useState is called , both component re-render and useEffect are called.
The order is useEffect -> re-render?
If so, how can I solve this problem?
const TopPage = (props) =>{
const [fileObj, setFileObj ] = useState();
useEffect(() =>{
imagePreviewRef.current.loadPic(fileObj);
},[fileObj]);
if (fileObj){
return <ImagePreview ref={imagePreviewRef}></ImagePreview>
}
else {
return <FileUploader SetFileObj=setFileObj></FileUploader>
}
}
const FileUploader = (props) => {
// props.setFileObj() is called here.
}
const ImagePreview = (props) => {
const loadPic = () =>{// loadpicture to canvas }
}
I need to send (upload) an image file from the web client (html+javascript) to the server (java/springboot) that will then store it.
On the client side I have created a form, of course
<form action="" name="missionForm" method="post" enctype="multipart/form-data" novalidate>
<fieldset>
<div class="field">
<label>
<span style="font-weight:bold">Mission name</span>
<input data-validate-length-range="3" name="name" id="name" required="required" />
</label>
</div>
<div class="field">
<label>
<span>Mission image (png):</span>
<input type='file' class='optional' name='loadImage' id='loadImage' accept='image/png'>
</label>
</div>
</fieldset>
</form>
The form is read below via javascript, who sends the request via fetch
document.forms[0].onsubmit = function(e){
e.preventDefault();
var imageFile = document.forms['missionForm']['loadImage'].files[0];
const test = fetch(url+"/api/saveImage", {
method: 'POST',
body: imageFile,
});
}
On the server side (Java / Springboot), I have created the following method in the Controller class
@PostMapping(value="/api/saveImage")
public void saveImage(@RequestParam("file") MultipartFile multipartFile) throws SQLException{
String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename());
System.out.println("filename is "+fileName);
}
When I launch this, I get error 500 on the client.
On the server side, I get the following error “org.springframework.web.multipart.MultipartException: Current request is not a multipart request”
I do not understand why. Can anybody help? I am sure I am missing something silly here.
Thanks!
I tried “forcing” the content-type in the fetch request, but I only get a different error
const test = fetch(url+"/api/saveImage", {
method: 'POST',
headers: {'Content-Type': 'multipart/form-data',},
body: imageFile,
});
and the error is “org.apache.tomcat.util.http.fileupload.FileUploadException: the request was rejected because no multipart boundary was found”
I am using Tabulator in Angular.
I have added my own processing in headerClick, but I don’t know how to write the test code for that.
column: any[] = [
{title:"Name",
field:"name",
width:150,
headerClick: (e:any, column:any) => {
// here
}
},
];
private drawTable(): any {
var tabulator = new Tabulator(this.tab, {
data: this.tableData,
reactiveData:true,
columns: this.column,
layout: 'fitData',
});
document.getElementById('my-tabular-table').appendChild(this.tab);
return tabulator
}
If anyone knows, I would like to know.
I am trying to introduce a function to a .java class file aircraft mod, that will have the effect of multiplying the speed calculated via the ‘flightmodel (FM) function. The mod is for the computer game ‘il2-1946’
This is how the speed is calculated in the ‘flightmodel class’.
public class FlightModelMain extends FMMath
{
public float getSpeedKMH()
{
return (float)(Vflow.x * 3.6000000000000001D);
}
public float getSpeed()
{
return (float)Vflow.x;
}
public void getSpeed(Vector3d vector3d)
{
vector3d.set(Vair);
}
public float getVertSpeed()
{
return (float)Vair.z;
}
type here
The speed of the actual aircraft in game is calculated the the ‘vector3d’ object in the above code. I have experimented with some Java modifications to try to implement the multiplier effect in game in the aircraft.class as shown below.
The vector 3d calculation is based off of the flight model parameters, but despite trying to push the parameters of flight model as far as possible, I seem to be running into an ‘in-game’ speed limit.
So I basically want to create a code that will take the calculated speed for the aircraft from the flight model, then apply a multiplier to that speed in the class file that the game will then use as the new speed for that aircraft only.
public void applySpeedMultiplier(float multiplier)
{
float currentSpeedKMH = ((FlightModelMain) super.FM).getSpeedKMH();
float newSpeedKMH = currentSpeedKMH * (2.0F); //put as (2.00F) for doubling? (0.5F) half
((FlightModelMainMultiplier) super.FM).setSpeedKMH(newSpeedKMH);
}
public void applySpeedMultiplier(float multiplier) {
Vector3d speedVector = new Vector3d();
flightModel.getSpeed(speedVector);
float currentSpeedKMH = (float) (speedVector.length() * 3.6);
float newSpeedKMH = currentSpeedKMH * multiplier;
flightModel.setSpeedKMH(newSpeedKMH);
}
}
I also made an extension to the ‘FlightModelMain’ containing the speed code, that would allow me to add any extra lines required in the .fm. javapackage
package com.maddox.il2.fm;
import com.maddox.JGP.*;
import com.maddox.il2.ai.*;
import com.maddox.il2.engine.*;
import com.maddox.il2.game.Main;
import com.maddox.il2.game.Mission;
import com.maddox.il2.objects.air.*;
import com.maddox.il2.objects.effects.Explosions;
import com.maddox.il2.objects.sounds.Voice;
import com.maddox.rts.*;
import java.io.*;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.StringTokenizer;
// Referenced classes of package com.maddox.il2.fm:
// FMMath, FlightModel, Controls, EnginesInterface,
// Mass, AircraftState, Squares, Supersonic,
// Arm, Gear, Polares, RealFlightModel,
// Atmosphere, Turret, Motor, Autopilotage
public class FlightModelMainMultiplier extends FlightModelMain
{
public FlightModelMainMultiplier(String arg0) {
super(arg0);
// TODO Auto-generated constructor stub
}
public void setSpeedKMH(float setSpeedKMH) {
Vflow.x = setSpeedKMH / 3.6f;
}
}
However, it does not appear to be having an effect in the game or equally causing the game to crash.
An error that I am finding in Eclipse is ‘Cannot cast from FlightModel to FlightModelMainMultiplier’, despite trying this code instead.
public void applySpeedMultiplier(float multiplier)
{
if (super.FM instanceof FlightModelMainMultiplier) {
float currentSpeedKMH = ((FlightModelMain) super.FM).getSpeedKMH();
float newSpeedKMH = currentSpeedKMH * multiplier;
((FlightModelMainMultiplier) super.FM).setSpeedKMH(newSpeedKMH);
} else if (super.FM instanceof FlightModelMain) {
float currentSpeedKMH = ((FlightModelMain) super.FM).getSpeedKMH();
float newSpeedKMH = currentSpeedKMH * multiplier;
((FlightModelMain) super.FM).setSpeedKMH(newSpeedKMH);
} else {
// Handle the case where super.FM is not an instance of FlightModelMain or FlightModelMainMultiplier
System.out.println("Cannot apply speed multiplier: super.FM is not an instance of FlightModelMain or FlightModelMainMultiplier");
}
}
What is the best way to adjust my code so can implement the speed multiplier function?