Matterport SDK Tutorial
Matterport
What is matterport ?
Matterport is a software as a service platform we you can create 3D models of any physical space using 360° photos
What is SDK ?
SDK stands for Software Development Kit which contain a set development tools and packages through other developer can create there own application for a specific platform
Application Using Matterport SDK:
Mattertag editor
- SDK for Embed
- SDK bundle
SDK for Embed
for example : we can add tags in the space , change their appearance etc
SDK Bundle
Mattertag Editor has been made using SDK for Embed , the whole SDK has written in javascript language , So here i will show you the step by step work flow this application to understand it better
before embeding the matterport showcase in your web app we need the two important things
- SDK key
- Model SID
2) Creating a custom server for development purpose
- first creating a folder named Matterport on which we store all the folders
- after that we install express framework into this directory using NPM which is a package manager for javascript
- after this step we will create the a server.js file which will use to run the server
- We will save all the necessary file in a public folder
- Now come the most important step is to create the app.js file where we use SDK . I will break down all the steps of the code to get the clear understanding
- First we initialize all the variable which is being used throughout the code
code in line 13 is used to check the user's browser is firefox or not because firefox has some issue in rendering the matterport showcase .
4. when iframe start loading then we will connect it through matterport SDK using showcaseload() function
this function is asynchronous type of function which will return a promise that it will wait until the sdk connect , then execute further codes
5. After that we will execute loadedShowcaseHandler() function which contains multiple other function within it , first we fetch the mattertag data associated to the model using mpsdk.Matterport.getData() function from the SDK.
- populateTags()
- setupFunctionality()
populateTags will call addToTable() function will create a structure for row to feed the data in (label , description , colour, gotolink,delete) columns
Here we have used SDK function (mpsdk.Mattertag.navigateToTag()) which when activated will move the sweep to the tag location instantly .
First the function will take the input from the user and set the change variable to focus() and wait until the user hit the enter key , once the user hit the enter the change variable convert to blur() and call the clickAway() function
this function will first remove blur function from the change variable and check whether user has given any input in each cell of the table or not using ternary operator , if the user have given the valid input then it will call updataTag function with label and description and input , but if they click again on the cell they it will call back to changeInfo function
this function will first create a empty dictionary for label and description and make the changes permanent in cell of table using the SDK function (mpsdk.Mattertag.editBillBoard())
- Place new tag
- Import tags
- Remove all tags
- Export tags
we use SDK function (mpsdk.mattertag.add) function to initiate the adding tag procedure which will set the default label , description , location information to that tag and give that tag a SID no
here we use the sdk function (mpsdk.Renderer.getWorldPositionData) which convert the screen position into 3d world position , actually it mean basically it convert 2D coordinates to 3D coordinates ,
This function will use sdk function (mpsdk.mattertag.editPosition) to update the x,y,z coordinates of the tag.
this function first reads the file type , if it is JSON format then it proceed further and call replaceShowcaseTag function to replace all the sid no of old tags with new one using "mpsdk.Mattertag.remove" function and populate the new tags in the space using populateTag function . It also update the parameters the tags like mattertag.media which is used to add media files like photo and videos
here we use "mpsdk.Mattertag.remove"function to remove all the tag from the model database. and also update the html tables
Here are the list of SDK functions which are being used in this project :
- mpsdk.Matterport.getData()
- mpsdk.Mattertag.remove()
- mpsdk.Mattertag.navigateToTag()
- mpsdk.Mattertag.editBillBoard()
- mpsdk.Mattertag.add()
- mpsdk.Renderer.getWorldPositionData()
- mpsdk.Mattertag.editPosition()
- mpsdk.Pointer.intersection.subscribe()
- mpsdk.Mattertag.remove()
Comments
Post a Comment