def __js__(self, pres_ctx, scene_js): # fovY, nearFrac, farFrac, focalPoint, orbitalRadius, azimuth, altitude materials_src = '[' + ', '.join([ mat.__js__(pres_ctx, scene_js).build_js(pres_ctx) for mat in self.materials ]) + ']' return scene_js.createSkybox(js.JSExprSrc(materials_src))
def __js__(self, pres_ctx, scene_js): shader_js = self.shader.__js__(pres_ctx, scene_js) sampler_names_to_textures_src = '{' + ', '.join([ '{0}:{1}'.format( name, texture.__js__(pres_ctx, scene_js).build_js(pres_ctx)) for name, texture in self.sampler_names_to_textures.items() ]) + '}' return scene_js.createMaterial( shader_js, js.JSExprSrc(sampler_names_to_textures_src), self.use_blending)
def show_using_js_eval(self, js_expr): """ Show the popup using a supplied Javascript expression :param js_expr: a javascript expression to be evaluated. The variables popup_id and nodes will be available in the local scope, providing the ID of the popup and the DOM nodes that it is to contain. :return: the segment ID of the popup """ if isinstance(js_expr, basestring): js_expr = js.JSExprSrc(js_expr) elif not isinstance(js_expr, js.JS): raise TypeError, 'Javascript expression must be a string or a JS object' seg = self.__inc_view.create_popup_segment(self.__popup_contents, self.__perspective, js_expr) return seg.id
def page_js_eval(self, expr): """ Schedule a page-level script to be executed :param expr: the Javascript script to execute, either in the form of a js.JS subclass or a string :return: None """ if isinstance(expr, basestring): expr = js.JSExprSrc(expr) elif not isinstance(expr, js.JS): raise TypeError, 'Javascript expression must be a string or a JS object' # TODO: passing None as the presentation context will cause Resource instances to break expr_src = expr.build_js(None) self._page.queue_js_to_execute(expr_src) # Notifying the page of a modification causes it to schedule a refresh, which will cause the script to be executed self._page._notify_page_modified()
def __js__(self, pres_ctx, scene_js): resources = '[' + ', '.join( [rsc.build_js(pres_ctx) for rsc in self.resources]) + ']' return scene_js.createTextureCube(js.JSExprSrc(resources))
def js_shutdown_eval(self, expr): if isinstance(expr, basestring): expr = js.JSExprSrc(expr) elif not isinstance(expr, js.JS): raise TypeError, 'Javascript expression must be a string or a JS object' return self._wrap_in_eval([], [expr])