bestog

Extend Mesh class

Recommended Posts

Hello,

I wanted to extend the class BABYLON.Mesh with some functions, but I have problems. I created a file that does the following (extend.js):

import BABYLON from 'babylonjs'
import Helper from './helper.js'

const {roundFloat} = Helper

class Mesh extends BABYLON.Mesh {
  constructor () {
    super()
    console.log('check')
  }

  getMeshBounding (axis, val) {
    const boundingInfo = this.getBoundingInfo() // Native Bounding Info
    const max = boundingInfo.boundingBox.maximumWorld
    const min = boundingInfo.boundingBox.minimumWorld

    if (axis) {
      const value = val === 'max' ? max : min
      return roundFloat(value[axis])
    } else {
      return {
        max: {x: roundFloat(max.x), y: roundFloat(max.y), z: roundFloat(max.z)},
        min: {x: roundFloat(min.x), y: roundFloat(min.y), z: roundFloat(min.z)}
      }
    }
  }
}

export default Mesh

And in the file, I want to use it (loader.js / same directory):

import Mesh from './extend.js'

const Loader = {
  loadObject: (scene, pos) => {
    // Create a built-in "sphere" shape; its constructor takes 6 params: name, segment, diameter, scene, updatable, sideOrientation
    var sphere = Mesh.CreateSphere('sphere1', 16, 2, scene, false, Mesh.FRONTSIDE)
    ....
  }
}

export default Loader

But apparently he doesn't do it, otherwise a console.log would come.

I'm relatively new to the ES2015 and Vue. Don't be too hard. :D

Share this post


Link to post
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.

Guest
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.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.