|
1398 | 1398 | { |
1399 | 1399 | name: 'color cube', |
1400 | 1400 | uiHtml: ` |
1401 | | - x pixels = #FF00000A (red)<br /> |
1402 | | - y pixels = #00FF000A (green)<br /> |
1403 | | - z pixels = #0000FF0A (blue)<br /> |
| 1401 | + x-pixels = #FF00000A (red)<br /> |
| 1402 | + y-pixels = #00FF000A (green)<br /> |
| 1403 | + z-pixels = #0000FF0A (blue)<br /> |
1404 | 1404 | <br /> |
1405 | 1405 | Look at the display from different angles to see the colors. |
1406 | 1406 | `, |
|
1597 | 1597 | timeMs: 0, |
1598 | 1598 | lastTimeMs: 0, |
1599 | 1599 | isPaused: false, |
| 1600 | + requestAnimate: false, |
1600 | 1601 | pauseRippleButton: null |
1601 | 1602 | }, |
1602 | 1603 | init() { |
1603 | | - this.instanceData.isPaused = false; |
1604 | 1604 | this.instanceData.pauseRippleButton = VolumetricDisplayControl.uiDisplayRightPanelBody.querySelector('#pauseRipple'); |
1605 | | - this.instanceData.pauseRippleButton.innerText = 'pause ripple'; |
1606 | | - this.instanceData.pauseRippleButton.style.backgroundColor = '#000000'; |
1607 | | - this.instanceData.pauseRippleButton.style.color = '#88ffff'; |
| 1605 | + if (this.instanceData.isPaused) { |
| 1606 | + this.instanceData.pauseRippleButton.innerText = 'resume ripple'; |
| 1607 | + this.instanceData.pauseRippleButton.style.backgroundColor = '#88ffff'; |
| 1608 | + this.instanceData.pauseRippleButton.style.color = '#000000'; |
| 1609 | + } else { |
| 1610 | + this.instanceData.lastTimeMs = Date.now(); |
| 1611 | + this.instanceData.pauseRippleButton.innerText = 'pause ripple'; |
| 1612 | + this.instanceData.pauseRippleButton.style.backgroundColor = '#000000'; |
| 1613 | + this.instanceData.pauseRippleButton.style.color = '#88ffff'; |
| 1614 | + } |
1608 | 1615 | this.instanceData.pauseRippleButton.addEventListener('click', (event) => { |
1609 | 1616 | event.stopPropagation(); |
1610 | 1617 | event.preventDefault(); |
|
1613 | 1620 | this.instanceData.pauseRippleButton.innerText = 'resume ripple'; |
1614 | 1621 | this.instanceData.pauseRippleButton.style.backgroundColor = '#88ffff'; |
1615 | 1622 | this.instanceData.pauseRippleButton.style.color = '#000000'; |
| 1623 | + this.instanceData.requestAnimate = true; |
1616 | 1624 | } else { |
1617 | 1625 | this.instanceData.lastTimeMs = Date.now(); |
1618 | 1626 | this.instanceData.pauseRippleButton.innerText = 'pause ripple'; |
|
1622 | 1630 | }); |
1623 | 1631 | VolumetricDisplay.fill(); |
1624 | 1632 | VolumetricDisplay.update(); |
| 1633 | + if (this.instanceData.isPaused) { |
| 1634 | + this.instanceData.requestAnimate = true; |
| 1635 | + } else { |
| 1636 | + this.instanceData.lastTimeMs = Date.now(); |
| 1637 | + } |
1625 | 1638 | }, |
1626 | 1639 | animate() { |
1627 | | - if (this.instanceData.isPaused) { |
| 1640 | + if (this.instanceData.isPaused && !this.instanceData.requestAnimate) { |
1628 | 1641 | return; |
1629 | 1642 | } |
1630 | | - this.instanceData.timeMs += (Date.now() - this.instanceData.lastTimeMs) | 0; |
| 1643 | + if (!this.instanceData.isPaused) { |
| 1644 | + this.instanceData.timeMs += (Date.now() - this.instanceData.lastTimeMs) | 0; |
| 1645 | + } |
1631 | 1646 | this.instanceData.lastTimeMs = Date.now(); |
1632 | 1647 | const timeMs = this.instanceData.timeMs; |
1633 | 1648 | VolumetricDisplay.fill(); |
|
1665 | 1680 | } |
1666 | 1681 | } |
1667 | 1682 | VolumetricDisplay.update(); |
| 1683 | + this.instanceData.requestAnimate = false; |
1668 | 1684 | } |
1669 | 1685 | }, |
1670 | 1686 | { |
|
0 commit comments