raycasting

Three.js Raycaster not detecting scene mesh

别等时光非礼了梦想. 提交于 2019-12-11 09:57:10
问题 I am using three.js r67 in Chrome Version 35.0.1916.153 m I am attempting to intersect some custom meshes that I have created in my scene. The raycaster does not appear to be registering the meshes although they exist within scene.children . Mesh creation code: if (modelVertices != null && modelVertices.length >= 3) { triangles = THREE.Shape.Utils.triangulateShape ( modelVertices, holes ); for( var i = 0; i < triangles.length; i++ ){ modelGeometry.faces.push( new THREE.Face3( triangles[i][0],

Three.JS- Detecting intersection in Collada (Ray Casting)

大憨熊 提交于 2019-12-11 07:50:00
问题 There is a function in my prototype system which detects intersections when you click on a Collada file. The intersect function is below: function Intersectfun ( event ) { 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 ); var toIntersect = []; THREE.SceneUtils.traverseHierarchy(scene, function (child) { if (child instanceof THREE.Mesh) { toIntersect.push(child); } }); //

Raycasting and container in Three.js

依然范特西╮ 提交于 2019-12-11 06:56:11
问题 I have been struggling with issues concerning raycasting on small circlegeometries on a sphere . I know raycasting can't be done with sprites and this is why I use circlegeometries, but it doesn't work all the time, and moreover the raycasting doesn't always work on circles but sometimes around them as well. Does anybody have an idea ? Here is a JSBin to show you basically Edit : I updated my previous version of JSBin, you can click any circleGeometries it will work here , run it with output

How to determine thickness vs width? (Using Raycasting)

别来无恙 提交于 2019-12-11 05:26:29
问题 Visual aids Thickness vs width: here Please view the short gif. Thickness here is different from width as there are multiple walls as there are outer and inner cylinders. Thickness is the measurement of the distance between the outer/inner wall of any side of the cylinder where as thickness is the distance from one end to the other encompassing the hollow space between. Quick synopsis on the gifs provided -On every click the origin point (blue) and destination point (orange) orbs are created

Moved coordinates of the scene when DOM element with renderer is not at the top of the screen

时光毁灭记忆、已成空白 提交于 2019-12-11 04:08:14
问题 I encountered a problem, where I have a three.js scene in angular custom directive, which is in the view. A the top, I have a navigation bar which is always there to provide navigatin and switching between wiews (nothing abnormal yet). Lets say I set up a simple scene (as many times before, but not under the angular), I put a simple cube in the scene, set up camera rotation and other basic stuff. Problem starts when I try to hit that object on mouse down (raycaster works perfectly) but it

2D bouncing formula doesn't work properly

心已入冬 提交于 2019-12-11 02:33:46
问题 I am new to unity, and i am trying to create a bouncing ball, so i've did many researches about bouncing realted physics and i found a formula : Formula: -2*(V dot N)*N + V Where V is the velocity vector and N is the normal of the surface on which the ball will bounce Here is my script : using UnityEngine; using System.Collections; public class BallPhysics : MonoBehaviour { void Start () { rigidbody2D.velocity =new Vector2 (-1,-3); } // Update is called once per frame void Update () { } void

How to determine point/time of intersection for ray hitting a moving triangle?

筅森魡賤 提交于 2019-12-10 11:35:19
问题 I have a deforming triangle, whose vertices all move between t0 and t1. I am shooting a ray toward the triangle. The ray doesn't hit the triangle at t0 or t1, but somewhere within that interval of time. How do I calculate the exact point of intersection for the ray, and at what time (between t0 and t1) that the ray hits the triangle? Here's an image that hopefully helps illustrate the question better: 来源: https://stackoverflow.com/questions/43771759/how-to-determine-point-time-of-intersection

How do I 'wrap' a plane over a sphere with three.js?

杀马特。学长 韩版系。学妹 提交于 2019-12-09 14:09:19
问题 I am relatively new to three.js and am trying to position and manipulate a plane object to have the effect of laying over the surface of a sphere object (or any for that matter), so that the plane takes the form of the object surface. The intention is to be able to move the plane on the surface later on. I position the plane in front of the sphere and index through the plane's vertices casting a ray towards the sphere to detect the intersection with the sphere. I then try to change the z

Three.js raycast produces empty intersects array

☆樱花仙子☆ 提交于 2019-12-09 07:08:29
问题 I'm trying to detect when the user has clicked on a specific cube in my 3d scene I've seen a few similar questions but none seem to have quite the same problem as me. I have a 3D Array of cubes which populates and displays fine but when my mouse down function is called, the intersect array is always empty - I can't see what's wrong and would appreciate any help. My renderer is set up like so: function setupRenderer() { renderer = new THREE.WebGLRenderer({antialias: true}); renderer.setSize

Unity C# Raycast Mouse Click

坚强是说给别人听的谎言 提交于 2019-12-08 09:37:49
问题 I have literally spent all day researching the light out of Unity C# Raycasting and I have nothing to show for it. I have studied tutorials, online resources, stack overflow questions, and have even word for word copied script in hopes that Unity would finally recognize all my attempts to actually use a Raycast. Here is an example of a script using Raycast that simply won't work for me: if (mouseDown) { print ("mouse is down"); Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);