Home Reference Source
import Patch from './core/core_patch.js'
public class | source

Patch

Extends:

EventTarget → Patch

Patch class, contains all operators,values,links etc. manages loading and running of the whole patch

see PatchConfig

Example:

CABLES.patch=new CABLES.Patch(
{
    patch:pStr,
    glCanvasId:'glcanvas',
    glCanvasResizeToWindow:true,
    canvas:{powerPreference:"high-performance"},
    prefixAssetPath:'/assets/',
    prefixJsPath:'/js/',
    onError:function(e){console.log(e);}
    glslPrecision:'highp'
});

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public

aborted: boolean

public
public
public
public

cgl: *

public

cgp: *

public

config: *

public

deSerialized: boolean

public
public

gui: boolean

public

loading: *

public

name: *

public
public
public
public

ops: *[]

public
public
public

settings: {}

public

silent: *

public

storeObjNames: boolean

public
public

timer: *

public

vars: {}

Private Members
private
private
private

_frameInterval: number

private

_frameNext: number

private

_frameNum: number

private

_frameWasdelayed: boolean

private
private

_lastFrameTime: number

private

_log: *

private
private
private

_paused: boolean

private

_renderOneFrame: boolean

private
private
private
private
private

Method Summary

Public Methods
public
public
public

addOp(opIdentifier: string, uiAttribs: Object, id: string, fromDeserialize: boolean, opName: string): *

create a new op in patch

public

clear()

public

createOp(identifier: *, id: *, opName: undefined): *

public

deSerialize(obj: *, options: *)

public

deleteOp(opid: *, tryRelink: *, reloadingOp: *)

public

deleteVar(name: *)

public
public

emitOnAnimFrameEvent(time: *, delta: *)

public

exec(timestamp: *)

public

getAssetPath(patchId: *): string

get asset path

public

getDocument(): Object

returns document object of the patch could be != global document object when opening canvas ina popout window

public

getFPS(): Number

current number of frames per second

public

getFilePath(filename: String): String

get url/filepath for a filename this uses prefixAssetpath in exported patches

public

getFirstSubPatchOpByName(patchId: *, objName: *): boolean

public
public

getJsPath(): string

get js path

public

getOpById(opid: *): *

public

getOpsByName(name: *): *

public

getOpsByObjName(name: *): *

public

getOpsByOpId(opid: *): *

public

getOpsByRefId(refId: *): *

public

getSubPatchOp(patchId: *, objName: *): *

public

getSubPatchOpsByName(patchId: *, objName: *): *

public

getVar(name: String): Variable

public

getVarValue(name: *, val: *): *

public

getVars(t: *): Array<Variable>

public

hasVar(name: String): *

has variable

public

isEditorMode(): Boolean

returns true if patch is opened in editor/gui mode

public

isPlaying(): *

public
public

link(op1: Op, port1Name: String, op2: Op, port2Name: String, lowerCase: boolean, fromDeserialize: boolean): *

link two ops/ports

public

loadLib(which: *)

public

pause()

pauses patch execution

public
public
public
public

profile(enable: *)

public
public
public
public

renderFrame(timestamp: *)

public
public

resume()

resumes patch execution

public

serialize(options: *): *

public

setVarValue(name: *, val: *, type: *): *

public

setVariable(name: String, val: Number | String | Boolean)

set variable value

public

setVolume(v: Number)

set volume [0-1]

Private Methods
private

_addLink(opinid: *, opoutid: *, inName: *, outName: *): *

private

Public Constructors

public constructor() source

Public Members

public aborted: boolean source

public animFrameCallbacks: *[] source

public animFrameOps: *[] source

public cgCanvas: * source

public cgl: * source

public cgp: * source

public config: * source

public deSerialized: boolean source

public freeTimer: * source

public gui: boolean source

public loading: * source

public name: * source

public namedTriggers: {} source

public namespace: * source

public onOneFrameRendered: * source

public ops: *[] source

public profiler: * source

public reqAnimTimeStamp: number source

public settings: {} source

public silent: * source

public storeObjNames: boolean source

public tempData: * source

public timer: * source

public vars: {} source

Private Members

private _animReq: * source

private _crashedOps: *[] source

private _frameInterval: number source

private _frameNext: number source

private _frameNum: number source

private _frameWasdelayed: boolean source

private _isLocal: * source

private _lastFrameTime: number source

private _log: * source

private _opIdCache: {} source

private _origData: * source

private _paused: boolean source

private _renderOneFrame: boolean source

private _subpatchOpCache: {} source

private _triggerStack: *[] source

private _variableListeners: *[] source

private _variables: {} source

private _volumeListeners: *[] source

Public Methods

public addOnAnimFrame(op: *) source

Params:

NameTypeAttributeDescription
op *

public addOnAnimFrameCallback(cb: *) source

Params:

NameTypeAttributeDescription
cb *

public addOp(opIdentifier: string, uiAttribs: Object, id: string, fromDeserialize: boolean, opName: string): * source

create a new op in patch

