Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- placePoint: function(event, rect, positions, count, scene) {
- if (input["LMB"] && input["KeyV"]) {
- var plane = new THREE.Plane(new THREE.Vector3(0, 1, 0), 0);
- var mouse = new THREE.Vector2();
- var raycaster = new THREE.Raycaster();
- mouse.x = ((event.clientX - rect.left) / rect.width ) * 2 - 1;
- mouse.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
- raycaster.setFromCamera(mouse, camera);
- var intersection = raycaster.ray.intersectPlane(plane);
- var dotGeometry = new THREE.Geometry();
- dotGeometry.vertices.push(new THREE.Vector3(intersection.x, 0, intersection.z));
- var dotMaterial = new THREE.PointsMaterial({size: 3, sizeAttenuation: false});
- var dot = new THREE.Points(dotGeometry, dotMaterial);
- scene.add(dot);
- positions[count.c * 3 + 0] = intersection.x;
- positions[count.c * 3 + 1] = intersection.y;
- positions[count.c * 3 + 2] = intersection.z;
- count.c++;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement