pxlRoom/RoomEnvironment

pxlRoom/RoomEnvironment

Class representing a Room Environment.

Constructor

new pxlRoom/RoomEnvironment(roomName, assetPath, msRunner, camera, scene, cloud3dTexture)

Description:
  • Core functionality and base classes
Source:
Parameters:
Name Type Default Description
roomName string pxlRoomEnvironment The name of the room.
assetPath string | null null The path to the assets.
msRunner Object | null null The millisecond runner.
camera Object | null null The camera object.
scene Object | null null The scene object.
cloud3dTexture Object | null null The 3D cloud texture.

Members

avgDeltaTime

Description:
  • Get the average delta time.
Source:
Get the average delta time.

deltaTime

Description:
  • Get the delta time.
Source:
Get the delta time.

Methods

addColliderHelper(colliderTypeopt)

Description:
  • Add a visual collider helper.
Source:
Example
// To add a floor collider helper
//   To visualize collider triangles in blue & green
// Run these helper functions in your rooms `build()` & `step()`-
build(){
 this.addColliderHelper( COLLIDER_TYPE.FLOOR );
}

step(){
 this.stepColliderHelper( COLLIDER_TYPE.FLOOR );
}
Parameters:
Name Type Attributes Default Description
colliderType number <optional>
COLLIDER_TYPE.FLOOR The type of collider.

animPostLoad(animKey, animMixers)

Description:
  • Ran after the room's animation FBX files load & process.
Source:
Parameters:
Name Type Description
animKey string The animation key.
animMixers Object The animation mixers.

applyRoomPass(roomComposeropt) → {Object|null}

Description:
  • Apply composer's room pass.
Source:
Parameters:
Name Type Attributes Default Description
roomComposer Object | null <optional>
null The room composer.
Returns:
The shader pass.
Type
Object | null

build()

Description:
  • Build the scene and assets.
Source:

castRay(isClick, mButton)

Description:
  • Cast a ray using pxlNav's raycaster. For Three.js' raycaster, please use the Three.js raycaster directly Note - pxlNav's raycaster requires object's are registered, All object's are pre-processes for faster raycasting
Source:
Parameters:
Name Type Description
isClick boolean Whether it is a click.
mButton number The mouse button.

cleanupPortalRender()

Description:
  • Cleanup portal render.
Source:

fbxPostLoad()

Description:
  • Ran after the room's FBX loads & processes.
Source:

getArtistInfo() → {Object|null}

Description:
  • Get artist information.
Source:
Returns:
The artist information.
Type
Object | null

getColliders(colliderTypeopt) → {Array}

Description:
  • Get the colliders of a specific type.
Source:
Parameters:
Name Type Attributes Default Description
colliderType number <optional>
COLLIDER_TYPE.FLOOR The type of collider.
Returns:
The list of colliders.
Type
Array

getCurrentShader() → {string}

Description:
  • Get the currently editing shader.
Source:
Returns:
The current shader.
Type
string

getLerpAvgRate(rate) → {number}

Description:
  • Get the average lerp rate.
Source:
Parameters:
Name Type Description
rate number The rate.
Returns:
The average lerp rate.
Type
number

getLerpRate(rate) → {number}

Description:
  • Get the lerp rate.
Source:
Parameters:
Name Type Description
rate number The rate.
Returns:
The lerp rate.
Type
number

getName() → {string}

Description:
  • Get the room name.
Source:
Returns:
The room name.
Type
string

getShaderList() → {Object}

Description:
  • Get the geometry shader list.
Source:
Returns:
The shader list.
Type
Object

hasColliderType(colliderTypeopt) → {boolean}

Description:
  • Check if a specific type of collider exists.
Source:
Parameters:
Name Type Attributes Default Description
colliderType number <optional>
COLLIDER_TYPE.FLOOR The type of collider.
Returns:
Whether the specific type of collider exists.
Type
boolean

hasColliders() → {boolean}

Description:
  • Check if colliders exist.
Source:
Returns:
Whether colliders exist.
Type
boolean

hitColliders(colliderList, colliderTypeopt)

Description:
  • Handle pxlColliders collider hits.
Source:
Parameters:
Name Type Attributes Default Description
colliderList Array The list of colliders.
colliderType number <optional>
COLLIDER_TYPE.FLOOR The type of collider.

init()

Description:
  • Initialize the room environment. Ran after core `pxlNav` modules have been loaded and initialized But before the render composers / post-processing
Source:

onMessage(msgType, msgValue)

Description:
  • Handle incoming messages.
Source:
Parameters:
Name Type Description
msgType string The type of message.
msgValue Object The value of the message.

prepPortalRender()

Description:
  • Prepare Warp Zone Portal Texture
Source:

readShader(objShaderopt, sliderVectorObjopt) → {Object}

Description:
  • Read the shader from the object.
Source:
Parameters:
Name Type Attributes Default Description
objShader string <optional>
"" The shader object.
sliderVectorObj Object | null <optional>
null The slider vector object.
Returns:
The shader material.
Type
Object

resetCamera()

Description:
  • Reset the camera.
Source:

resize(sW, sH)

Description:
  • Handle window resize.
Source:
Parameters:
Name Type Description
sW number The width of the window.
sH number The height of the window.

setDependencies(pxlNav)

Description:
  • Set pxlNav dependencies.
Source:
Parameters:
Name Type Description
pxlNav Object The pxlNav object.

setFog(color)

Description:
  • Set the fog color.
Source:
Parameters:
Name Type Description
color Object The color.

setPortalTexture(texture, toRoomopt)

Description:
  • Set the portal texture. Set the Room Warp Portal plane to display the render from the main room
Source:
Parameters:
Name Type Attributes Default Description
texture Object The texture.
toRoom string | null <optional>
null The room to set.

setShader(unis, vert, frag)

Description:
  • Set the geometry's material vertex & fragment shaders.
Source:
Parameters:
Name Type Description
unis Object The uniforms.
vert string The vertex shader.
frag string The fragment shader.

setUserHeight(toHeightopt)

Description:
  • Set the user height.
Source:
Parameters:
Name Type Attributes Default Description
toHeight number <optional>
1 The height to set.

start()

Description:
  • Start the room environment. Run on init room warp; reset room values
Source:

step()

Description:
  • Per-frame render updates.
Source:

stepColliderHelper(colliderTypeopt)

Description:
  • Step the collider helper.
Source:
Example
// To add a floor collider helper
//   To visualize collider triangles in blue & green
// Run these helper functions in your rooms `build()` & `step()`-
build(){
 this.addColliderHelper( COLLIDER_TYPE.FLOOR );
}

step(){
 this.stepColliderHelper( COLLIDER_TYPE.FLOOR );
}
Parameters:
Name Type Attributes Default Description
colliderType number <optional>
COLLIDER_TYPE.FLOOR The type of collider.

stop()

Description:
  • Stop the room environment. Ran When leaving the room
Source:

toCameraPos(positionNameopt)

Description:
  • Move the camera to a specific position.
Source:
Parameters:
Name Type Attributes Default Description
positionName string | null <optional>
null The name of the position.