@inweb/viewer-three 26.6.3 → 26.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/plugins/components/StatsPanelComponent.js +216 -0
- package/dist/plugins/components/StatsPanelComponent.js.map +1 -0
- package/dist/plugins/components/StatsPanelComponent.min.js +1 -0
- package/dist/plugins/components/StatsPanelComponent.module.js +25 -0
- package/dist/plugins/components/StatsPanelComponent.module.js.map +1 -0
- package/dist/viewer-three.js +1 -0
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +1 -1
- package/dist/viewer-three.module.js +4 -0
- package/dist/viewer-three.module.js.map +1 -1
- package/package.json +5 -5
- package/plugins/components/StatsPanelComponent.ts +53 -0
- package/src/Viewer/components/RenderLoopComponent.ts +2 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('@inweb/viewer-three')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['@inweb/viewer-three'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ODA.Three));
|
|
5
|
+
})(this, (function (viewerThree) { 'use strict';
|
|
6
|
+
|
|
7
|
+
var Stats = function () {
|
|
8
|
+
|
|
9
|
+
var mode = 0;
|
|
10
|
+
|
|
11
|
+
var container = document.createElement( 'div' );
|
|
12
|
+
container.style.cssText = 'position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000';
|
|
13
|
+
container.addEventListener( 'click', function ( event ) {
|
|
14
|
+
|
|
15
|
+
event.preventDefault();
|
|
16
|
+
showPanel( ++ mode % container.children.length );
|
|
17
|
+
|
|
18
|
+
}, false );
|
|
19
|
+
|
|
20
|
+
//
|
|
21
|
+
|
|
22
|
+
function addPanel( panel ) {
|
|
23
|
+
|
|
24
|
+
container.appendChild( panel.dom );
|
|
25
|
+
return panel;
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function showPanel( id ) {
|
|
30
|
+
|
|
31
|
+
for ( var i = 0; i < container.children.length; i ++ ) {
|
|
32
|
+
|
|
33
|
+
container.children[ i ].style.display = i === id ? 'block' : 'none';
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
mode = id;
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//
|
|
42
|
+
|
|
43
|
+
var beginTime = ( performance || Date ).now(), prevTime = beginTime, frames = 0;
|
|
44
|
+
|
|
45
|
+
var fpsPanel = addPanel( new Stats.Panel( 'FPS', '#0ff', '#002' ) );
|
|
46
|
+
var msPanel = addPanel( new Stats.Panel( 'MS', '#0f0', '#020' ) );
|
|
47
|
+
|
|
48
|
+
if ( self.performance && self.performance.memory ) {
|
|
49
|
+
|
|
50
|
+
var memPanel = addPanel( new Stats.Panel( 'MB', '#f08', '#201' ) );
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
showPanel( 0 );
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
|
|
58
|
+
REVISION: 16,
|
|
59
|
+
|
|
60
|
+
dom: container,
|
|
61
|
+
|
|
62
|
+
addPanel: addPanel,
|
|
63
|
+
showPanel: showPanel,
|
|
64
|
+
|
|
65
|
+
begin: function () {
|
|
66
|
+
|
|
67
|
+
beginTime = ( performance || Date ).now();
|
|
68
|
+
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
end: function () {
|
|
72
|
+
|
|
73
|
+
frames ++;
|
|
74
|
+
|
|
75
|
+
var time = ( performance || Date ).now();
|
|
76
|
+
|
|
77
|
+
msPanel.update( time - beginTime, 200 );
|
|
78
|
+
|
|
79
|
+
if ( time >= prevTime + 1000 ) {
|
|
80
|
+
|
|
81
|
+
fpsPanel.update( ( frames * 1000 ) / ( time - prevTime ), 100 );
|
|
82
|
+
|
|
83
|
+
prevTime = time;
|
|
84
|
+
frames = 0;
|
|
85
|
+
|
|
86
|
+
if ( memPanel ) {
|
|
87
|
+
|
|
88
|
+
var memory = performance.memory;
|
|
89
|
+
memPanel.update( memory.usedJSHeapSize / 1048576, memory.jsHeapSizeLimit / 1048576 );
|
|
90
|
+
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return time;
|
|
96
|
+
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
update: function () {
|
|
100
|
+
|
|
101
|
+
beginTime = this.end();
|
|
102
|
+
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
// Backwards Compatibility
|
|
106
|
+
|
|
107
|
+
domElement: container,
|
|
108
|
+
setMode: showPanel
|
|
109
|
+
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
Stats.Panel = function ( name, fg, bg ) {
|
|
115
|
+
|
|
116
|
+
var min = Infinity, max = 0, round = Math.round;
|
|
117
|
+
var PR = round( window.devicePixelRatio || 1 );
|
|
118
|
+
|
|
119
|
+
var WIDTH = 80 * PR, HEIGHT = 48 * PR,
|
|
120
|
+
TEXT_X = 3 * PR, TEXT_Y = 2 * PR,
|
|
121
|
+
GRAPH_X = 3 * PR, GRAPH_Y = 15 * PR,
|
|
122
|
+
GRAPH_WIDTH = 74 * PR, GRAPH_HEIGHT = 30 * PR;
|
|
123
|
+
|
|
124
|
+
var canvas = document.createElement( 'canvas' );
|
|
125
|
+
canvas.width = WIDTH;
|
|
126
|
+
canvas.height = HEIGHT;
|
|
127
|
+
canvas.style.cssText = 'width:80px;height:48px';
|
|
128
|
+
|
|
129
|
+
var context = canvas.getContext( '2d' );
|
|
130
|
+
context.font = 'bold ' + ( 9 * PR ) + 'px Helvetica,Arial,sans-serif';
|
|
131
|
+
context.textBaseline = 'top';
|
|
132
|
+
|
|
133
|
+
context.fillStyle = bg;
|
|
134
|
+
context.fillRect( 0, 0, WIDTH, HEIGHT );
|
|
135
|
+
|
|
136
|
+
context.fillStyle = fg;
|
|
137
|
+
context.fillText( name, TEXT_X, TEXT_Y );
|
|
138
|
+
context.fillRect( GRAPH_X, GRAPH_Y, GRAPH_WIDTH, GRAPH_HEIGHT );
|
|
139
|
+
|
|
140
|
+
context.fillStyle = bg;
|
|
141
|
+
context.globalAlpha = 0.9;
|
|
142
|
+
context.fillRect( GRAPH_X, GRAPH_Y, GRAPH_WIDTH, GRAPH_HEIGHT );
|
|
143
|
+
|
|
144
|
+
return {
|
|
145
|
+
|
|
146
|
+
dom: canvas,
|
|
147
|
+
|
|
148
|
+
update: function ( value, maxValue ) {
|
|
149
|
+
|
|
150
|
+
min = Math.min( min, value );
|
|
151
|
+
max = Math.max( max, value );
|
|
152
|
+
|
|
153
|
+
context.fillStyle = bg;
|
|
154
|
+
context.globalAlpha = 1;
|
|
155
|
+
context.fillRect( 0, 0, WIDTH, GRAPH_Y );
|
|
156
|
+
context.fillStyle = fg;
|
|
157
|
+
context.fillText( round( value ) + ' ' + name + ' (' + round( min ) + '-' + round( max ) + ')', TEXT_X, TEXT_Y );
|
|
158
|
+
|
|
159
|
+
context.drawImage( canvas, GRAPH_X + PR, GRAPH_Y, GRAPH_WIDTH - PR, GRAPH_HEIGHT, GRAPH_X, GRAPH_Y, GRAPH_WIDTH - PR, GRAPH_HEIGHT );
|
|
160
|
+
|
|
161
|
+
context.fillRect( GRAPH_X + GRAPH_WIDTH - PR, GRAPH_Y, PR, GRAPH_HEIGHT );
|
|
162
|
+
|
|
163
|
+
context.fillStyle = bg;
|
|
164
|
+
context.globalAlpha = 0.9;
|
|
165
|
+
context.fillRect( GRAPH_X + GRAPH_WIDTH - PR, GRAPH_Y, PR, round( ( 1 - ( value / maxValue ) ) * GRAPH_HEIGHT ) );
|
|
166
|
+
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
174
|
+
// Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
|
|
175
|
+
// All rights reserved.
|
|
176
|
+
//
|
|
177
|
+
// This software and its documentation and related materials are owned by
|
|
178
|
+
// the Alliance. The software may only be incorporated into application
|
|
179
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
180
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
181
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
182
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
183
|
+
// protected by copyright law and international treaty provisions. Application
|
|
184
|
+
// programs incorporating this software must include the following statement
|
|
185
|
+
// with their copyright notices:
|
|
186
|
+
//
|
|
187
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
188
|
+
// license agreement with Open Design Alliance.
|
|
189
|
+
// Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
|
|
190
|
+
// All rights reserved.
|
|
191
|
+
//
|
|
192
|
+
// By use of this software, its documentation or related materials, you
|
|
193
|
+
// acknowledge and accept the above terms.
|
|
194
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
195
|
+
class StatsPanelComponent {
|
|
196
|
+
constructor(viewer) {
|
|
197
|
+
this.updateStats = () => {
|
|
198
|
+
this.stats.update();
|
|
199
|
+
this.viewer.update();
|
|
200
|
+
};
|
|
201
|
+
this.stats = new Stats();
|
|
202
|
+
this.stats.dom.style.position = "absolute";
|
|
203
|
+
viewer.canvas.parentElement.appendChild(this.stats.dom);
|
|
204
|
+
this.viewer = viewer;
|
|
205
|
+
this.viewer.on("animate", this.updateStats);
|
|
206
|
+
}
|
|
207
|
+
dispose() {
|
|
208
|
+
this.viewer.off("animate", this.updateStats);
|
|
209
|
+
this.stats.dom.remove();
|
|
210
|
+
this.stats = undefined;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
viewerThree.components.registerComponent("StatsPanelComponent", (viewer) => new StatsPanelComponent(viewer));
|
|
214
|
+
|
|
215
|
+
}));
|
|
216
|
+
//# sourceMappingURL=StatsPanelComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StatsPanelComponent.js","sources":["../../../../../node_modules/three/examples/jsm/libs/stats.module.js","../../../plugins/components/StatsPanelComponent.ts"],"sourcesContent":["var Stats = function () {\n\n\tvar mode = 0;\n\n\tvar container = document.createElement( 'div' );\n\tcontainer.style.cssText = 'position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000';\n\tcontainer.addEventListener( 'click', function ( event ) {\n\n\t\tevent.preventDefault();\n\t\tshowPanel( ++ mode % container.children.length );\n\n\t}, false );\n\n\t//\n\n\tfunction addPanel( panel ) {\n\n\t\tcontainer.appendChild( panel.dom );\n\t\treturn panel;\n\n\t}\n\n\tfunction showPanel( id ) {\n\n\t\tfor ( var i = 0; i < container.children.length; i ++ ) {\n\n\t\t\tcontainer.children[ i ].style.display = i === id ? 'block' : 'none';\n\n\t\t}\n\n\t\tmode = id;\n\n\t}\n\n\t//\n\n\tvar beginTime = ( performance || Date ).now(), prevTime = beginTime, frames = 0;\n\n\tvar fpsPanel = addPanel( new Stats.Panel( 'FPS', '#0ff', '#002' ) );\n\tvar msPanel = addPanel( new Stats.Panel( 'MS', '#0f0', '#020' ) );\n\n\tif ( self.performance && self.performance.memory ) {\n\n\t\tvar memPanel = addPanel( new Stats.Panel( 'MB', '#f08', '#201' ) );\n\n\t}\n\n\tshowPanel( 0 );\n\n\treturn {\n\n\t\tREVISION: 16,\n\n\t\tdom: container,\n\n\t\taddPanel: addPanel,\n\t\tshowPanel: showPanel,\n\n\t\tbegin: function () {\n\n\t\t\tbeginTime = ( performance || Date ).now();\n\n\t\t},\n\n\t\tend: function () {\n\n\t\t\tframes ++;\n\n\t\t\tvar time = ( performance || Date ).now();\n\n\t\t\tmsPanel.update( time - beginTime, 200 );\n\n\t\t\tif ( time >= prevTime + 1000 ) {\n\n\t\t\t\tfpsPanel.update( ( frames * 1000 ) / ( time - prevTime ), 100 );\n\n\t\t\t\tprevTime = time;\n\t\t\t\tframes = 0;\n\n\t\t\t\tif ( memPanel ) {\n\n\t\t\t\t\tvar memory = performance.memory;\n\t\t\t\t\tmemPanel.update( memory.usedJSHeapSize / 1048576, memory.jsHeapSizeLimit / 1048576 );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn time;\n\n\t\t},\n\n\t\tupdate: function () {\n\n\t\t\tbeginTime = this.end();\n\n\t\t},\n\n\t\t// Backwards Compatibility\n\n\t\tdomElement: container,\n\t\tsetMode: showPanel\n\n\t};\n\n};\n\nStats.Panel = function ( name, fg, bg ) {\n\n\tvar min = Infinity, max = 0, round = Math.round;\n\tvar PR = round( window.devicePixelRatio || 1 );\n\n\tvar WIDTH = 80 * PR, HEIGHT = 48 * PR,\n\t\tTEXT_X = 3 * PR, TEXT_Y = 2 * PR,\n\t\tGRAPH_X = 3 * PR, GRAPH_Y = 15 * PR,\n\t\tGRAPH_WIDTH = 74 * PR, GRAPH_HEIGHT = 30 * PR;\n\n\tvar canvas = document.createElement( 'canvas' );\n\tcanvas.width = WIDTH;\n\tcanvas.height = HEIGHT;\n\tcanvas.style.cssText = 'width:80px;height:48px';\n\n\tvar context = canvas.getContext( '2d' );\n\tcontext.font = 'bold ' + ( 9 * PR ) + 'px Helvetica,Arial,sans-serif';\n\tcontext.textBaseline = 'top';\n\n\tcontext.fillStyle = bg;\n\tcontext.fillRect( 0, 0, WIDTH, HEIGHT );\n\n\tcontext.fillStyle = fg;\n\tcontext.fillText( name, TEXT_X, TEXT_Y );\n\tcontext.fillRect( GRAPH_X, GRAPH_Y, GRAPH_WIDTH, GRAPH_HEIGHT );\n\n\tcontext.fillStyle = bg;\n\tcontext.globalAlpha = 0.9;\n\tcontext.fillRect( GRAPH_X, GRAPH_Y, GRAPH_WIDTH, GRAPH_HEIGHT );\n\n\treturn {\n\n\t\tdom: canvas,\n\n\t\tupdate: function ( value, maxValue ) {\n\n\t\t\tmin = Math.min( min, value );\n\t\t\tmax = Math.max( max, value );\n\n\t\t\tcontext.fillStyle = bg;\n\t\t\tcontext.globalAlpha = 1;\n\t\t\tcontext.fillRect( 0, 0, WIDTH, GRAPH_Y );\n\t\t\tcontext.fillStyle = fg;\n\t\t\tcontext.fillText( round( value ) + ' ' + name + ' (' + round( min ) + '-' + round( max ) + ')', TEXT_X, TEXT_Y );\n\n\t\t\tcontext.drawImage( canvas, GRAPH_X + PR, GRAPH_Y, GRAPH_WIDTH - PR, GRAPH_HEIGHT, GRAPH_X, GRAPH_Y, GRAPH_WIDTH - PR, GRAPH_HEIGHT );\n\n\t\t\tcontext.fillRect( GRAPH_X + GRAPH_WIDTH - PR, GRAPH_Y, PR, GRAPH_HEIGHT );\n\n\t\t\tcontext.fillStyle = bg;\n\t\t\tcontext.globalAlpha = 0.9;\n\t\t\tcontext.fillRect( GRAPH_X + GRAPH_WIDTH - PR, GRAPH_Y, PR, round( ( 1 - ( value / maxValue ) ) * GRAPH_HEIGHT ) );\n\n\t\t}\n\n\t};\n\n};\n\nexport default Stats;\n","///////////////////////////////////////////////////////////////////////////////\n// Copyright (C) 2002-2025, Open Design Alliance (the \"Alliance\").\n// All rights reserved.\n//\n// This software and its documentation and related materials are owned by\n// the Alliance. The software may only be incorporated into application\n// programs owned by members of the Alliance, subject to a signed\n// Membership Agreement and Supplemental Software License Agreement with the\n// Alliance. The structure and organization of this software are the valuable\n// trade secrets of the Alliance and its suppliers. The software is also\n// protected by copyright law and international treaty provisions. Application\n// programs incorporating this software must include the following statement\n// with their copyright notices:\n//\n// This application incorporates Open Design Alliance software pursuant to a\n// license agreement with Open Design Alliance.\n// Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.\n// All rights reserved.\n//\n// By use of this software, its documentation or related materials, you\n// acknowledge and accept the above terms.\n///////////////////////////////////////////////////////////////////////////////\n\nimport Stats from \"three/examples/jsm/libs/stats.module.js\";\nimport { IComponent, components, Viewer } from \"@inweb/viewer-three\";\n\nclass StatsPanelComponent implements IComponent {\n protected viewer: Viewer;\n protected stats: Stats;\n\n constructor(viewer: Viewer) {\n this.stats = new Stats();\n this.stats.dom.style.position = \"absolute\";\n viewer.canvas.parentElement.appendChild(this.stats.dom);\n\n this.viewer = viewer;\n this.viewer.on(\"animate\", this.updateStats);\n }\n\n dispose() {\n this.viewer.off(\"animate\", this.updateStats);\n\n this.stats.dom.remove();\n this.stats = undefined;\n }\n\n updateStats = () => {\n this.stats.update();\n this.viewer.update();\n };\n}\n\ncomponents.registerComponent(\"StatsPanelComponent\", (viewer) => new StatsPanelComponent(viewer));\n"],"names":["components"],"mappings":";;;;;;CAAA,IAAI,KAAK,GAAG,YAAY;;CAExB,CAAC,IAAI,IAAI,GAAG,CAAC;;CAEb,CAAC,IAAI,SAAS,GAAG,QAAQ,CAAC,aAAa,EAAE,KAAK,EAAE;CAChD,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,GAAG,sEAAsE;CACjG,CAAC,SAAS,CAAC,gBAAgB,EAAE,OAAO,EAAE,WAAW,KAAK,GAAG;;CAEzD,EAAE,KAAK,CAAC,cAAc,EAAE;CACxB,EAAE,SAAS,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE;;CAElD,EAAE,EAAE,KAAK,EAAE;;CAEX;;CAEA,CAAC,SAAS,QAAQ,EAAE,KAAK,GAAG;;CAE5B,EAAE,SAAS,CAAC,WAAW,EAAE,KAAK,CAAC,GAAG,EAAE;CACpC,EAAE,OAAO,KAAK;;CAEd;;CAEA,CAAC,SAAS,SAAS,EAAE,EAAE,GAAG;;CAE1B,EAAE,MAAM,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG;;CAEzD,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,KAAK,EAAE,GAAG,OAAO,GAAG,MAAM;;CAEtE;;CAEA,EAAE,IAAI,GAAG,EAAE;;CAEX;;CAEA;;CAEA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,GAAG,UAAU;CAC1C,QAAA,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;CAEvD,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;SACpB,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC;;KAG7C,OAAO,GAAA;SACL,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC;CAE5C,QAAA,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE;CACvB,QAAA,IAAI,CAAC,KAAK,GAAG,SAAS;;CAOzB;AAEDA,uBAAU,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,CAAC,MAAM,KAAK,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAAC;;;;;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("@inweb/viewer-three")):"function"==typeof define&&define.amd?define(["@inweb/viewer-three"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ODA.Three)}(this,(function(e){"use strict";var t=function(){var e=0,n=document.createElement("div");function i(e){return n.appendChild(e.dom),e}function a(t){for(var i=0;i<n.children.length;i++)n.children[i].style.display=i===t?"block":"none";e=t}n.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",n.addEventListener("click",(function(t){t.preventDefault(),a(++e%n.children.length)}),!1);var l=(performance||Date).now(),o=l,s=0,r=i(new t.Panel("FPS","#0ff","#002")),f=i(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var d=i(new t.Panel("MB","#f08","#201"));return a(0),{REVISION:16,dom:n,addPanel:i,showPanel:a,begin:function(){l=(performance||Date).now()},end:function(){s++;var e=(performance||Date).now();if(f.update(e-l,200),e>=o+1e3&&(r.update(1e3*s/(e-o),100),o=e,s=0,d)){var t=performance.memory;d.update(t.usedJSHeapSize/1048576,t.jsHeapSizeLimit/1048576)}return e},update:function(){l=this.end()},domElement:n,setMode:a}};t.Panel=function(e,t,n){var i=1/0,a=0,l=Math.round,o=l(window.devicePixelRatio||1),s=80*o,r=48*o,f=3*o,d=2*o,c=3*o,p=15*o,h=74*o,u=30*o,m=document.createElement("canvas");m.width=s,m.height=r,m.style.cssText="width:80px;height:48px";var v=m.getContext("2d");return v.font="bold "+9*o+"px Helvetica,Arial,sans-serif",v.textBaseline="top",v.fillStyle=n,v.fillRect(0,0,s,r),v.fillStyle=t,v.fillText(e,f,d),v.fillRect(c,p,h,u),v.fillStyle=n,v.globalAlpha=.9,v.fillRect(c,p,h,u),{dom:m,update:function(r,w){i=Math.min(i,r),a=Math.max(a,r),v.fillStyle=n,v.globalAlpha=1,v.fillRect(0,0,s,p),v.fillStyle=t,v.fillText(l(r)+" "+e+" ("+l(i)+"-"+l(a)+")",f,d),v.drawImage(m,c+o,p,h-o,u,c,p,h-o,u),v.fillRect(c+h-o,p,o,u),v.fillStyle=n,v.globalAlpha=.9,v.fillRect(c+h-o,p,o,l((1-r/w)*u))}}};class n{constructor(e){this.updateStats=()=>{this.stats.update(),this.viewer.update()},this.stats=new t,this.stats.dom.style.position="absolute",e.canvas.parentElement.appendChild(this.stats.dom),this.viewer=e,this.viewer.on("animate",this.updateStats)}dispose(){this.viewer.off("animate",this.updateStats),this.stats.dom.remove(),this.stats=void 0}}e.components.registerComponent("StatsPanelComponent",(e=>new n(e)))}));
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import Stats from "three/examples/jsm/libs/stats.module.js";
|
|
2
|
+
|
|
3
|
+
import { components } from "@inweb/viewer-three";
|
|
4
|
+
|
|
5
|
+
class StatsPanelComponent {
|
|
6
|
+
constructor(viewer) {
|
|
7
|
+
this.updateStats = () => {
|
|
8
|
+
this.stats.update();
|
|
9
|
+
this.viewer.update();
|
|
10
|
+
};
|
|
11
|
+
this.stats = new Stats;
|
|
12
|
+
this.stats.dom.style.position = "absolute";
|
|
13
|
+
viewer.canvas.parentElement.appendChild(this.stats.dom);
|
|
14
|
+
this.viewer = viewer;
|
|
15
|
+
this.viewer.on("animate", this.updateStats);
|
|
16
|
+
}
|
|
17
|
+
dispose() {
|
|
18
|
+
this.viewer.off("animate", this.updateStats);
|
|
19
|
+
this.stats.dom.remove();
|
|
20
|
+
this.stats = undefined;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
components.registerComponent("StatsPanelComponent", (viewer => new StatsPanelComponent(viewer)));
|
|
25
|
+
//# sourceMappingURL=StatsPanelComponent.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StatsPanelComponent.module.js","sources":["../../../plugins/components/StatsPanelComponent.ts"],"sourcesContent":["///////////////////////////////////////////////////////////////////////////////\n// Copyright (C) 2002-2025, Open Design Alliance (the \"Alliance\").\n// All rights reserved.\n//\n// This software and its documentation and related materials are owned by\n// the Alliance. The software may only be incorporated into application\n// programs owned by members of the Alliance, subject to a signed\n// Membership Agreement and Supplemental Software License Agreement with the\n// Alliance. The structure and organization of this software are the valuable\n// trade secrets of the Alliance and its suppliers. The software is also\n// protected by copyright law and international treaty provisions. Application\n// programs incorporating this software must include the following statement\n// with their copyright notices:\n//\n// This application incorporates Open Design Alliance software pursuant to a\n// license agreement with Open Design Alliance.\n// Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.\n// All rights reserved.\n//\n// By use of this software, its documentation or related materials, you\n// acknowledge and accept the above terms.\n///////////////////////////////////////////////////////////////////////////////\n\nimport Stats from \"three/examples/jsm/libs/stats.module.js\";\nimport { IComponent, components, Viewer } from \"@inweb/viewer-three\";\n\nclass StatsPanelComponent implements IComponent {\n protected viewer: Viewer;\n protected stats: Stats;\n\n constructor(viewer: Viewer) {\n this.stats = new Stats();\n this.stats.dom.style.position = \"absolute\";\n viewer.canvas.parentElement.appendChild(this.stats.dom);\n\n this.viewer = viewer;\n this.viewer.on(\"animate\", this.updateStats);\n }\n\n dispose() {\n this.viewer.off(\"animate\", this.updateStats);\n\n this.stats.dom.remove();\n this.stats = undefined;\n }\n\n updateStats = () => {\n this.stats.update();\n this.viewer.update();\n };\n}\n\ncomponents.registerComponent(\"StatsPanelComponent\", (viewer) => new StatsPanelComponent(viewer));\n"],"names":["StatsPanelComponent","constructor","viewer","this","updateStats","stats","update","Stats","dom","style","position","canvas","parentElement","appendChild","on","dispose","off","remove","undefined","components","registerComponent"],"mappings":";;;;AA0BA,MAAMA;IAIJ,WAAAC,CAAYC;QAgBZC,KAAWC,cAAG;YACZD,KAAKE,MAAMC;YACXH,KAAKD,OAAOI;AAAQ;QAjBpBH,KAAKE,QAAQ,IAAIE;QACjBJ,KAAKE,MAAMG,IAAIC,MAAMC,WAAW;QAChCR,OAAOS,OAAOC,cAAcC,YAAYV,KAAKE,MAAMG;QAEnDL,KAAKD,SAASA;QACdC,KAAKD,OAAOY,GAAG,WAAWX,KAAKC;;IAGjC,OAAAW;QACEZ,KAAKD,OAAOc,IAAI,WAAWb,KAAKC;QAEhCD,KAAKE,MAAMG,IAAIS;QACfd,KAAKE,QAAQa;;;;AASjBC,WAAWC,kBAAkB,wBAAwBlB,UAAW,IAAIF,oBAAoBE"}
|
package/dist/viewer-three.js
CHANGED
|
@@ -60512,6 +60512,7 @@ void main() {
|
|
|
60512
60512
|
this.animate = (time = 0) => {
|
|
60513
60513
|
this.requestId = requestAnimationFrame(this.animate);
|
|
60514
60514
|
this.viewer.render(time);
|
|
60515
|
+
this.viewer.emitEvent({ type: "animate", time });
|
|
60515
60516
|
};
|
|
60516
60517
|
this.viewer = viewer;
|
|
60517
60518
|
this.animate();
|