marble3 / Collectible
Class: Collectible
Defined in: src/collectible.ts:31
An item lying in the world for the player to pick up. It is a dynamic body that collides as the convex hull of its geometry: spawn it above the ground and it drops and settles.
Call enablePickup() once it is added. On pickup it calls back and removes itself from the world; it does not touch the inventory, so add the item there in the callback.
Extends
Constructors
Constructor
new Collectible(
__namedParameters):Collectible
Defined in: src/collectible.ts:42
Parameters
__namedParameters
Returns
Collectible
Overrides
Properties
body
body:
btRigidBody
Defined in: src/entity/physic.ts:55
Inherited from
disposed
protecteddisposed:boolean=false
Defined in: src/entity/graphic.ts:19
Inherited from
id
id:
string
Defined in: src/entity/graphic.ts:16
Unique per entity. Keys FPS.entities, and is stamped on collision shapes so a ray or contact hit resolves back to its entity.
Inherited from
interactRange?
optionalinteractRange?:number
Defined in: src/collectible.ts:34
Set for 'look' and 'both': what makes the item focusable by a LookAtCursor.
item
readonlyitem:string
Defined in: src/collectible.ts:32
mass
mass:
number
Defined in: src/entity/physic.ts:57
Inherited from
mesh?
protectedoptionalmesh?:Mesh<BufferGeometry<NormalBufferAttributes>,Material|Material[],Object3DEventMap>
Defined in: src/entity/physic.ts:59
Inherited from
shape
shape:
btCollisionShape
Defined in: src/entity/physic.ts:56
Inherited from
three
three:
Group
Defined in: src/entity/graphic.ts:18
The entity's node in the scene; FPS.add() puts it there. Add your meshes under it.
Inherited from
Accessors
position
Get Signature
get position():
Vector3
Defined in: src/entity/physic.ts:137
Where the body is, as a new vector. Setting it teleports the body and its mesh, and leaves the body's velocity as it was.
Returns
Vector3
Set Signature
set position(
position):void
Defined in: src/entity/physic.ts:143
Parameters
position
Vector3
Returns
void
Inherited from
Methods
dispose()
dispose():
void
Defined in: src/entity/physic.ts:124
Frees the body, its motion state and the shape, then the Three resources. The body must already be out of the world: use FPS.remove(), which does both.
Returns
void
Inherited from
enablePickup()
enablePickup(
fps,player,onCollect):void
Defined in: src/collectible.ts:74
Starts watching for a pickup by player. onCollect runs once, just before the item leaves the world.
Parameters
fps
player
onCollect
(c, player) => void
Returns
void
onCursorSelect()
onCursorSelect():
void
Defined in: src/collectible.ts:82
Returns
void
registerPhysics()
registerPhysics(
world):void
Defined in: src/entity/physic.ts:112
Parameters
world
btDiscreteDynamicsWorld
Returns
void
Inherited from
unregisterPhysics()
unregisterPhysics(
world):void
Defined in: src/entity/physic.ts:116
Parameters
world
btDiscreteDynamicsWorld
Returns
void
Inherited from
PhysicEntity.unregisterPhysics
update()
update(
delta?,engine?):void
Defined in: src/collectible.ts:91
Called every frame the world is not paused, with the seconds since the last frame and the FPS the entity lives in (for its world and entities).
Parameters
delta?
number = 0
engine?
Returns
void