From 2e880e9aab1e430ad4729ce596d69a7a6b4a1a80 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 2 Sep 2015 16:29:15 -0700 Subject: [PATCH] change how pick-ray direction is calculated --- examples/voxels.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/voxels.js b/examples/voxels.js index c5564fe391..547585198c 100644 --- a/examples/voxels.js +++ b/examples/voxels.js @@ -356,8 +356,9 @@ function attemptVoxelChangeForEntity(entityID, pickRayDir, intersectionLocation) return false; } + var voxelOrigin = Entities.worldCoordsToVoxelCoords(entityID, Vec3.subtract(intersectionLocation, pickRayDir)); var voxelPosition = Entities.worldCoordsToVoxelCoords(entityID, intersectionLocation); - var pickRayDirInVoxelSpace = Entities.localCoordsToVoxelCoords(entityID, pickRayDir); + var pickRayDirInVoxelSpace = Vec3.subtract(voxelPosition, voxelOrigin); pickRayDirInVoxelSpace = Vec3.normalize(pickRayDirInVoxelSpace); var doAdd = addingVoxels; @@ -409,8 +410,6 @@ function attemptVoxelChange(pickRayDir, intersection) { ids.push(intersection.entityID); } - // print("ids = " + ids); - var success = false; for (var i = 0; i < ids.length; i++) { var entityID = ids[i];