Created
February 8, 2018 06:53
-
-
Save HelloWorld017/449424ae0a56a171c6741ef78573b4ce to your computer and use it in GitHub Desktop.
A script to create a structure source
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const build3 = (name) => { | |
const PascalCase = name[0].toUpperCase() + name.slice(1).replace(/_([a-z])/, (match, p1) => p1.toUpperCase()); | |
return ` | |
import Structure from "./Structure"; | |
import ${PascalCase}Model from "../../models/objects/${name}.obj"; | |
import ${PascalCase}Material from "../../models/objects/${name}.mtl"; | |
import ${PascalCase}Texture from "../../models/objects/${name}.png"; | |
class Structure${PascalCase} extends Structure{ | |
constructor(world, x, y, z) { | |
super(Structure${PascalCase}.type, world, x, y, z); | |
} | |
static async registerModel(loader) { | |
return loader.load( | |
Structure${PascalCase}.type, | |
${PascalCase}Model, | |
${PascalCase}Material, | |
${PascalCase}Texture | |
); | |
} | |
} | |
Structure${PascalCase}.type = "${name}"; | |
export default Structure${PascalCase}; | |
` | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment