Class: MapPortion

MapPortion

A portion of the map

new MapPortion (realX, realY, realZ)

Name Type Description
realX number The real x portion
realY number The real y portion
realZ number The real z portion
Properties:
Name Type Description
BB_MATERIAL THREE.MeshBasicMaterial
realX number The real x portion
realY number The real y portion
realZ number The real z portion
staticFloorsMesh THREE.Mesh The mesh used for drawing all the floors
staticSpritesMesh Array.<THREE.Mesh> List of all the static sprites in the scene
squareNonEmpty Array.<Array.<Array.<number>>> List of all y floors according to x and y square
boundingBoxesLands Array.<Object> Bounding boxes for lands acording to index
boundingBoxesSprites Array.<Object> Bounding boxes for sprites acording to index
boundingBoxesMountains Array.<Object> Bounding boxes for mountains acording to index
boundingBoxesObjects3D Array.<Object> Bounding boxes for 3D objects acording to index
staticAutotilesList Array.<THREE.Mesh> List of all the static autotiles in the map portion
staticMountainsList Array.<THREE.Mesh> List of all the static mountains in the map portion
objectsList Array.<MapObject> List of all the objects in the portion
faceSpritesList Array.<THREE.Mesh> List of all the face sprites in the scene
staticWallsList Array.<THREE.Mesh> List of all the static walls in the map portion
staticObjects3DList Array.<THREE.Mesh> List of all the static 3D objects in the map portion
overflowMountains Array.<Array.<number>> Position of overflow mountians
heroID Array.<THREE.Mesh> The hero ID if in this portions

Methods

MapPortion.checkCollisionRay (positionBefore, positionAfter, object)boolean static

Check collision ray
Name Type Description
positionBefore THREE.Vector3 The position before collision
positionAfter THREE.Vector3 The position after collision
object MapObject The map object to test collision
Returns:
Type Description
boolean

MapPortion.applyBoxLandTransforms (box, boundingBox) static

Apply transform for lands bounding box
Name Type Description
box THREE.Mesh The mesh bounding box
boundingBox Array.<number> The bounding box list parameters

MapPortion.applyBoxSpriteTransforms (box, boundingBox) static

Apply transform for sprite bounding box
Name Type Description
box THREE.Mesh The mesh bounding box
boundingBox Array.<number> The bounding box list parameters

MapPortion.applyOrientedBoxTransforms (box, boundingBox) static

Apply transform for oriented bounding box
Name Type Description
box THREE.Mesh The mesh bounding box
boundingBox Array.<number> The bounding box list parameters

MapPortion.createBox ()THREE.Mesh static

Create a box for bounding box
Returns:
Type Description
THREE.Mesh

MapPortion.createOrientedBox ()THREE.Mesh static

Create an oriented box for bounding box
Returns:
Type Description
THREE.Mesh

read (json, isMapHero)

Read the JSON associated to the map portion
Name Type Description
json Object Json object describing the map portion
isMapHero boolean Indicates if this map is where the hero is at the beginning of the game.

readLands (json)

Read the JSON associated to the lands in the portion
Name Type Description
json Object Json object describing the lands

readFloors (json)

Read the JSON associated to the floors in the portion
Name Type Description
json Object Json object describing the floors

readAutotiles (json)

Read the JSON associated to the autotiles in the portion
Name Type Description
json Object Json object describing the autotiles

readSprites (json)

Read the JSON associated to the sprites in the portion
Name Type Description
json Object Json object describing the sprites

readSpritesGlobals (json)

Read the JSON associated to the sprites globals in the portion
Name Type Description
json Object Json object describing the sprites globals

readSpritesWalls (json)

Read the JSON associated to the sprites walls in the portion
Name Type Description
json Object Json object describing the sprites walls

readMountains (json)

Read the JSON associated to the mountains in the portion
Name Type Description
json Object Json object describing the mountains

readObjects3D (json)

Read the JSON associated to the objects 3D in the portion
Name Type Description
json Object Json object describing the objects 3D

readObjects (json, isMapHero)

Read the JSON associated to the objects in the portion
Name Type Description
json Object Json object describing the objects
isMapHero boolean Indicates if this map is where the hero is at the beginning of the game

cleanAll ()

Remove all the objects from the scene

getObjFromID (json, id)MapObject

Search for the object with the ID
Name Type Description
json Object Json object describing the objects
id number The ID of the object
Returns:
Type Description
MapObject

getHeroModel (json)MapObject

Get hero model
Name Type Description
json Object Json object describing the objects
Returns:
Type Description
MapObject

updateFaceSprites (angle)

Update the face sprites orientation
Name Type Description
angle number The angle on the Y axis

updateCollisionSprite (collisions, position)

Update the collision sprite
Name Type Description
collisions Array.<Object> The collisions objects
position Array.<number> The json position of the sprite

updateCollision (boundingBoxes, collisions, position, side)

Update the collision sprite
Name Type Description
boundingBoxes Array.<Object> The bounding boxes list to update
collisions Array.<Object> The collisions objects
position Array.<number> The json position of the sprite
side boolean Indicate if collision side

