new Raycaster( [options])
Parameters:
Name | Type | Argument | Description | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
Raycaster's configuration options. May include:
Properties
|
- Since:
-
- 0.6.0
- Source:
Classes
Members
-
<readonly> version :string
-
Plugin version.
Type:
- string
- Since:
-
- 0.6.0
- Source:
-
debugOptions :Object
-
Raycaster's debug config
Type:
- Object
- Since:
-
- 0.10.0
- Source:
Properties:
Name Type Argument Default Description enable
boolean <optional>
false Enable debug mode maps
boolean <optional>
true Enable maps debug graphics
boolean Debug graphics options Properties
Name Type Argument Default Description ray
boolean | number <optional>
0x00ff00 Debug ray color. Set false to disable. rayPoint
boolean | number <optional>
0xff00ff Debug ray point color. Set false to disable. mapPoint
boolean | number <optional>
0x00ffff debug map point color. Set false to disable. mapSegment
boolean | number <optional>
0x0000ff Debug map segment color. Set false to disable. mapBoundingBox
boolean | number <optional>
0xff0000 Debug map bounding box color. Set false to disable. -
mappedObjects :Array.<object>
-
Array of mapped game objects.
Type:
- Array.<object>
- Since:
-
- 0.6.0
- Source:
-
dynamicMappedObjects :Array.<object>
-
Array of dynamic mapped game objects.
Type:
- Array.<object>
- Since:
-
- 0.10.6
- Source:
-
mapSegmentCount :number
-
Number of segments of circle maps.
Type:
- number
- Since:
-
- 0.6.0
- Default Value:
-
- 0
- Source:
-
<static> Map_dynamic :boolean
-
If set true, map will be automatically updated on scene update event.
Type:
- boolean
- Since:
-
- 0.6.0
- Default Value:
-
- false
- Source:
Methods
-
setOptions( [options])
-
Configure raycaster.
Parameters:
Name Type Argument Description options
object <optional>
Raycaster's congfiguration options. May include: Properties
Name Type Argument Default Description scene
Phaser.Scene <optional>
Scene in which Raycaster will be used. mapSegmentCount
number <optional>
0 Number of segments of circle maps. objects
object | Array.<object> <optional>
Game object or array of game objects to map. boundingBox
Phaser.Geom.Rectangle <optional>
Raycaster's bounding box. debug
boolean | object <optional>
Enable debug mode or cofigure debugOptions. - Since:
-
- 0.6.0
- Source:
Returns:
Raycaster instance- Type
- Raycaster
-
setBoundingBox(x, y, width, height)
-
Set Raycaster's bounding box.
Parameters:
Name Type Description x
number The X coordinate of the top left corner of bounding box. y
number The Y coordinate of the top left corner of bounding box. width
number The width of bounding box. height
number The height of bounding box. - Since:
-
- 0.6.0
- Source:
Returns:
Raycaster instance- Type
- Raycaster
-
mapGameObjects(objects [, dynamic] [, options])
-
Map game objects
Parameters:
Name Type Argument Default Description objects
object | Array.<object> Game object / matter body or array of game objects / matter bodies to map. dynamic
boolean <optional>
false Raycaster.Map dynamic flag (determines map will be updated automatically). options
object <optional>
Additional options for Raycaster.Map - Since:
-
- 0.6.0
- Source:
Returns:
Raycaster instance- Type
- Raycaster
-
removeMappedObjects(objects)
-
Remove game object's Raycaster.Map maps.
Parameters:
Name Type Description objects
object | Array.<object> Game object or array of game objects which maps will be removed. - Since:
-
- 0.6.0
- Source:
Returns:
Raycaster instance- Type
- Raycaster
-
enableMaps(objects)
-
Enable game object's Raycaster.Map maps.
Parameters:
Name Type Description objects
object | Array.<object> Game object or array of game objects which maps will be enabled. - Since:
-
- 0.7.2
- Source:
Returns:
Raycaster instance- Type
- Raycaster
-
disableMaps(objects)
-
Disable game object's Raycaster.Map maps.
Parameters:
Name Type Description objects
object | Array.<object> Game object or array of game objects which maps will be disabled. - Since:
-
- 0.7.2
- Source:
Returns:
Raycaster instance- Type
- Raycaster
-
update()
-
Updates all Raycaster.Map dynamic maps. Fired on Phaser.Scene update event.
- Since:
-
- 0.6.0
- Source:
Returns:
Raycaster instance- Type
- Raycaster
-
createRay( [options])
-
Create Raycaster.Ray object.
Parameters:
Name Type Argument Description options
object <optional>
Ray's congfiguration options. May include: Properties
Name Type Argument Default Description origin
Phaser.Geom.Point | Point <optional>
{x:0, y:0} Ray's position. angle
number <optional>
0 Ray's angle in radians. angleDeg
number <optional>
0 Ray's angle in degrees. cone
number <optional>
0 Ray's cone angle in radians. coneDeg
number <optional>
0 Ray's cone angle in degrees. range
number <optional>
Phaser.Math.MAX_SAFE_INTEGER Ray's range. collisionRange
number <optional>
Phaser.Math.MAX_SAFE_INTEGER Ray's maximum collision range of ray's field of view. detectionRange
number <optional>
Phaser.Math.MAX_SAFE_INTEGER Maximum distance between ray's position and tested objects bounding boxes. ignoreNotIntersectedRays
boolean <optional>
true If set true, ray returns false when it didn't hit anything. Otherwise returns ray's target position. autoSlice
boolean <optional>
false If set true, ray will automatically slice intersections into array of triangles and store it in Ray.slicedIntersections. round
boolean <optional>
false If set true, point where ray hit will be rounded. enablePhysics
boolean | 'arcade' | 'matter' <optional>
false Add to ray physics body. Body will be a circle with radius equal to Ray.collisionRange. If set true, arcade physics body will be added. - Since:
-
- 0.6.0
- Source:
Returns:
Raycaster.Ray instance- Type
- Raycaster.Ray
-
getStats()
-
Get raycaster statistics.
- Since:
-
- 0.10.0
- Source:
Returns:
Raycaster statistics.- Type
- object
-
destroy()
-
Destroy object and all mapped objects.
- Since:
-
- 0.10.3
- Source: