File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import defaults from "lodash-es/defaults" ;
22import isString from "lodash-es/isString" ;
33import Component , { IComponentConstructor , IContainer } from "./Component" ;
4+ import Inert from "./Inert" ;
45import ComponentRegistry from "./ComponentRegistry" ;
56import IMain from "./IMain" ;
67import TextureSetManager from "./webgl/TextureSetManager" ;
@@ -49,6 +50,9 @@ export default abstract class Container extends Component implements IContainer
4950 continue ;
5051 }
5152 const component = new componentClass ( this . main , this , opts ) ;
53+ if ( component instanceof Inert ) {
54+ console . warn ( `Inert Component: ${ opts . type } . Will not affect rendering.` ) ;
55+ }
5256 components . push ( component ) ;
5357 }
5458 }
Original file line number Diff line number Diff line change 11import Component from "./Component" ;
2+ import Inert from "./Inert" ;
23import Container from "./Container" ;
34import CodeInstance from "./expr/CodeInstance" ;
45import compileExpr from "./expr/compileExpr" ;
@@ -177,7 +178,7 @@ export default class EffectList extends Container {
177178 // render all the components
178179 // for (let i = 0; i < this.components.length; i++) {
179180 for ( const component of this . components ) {
180- if ( component . isEnabled ( ) ) {
181+ if ( component . isEnabled ( ) && ! ( component instanceof Inert ) ) {
181182 component . draw ( ) ;
182183 }
183184 }
Original file line number Diff line number Diff line change 1+ import Component , { IContainer } from "./Component" ;
2+ import IMain from "./IMain" ;
3+
4+
5+ /**
6+ * Base class for passive components.
7+ *
8+ * A base class for component types that don't affect rendering,
9+ * most notably Comment, but also unknown components in general.
10+ */
11+ export default abstract class Inert extends Component {
12+ protected opts : any ;
13+
14+ public init ( ) {
15+ throw new Error ( "Calling init on inert component." ) ;
16+ }
17+ public draw ( ) {
18+ throw new Error ( "Calling draw on inert component." ) ;
19+ }
20+ }
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ import Invert from "./trans/Invert";
2626import Mirror from "./trans/Mirror" ;
2727import Mosaic from "./trans/Mosaic" ;
2828import UniqueTone from "./trans/UniqueTone" ;
29+ import Comment from "./misc/Comment" ;
2930import { checkRequiredOptions } from "./utils" ;
3031import Buffer from "./webgl/Buffer" ;
3132import CopyProgram from "./webgl/CopyProgram" ;
@@ -403,6 +404,8 @@ export default class Main extends Model implements IMain {
403404
404405 BufferSave ,
405406 GlobalVar ,
407+
408+ Comment ,
406409 ] ) ;
407410 }
408411
Original file line number Diff line number Diff line change 1+ import Inert from "../Inert" ;
2+ import { IContainer } from "../Component" ;
3+ import IMain from "../IMain" ;
4+
5+
6+ export interface ICommentOpts {
7+ text : string ;
8+ }
9+
10+ /**
11+ * A component containing free text.
12+ */
13+ export default class Comment extends Inert {
14+ public static componentName : string = "Comment" ;
15+ public static componentTag : string = "misc" ;
16+ protected static optUpdateHandlers = {
17+ text : "updateText" ,
18+ } ;
19+ protected static defaultOptions : ICommentOpts = {
20+ text : "" ,
21+ } ;
22+
23+ protected opts : ICommentOpts ;
24+ private text : string ;
25+
26+ constructor ( main : IMain , parent : IContainer , opts : any ) {
27+ super ( main , parent , opts ) ;
28+ }
29+
30+ public updateText ( ) {
31+ this . text = this . opts . text ;
32+ }
33+ }
You can’t perform that action at this time.
0 commit comments