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:

Hi !

How could I import “babylonjs-editor-extensions” ? I tried with npm but it didn’t find it…

Thanks !

Adding our friend @julien-moreau the editor king.

Hey @moko_maracucho
I just don’t understand how that is possible but the « babylonjs-editor-extensions » package just disappeared from npm :frowning:

Have you heard from the V4 ?
It is available here with some documentation still WIP here Editor/ at release/4.0.0 · BabylonJS/Editor · GitHub

I think you will prefer working with the editor V4
Please note that V3 projects are not compatible with V4 projects :slight_smile:

1 Like

Thanks for the reply ! I didn’t seen it… sorry… finally I used another way !!!