#Upgrading an old Three.js code to the latest version
1 messages · Page 1 of 1 (latest)
So i have another problem
geometry.attributes.position.array doesn't seem to have a .push() method
also, can I push a Vector3 to the array? Or does it need to be a plain array?
it is a typed array, thats why
you need to know how much data will be there, and create an array of the right size
probably just look it up in https://threejs.org/examples, look for points demos
oh okay
Alright so after a bit of looking here and there I settled on ```js
camera.position.setX(top * 0.0002);
camera.position.setZ(top * -0.01);
camera.rotation.setY(top * -0.0002);
To move the stars, however, the setZ method causes some unexpected behaviour that can be best explained by the gif below:
I also created a post about it yesterday, when I was seeing the same behavior but wasn't able to pin-point which line actually caused it: https://discord.com/channels/685241246557667386/1148609034937708554
what is unexpected about it
when I scroll for the first time, the stars do not need to look animated, they just seem to change their position by a huge amount that you can't even see them going inwards
probably because your starting position is vastly different from what the code changes it to
btw i updated the code to set the arg of .setZ(top * -0.01) [it was -0.0001 before, which ins't my code]
I added a camera.position.setZ(0) at the top
shouldn't that not cause it?
1 log the actual top value
2 set xyz not just z
what is the "actual" top value? On the top of the page, the value seems to be 8
if you log it, you will know what the scroll starts from
yup, its 8
well that's setZ(-0.08) not (0)
Just to be sure, is the value of top always gonna be 8 on the top on all machines and viewport sizes? This is the line that gets the top value:
const top = document.body.getBoundingClientRect().top;
nobody knows that but you 🤷🏻
I added this line; but it still doesn't work
camera.position.setZ(-0.08);
I think you had your 3 pings already 😄