bestog Posted April 12, 2018 Share Posted April 12, 2018 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. Quote Link to comment Share on other sites More sharing options...
Hersir Posted April 13, 2018 Share Posted April 13, 2018 Hi You have extended mesh class but method CreateSphere still uses Babylon.Mesh to create sphere Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.