| | |
| | | |
| | | this.activateMapScale(); |
| | | this.activateMapPan(); |
| | | this.showCoordinates(); |
| | | this.startupTicker(); |
| | | |
| | | const bunny = PIXI.Sprite.from('https://pixijs.com/assets/bunny.png'); |
| | |
| | | }, 200).start(); |
| | | } |
| | | |
| | | showCoordinates = () => { |
| | | const coordinatesText = new PIXI.Text('{ x: 0, y: 0 }', { |
| | | fill: this.themeMode === 'dark' ? 0xffffff : 0x000000, |
| | | fontSize: 13, |
| | | fontFamily: 'MicrosoftYaHei', |
| | | fontWeight: 'bold', |
| | | }); |
| | | coordinatesText.name = 'xyStr' |
| | | coordinatesText.position.set(10, 10); |
| | | this.app.stage.addChild(coordinatesText); |
| | | |
| | | const mouseMoveInfoTextHandler = (event) => { |
| | | const mouseX = (event.clientX - this.mapContainer.position.x) / this.scale; |
| | | const mouseY = (event.clientY - this.mapContainer.position.y) / this.scale; |
| | | coordinatesText.text = `{ x: ${mouseX.toFixed(2)}, y: ${mouseY.toFixed(2)} }`; |
| | | }; |
| | | this.app.view.addEventListener('mousemove', mouseMoveInfoTextHandler); |
| | | } |
| | | |
| | | showGridLines = () => { |
| | | this.hideGridLines(); |
| | | if (!this.gridLineContainer) { |
| | |
| | | this.gridLineContainer = null; |
| | | } |
| | | } |
| | | |
| | | |
| | | startupTicker = () => { |
| | | this.app.ticker.add((delta) => { |