getObjectCollisionAt (positionSource, positionTarget, kind)

Get the object collision according to position
Name Type Description
positionSource Array.<number> The source json position
positionTarget Array.<number> The target json position
kind ElementMapKind The element map kind

addToNonEmpty (position)

Add a position to non empty
Name Type Description
position Array.<number> The position to add

isPositionIn (position)boolean

Check if position if in this map portion
Name Type Description
position Array.<number> The position to check
Returns:
Type Description
boolean

checkCollision (jpositionBefore, jpositionAfter, positionAfter, object, direction, testedCollisions)boolean

Check if there is a collision at this position
Name Type Description
jpositionBefore Array.<number> The json position before collision
jpositionAfter Array.<number> The json position after collision
positionAfter THREE.Vector3 The position after collision
object MapObject The map object collision test
direction THREE.Vector3 The direction collision
testedCollisions Array.<Object> The object collisions that were already tested
Returns:
Type Description
boolean

checkLandsCollision (jpositionBefore, jpositionAfter, object, direction, testedCollisions)boolean

Check if there is a collision with lands at this position
Name Type Description
jpositionBefore Array.<number> The json position before collision
jpositionAfter Array.<number> The json position after collision
object MapObject The map object collision test
direction THREE.Vector3 The direction collision
testedCollisions Array.<Object> The object collisions that were already tested
Returns:
Type Description
boolean

checkLandsCollisionInside (jpositionBefore, jpositionAfter, direction)boolean

Check if there is a collision with lands with directions
Name Type Description
jpositionBefore Array.<number> The json position before collision
jpositionAfter Array.<number> The json position after collision
direction THREE.Vector3 The direction collision
Returns:
Type Description
boolean

checkIntersectionLand (collision, boundingBox, object)boolean

Check intersection between ray and an object
Name Type Description
collision Object The collision object
boundingBox Array.<number> The bounding box values
object MapObject The map object to check
Returns:
Type Description
boolean

checkDirections (jpositionBefore, jpositionAfter, collision, boundingBox, direction, object)boolean

Check directions
Name Type Description
jpositionBefore Array.<number> The json position before collision
jpositionAfter Array.<number> The json position after collision
collision Object The collision object
boundingBox Array.<number> The bounding box values
direction THREE.Vector3 The direction collision
object MapObject The map object collision test
Returns:
Type Description
boolean

checkDirectionsInside (jpositionBefore, jpositionAfter, collision, direction)boolean

Check directions inside
Name Type Description
jpositionBefore Array.<number> The json position before collision
jpositionAfter Array.<number> The json position after collision
collision Object The collision object
direction THREE.Vector3 The direction collision
Returns:
Type Description
boolean

checkSpritesCollision (jpositionAfter, testedCollisions, object)boolean

Check if there is a collision with sprites at this position
Name Type Description
jpositionAfter Array.<number> The json position after collision
testedCollisions Array.<Object> The object collisions that were already tested
object MapObject The map object collision test
Returns:
Type Description
boolean

checkIntersectionSprite (boundingBox, fix, object)boolean

Check intersection between ray and an object
Name Type Description
boundingBox Array.<number> The bounding box values
fix boolean Indicate if the sprite is fix or not
object MapObject The map object collision test
Returns:
Type Description
boolean

checkObjects3DCollision (jpositionAfter, testedCollisions, object)boolean

Check if there is a collision with sprites at this position
Name Type Description
jpositionAfter Array.<number> The json position after collision
testedCollisions Array.<Object> The object collisions that were already tested
object MapObject The map object collision test
Returns:
Type Description
boolean

checkMountainsCollision (jpositionAfter, positionAfter, testedCollisions, object)boolean

Check if there is a collision with mountains at this position
Name Type Description
jpositionAfter Array.<number> The json position after collision
positionAfter THREE.Vector3 The position after collision
testedCollisions Array.<Object> The object collisions that were already tested
object MapObject The map object collision test
Returns:
Type Description
boolean

checkMountainCollision (jpositionAfter, positionAfter, testedCollisions, object, objCollision, yMountain, block)boolean

Check if there is a collision with mountains at this position
Name Type Description
jpositionAfter Array.<number> The json position after collision
positionAfter THREE.Vector3 The position after collision
testedCollisions Array.<Object> The object collisions that were already tested
object MapObject The map object collision test
objCollision Object The object collision
yMountain number The y mountain collision
block boolean The block mountain collision
Returns:
Type Description
boolean

checkIntersectionMountain (jpositionAfter, positionAfter, objCollision, object)boolean

Check intersection with a mountain
Name Type Description
jpositionAfter Array.<number> The json position after collision
positionAfter THREE.Vector3 The position after collision
objCollision Object The object collision
object MapObject The map object collision test
Returns:
Type Description
boolean

checkObjectsCollision (object)boolean

Check collision with objects
Name Type Description
object MapObject The map object collision test
Returns:
Type Description
boolean

checkObjectsCollisionList (list, object)boolean

Check collision with objects
Name Type Description
list Array.<MapObject> The map objects list to test
object MapObject The map object collision test
Returns:
Type Description
boolean