Object3D.worldToLocal() returning incorrect vectors
See original GitHub issueDescribe the bug
Object3D.worldToLocal()
sometimes returns [NaN, NaN, NaN]
To Reproduce
Steps to reproduce the behavior:
Call Object3D.worldToLocal()
Code
function animate(t) {
requestAnimationFrame( animate );
let start = new THREE.Vector3(0,-10,0);
let end = new THREE.Vector3(5,-10,0);
let offset = new THREE.Vector3(0,0,0);
start.lerp(end, t / 1000).add(offset);
if (t < 1000) {
// Restuls in start = [NaN, NaN, NaN]
circle.worldToLocal(start);
console.log(start);
let matrixWorldCopy = new THREE.Matrix4().copy(circle.matrixWorld);
// These are different in the console.
console.log(matrixWorldCopy);
console.log(circle.matrixWorld);
}
circle.position.copy(start);
renderer.render( scene, camera );
stats.update();
}
Live example
Expected behavior
The input vector should be converted to the local coordinates of the Object3D.
Platform:
- Device: Desktop
- OS: Linux
- Browser: Chrome
- Three.js version: dev and latest release
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Object3D.worldToLocal() causes jittering - three.js forum
I found that the jittering was caused because worldToLocal() would alternate between first returning the offset of the mesh, then after copying that...
Read more >rotated child object looking at Camera, using lookaAt() and ...
Object3D.prototype.worldToLocal = function ( vector ) { if ( !this.__inverseMatrixWorld ) this.__inverseMatrixWorld = new THREE.Matrix4(); return vector.
Read more >Absolute Object3D.lookAt? #1752 - mrdoob/three.js - GitHub
if we were to support hierarchy lookAt(), there's a question of which up vector to use - the object's local up, the parent's...
Read more >Introduction to Computer Graphics, Section 5.3 -- Other Features
The return value from intersectObjects is an array of JavaScript objects. Each item in the array represents an intersection of the ray with...
Read more >three - npm
(bhickey); Renamed Object3D 's getChildByName() to ... (mrdoob); Optimized the PCF shadow map filtering to use vector comparisons.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Please no. This is an issue in your app. GitHub is for bugs and feature requests only. Please use the forum.
The example from the documentation uses requestAnimationFrame if you decide to change it there https://threejs.org/docs/index.html#manual/en/introduction/Creating-a-scene