Params:

NameTypeAttributeDescription
opIdentifier string

uuid or name, e.g. Ops.Math.Sum

uiAttribs Object

Attributes

id string
fromDeserialize boolean
opName string

e.g. Ops.Math.Sum

Return:

*

Example:

// add invisible op
patch.addOp('Ops.Math.Sum', { showUiAttribs: false });

public clear() source

public createOp(identifier: *, id: *, opName: undefined): * source

Params:

NameTypeAttributeDescription
identifier *
id *
opName undefined
  • optional
  • default: undefined

Return:

*

public deSerialize(obj: *, options: *) source

Params:

NameTypeAttributeDescription
obj *
options *

public deleteOp(opid: *, tryRelink: *, reloadingOp: *) source

Params:

NameTypeAttributeDescription
opid *
tryRelink *
reloadingOp *

public deleteVar(name: *) source

Params:

NameTypeAttributeDescription
name *

public dispose() source

public emitOnAnimFrameEvent(time: *, delta: *) source

Params:

NameTypeAttributeDescription
time *
delta *

public exec(timestamp: *) source

Params:

NameTypeAttributeDescription
timestamp *

public getAssetPath(patchId: *): string source

get asset path

Params:

NameTypeAttributeDescription
patchId *

Return:

string

public getDocument(): Object source

returns document object of the patch could be != global document object when opening canvas ina popout window

Return:

Object

document

public getFPS(): Number source

current number of frames per second

Return:

Number

fps

public getFilePath(filename: String): String source

get url/filepath for a filename this uses prefixAssetpath in exported patches

Params:

NameTypeAttributeDescription
filename String

Return:

String

url

public getFirstSubPatchOpByName(patchId: *, objName: *): boolean source

Params:

NameTypeAttributeDescription
patchId *
objName *

Return:

boolean

public getFrameNum(): * source

Return:

*

public getJsPath(): string source

get js path

Return:

string

public getOpById(opid: *): * source

Params:

NameTypeAttributeDescription
opid *

Return:

*

public getOpsByName(name: *): * source

Params:

NameTypeAttributeDescription
name *

Return:

*

public getOpsByObjName(name: *): * source

Params:

NameTypeAttributeDescription
name *

Return:

*

public getOpsByOpId(opid: *): * source

Params:

NameTypeAttributeDescription
opid *

Return:

*

public getOpsByRefId(refId: *): * source

Params:

NameTypeAttributeDescription
refId *

Return:

*

public getSubPatchOp(patchId: *, objName: *): * source

Params:

NameTypeAttributeDescription
patchId *
objName *

Return:

*

public getSubPatchOpsByName(patchId: *, objName: *): * source

Params:

NameTypeAttributeDescription
patchId *
objName *

Return:

*

public getVar(name: String): Variable source

Params:

NameTypeAttributeDescription
name String

Return:

Variable

variable

public getVarValue(name: *, val: *): * source

Params:

NameTypeAttributeDescription
name *
val *

Return:

*

public getVars(t: *): Array<Variable> source

Params:

NameTypeAttributeDescription
t *

Return:

Array<Variable>

variables

public hasVar(name: String): * source

has variable

Params:

NameTypeAttributeDescription
name String

of variable

Return:

*

public isEditorMode(): Boolean source

returns true if patch is opened in editor/gui mode

Return:

Boolean

editor mode

public isPlaying(): * source

Return:

*

public isRenderingOneFrame(): * source

Return:

*

link two ops/ports

Params:

NameTypeAttributeDescription
op1 Op
port1Name String
op2 Op
port2Name String
lowerCase boolean
fromDeserialize boolean

Return:

*

public loadLib(which: *) source

Params:

NameTypeAttributeDescription
which *

public pause() source

pauses patch execution

public popTriggerStack() source

public preRenderOps() source

public printTriggerStack() source

public profile(enable: *) source

Params:

NameTypeAttributeDescription
enable *

public pushTriggerStack(p: *) source

Params:

NameTypeAttributeDescription
p *

public removeOnAnimCallback(cb: *) source

Params:

NameTypeAttributeDescription
cb *

public removeOnAnimFrame(op: *) source

Params:

NameTypeAttributeDescription
op *

public renderFrame(timestamp: *) source

Params:

NameTypeAttributeDescription
timestamp *

public renderOneFrame() source

public resume() source

resumes patch execution

public serialize(options: *): * source

Params:

NameTypeAttributeDescription
options *

Return:

*

public setVarValue(name: *, val: *, type: *): * source

Params:

NameTypeAttributeDescription
name *
val *
type *

Return:

*

public setVariable(name: String, val: Number | String | Boolean) source

set variable value

Params:

NameTypeAttributeDescription
name String

of variable

val Number | String | Boolean

value

public setVolume(v: Number) source

set volume [0-1]

Params:

NameTypeAttributeDescription
v Number

volume

Private Methods

Params:

NameTypeAttributeDescription
opinid *
opoutid *
inName *
outName *

Return:

*

private _sortVars() source