Add example for loading a model from a file as an arraybuffer.
This commit is contained in:
parent
d7545b8a88
commit
80b690fb9d
47
sandbox/embed_selfhost_code_binary.html
Normal file
47
sandbox/embed_selfhost_code_binary.html
Normal file
@ -0,0 +1,47 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html;charset=utf-8">
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no">
|
||||
|
||||
<title>Online 3D Viewer</title>
|
||||
|
||||
<script type="text/javascript" src="../build/o3dv.min-dev.js"></script>
|
||||
|
||||
<style>
|
||||
div.online_3d_viewer
|
||||
{
|
||||
float: left;
|
||||
border: 1px solid #eeeeee;
|
||||
width: 640px;
|
||||
height: 480px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type='text/javascript'>
|
||||
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
|
||||
let viewer = new OV.EmbeddedViewer (parentDiv);
|
||||
|
||||
fetch ('../../test/testfiles/obj/hundred_cubes.obj')
|
||||
.then (response => response.arrayBuffer ())
|
||||
.then ((arrayBuffer) => {
|
||||
let fileList = [
|
||||
new File ([arrayBuffer], "file.obj")
|
||||
];
|
||||
viewer.LoadModelFromFileList (fileList);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="online_3d_viewer" id="viewer">
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Loading…
Reference in New Issue
Block a user