Overview
MyTile represents a single cell in the maze grid. Each tile has a type (wall, empty, dot, pill, or teleport) and handles its own collision detection, visual rendering, and dot collection. Tiles are created by MyMaze during maze generation.
Extends: THREE.Object3D
Constructor
World position for the tile center
Tile type:
"wall", "empty", "dot", "pill", or "teleport"Width/height/depth of the tile cube (typically
MyConstant.BOX_SIZE)Whether this tile has collision detection (walls and teleports have hitboxes)
Optional procedurally generated material for wall tiles (Voronoi shader)
Properties
has_hitbox
Type:boolean
Whether this tile has collision detection. Walls and teleports have hitboxes to prevent characters from passing through.
size
Type:number
The dimensions of the tile cube. Used for hitbox calculations and rendering.
hitbox
Type:THREE.Box3
Axis-aligned bounding box for collision detection. Only present if has_hitbox is true.
helper
Type:THREE.Box3Helper
Visual debug helper showing the hitbox. Only created if MyConstant.SHOW_MAZE_HITBOX is enabled.
square
Type:THREE.Mesh
Flat plane mesh used for pathfinding visualization. Material can be changed to show ghost paths during debugging.
cube
Type:MyCube
The main cube geometry representing the tile. For walls, this uses the procedural material. For empty tiles, it’s invisible.
dot
Type:THREE.Mesh
Sphere mesh for collectible dots and power pills. Only present on "dot" and "pill" tiles.
- Dot size:
size/6radius (small sphere) - Pill size:
size/3radius (large sphere) - Material:
MyMaterial.WHITE
portal
Type:MyPortal
Animated portal effect for teleport tiles. Only present on "teleport" tiles.
Methods
getCollisionBox()
Returns the tile’s hitbox for collision detection. Returns:THREE.Box3 - The axis-aligned bounding box
dispose()
Cleans up all geometries, materials, and helpers to free memory. Should be called when removing tiles from the scene.- Path plane geometry
- Dot/pill sphere geometry (if present)
- Hitbox helper geometry (if present)
- Portal resources (if present)
- Cube resources
update()
Called each frame to update animated elements. Currently unused but available for future animations.Tile Types
Wall Tiles
- Solid obstacles that block character movement
- Use procedural Voronoi texture if
MyConstant.ACTIVE_SHADERis enabled - Collision detection prevents characters from passing through
Empty Tiles
- Walkable paths with no collectibles
- Invisible cube (used for pathfinding grid)
- No collision detection
Dot Tiles
- Standard collectible dots (10 points each)
- Small white sphere (
size/6radius) - 244 dots per maze
- Removed when Pac-Man collects them
Pill Tiles
- Power pills that enable ghost hunting (50 points each)
- Large white sphere (
size/3radius) - 4 pills per maze (corners)
- Triggers scared ghost behavior when collected
Teleport Tiles
- Portals at left/right maze edges
- Animated torus with rotating texture
- Collision detection triggers teleportation to opposite portal
- Typically 1-2 portal pairs per maze
Usage in MyMaze
Tiles are created during maze generation:MyMaze.js
Related Classes
- MyMaze - Creates and manages all tiles in the maze grid
- MyMaterial - Provides materials for dots and visual effects
- MyConstant - Defines BOX_SIZE and debug flags
- MyCube - Low-level cube wrapper used internally
- MyPortal - Animated portal effect for teleport tiles