Jump to content

Use babylonjs in ES6 Javascript Project


Recommended Posts

Hello there,

i would like to use the babylonjs package in my JS project.
If I do this with my import statement, everything goes. I then call a function in another file and want to assign a new standard material to the object (I pass scene to the function). But now he tells me "this.getScene is not a function". Can it be because this package is not designed for webpack+js+module?

Uncaught (in promise) TypeError: this.getScene is not a function


Link to comment
Share on other sites



import {Color3, SceneLoader, StandardMaterial, Vector3} from 'babylonjs'
import Material from './material'

const {ImportMeshAsync} = SceneLoader

const Objects = {
  loadMesh: async (scene, object) => {
    const result = await ImportMeshAsync('', URL + object.object_id + '/', 'mesh.babylon', scene)
    const meshes = result.meshes

    await Material.loadMaterial(scene, object.set, meshes[0])
    console.log('load finish')

export default Objects


import {StandardMaterial, Vector2, Vector3, Vector4, Color3, Texture} from 'babylonjs'

const Material = {
  loadMaterial: async (scene, material, mesh) => {
    var mMaterial = StandardMaterial('material.' + material.id, scene)


    mesh.material = mMaterial

export default Material


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...