You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
console.log("hello 3D world!")
var viewer
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
var filename = urlParams.get('model')
if (filename == null) filename = "AvocadoV1.glb"
var eyeX = urlParams.get('eyeX')
if (eyeX == null) eyeX = 1.5
var eyeY = urlParams.get('eyeY')
if (eyeY == null) eyeY = 4.0
var eyeZ = urlParams.get('eyeZ')
if (eyeZ == null) eyeZ = 6.0
var centerX= urlParams.get('centerX')
if (centerX == null) centerX = 0.0
var centerY= urlParams.get('centerY')
if (centerY == null) centerY = 0.0
var centerZ = urlParams.get('centerZ')
if (centerZ == null) centerZ = 0.0
var upX = urlParams.get('upX')
if (upX == null) upX = 0.0
var upY= urlParams.get('upY')
if (upY == null) upY = 1.0
var upZ= urlParams.get('upZ')
if (upZ == null) upZ = 0.0
var fov= urlParams.get('fov')
if (fov == null) fov = 45.0
var modelpath = 'https://www-users.york.ac.uk/~samh502/3Dviewer/models/' + filename
window.addEventListener ('load', () => {
// get the parent element of the viewer
let parentDiv = document.getElementById ('viewer');
// initialize the viewer with the parent element and some parameters
viewer = new OV.EmbeddedViewer (parentDiv, {
camera : new OV.Camera (
new OV.Coord3D (eyeX, eyeY, eyeZ), //eye
new OV.Coord3D (centerX, centerY, centerZ), //center
new OV.Coord3D (upX, upY, upZ), //up
fov //field of view
),
backgroundColor : new OV.RGBAColor (255, 255, 255, 255),
defaultColor : new OV.RGBColor (200, 200, 200),
edgeSettings : new OV.EdgeSettings (false, new OV.RGBColor (0, 0, 255), 1),
environmentSettings : new OV.EnvironmentSettings (
[
],
false
)
})
// load a model providing model urls
//console.log( modelpath )
viewer.LoadModelFromUrlList ([ modelpath ,])
// from JSON
viewer.viewer.camera.eye = [eyeX, eyeY, eyeZ ]
//OV.MoveCamera (viewer.camera, eyeX, eyeY, eyeZ ));
console.log(viewer.viewer)
console.log(OV)
});
I guess that eyeX, eyeY, eyeZ might be x position, y posiition and that Z is how near / far away it is... and yet when I change the eyeZ from -30 to -60 it seems to change angle. Am I right and/or am I even doing all of this correctly?
Might there also be a way to call a function to get the position settings so I could maybe get the model where I want it, then get the values I'd need to be able to start at that position?
Thanks
Tom
The text was updated successfully, but these errors were encountered:
Hello,
I've been experimenting trying to make a webpage that loads a model, and sets position based on the URL Query params. Like this...
https://uoy3d.glitch.me/?model=AvocadoV1.fbx&fov=45&eyeX=0&eyeY=60&eyeZ=-30
You can my the code in context here...
I guess that eyeX, eyeY, eyeZ might be x position, y posiition and that Z is how near / far away it is... and yet when I change the eyeZ from -30 to -60 it seems to change angle. Am I right and/or am I even doing all of this correctly?
Might there also be a way to call a function to get the position settings so I could maybe get the model where I want it, then get the values I'd need to be able to start at that position?
Thanks
Tom
The text was updated successfully, but these errors were encountered: