raycasting

Physics.Raycast not hit sometimes

人盡茶涼 提交于 2019-12-13 04:50:30
问题 I have a very strange Raycast behaviour. Theare are 2 moving objects in my game. I use raycast in the Update method to find out if the second object is near. But sometimes raycast return false in obviously "true" situations. Can somebody help me to fix this issue? Thanks a lot! // Returns false, but should be true var middle = Physics.Raycast(Car.SensorPointRight.position, Car.CarObject.right, out middleHitsInfo, (DistanceBetweenPaths - _carColliderOffset)); if (IsUserCar) DebugHepler.Ray(Car

Improving speed with Ray-cast in UE4

假如想象 提交于 2019-12-13 03:55:18
问题 I am currently developing a lidar sensor model using Ray-cast. A 16 channel sensor rotating at 10Hz should produce 300000 points. I can use 300000 Ray-cast operations to get this result but the performance is very weak (frame rate falls to 8 when motion is given to the sensor). Is there any other better way or algorithms I can use? Requirement : To scan 360 degrees: Horizontal -25 to 15 degrees: Vertical 300000 scans Here is what I'm using: for (auto i = 0u; i < 3125; ++i){ for (auto Channel

Finding UV coordinates of a point on material rendered on 3D cube in threejs

天大地大妈咪最大 提交于 2019-12-13 03:44:18
问题 I want to calculate the UV co-ordinates of a single point of a material rendered on 3D cube. I am finding the mouse pointer intersection with the camera ray using THREE.Raycaster as: mouse.x = (event.clientX / window.innerWidth) * 2 - 1; mouse.y = -(event.clientY / window.innerHeight) * 2 + 1; var vector = new THREE.Vector3(mouse.x, mouse.y, 1); vector.unproject(camera); var raycaster = new THREE.Raycaster(camera.position, vector.sub(camera.position).normalize()); var intersects = raycaster

Raycasting doesn't give any intersections

孤者浪人 提交于 2019-12-13 02:59:14
问题 I'm trying to to use raycasting to get the intersection between a sphere and a ray, both located at the center of the scene. It's a pretty simple scenario but I'm not being able to make it work. Relevant code: // renderer, camera, etc... var material = new THREE.MeshStandardMaterial(); material.opacity = 0.25; material.transparent = true; sphere = new THREE.Mesh(new THREE.SphereGeometry(100, 32, 32), material); scene.add(sphere); var start = new THREE.Vector3(0, 0, 0); var direction = new

three.js 2D mouseclick to 3d co-ordinates using raycaster

≡放荡痞女 提交于 2019-12-13 02:39:42
问题 I'm trying to draw 2D objects in z=0 plane, now I want to convert screen mouse co-ordinates into 3D world co-ordinates. I used camera below: camera = new THREE.OrthographicCamera(SCREEN_WIDTH / - 2, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, SCREEN_HEIGHT / - 2, NEAR, FAR ); camera.position.set(0,0,500); camera.lookAt(scene.position); container = document.getElementById( 'ThreeJS' ); container.appendChild( renderer.domElement ); var floorGeometry = new THREE.PlaneGeometry(1000, 1000, 10, 10); var

Three.js raycaster intersection

独自空忆成欢 提交于 2019-12-12 16:15:56
问题 I wrote the code below to get intersection point with a 3d shape. It works well but if there are two intersection point with shape, it returns me only the farest intersection while I need the nearest intersection with the shape. How can I do to get the nearest intersection? /*here I create a cube*/ var geometry0 = new THREE.Geometry() geometry0.vertices = [new THREE.Vector3(0.5, -0.5, 0.5), new THREE.Vector3(-0.5, -0.5, 0.5), new THREE.Vector3(-0.5, -0.5, -0.5), new THREE.Vector3(0.5, -0.5,

Clickable particles in three.js PointCloud

可紊 提交于 2019-12-12 10:43:30
问题 I am visualizing 3d data points (which I read in via a csv-file) with the help of three.js. I want to click on points in that PointCloud to show other measurement data for those specific points. According to examples I found this is possible apparently but I don't get it working. I have the following code (basically from those examples): function onDocumentMouseMove(e) { mouseVector.x = 2 * (e.clientX / containerWidth) - 1; mouseVector.y = 1 - 2 * (e.clientY / containerHeight); var vector =

three.js: sceneLoader & rays issue

时间秒杀一切 提交于 2019-12-12 03:53:55
问题 Issue: Rays doesn't work with models loaded via sceneLoader Problem explanation: I used to load my model with JSONLoader, but needed to import all information of scene, so I tried sceneLoader(). Everything loads fine, but raycasters intersectObject() function doesn't find intersections. Old version with JSONLoader (cca line 350): http://golem.fjfi.cvut.cz/virtual/matusu/BakalarkaMM/Bakalarka.html New version with sceneLoader (cca line 900): https://www.dropbox.com/s/ikpobra4bo5iz2y/BMM.html

Raycasting against 'subscenes' in three.js

半世苍凉 提交于 2019-12-12 01:38:31
问题 So I am working with the webgl_interactive_cubes.html in the three.js examples, and I have a relatively simple question: Is it possible to test for intersection of a ray with the children of an object. for example, if I do something like: for ( var i = 0; i < 2000; i ++ ) { var object = new THREE.Mesh( geometry, new THREE.MeshLambertMaterial( { color: Math.random() * 0xffffff } ) ); scene.add( object ); } When I call var intersects = raycaster.intersectObjects( scene.children ); It will

Threejs, understanding raycaster's intersectd object coordinates

本小妞迷上赌 提交于 2019-12-11 14:36:03
问题 Hello, I have one doubt: I have implemented a raycaster and I have been testing it manually, however I do not know why on most of the clicks which I made on the 3D model, it did not get the intersection point. First I will show you the points I clicked on, then the points which were logged in the web console then the code I have implemented and finally the web structure: I have clicked on those eight points: And the results are: []length: 0__proto__: Array(0) []length: 0__proto__: Array(0) [