@viewar/guide
Advanced tools
Comparing version 0.11.4 to 0.11.5
{ | ||
"name": "@viewar/guide", | ||
"version": "0.11.4", | ||
"version": "0.11.5", | ||
"description": "ViewAR Guide", | ||
@@ -5,0 +5,0 @@ "main": "dist/viewar-guide.js", |
@@ -7,3 +7,3 @@ import Vector3 from '../../math/vector3' | ||
import logPath from '../../utils/log-path'; | ||
import { NO_WAYPOINT } from '../../constants'; | ||
import { NO_WAYPOINT, METER } from '../../constants'; | ||
import { projectPointOnEdge, clamp } from '../../math/math' | ||
@@ -84,19 +84,22 @@ | ||
let previousPosition; | ||
if (previous !== NO_WAYPOINT) { | ||
const previousPosition = new Vector3(previous.pose.position); | ||
previousPosition = new Vector3(previous.pose.position); | ||
} else { | ||
previousPosition = new Vector3(body.initialPose.position); | ||
} | ||
let guidePosition = projectPointOnEdge(position, [currentPosition, previousPosition]); | ||
let guidePosition = projectPointOnEdge(position, [currentPosition, previousPosition]); | ||
if (guidePosition) { | ||
const totalDistance = currentPosition.clone().subtract(previousPosition).length(); | ||
const distance = guidePosition.clone().subtract(previousPosition).length(); | ||
if (guidePosition) { | ||
const totalDistance = currentPosition.clone().subtract(previousPosition).length(); | ||
const distance = guidePosition.clone().subtract(previousPosition).length(); | ||
const heightDiff = currentPosition.y - previousPosition.y; | ||
let height = (previousPosition.y + heightDiff / totalDistance * distance) - body.initialPose.position.y; | ||
return { success: true, height }; | ||
} | ||
const heightDiff = currentPosition.y - previousPosition.y; | ||
let height = (previousPosition.y + heightDiff / totalDistance * distance) - body.initialPose.position.y + METER * 0.4; | ||
return { success: true, height }; | ||
} | ||
} | ||
// Return zero height for guidePosition can't be projected onto the path. | ||
// Return zero height if guidePosition can't be projected onto the path. | ||
return { success: false, height: 0 }; | ||
@@ -103,0 +106,0 @@ } |
Sorry, the diff of this file is too big to display
192971
2665