Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 780x 130x 650x 130x 520x 260x 260x 130x 130x 130x 130x 130x 130x 130x 130x 780x 780x 780x 780x 780x 780x 780x 780x 3120x 3120x 3120x 3120x 3120x 780x 780x 780x 390x 390x 780x | import { Node } from "../../../codeCharta.model" import { CodeMapBuilding } from "./codeMapBuilding" import { Box3, Vector3 } from "three" import { CodeMapGeometricDescription } from "./codeMapGeometricDescription" import { ColorConverter } from "../../../util/color/colorConverter" export interface BoxMeasures { x: number y: number z: number width: number height: number depth: number } export interface SurfaceInformation { node: Node surfaceStartIndex: number minPos: { z: number; x: number } maxPos: { z: number; x: number } } export interface IntermediateVertexData { positions: Float32Array normals: Float32Array uvs: Float32Array colors: Float32Array indices: Uint32Array ids: Float32Array deltas: Float32Array isHeight: Float32Array } enum sides { left = 0, right = 1, bottom = 2, top = 3, back = 4, front = 5 } // Vector 3: x, y, z const normals = [ [-1, 0, 0], [1, 0, 0], [0, -1, 0], [0, 1, 0], [0, 0, -1], [0, 0, 1] ] const uvArray = [ // Left x, y 1, 0, 1, 1, 0, 1, 0, 0, // Right x, y 0, 0, 0, 1, 1, 1, 1, 0, // Bottom x, y 0, 1, 1, 1, 1, 0, 0, 0, // Top x, y 0, 1, 1, 1, 1, 0, 0, 0, // Back x, y 0, 0, 1, 0, 1, 1, 0, 1, // Front x, y 1, 0, 0, 0, 0, 1, 1, 1 ] const numberSides = 6 const verticesPerSide = 4 const threeDimensions = 3 export function addBoxToVertexData( data: IntermediateVertexData, node: Node, measures: BoxMeasures, color: string, subGeomIndex: number, desc: CodeMapGeometricDescription, delta: number ) { desc.add( new CodeMapBuilding( subGeomIndex, new Box3( new Vector3(measures.x, measures.y, measures.z), new Vector3(measures.x + measures.width, measures.y + measures.height, measures.z + measures.depth) ), node, color ) ) data.uvs.set(uvArray, subGeomIndex * uvArray.length) setPositions(data.positions, measures, subGeomIndex) setVerticesAndFaces(node, measures, color, delta, subGeomIndex, data) } function setPositions(positions: Float32Array, measures: BoxMeasures, index: number) { const { x: minPosX, y: minPosY, z: minPosZ, width, height, depth } = measures const maxPosX = minPosX + width const maxPosY = minPosY + height const maxPosZ = minPosZ + depth let positionIndex = index * verticesPerSide * numberSides * threeDimensions // Left // Bottom left positions[positionIndex++] = minPosX positions[positionIndex++] = minPosY positions[positionIndex++] = minPosZ // Top left positions[positionIndex++] = minPosX positions[positionIndex++] = maxPosY positions[positionIndex++] = minPosZ // Top right positions[positionIndex++] = minPosX positions[positionIndex++] = maxPosY positions[positionIndex++] = maxPosZ // Bottom right positions[positionIndex++] = minPosX positions[positionIndex++] = minPosY positions[positionIndex++] = maxPosZ // Right // Bottom left positions[positionIndex++] = maxPosX positions[positionIndex++] = minPosY positions[positionIndex++] = minPosZ // Top left positions[positionIndex++] = maxPosX positions[positionIndex++] = maxPosY positions[positionIndex++] = minPosZ // Top right positions[positionIndex++] = maxPosX positions[positionIndex++] = maxPosY positions[positionIndex++] = maxPosZ // Bottom right positions[positionIndex++] = maxPosX positions[positionIndex++] = minPosY positions[positionIndex++] = maxPosZ // Bottom // Bottom left positions[positionIndex++] = minPosX positions[positionIndex++] = minPosY positions[positionIndex++] = minPosZ // Top left positions[positionIndex++] = minPosX positions[positionIndex++] = minPosY positions[positionIndex++] = maxPosZ // Top right positions[positionIndex++] = maxPosX positions[positionIndex++] = minPosY positions[positionIndex++] = maxPosZ // Bottom right positions[positionIndex++] = maxPosX positions[positionIndex++] = minPosY positions[positionIndex++] = minPosZ // Top // Bottom left positions[positionIndex++] = minPosX positions[positionIndex++] = maxPosY positions[positionIndex++] = minPosZ // Top left positions[positionIndex++] = minPosX positions[positionIndex++] = maxPosY positions[positionIndex++] = maxPosZ // Top right positions[positionIndex++] = maxPosX positions[positionIndex++] = maxPosY positions[positionIndex++] = maxPosZ // Bottom right positions[positionIndex++] = maxPosX positions[positionIndex++] = maxPosY positions[positionIndex++] = minPosZ // Back // Bottom left positions[positionIndex++] = maxPosX positions[positionIndex++] = minPosY positions[positionIndex++] = maxPosZ // Top left positions[positionIndex++] = minPosX positions[positionIndex++] = minPosY positions[positionIndex++] = maxPosZ // Top right positions[positionIndex++] = minPosX positions[positionIndex++] = maxPosY positions[positionIndex++] = maxPosZ // Bottom right positions[positionIndex++] = maxPosX positions[positionIndex++] = maxPosY positions[positionIndex++] = maxPosZ // Front // Bottom left positions[positionIndex++] = maxPosX positions[positionIndex++] = minPosY positions[positionIndex++] = minPosZ // Top left positions[positionIndex++] = minPosX positions[positionIndex++] = minPosY positions[positionIndex++] = minPosZ // Top right positions[positionIndex++] = minPosX positions[positionIndex++] = maxPosY positions[positionIndex++] = minPosZ // Bottom right positions[positionIndex++] = maxPosX positions[positionIndex++] = maxPosY positions[positionIndex++] = minPosZ } function isTopSide(side: number, node: Node) { if (!node.isLeaf || side === sides.bottom) { return [0, 0, 0, 0] } if (side === sides.top) { return [1, 1, 1, 1] } if (side <= sides.right) { return [0, 1, 1, 0] } return [0, 0, 1, 1] } function setVerticesAndFaces( node: Node, measures: BoxMeasures, color: string, delta: number, subGeomIndex: number, data: IntermediateVertexData ) { const { y: minPosY, height } = measures const maxPosY = minPosY + height const deltaRelativeToHeight = delta / (maxPosY - minPosY) let index = subGeomIndex * numberSides * verticesPerSide let vector3Index = index * threeDimensions let surfaceStartIndex = subGeomIndex * numberSides * numberSides const colors = ColorConverter.getVector3Array(color) for (let side = 0; side < numberSides; side++) { const topSides = isTopSide(side, node) const normal = normals[side] const indexBottomLeft = index const indexTopLeft = index + 1 const indexTopRight = index + 2 const indexBottomRight = index + 3 data.isHeight.set(topSides, index) for (const end = index + verticesPerSide; index < end; index++) { data.normals.set(normal, vector3Index) data.colors.set(colors, vector3Index) vector3Index += threeDimensions data.ids[index] = subGeomIndex data.deltas[index] = deltaRelativeToHeight } const dimension = Math.floor(side / 2) const positiveFacing = normal[dimension] === 1 if (positiveFacing) { data.indices.set( [indexBottomLeft, indexTopLeft, indexTopRight, indexBottomLeft, indexTopRight, indexBottomRight], surfaceStartIndex ) } else { data.indices.set( [indexBottomLeft, indexTopRight, indexTopLeft, indexBottomLeft, indexBottomRight, indexTopRight], surfaceStartIndex ) } surfaceStartIndex += numberSides } } |