How to call a script function from outside the Babylonjs Editor?

Say I have a script like this which I’ve attached to the scene object:

import { Scene, Color4, Mesh } from 'babylonjs';

export default class Teleporter implements IScript {
    constructor (public mesh: Mesh, public scene: Scene) {


    public start (): void {
        // You can access the attached object everywhere

    public teleport(location): void {
        console.log("Now changing 3D location: "+location);

    public update (deltaTimeMs: number): void {
        // Your code...

    public dispose (): void {
        // Called once the attached object has been disposed

// Export the script as an attached script
// (attached to a node or scene)

How can I call the teleport() function from outside of that script? Like say from game.ts or from the script of another object.

pinging @julien-moreau

Hey @ozRocker
Sorry for the delay.

Has mentioned in other posts, the babylonjs editor v3 hasn’t been designed to support that kind of feature. I would say support that kind of feature in clean way.

Anyway, you send messages to nodes that have attached scripts using the “babylonjs-editor-extensions” module:

import { Extensions } from "babylonjs-editor-extensions";

Extensions.Tools.sendMessage(myNodeReference, "teleport");

You can also give arguments to the function next to the function name, like:

import { Extensions } from "babylonjs-editor-extensions";

Extensions.Tools.sendMessage(myNodeReference, "teleport", param1, param2, etc.);

Hope this will do the trick :slight_smile: