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

Patch

Extends:

cables-shared-client~Events → Patch

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'
});

Static Member Summary

Static Public Members
public static
public static
public static
public static
public static
public static
public static
public static
public static
public static
public static
public static

Static Method Summary

Static Public Methods
public static

getGui(): *

public static

getOpClass(objName: string): *

public static

replaceOpIds(json: Object, options: Object): *

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public

: boolean

public

aborted: boolean

public
public
public

cg: *

public

cgl: *

public

cgp: *

public
public get
public
public

gui: boolean

public
public
public

name: *

public
public
public

ops: Array<Op>

public
public
public
public
public

storeObjNames: boolean

public
public

timer: *

public
public

vars: {}

Private Members
private
private
private

_log: *

private
private
private
private
private

_variables: Object<string, PatchVariable>

private
private

Method Summary

Public Methods
public

addOnAnimFrame(op: Op)

public

addOnAnimFrameCallback(cb: function)

public

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

create a new op in patch

public

clear()

public

createOp(identifier: string, id: string, opName: string): Op

public

deSerialize(obj: Object, options: DeserializeOptions): any

Description

public

deleteOp(opid: string, tryRelink: boolean, reloadingOp: boolean)

public

deleteVar(name: string)

public
public

getAssetPath(patchId: undefined): 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

getFilePath(filename: String): String

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

public

getFirstSubPatchOpByName(patchId: string, objName: string): Op

public
public

getJsPath(): string

get js path

public

getOpById(opid: String): T

public

getOpsByObjName(name: String): *

public

getOpsByOpId(opid: String): *

public

getOpsByRefId(refId: *): *

public

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

public

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

public

getVar(name: String): PatchVariable

public

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

public

getVars(t: number): PatchVariable[]

public

hasVar(name: String): *

has variable

public

isEditorMode(): Boolean

returns true if patch is opened in editor/gui mode

public

isPlaying(): boolean

public

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

link two ops/ports

public

logStartup(s: String)

public

pause()

pauses patch execution

public
public
public
public

profile(enable: boolean)

public
public

removeOnAnimCallback(cb: function)

public
public
this method was deprecated.
public

resume()

resumes patch execution

public

serialize(options: Object): Object | String

public

setVarValue(name: string, val: string | number, type: number): *

public

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

set variable value

public

setVolume(v: Number)

set volume [0-1]

public
public
public

updateAnims(time: number, delta: number, timestamp: number)

Private Methods
private

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

private

Static Public Members

public static EVENT_ANIM_MAXTIME_CHANGE: * source

public static EVENT_DISPOSE: * source

public static EVENT_OP_ADDED: * source

public static EVENT_OP_DELETED: * source

public static EVENT_PATCHLOADEND: * source

public static EVENT_PAUSE: * source

public static EVENT_RENDERED_ONE_FRAME: * source

public static EVENT_RENDER_FRAME: * source

public static EVENT_RESUME: * source

public static EVENT_VALUESSET: * source

public static EVENT_VARIABLES_CHANGED: * source

Static Public Methods

public static getGui(): * source

Return:

*

public static getOpClass(objName: string): * source

Params:

NameTypeAttributeDescription
objName string

Return:

*

public static replaceOpIds(json: Object, options: Object): * source

Params:

NameTypeAttributeDescription
json Object
options Object

Return:

*

Public Constructors

public constructor(cfg: PatchConfig) source

Params:

NameTypeAttributeDescription
cfg PatchConfig

Public Members

public : boolean source

public aborted: boolean source

public animFrameOps: *[] source

public animMaxTime: * source

public cg: * source

public cgl: * source

public cgp: * source

public config: PatchConfig source

public get containerElement: * source

public freeTimer: * source

public gui: boolean source

public loading: LoadingStatus source

public missingClipAnims: * source

public name: * source

public namedTriggers: {} source

public namespace: * source

public ops: Array<Op> source

public profiler: * source

public renderloop: RenderLoop source

public settings: * source

public silent: * source

