add fps tracker in expert mode
This commit is contained in:
parent
ed0a831332
commit
ab81c2dd92
5 changed files with 47 additions and 25 deletions
3
notes.md
3
notes.md
|
|
@ -2,11 +2,10 @@
|
||||||
|
|
||||||
NEXT
|
NEXT
|
||||||
- contour tabs support
|
- contour tabs support
|
||||||
- flat render
|
- cap path ends
|
||||||
- path arrows
|
- path arrows
|
||||||
- help dialog
|
- help dialog
|
||||||
- full bug reports
|
- full bug reports
|
||||||
- frame rate tracking
|
|
||||||
|
|
||||||
## `C` cosmetic, `F` functional, `P` performance, `B` bug fix
|
## `C` cosmetic, `F` functional, `P` performance, `B` bug fix
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@
|
||||||
selectedTool = null,
|
selectedTool = null,
|
||||||
editTools = null,
|
editTools = null,
|
||||||
maxTool = 0,
|
maxTool = 0,
|
||||||
|
fpsTimer = null,
|
||||||
platformColor;
|
platformColor;
|
||||||
|
|
||||||
// extend KIRI API with local functions
|
// extend KIRI API with local functions
|
||||||
|
|
@ -143,6 +144,18 @@
|
||||||
maxpass: control.decimate ? 10 : 0
|
maxpass: control.decimate ? 10 : 0
|
||||||
});
|
});
|
||||||
UC.setHoverPop(control.hoverPop);
|
UC.setHoverPop(control.hoverPop);
|
||||||
|
updateFPS();
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateFPS() {
|
||||||
|
clearTimeout(fpsTimer);
|
||||||
|
const on = UI.expert.checked;
|
||||||
|
UI.fps.style.display = on ? 'block' : '';
|
||||||
|
if (on) {
|
||||||
|
setInterval(() => {
|
||||||
|
UI.fps.innerText = SPACE.view.getFPS().toFixed(2);
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onLayerToggle() {
|
function onLayerToggle() {
|
||||||
|
|
@ -1233,6 +1246,7 @@
|
||||||
export: $('act-export')
|
export: $('act-export')
|
||||||
},
|
},
|
||||||
|
|
||||||
|
fps: $('fps'),
|
||||||
load: $('load-file'),
|
load: $('load-file'),
|
||||||
speeds: $('speeds'),
|
speeds: $('speeds'),
|
||||||
speedbar: $('speedbar'),
|
speedbar: $('speedbar'),
|
||||||
|
|
@ -1929,6 +1943,7 @@
|
||||||
UI.decimate.checked = control.decimate;
|
UI.decimate.checked = control.decimate;
|
||||||
lineTypeSave();
|
lineTypeSave();
|
||||||
detailSave();
|
detailSave();
|
||||||
|
updateFPS();
|
||||||
|
|
||||||
// load script extensions
|
// load script extensions
|
||||||
if (SETUP.s) SETUP.s.forEach(function(lib) {
|
if (SETUP.s) SETUP.s.forEach(function(lib) {
|
||||||
|
|
|
||||||
|
|
@ -230,17 +230,17 @@
|
||||||
|
|
||||||
contourClosed = contourClosed !== undefined ? contourClosed : true;
|
contourClosed = contourClosed !== undefined ? contourClosed : true;
|
||||||
|
|
||||||
let profileGeometry = new THREE.ShapeBufferGeometry(profileShape);
|
const profileGeometry = new THREE.ShapeBufferGeometry(profileShape);
|
||||||
profileGeometry.rotateX(Math.PI * .5);
|
profileGeometry.rotateX(Math.PI * .5);
|
||||||
|
|
||||||
let profile = profileGeometry.attributes.position;
|
const profile = profileGeometry.attributes.position;
|
||||||
let faces = new Float32Array(profile.count * contour.length * 3);
|
const faces = new Float32Array(profile.count * contour.length * 3);
|
||||||
|
|
||||||
for (let i = 0; i < contour.length; i++) {
|
for (let i = 0; i < contour.length; i++) {
|
||||||
let v1 = new THREE.Vector2().subVectors(contour[i - 1 < 0 ? contour.length - 1 : i - 1], contour[i]);
|
const v1 = new THREE.Vector2().subVectors(contour[i - 1 < 0 ? contour.length - 1 : i - 1], contour[i]);
|
||||||
let v2 = new THREE.Vector2().subVectors(contour[i + 1 == contour.length ? 0 : i + 1], contour[i]);
|
const v2 = new THREE.Vector2().subVectors(contour[i + 1 == contour.length ? 0 : i + 1], contour[i]);
|
||||||
let angle = v2.angle() - v1.angle();
|
const angle = v2.angle() - v1.angle();
|
||||||
let halfAngle = angle * .5;
|
const halfAngle = angle * .5;
|
||||||
let hA = halfAngle;
|
let hA = halfAngle;
|
||||||
let tA = v2.angle() + Math.PI * .5;
|
let tA = v2.angle() + Math.PI * .5;
|
||||||
|
|
||||||
|
|
@ -249,30 +249,30 @@
|
||||||
if (i == contour.length - 1) {tA = v1.angle() - Math.PI * .5;}
|
if (i == contour.length - 1) {tA = v1.angle() - Math.PI * .5;}
|
||||||
}
|
}
|
||||||
|
|
||||||
let shift = Math.tan(hA - Math.PI * .5);
|
const shift = Math.tan(hA - Math.PI * .5);
|
||||||
let shiftMatrix = new THREE.Matrix4().set(
|
const shiftMatrix = new THREE.Matrix4().set(
|
||||||
1, 0, 0, 0,
|
1, 0, 0, 0,
|
||||||
-shift, 1, 0, 0,
|
-shift, 1, 0, 0,
|
||||||
0, 0, 1, 0,
|
0, 0, 1, 0,
|
||||||
0, 0, 0, 1
|
0, 0, 0, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
let tempAngle = tA;
|
const tempAngle = tA;
|
||||||
let rotationMatrix = new THREE.Matrix4().set(
|
const rotationMatrix = new THREE.Matrix4().set(
|
||||||
Math.cos(tempAngle), -Math.sin(tempAngle), 0, 0,
|
Math.cos(tempAngle), -Math.sin(tempAngle), 0, 0,
|
||||||
Math.sin(tempAngle), Math.cos(tempAngle), 0, 0,
|
Math.sin(tempAngle), Math.cos(tempAngle), 0, 0,
|
||||||
0, 0, 1, 0,
|
0, 0, 1, 0,
|
||||||
0, 0, 0, 1
|
0, 0, 0, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
let translationMatrix = new THREE.Matrix4().set(
|
const translationMatrix = new THREE.Matrix4().set(
|
||||||
1, 0, 0, contour[i].x,
|
1, 0, 0, contour[i].x,
|
||||||
0, 1, 0, contour[i].y,
|
0, 1, 0, contour[i].y,
|
||||||
0, 0, 1, 0,
|
0, 0, 1, 0,
|
||||||
0, 0, 0, 1,
|
0, 0, 0, 1,
|
||||||
);
|
);
|
||||||
|
|
||||||
let cloneProfile = profile.clone();
|
const cloneProfile = profile.clone();
|
||||||
cloneProfile.applyMatrix4(shiftMatrix);
|
cloneProfile.applyMatrix4(shiftMatrix);
|
||||||
cloneProfile.applyMatrix4(rotationMatrix);
|
cloneProfile.applyMatrix4(rotationMatrix);
|
||||||
cloneProfile.applyMatrix4(translationMatrix);
|
cloneProfile.applyMatrix4(translationMatrix);
|
||||||
|
|
@ -280,20 +280,20 @@
|
||||||
faces.set(cloneProfile.array, cloneProfile.count * i * 3);
|
faces.set(cloneProfile.array, cloneProfile.count * i * 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
let index = [];
|
const index = [];
|
||||||
let lastCorner = contourClosed == false ? contour.length - 1: contour.length;
|
const lastCorner = contourClosed == false ? contour.length - 1: contour.length;
|
||||||
|
|
||||||
for (let i = 0; i < lastCorner; i++) {
|
for (let i = 0; i < lastCorner; i++) {
|
||||||
for (let j = 0; j < profile.count; j++) {
|
for (let j = 0; j < profile.count; j++) {
|
||||||
let currCorner = i;
|
const currCorner = i;
|
||||||
let nextCorner = i + 1 == contour.length ? 0 : i + 1;
|
const nextCorner = i + 1 == contour.length ? 0 : i + 1;
|
||||||
let currPoint = j;
|
const currPoint = j;
|
||||||
let nextPoint = j + 1 == profile.count ? 0 : j + 1;
|
const nextPoint = j + 1 == profile.count ? 0 : j + 1;
|
||||||
|
|
||||||
let a = nextPoint + profile.count * currCorner;
|
const a = nextPoint + profile.count * currCorner;
|
||||||
let b = currPoint + profile.count * currCorner;
|
const b = currPoint + profile.count * currCorner;
|
||||||
let c = currPoint + profile.count * nextCorner;
|
const c = currPoint + profile.count * nextCorner;
|
||||||
let d = nextPoint + profile.count * nextCorner;
|
const d = nextPoint + profile.count * nextCorner;
|
||||||
|
|
||||||
index.push(a, b, d);
|
index.push(a, b, d);
|
||||||
index.push(b, c, d);
|
index.push(b, c, d);
|
||||||
|
|
|
||||||
|
|
@ -1054,3 +1054,10 @@ th, tr, td, label {
|
||||||
padding: 5px 20px 5px 20px;
|
padding: 5px 20px 5px 20px;
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
}
|
}
|
||||||
|
#fps {
|
||||||
|
position: fixed;
|
||||||
|
right: 5px;
|
||||||
|
bottom: 5px;
|
||||||
|
font-size: 10px;
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -381,6 +381,7 @@
|
||||||
<p>this site uses cookies to preserve application preferences</p>
|
<p>this site uses cookies to preserve application preferences</p>
|
||||||
<button id="gotit" class="f-col j-center">got it</button>
|
<button id="gotit" class="f-col j-center">got it</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="fps" class="noshow"></div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue