WebGLNode¶
Overview¶
An abstract node (should be subtyped) that is drawn by user-provided custom WebGL code.
The region that can be drawn in is handled manually, by controlling the canvasBounds property of this WebGLNode. Any regions outside of the canvasBounds will not be guaranteed to be drawn. This can be set with canvasBounds in the constructor, or later with node.canvasBounds = bounds or setCanvasBounds( bounds ).
@author Jonathan Olson <jonathan.olson@colorado.edu> @author Sam Reid (PhET Interactive Simulations)
Class WebGLNode¶
Constructor¶
new WebGLNode( painterType : WebGLNodePainterType, options? : WebGLNodeOptions )¶
Instance Methods¶
setCanvasBounds( selfBounds : Bounds2 ) : this¶
Sets the bounds that are used for layout/repainting.
These bounds should always cover at least the area where the WebGLNode will draw in. If this is violated, this node may be partially or completely invisible in Scenery's output.
getCanvasBounds() : Bounds2¶
Returns the previously-set canvasBounds, or Bounds2.NOTHING if it has not been set yet.
isPainted() : boolean¶
Whether this Node itself is painted (displays something itself).
invalidatePaint()¶
Should be called when this node needs to be repainted. When not called, Scenery assumes that this node does NOT need to be repainted (although Scenery may repaint it due to other nodes needing to be repainted).
This sets a "dirty" flag, so that it will be repainted the next time it would be displayed.
containsPointSelf( point : Vector2 ) : boolean¶
Computes whether the provided point is "inside" (contained) in this Node's self content, or "outside".
If WebGLNode subtypes want to support being picked or hit-tested, it should override this function.
@param point - Considered to be in the local coordinate frame
getSelfShape() : Shape¶
Returns a Shape that represents the area covered by containsPointSelf.
renderToCanvasSelf( wrapper : CanvasContextWrapper, matrix : Matrix3 )¶
Renders this Node only (its self) into the Canvas wrapper, in its local coordinate frame.
@param wrapper @param matrix - The current transformation matrix associated with the wrapper
mutate( options? : WebGLNodeOptions ) : this¶
Static Properties¶
PAINTED_NOTHING¶
(readonly)
Return code from painter.paint() when nothing was painted to the WebGL context.
PAINTED_SOMETHING¶
(readonly)
Return code from painter.paint() when something was painted to the WebGL context.
Type WebGLNodeOptions¶
- canvasBounds?: Bounds2
- & NodeOptions
Type WebGLNodePainter¶
- paint: ( modelViewMatrix: Matrix3, projectionMatrix: Matrix3 ) => WebGLNodePainterResult
- dispose: () => void
Type WebGLNodePainterResult¶
0 | 1
Source Code¶
See the source for WebGLNode.ts in the scenery repository.