Skip to content

Commit

Permalink
CodeNode: Added language and serialize.
Browse files Browse the repository at this point in the history
  • Loading branch information
sunag committed Mar 16, 2023
1 parent ed6458e commit 818d2ea
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion examples/jsm/nodes/core/CodeNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import { nodeProxy } from '../shadernode/ShaderNode.js';

class CodeNode extends Node {

constructor( code = '', includes = [] ) {
constructor( code = '', includes = [], language = '' ) {

super( 'code' );

this.isCodeNode = true;

this.code = code;
this.language = language;

this._includes = includes;

Expand Down Expand Up @@ -46,10 +47,29 @@ class CodeNode extends Node {

}

serialize( data ) {

super.serialize( data );

data.code = this.code;
data.language = this.language;

}

deserialize( data ) {

super.deserialize( data );

this.code = data.code;
this.language = data.language;

}

}

export default CodeNode;

export const code = nodeProxy( CodeNode );
export const js = ( src, includes ) => code( src, includes, 'js' );

addNodeClass( CodeNode );

0 comments on commit 818d2ea

Please sign in to comment.