Skip to content

Instantly share code, notes, and snippets.

@HelloWorld017
Created February 8, 2018 06:53
Show Gist options
  • Save HelloWorld017/449424ae0a56a171c6741ef78573b4ce to your computer and use it in GitHub Desktop.
Save HelloWorld017/449424ae0a56a171c6741ef78573b4ce to your computer and use it in GitHub Desktop.
A script to create a structure source
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