BabylonJS-CharacterController
BabylonJS-CharacterController copied to clipboard
BabylonJS ES6 Module support
Hi there,
Really nice project, appreciate it. May I ask if my project is using BJS ES6 module, how can I get this lib to work without hard forking? Or is there any plan of adding BJS ES6 module support to this? Thank you in advance!!
I would like to do that but not quite sure how. Show me some code snippet as to how you would like to use and let me see if I can work something out
Thanks for the replay @ssatguru
Basically, you just need to replace your BJS dependencies to ES6 module version
BJS ES6 Module
Then replace the import usage within your code
What about users who are using the non es6 version of BABYLONJS ? Would I have to maintain a separate version for them?
Yes, normally that is how it works. Two seperate repos.
BTW, do you have any existing project using this lib?
Ok. This might take some time. I would suggest that for now just fork and use it. Its just one file. You can probably just add the source itself to your project. Yes I do have a project which uses this. This was actually part of that project . I moved it out thinking it might be useful to others. The project - https://github.com/ssatguru/Vishva.ts/tree/modularize
Got it working in es6 with straight javascript (versus typescript): Here's the file: cc.js.zip
and then in my entry file i've got the following imports (some of these aren't needed just for character controller, but here you go anyway):
import { Engine } from '@babylonjs/core/Engines/engine'
import { Texture } from '@babylonjs/core/Materials/Textures/texture'
import { CubeTexture } from '@babylonjs/core/Materials/Textures/cubeTexture'
import { StandardMaterial } from '@babylonjs/core/Materials/standardMaterial'
import { Vector3, Color3 } from '@babylonjs/core/Maths/math'
import { ArcRotateCamera } from '@babylonjs/core/Cameras/arcRotateCamera'
import { HemisphericLight } from '@babylonjs/core/Lights/hemisphericLight'
import { DirectionalLight } from '@babylonjs/core/Lights/directionalLight'
import { CreateSphere } from "@babylonjs/core/Meshes/Builders/sphereBuilder";
import { CreateGround } from "@babylonjs/core/Meshes/Builders/groundBuilder";
import { CreateGroundFromHeightMap } from "@babylonjs/core/Meshes/Builders/groundBuilder";
import { CreateBox} from "@babylonjs/core/Meshes/Builders/boxBuilder"
import { ShadowGenerator } from '@babylonjs/core/Lights/Shadows/shadowGenerator'
import { ShadowGeneratorSceneComponent } from '@babylonjs/core/Lights/Shadows/shadowGeneratorSceneComponent'
import { EnvironmentHelper } from '@babylonjs/core/Helpers/sceneHelpers'
import {CharacterController} from './cc'
import { SceneLoader } from "@babylonjs/core/Loading/sceneLoader"
import { GLTFLoader } from "@babylonjs/loaders/glTF/2.0/glTFLoader"```