new ThreeRendererBridge()
Render bridge class of three.js.
In this bridge, context is a Kekule.Render.ThreeContext object, thus we can handle both scene and camera at the same time.
Methods
-
(static) isSupported() → {Bool}
-
Check if current environment supports Three.js drawing.
Returns:
- Type
- Bool
-
canModifyGraphic(context) → {Bool}
-
Indicate whether this bridge and context can change glyph content or position after drawing it. Raphael is a typical environment of this type while canvas should returns false.
Parameters:
Name Type Description context
Object Returns:
- Type
- Bool
-
clearContext(context)
-
Clear the whole context.
Parameters:
Name Type Description context
Object -
createContext(parentElem, width, height) → {Object}
-
Create a context element for drawing.
Parameters:
Name Type Description parentElem
Element width
Int Width of context, in px. height
Int Height of context, in px. Returns:
Context used for drawing.- Type
- Object
-
getCameraProps(context) → {Hash}
-
Returns properties of current camera, including position(coord), fov, aspect and so on.
Parameters:
Name Type Description context
Object Returns:
- Type
- Hash
-
getContextDimension(context) → {Hash}
-
Get width and height of context.
Parameters:
Name Type Description context
Object Returns:
{width, height}- Type
- Hash
-
getContextElem(context)
-
Get context related element.
Parameters:
Name Type Description context
Object -
getLightCount(context) → {Int}
-
Returns count of lights in context.
Parameters:
Name Type Description context
Object Returns:
- Type
- Int
-
getLightProps(context, lightIndex) → {Hash}
-
Get properties of light at index.
Parameters:
Name Type Description context
Object lightIndex
Int Returns:
- Type
- Hash
-
releaseContext(context)
-
Destroy context created.
Parameters:
Name Type Description context
Object -
setCameraProps(context, props)
-
Set properties of current camera, including position(coord), fov, aspect, lookAtVector and so on.
Parameters:
Name Type Description context
Object props
Hash -
setContextDimension(context, width, height)
-
Set new width and height of context. Note in canvas, the content should be redrawn after resizing.
Parameters:
Name Type Description context
Object width
Int height
Int -
setLightProps(context, lightIndex, props)
-
Get properties of light at index.
Parameters:
Name Type Description context
Object lightIndex
Int props
Hash -
transformContextCoordToScreen(context, coord) → {Hash}
-
Transform a context based coord to screen based one (usually in pixel).
Parameters:
Name Type Description context
Object coord
Hash Returns:
- Type
- Hash
-
transformContextCoordToScreen(context, coord) → {Hash}
-
Transform a 3D context based coord to screen based one (usually 2D in pixel).
Parameters:
Name Type Description context
Object coord
Hash Returns:
- Type
- Hash
-
transformScreenCoordToContext(context, coord) → {Hash}
-
Transform a screen based coord to context based one.
Parameters:
Name Type Description context
Object coord
Hash Returns:
- Type
- Hash