PageSourceSearch

http://www.meshlabjs.net/js/mlj/core/plugin/GlobalRendering.js

js meshlabjs.net collected 2026-10-03 20:42:41 UTC 2,760 bytes, 85 lines download raw bytes

1/**
2 * @file Defines the class to create "scene level" rendering plugins. These plugins
3 * implement rendering passes that are not tied to a particular mesh layer, but
4 * affect the whole scene. 
5 */
6
7/**         
8 * @class Base class to create rendering plugins that are not tied to a mesh layer.
9 *
10 * @param {Object} parameters - The plugin parameters (see {@link MLJ.core.plugin.BaseRendering}
11 * for details). Note that for this rendering class <code>parameters.toggle</code>
12 * is forced to <true>
13 *
14 * @memberOf MLJ.core.plugin
15 */
16MLJ.core.plugin.GlobalRendering = function (parameters) {
17    var renderingClass = "mlj_rendering_scene";
18    parameters.toggle = true;
19    MLJ.core.plugin.BaseRendering.call(this, parameters, renderingClass);
20
21    var _this = this;
22
23    var btn = this.getButton();
24    
25    // Changes to button state
26    btn.onToggle(function (on, event) {
27        if (on) {
28            _this._showOptionsPane();
29        }
30        _this._applyTo(on);
31        MLJ.core.Scene.render();
32    });
33
34    // Suppress right clicks
35    btn.onRightButtonClicked(function () {});
36    
37    $(document).on("SceneLayerAdded SceneLayerReloaded SceneLayerRemoved", function (event, meshFile, layersNumber) {
38        if (btn.isOn()) {
39            _this._applyTo(false);
40            _this._applyTo(true);
41            MLJ.core.Scene.render();
42        }
43    });
44
45    $(document).on("SceneLayerUpdated", function (event, meshFile) {
46        //TODO
47    });                
48
49    if (parameters.applyOnEvent !== undefined) {
50        $(window).ready(function() {
51                $($('canvas')[0]).on(parameters.applyOnEvent, function() {
52                    // Reapplying the plugin, but only if it was already on
53                    if(btn.isOn())
54                    {
55                        _this._applyTo(false);
56                        _this._applyTo(true);                       
57                    }
58                });
59            });
60    }
61
62    $(document).on("SceneLayerSelected", function (event, meshFile) {
63        // TODO layer selection should not affect scene level rendering plugins
64    });
65
66    //Prevents context menu opening
67    $(document).ready(function () {
68        $(this).on("contextmenu", function (e) {
69            if (btn.$.find("img").prop("outerHTML") === $(e.target).prop("outerHTML")) {
70                e.preventDefault();
71            }
72        });
73    });
74
75    _this._setOnParamChange(function (callback, value) {
76        // 'callback' is whatever was passed as bindTo, 'value' is the value of
77        // the parameter
78        if (jQuery.isFunction(callback)) {
79            callback(value);
80            MLJ.core.Scene.render();
81        }
82    });
83};
84
85MLJ.extend(MLJ.core.plugin.BaseRendering, MLJ.core.plugin.GlobalRendering);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.