public storeObjNames: boolean source

public tempData: * source

public timer: * source

public toAnimMaxTime: * source

public vars: {} source

Private Members

private _animReq: * source

private _crashedOps: *[] source

private _log: * source

private _opIdCache: {} source

private _origData: * source

private _subpatchOpCache: {} source

private _triggerStack: *[] source

private _variables: Object<string, PatchVariable> source

private _volumeListeners: *[] source

private initialDeserialize: * source

Public Methods

public addOnAnimFrame(op: Op) source

Params:

NameTypeAttributeDescription
op Op

public addOnAnimFrameCallback(cb: function) source

Params:

NameTypeAttributeDescription
cb function

public addOp(opIdentifier: string, uiAttribs: OpUiAttribs, 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 OpUiAttribs

Attributes

id string
  • optional
fromDeserialize boolean
  • optional
opName string
  • optional

e.g. Ops.Math.Sum

Return:

*

Example:

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

public clear() source

public createOp(identifier: string, id: string, opName: string): Op source

Params:

NameTypeAttributeDescription
identifier string
id string
opName string
  • optional

Return:

Op

public deSerialize(obj: Object, options: DeserializeOptions): any source

Description

Params:

NameTypeAttributeDescription
obj Object
options DeserializeOptions

Return:

any

public deleteOp(opid: string, tryRelink: boolean, reloadingOp: boolean) source

Params:

NameTypeAttributeDescription
opid string
tryRelink boolean
  • optional
reloadingOp boolean
  • optional

public deleteVar(name: string) source

Params:

NameTypeAttributeDescription
name string

public dispose() source

public getAssetPath(patchId: undefined): string source

get asset path

Params:

NameTypeAttributeDescription
patchId undefined
  • optional
  • default: undefined

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 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: string, objName: string): Op source

Params:

NameTypeAttributeDescription
patchId string
objName string

Return:

Op

public getFrameNum(): * source

Return:

*

public getJsPath(): string source

get js path

Return:

string

public getOpById(opid: String): T source

Params:

NameTypeAttributeDescription
opid String

Return:

T

public getOpsByObjName(name: String): * source

Params:

NameTypeAttributeDescription
name String

Return:

*

public getOpsByOpId(opid: String): * source

Params:

NameTypeAttributeDescription
opid String

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): PatchVariable source

Params:

NameTypeAttributeDescription
name String

Return:

PatchVariable

variable

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

Params:

NameTypeAttributeDescription
name *
val *

Return:

*

public getVars(t: number): PatchVariable[] source

Params:

NameTypeAttributeDescription
t number

Return:

PatchVariable[]

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(): boolean source

Return:

boolean

link two ops/ports

Params:

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

Return:

*

public logStartup(s: String) source

Params:

NameTypeAttributeDescription
s String

public pause() source

pauses patch execution

public popTriggerStack() source

public preRenderOps() source

public printTriggerStack() source

public profile(enable: boolean) source

Params:

NameTypeAttributeDescription
enable boolean

public pushTriggerStack(p: Port) source

Params:

NameTypeAttributeDescription
p Port

public removeOnAnimCallback(cb: function) source

Params:

NameTypeAttributeDescription
cb function

public removeOnAnimFrame(op: Op) source

Params:

NameTypeAttributeDescription
op Op

public renderOneFrame() source

this method was deprecated.

public resume() source

resumes patch execution

public serialize(options: Object): Object | String source

Params:

NameTypeAttributeDescription
options Object

Return:

Object | String

public setVarValue(name: string, val: string | number, type: number): * source

Params:

NameTypeAttributeDescription
name string
val string | number
type number
  • optional

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

public updateAnimMaxTime() source

public updateAnimMaxTimeSoon() source

public updateAnims(time: number, delta: number, timestamp: number) source

Params:

NameTypeAttributeDescription
time number
delta number
timestamp number

Private Methods

Params:

NameTypeAttributeDescription
opinid *
opoutid *
inName *
outName *

Return:

*

private _sortVars() source