Skip to content

Commit 3214e25

Browse files
authored
Merge pull request supermedium#288 from AriaMoKr/patch-1
Update intersection-spawn.js to resolve voxel placement issue
2 parents ecaeb50 + 159de0c commit 3214e25

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

scenes/aincraft/components/intersection-spawn.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,16 @@ AFRAME.registerComponent('intersection-spawn', {
1818
// Create element.
1919
const spawnEl = document.createElement('a-entity');
2020

21-
// Snap intersection point to grid and offset from center.
22-
spawnEl.setAttribute('position', evt.detail.intersection.point);
21+
// Get normal of the face of intersection and scale it down a bit
22+
var normal = evt.detail.intersection.face.normal;
23+
normal.multiplyScalar(0.25);
24+
25+
// Get the position of the intersection and add our scaled normal
26+
var position = evt.detail.intersection.point;
27+
position.add(normal);
28+
29+
// Snap new position to grid and offset from center.
30+
spawnEl.setAttribute('position', position);
2331

2432
// Set components and properties.
2533
Object.keys(data).forEach(name => {

0 commit comments

Comments
 (0)