Created
May 28, 2022 23:56
-
-
Save flushpot1125/359e41e5e49a25c461f57a3ae2b0ab22 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Node } from "@babylonjs/core/node"; | |
/** | |
* This represents a script that is attached to a node in the editor. | |
* Available nodes are: | |
* - Meshes | |
* - Lights | |
* - Cameas | |
* - Transform nodes | |
* | |
* You can extend the desired class according to the node type. | |
* Example: | |
* export default class MyMesh extends Mesh { | |
* public onUpdate(): void { | |
* this.rotation.y += 0.04; | |
* } | |
* } | |
* The function "onInitialize" is called immediately after the constructor is called. | |
* The functions "onStart" and "onUpdate" are called automatically. | |
*/ | |
export default class MyScript extends Node { | |
/** | |
* Override constructor. | |
* @warn do not fill. | |
*/ | |
// @ts-ignore ignoring the super call as we don't want to re-init | |
protected constructor() { } | |
/** | |
* Called on the node is being initialized. | |
* This function is called immediatly after the constructor has been called. | |
*/ | |
public onInitialize(): void { | |
// ... | |
} | |
/** | |
* Called on the scene starts. | |
*/ | |
public onStart(): void { | |
// ... | |
} | |
/** | |
* Called each frame. | |
*/ | |
public onUpdate(): void { | |
// ... | |
} | |
/** | |
* Called on the object has been disposed. | |
* Object can be disposed manually or when the editor stops running the scene. | |
*/ | |
public onStop(): void { | |
// ... | |
} | |
/** | |
* Called on a message has been received and sent from a graph. | |
* @param message defines the name of the message sent from the graph. | |
* @param data defines the data sent in the message. | |
* @param sender defines the reference to the graph class that sent the message. | |
*/ | |
public onMessage(name: string, data: any, sender: any): void { | |
switch (name) { | |
case "myMessage": | |
// Do something... | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment