|
|
@ -98,14 +98,25 @@ animate() |
|
|
|
function createTextMesh(text, colorName) { |
|
|
|
function createTextMesh(text, colorName) { |
|
|
|
let canvas = document.createElement('canvas') |
|
|
|
let canvas = document.createElement('canvas') |
|
|
|
let context = canvas.getContext('2d') |
|
|
|
let context = canvas.getContext('2d') |
|
|
|
let size = context.measureText(text) |
|
|
|
|
|
|
|
canvas.width = 100 |
|
|
|
|
|
|
|
canvas.height = 100 |
|
|
|
|
|
|
|
context.textAlign = "center" |
|
|
|
context.textAlign = "center" |
|
|
|
context.textBaseline = "middle" |
|
|
|
context.textBaseline = "middle" |
|
|
|
context.fillStyle = colorName |
|
|
|
context.fillStyle = colorName |
|
|
|
context.font = '24pt sans-serif' |
|
|
|
context.font = '144pt sans-serif' |
|
|
|
context.fillText(text, 50, 50) |
|
|
|
|
|
|
|
|
|
|
|
let size = context.measureText(text) |
|
|
|
|
|
|
|
let height = context.measureText('M').width |
|
|
|
|
|
|
|
size.height = height |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let canvasScale = 0.1 |
|
|
|
|
|
|
|
canvas.width = size.width * canvasScale * 0.6 |
|
|
|
|
|
|
|
canvas.height = size.height * canvasScale |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log([canvas.width, canvas.height]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context.fillStyle = 'red' |
|
|
|
|
|
|
|
context.fillRect(0, 0, canvas.width, canvas.height) |
|
|
|
|
|
|
|
context.fillStyle = 'blue' |
|
|
|
|
|
|
|
context.fillText(text, 5, 10) |
|
|
|
|
|
|
|
|
|
|
|
let texture = new THREE.CanvasTexture(canvas) |
|
|
|
let texture = new THREE.CanvasTexture(canvas) |
|
|
|
texture.needsUpdate = true |
|
|
|
texture.needsUpdate = true |
|
|
@ -114,7 +125,9 @@ function createTextMesh(text, colorName) { |
|
|
|
}) |
|
|
|
}) |
|
|
|
material.transparent = true |
|
|
|
material.transparent = true |
|
|
|
|
|
|
|
|
|
|
|
let plane = new THREE.PlaneGeometry(3, 3) |
|
|
|
let scaleFactor = 0.05 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let plane = new THREE.PlaneGeometry(canvas.width * scaleFactor, canvas.height * scaleFactor) |
|
|
|
let mesh = new THREE.Mesh(plane, material) |
|
|
|
let mesh = new THREE.Mesh(plane, material) |
|
|
|
|
|
|
|
|
|
|
|
return mesh |
|
|
|
return mesh |
|
|
@ -223,15 +236,19 @@ function configureScene(data) { |
|
|
|
roomLines.userData.name = "lines" |
|
|
|
roomLines.userData.name = "lines" |
|
|
|
roomContainer.add(roomLines) |
|
|
|
roomContainer.add(roomLines) |
|
|
|
|
|
|
|
|
|
|
|
let roomLabel = createTextMesh("A test or something", "red") |
|
|
|
|
|
|
|
roomLabel.userData.name = "label" |
|
|
|
|
|
|
|
roomContainer.add(roomLabel) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let roomZ = room.z || 0 |
|
|
|
let roomZ = room.z || 0 |
|
|
|
|
|
|
|
|
|
|
|
setPosition(roomContainer, room.x, room.y, roomZ, room.w, room.h, room.d) |
|
|
|
setPosition(roomContainer, room.x, room.y, roomZ, room.w, room.h, room.d) |
|
|
|
home.add(roomContainer) |
|
|
|
home.add(roomContainer) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let roomLabel = createTextMesh(room.name, room.color) |
|
|
|
|
|
|
|
roomLabel.position.x = roomContainer.position.x |
|
|
|
|
|
|
|
roomLabel.position.y = roomContainer.position.y |
|
|
|
|
|
|
|
roomLabel.position.z = roomZ |
|
|
|
|
|
|
|
roomLabel.renderOrder = 5000 |
|
|
|
|
|
|
|
// not yet
|
|
|
|
|
|
|
|
// homeContainer.add(roomLabel)
|
|
|
|
|
|
|
|
|
|
|
|
minX = Math.min(minX, room.x) |
|
|
|
minX = Math.min(minX, room.x) |
|
|
|
minY = Math.min(minY, room.y) |
|
|
|
minY = Math.min(minY, room.y) |
|
|
|
minZ = Math.min(minZ, roomZ) |
|
|
|
minZ = Math.min(minZ, roomZ) |
|
|
|