My camera height currently is 3, which is default walk mode i guess, whenever i click button, consider example drone button, i wanna to move the camera height to 8 or 10 from the current position, how to do that in code, what properties i need to look for
It’s not possible to change the camera height directly, but you can retrieve the current camera position & rotation with GitHub - shapespark/shapespark-viewer-api: JavaScript API for interacting with the Shapespark 3D scene., and then switch to an ad-hoc view with Z coordinate modified by 8 or 10 units. API for view switching is documented at GitHub - shapespark/shapespark-viewer-api: JavaScript API for interacting with the Shapespark 3D scene., the body-end.html
file from the example contains code to create an ad-hoc view.
Yea, thank you so much, shit, I stopped that way since I was facing one glitch, now it sorted out,
In case, if anyone is trying to figure out the code, here you go
var position = viewer.getCameraPosition();
var view = new WALK.View();
view.position.x =position.x
view.position.y = position.y
view.position.z = position.z===3?8:3;
viewer.switchToView(view);
You can simple put view.position.z =8 0r 3,
I have one more doubt can we get position and rotation in code from the switch-name which i added in the extension,
Like example, Suppose i wanna to get the position of this Villa_View_01, in code, by just using the name Villa_View_01 in code, because i wanna to override the position of this viewName
Hello @wojtek is it possible to override the veiwName position in script??
Any way to remove the views from the viewer, because every click, i’m creating new View(), using new WALK.View(); and its exterior view, there may be n number of clicks by the user, so worried it may affect the memory.
The views listed in the top-right view menu are accessible as Viewer.visibleViews()
. You can find your view in the returned list, and get its position & rotation.
Do you mean changing the position of a view listed in the top-right view menu?
If you use WALK.View objects only as arguments to Viewer.switchToView and then don’t use or store these objects in any way, then the objects will be automatically garbage collected.
@wojtek Yeah, in the top-right view menu only, but i’m hiding all views in top-right menu, to customise menu style in code, I just wanna to know just using this viewName(hidden top-right menu, which i created in extension) like example “Villa_View_01” , using this name only in code, how to get its viewObject, or access its position or rotation.
You should be able find such View objects in the list returned by Viewer.visibleViews()
.
I was hiding all the views in the menu right, so i was thinking i can’t access visibleViews in the code, or this error meant something else
Cannot read properties of null (reading ‘visibleViews’)
var viewer = WALK.getViewer();
var views = viewer.visibleViews();
console.log(views)
Do you use visibleViews()
after the scene has been loaded?