Comments (1)
sceneView.pointOfView
is the current ARKit point of view in the scene. The position of the currentFrame.camera
and the position of the sceneView.pointOfView
should be the same.
Now regarding the code that gets the orientation of the camera, that was actually done by someone else in this pull request: #2
let mat = SCNMatrix4FromMat4(currentFrame.camera.transform)
// here we get the 4x4 transform matrix from the current frame's camera
let dir = SCNVector3(-1 * mat.m31, -1 * mat.m32, -1 * mat.m33)
// .m31, .m32 and .m33 stand for the x, y and z components of the out vector of the matrix
// which has a magnitude of 1 and is parallel to the user's point of view (going outwards I think)
let currentPosition = pointOfView.position + (dir * 0.1)
// and here we multiply the camera's "out" vector by 0.1 (for 10 cm) and then add that to the
// camera's position to get the position of a point that's exactly 10 cm in front of the camera
You can read up on that output vector here: https://www.fastgraph.com/makegames/3drotation/
Also yes, it does look like your code would work (also could be simplified to simply return sceneView.pointOfView.position
) but it would "only" return the position of the camera, not 10 cm in front of it. I'm not an expert at 3D programming at all so that was my first approach too, to simply draw where the camera is positioned !
from arkit-line-drawing.
Related Issues (8)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arkit-line-drawing.