11// ----------------------------------------------------------------------------
2- // - Open3D: www.open3d.org -
2+ // - Open3D: www.open3d.org -
33// ----------------------------------------------------------------------------
4- // The MIT License (MIT)
5- //
6- // Copyright (c) 2018-2023 www.open3d.org
7- //
8- // Permission is hereby granted, free of charge, to any person obtaining a copy
9- // of this software and associated documentation files (the "Software"), to deal
10- // in the Software without restriction, including without limitation the rights
11- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12- // copies of the Software, and to permit persons to whom the Software is
13- // furnished to do so, subject to the following conditions:
14- //
15- // The above copyright notice and this permission notice shall be included in
16- // all copies or substantial portions of the Software.
17- //
18- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23- // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24- // IN THE SOFTWARE.
4+ // Copyright(c) 2018-2023 www.open3d.org
5+ // SPDX - License - Identifier: MIT
256// ----------------------------------------------------------------------------
267
278// Jupyter widget for Open3D WebRTC visualizer. See web_visualizer.py for the
@@ -44,49 +25,51 @@ let WebRtcStreamer = require("./webrtcstreamer");
4425//
4526// When serializing the entire widget state for embedding, only values that
4627// differ from the defaults will be specified.
47- let WebVisualizerModel = widgets . DOMWidgetModel . extend ( {
48- defaults : _ . extend ( widgets . DOMWidgetModel . prototype . defaults ( ) , {
49- _model_name : "WebVisualizerModel" ,
50- _view_name : "WebVisualizerView" ,
51- _model_module : "open3d" ,
52- _view_module : "open3d" ,
53- // @...@ is configured by cpp/pybind/make_python_package.cmake.
54- _model_module_version : "@PROJECT_VERSION_THREE_NUMBER@" ,
55- _view_module_version : "@PROJECT_VERSION_THREE_NUMBER@" ,
56- } ) ,
57- } ) ;
28+ class WebVisualizerModel extends widgets . DOMWidgetModel {
29+ defaults ( ) {
30+ return _ . extend ( widgets . DOMWidgetModel . prototype . defaults ( ) , {
31+ _model_name : "WebVisualizerModel" ,
32+ _view_name : "WebVisualizerView" ,
33+ _model_module : "open3d" ,
34+ _view_module : "open3d" ,
35+ // @...@ is configured by cpp/pybind/make_python_package.cmake.
36+ _model_module_version : "@PROJECT_VERSION_THREE_NUMBER@" ,
37+ _view_module_version : "@PROJECT_VERSION_THREE_NUMBER@" ,
38+ } ) ;
39+ }
40+ }
5841
5942// Custom View. Renders the widget model.
60- let WebVisualizerView = widgets . DOMWidgetView . extend ( {
61- sleep : function ( time_ms ) {
43+ class WebVisualizerView extends widgets . DOMWidgetView {
44+ sleep ( time_ms ) {
6245 return new Promise ( ( resolve ) => setTimeout ( resolve , time_ms ) ) ;
63- } ,
46+ }
6447
65- logAndReturn : function ( value ) {
48+ logAndReturn ( value ) {
6649 console . log ( "logAndReturn: " , value ) ;
6750 return value ;
68- } ,
51+ }
6952
70- callResultReady : function ( callId ) {
53+ callResultReady ( callId ) {
7154 let pyjs_channel = this . model . get ( "pyjs_channel" ) ;
7255 console . log ( "Current pyjs_channel:" , pyjs_channel ) ;
7356 let callResultMap = JSON . parse ( this . model . get ( "pyjs_channel" ) ) ;
7457 return callId in callResultMap ;
75- } ,
58+ }
7659
77- extractCallResult : function ( callId ) {
60+ extractCallResult ( callId ) {
7861 if ( ! this . callResultReady ( callId ) ) {
7962 throw "extractCallResult not ready yet." ;
8063 }
8164 let callResultMap = JSON . parse ( this . model . get ( "pyjs_channel" ) ) ;
8265 return callResultMap [ callId ] ;
83- } ,
66+ }
8467
8568 /**
8669 * Hard-coded to call "call_http_api". Args and return value are all
8770 * strings.
8871 */
89- callPython : async function ( func , args = [ ] ) {
72+ async callPython ( func , args = [ ] ) {
9073 let callId = this . callId . toString ( ) ;
9174 this . callId ++ ;
9275 let message = {
@@ -116,9 +99,9 @@ let WebVisualizerView = widgets.DOMWidgetView.extend({
11699 json_result
117100 ) ;
118101 return json_result ;
119- } ,
102+ }
120103
121- commsCall : function ( url , data = { } ) {
104+ commsCall ( url , data = { } ) {
122105 // https://stackoverflow.com/a/736970/1255535
123106 // parseUrl(url).hostname
124107 // parseUrl(url).entryPoint
@@ -180,9 +163,9 @@ let WebVisualizerView = widgets.DOMWidgetView.extend({
180163 } else {
181164 throw "Unsupported entryPoint: " + entryPoint ;
182165 }
183- } ,
166+ }
184167
185- render : function ( ) {
168+ render ( ) {
186169 let windowUID = this . model . get ( "window_uid" ) ;
187170 let onClose = function ( ) {
188171 console . log ( "onClose() called for window_uid:" , windowUID ) ;
@@ -214,8 +197,8 @@ let WebVisualizerView = widgets.DOMWidgetView.extend({
214197 this . commsCall . bind ( this )
215198 ) ;
216199 this . webRtcClient . connect ( windowUID ) ;
217- } ,
218- } ) ;
200+ }
201+ }
219202
220203module . exports = {
221204 WebVisualizerModel : WebVisualizerModel ,
0 commit comments