Buckets:
| import * as THREE from 'three'; | |
| function createText( message, height ) { | |
| const canvas = document.createElement( 'canvas' ); | |
| const context = canvas.getContext( '2d' ); | |
| let metrics = null; | |
| const textHeight = 100; | |
| context.font = 'normal ' + textHeight + 'px Arial'; | |
| metrics = context.measureText( message ); | |
| const textWidth = metrics.width; | |
| canvas.width = textWidth; | |
| canvas.height = textHeight; | |
| context.font = 'normal ' + textHeight + 'px Arial'; | |
| context.textAlign = 'center'; | |
| context.textBaseline = 'middle'; | |
| context.fillStyle = '#ffffff'; | |
| context.fillText( message, textWidth / 2, textHeight / 2 ); | |
| const texture = new THREE.Texture( canvas ); | |
| texture.needsUpdate = true; | |
| const material = new THREE.MeshBasicMaterial( { | |
| color: 0xffffff, | |
| side: THREE.DoubleSide, | |
| map: texture, | |
| transparent: true, | |
| } ); | |
| const geometry = new THREE.PlaneGeometry( | |
| ( height * textWidth ) / textHeight, | |
| height | |
| ); | |
| const plane = new THREE.Mesh( geometry, material ); | |
| return plane; | |
| } | |
| export { createText }; | |
Xet Storage Details
- Size:
- 1.02 kB
- Xet hash:
- 98aaad34e9204e6e542ac1c0ff4345c40341cdf1b122d035beecaf86f13608b5
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.