Undefinend values in planeBufferGeometry causes raycaster to return empty
See original GitHub issueDescription of the problem
I create a planeBufferGeometry and fill it like so:
var positions = new Float32Array(grid.elevations.length * 3).fill(undefined);
for(stuff){
positions[i * 3 + 0] = xpos ;
positions[i * 3 + 1] = ypos;
positions[i * 3 + 2] = (isNaN(zpos)) ? undefined : zpos;
}
var geometry = new THREE.PlaneBufferGeometry();
geometry.addAttribute('position', new THREE.BufferAttribute(positions, 3));
var terrainMesh = new THREE.Mesh(geometry, material);
terrainMesh.name = myMesh;
scene.add(terrainMesh)
then raycast using:
raycaster.setFromCamera(mouse, camera);
var intersects = raycaster.intersectObject(scene.getObjectByName('myMesh'));
intersects is always empty. If I do this:
vertices[i * 3 + 2] = (isNaN(zpos)) ? -1: zpos;
I get a result;
Currently I’m thinking best work around is making a second planeBufferGeometry and assign the undefined values a -1. Then handle if(z = -1) . This position array can get rather large though and having another one is not ideal.
Three.js version
- Dev
- [ X] r84
- …
Browser
- All of them
- Chrome
- Firefox
- Internet Explorer
OS
- All of them
- Windows
- macOS
- Linux
- Android
- iOS
Hardware Requirements (graphics card, VR Device, …)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:19 (8 by maintainers)
Top Results From Across the Web
three.js - Raycaster.intersectObjects() not returning anything?
My Solution. The function below takes an empty array ( intersects ). It searches each child in scene for THREE Group objects and...
Read more >three.js - Apple Open Source
isInteger = function ( value ) { return typeof value === 'number' ... target === null ) { throw new TypeError( 'Cannot convert...
Read more >https://network.aia.org/HigherLogic/System/Downloa...
subVectors(b.center,this.origin);var d=a.dot(this.direction),e=a.dot(a)-d*d,g=b.radius*b.radius;if(e>g)return null;g=Math.sqrt(g-e);e=d-g;d+=g;return ...
Read more >third_party/js/three.js/three.js - geovelo - Git at Google
value : function ( target ) {. 'use strict';. if ( target === undefined || target === null ) {. throw new TypeError(...
Read more >JavaScript 3D library
ColorKeyframeTrack( trackName, times, values ); return new THREE.AnimationClip( null, duration, [ track ] ); }; ... function three.CompressedTexture ( mipmaps, ...
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 Free
Top 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
@kpetrow what I am saying is that if you are (obviously) not happy with what 3js puts into boundingSphere/Box, you could do this:
instead of relying on geometry.computeBoundingSphere/Box calls. this will allow you to bypass the checks that you are saying are in the way of finding intersections, right?
that might be BufferGeometry. if you are not happy with (0,0,0)-(0,0,0)-(0,0,0) triangles in PlaneBufferGeometry, you can create your own geometry avoiding the need to do something about triangles with missing data - by not creating these triangles in the 1st place.