Jump to content

Need update to babylon.2.0.d.ts & other stuff for TOB Mesh Factory


JCPalmer
 Share

Recommended Posts

babylon.2.0.d.ts does not have the new BABYLON.Mesh constructor signature for mesh factory code I am generating from Tower of Babel 2.0 .  I am also wondering if source argument should have a default of null, instead of being optional (?)

 

The prelim code below has the class Arial.A instanced 2 different ways.  When not being cloned, Arial.A still needs to pass the source arg in the call to super.  What gets passed?

module Arial{    var meshLib = new Array<BABYLON.Mesh>(56);    var meshCount = [0,0,0, . . . ,0];    export function meshFactory(scene : BABYLON.Scene, meshName : string, materialsRootDir : string = "./") : BABYLON.Mesh {        if (typeof BABYLON.Engine.Version === "undefined" || Number(BABYLON.Engine.Version.substr(0, 4)) < 2.0) throw "Babylon version too old";        var ret:BABYLON.Mesh = null;        var src:BABYLON.Mesh;        switch (meshName){            case "A":                src = meshLib[55];                if (src === null){                    ret = new A("A", scene, materialsRootDir);                    meshLib[55] = ret;                }else                    ret = new A("A", scene, materialsRootDir, src);                meshCount[55] += 1;                break;             . . .        }        if (ret === null) BABYLON.Tools.Error("Mesh not found: " + meshName);        return ret;    }    export class A extends DIALOG.Letter {        constructor(name: string, scene: BABYLON.Scene, materialsRootDir: string = "./", source? : Arial.A) {            super(name, scene, null, source, true);            Arial.defineMaterials(scene, materialsRootDir); //embedded version check            BABYLON.Tools.Log('defining mesh: ' + this.name);            this.setMaterialByID("font.signMaterial");            this.id = this.name;            this.billboardMode  = 0;            this.position.x  = 0;            this.position.y  = 0;            this.position.z  = 0;            this.rotation.x  = 0;            this.rotation.y  = 0;            this.rotation.z  = 0;            this.scaling.x   = 1;            this.scaling.y   = 1;            this.scaling.z   = 1;            this.isVisible       = true;            this.checkCollisions = false;            this.receiveShadows  = false;            this.setVerticesData(BABYLON.VertexBuffer.PositionKind, [                0,0,0,0.362,0.686,0,0.293,0.686,0,0.326,0.536,0,0.667,0,0,0.224,0.289,0,0.436,0.289,0,0.186,0.201,0,0.476,0.201,0,0.1,0,0,0.567,0,0            ],            false);            this.setVerticesData(BABYLON.VertexBuffer.NormalKind, [                0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1            ],            false);            this.setIndices([                0,1,2,0,3,1,3,4,1,0,5,3,6,4,3,0,7,5,7,6,5,7,8,6,8,4,6,0,9,7,10,4,8            ]);            this.subMeshes = [];            new BABYLON.SubMesh(0, 0, 11, 0, 33, this);            this.computeWorldMatrix(true);        }    }}
Link to comment
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...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...