Toggle navigation
Toggle navigation
This project
Loading...
Sign in
arcs
/
arcs.js
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
3
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Jean-Yves Didier
2021-11-25 23:10:30 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6828396830f7af5b3869a9446f2cf1f674bada9d
68283968
1 parent
46519392
added prototype for xrviewer
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
91 additions
and
0 deletions
components/xrviewer.js
components/xrviewer.js
0 → 100644
View file @
6828396
import
ARCS
from
'../build/arcs.js'
;
import
*
as
THREE
from
'../deps/three.js/index.js'
;
//import FrustumCamera from '../deps/three.js/frustumcamera.js';
var
XRViewer
;
/**
* @class ARViewer
* @classdesc Simple compositing viewer for augmented reality
*/
XRViewer
=
ARCS
.
Component
.
create
(
/** @lends ARViewer.prototype */
function
()
{
let
renderer
,
scene3d
,
camera3d
;
let
sceneId
;
// scenegraph initializations
scene3d
=
new
THREE
.
Scene
();
/**
* Initializes the widgets (HTML elements) needed as a basis
* for the viewer.
* @param cName {string} id of the container that will enclose the scene renderer
* @param vName {string} id of the element at the source of the video stream
* @slot
* @function ARViewer#setWidgets
*/
this
.
setWidgets
=
function
()
{
renderer
=
new
THREE
.
WebGLRenderer
();
renderer
.
setClearColor
(
0x000000
,
1
);
renderer
.
setSize
(
container
.
width
,
container
.
height
);
container
.
appendChild
(
renderer
.
domElement
);
var
theta
=
45
;
camera3d
=
new
THREE
.
PerspectiveCamera
(
theta
,
container
.
width
/
container
.
height
,
0.01
,
10
);
scene3d
.
add
(
camera3d
);
var
_light
=
new
THREE
.
DirectionalLight
(
0xffffff
);
_light
.
position
.
set
(
0
,
5
,
5
);
scene3d
.
add
(
_light
);
updateAspectRatio
();
};
/**
* Adds new objects to the current 3D scene
* @param scene {object} 3D object as defined by Three.js to add to the scene.
* @slot
* @function ARViewer#addScene
*/
this
.
addScene
=
function
(
scene
)
{
scene3d
.
add
(
scene
);
};
/**
* Removes an object from the current 3D scene
* @param scene {object} 3D object as defined by Three.js to remove from the scene.
* @slot
* @function ARViewer#removeScene
*/
this
.
removeScene
=
function
(
scene
)
{
scene3d
.
remove
(
scene
);
};
/**
* Triggers the rendering of the composite scene
* @function ARViewer#render
* @slot
*/
this
.
render
=
function
()
{
renderer
.
autoClear
=
false
;
renderer
.
clear
();
renderer
.
render
(
scene3d
,
camera3d
);
}
},
/** @lends ARViewer.slots */
[
'setWidgets'
,
'setFocal'
,
'viewAll'
,
'setSize'
,
'addScene'
,
'resetCamera'
,
'removeScene'
,
'render'
,
'keepAspectRatio'
,
'setExtrinsics'
,
'setIntrinsics'
],
[]
);
export
default
{
XRViewer
:
XRViewer
};
Please
register
or
login
to post a comment