Jump to content

freetoplay

Members
  • Content Count

    63
  • Joined

  • Last visited

Posts posted by freetoplay

  1. If I make meshes invisible in the scene, does it have any impact on the performance of the scene? For example, if I have a several slow performing meshes in the scene, would making them invisible increase the performance of my scene? I want to make some meshes visible in only certain cases, but I don't know if making them invisible would do the trick or would I have to dispose to them, then reimport them?

  2. Hi, I am getting an error when I try to loop through checking for tags.

    In my code, I have:

     let oldMesh = scene.meshes;
                        for (let i=1; i < oldMesh.length; i++) {
                            BABYLON.Tags.EnableFor(oldMesh[i]);
                        }
                        oldMesh[3].addTags("test");

    Inside my importMesh function, I have:

    BABYLON.SceneLoader.ImportMesh(null, "/assets/", "test.glb", scene, function (meshes, particleSystems, skeletons) {
                           meshes[0].position.y += 1;
    
                            for (let i=1; i < oldMesh.length; i++) {
                                console.log(oldMesh[i]); // this works fine
                                console.log(oldMesh[i].hasTags()); // this throws an error
                            }
                   
                       });

     

    Does anyone know know why the hasTags function is throwing an error in the loop?

  3. 51 minutes ago, JohnK said:

    Possibly don't think hair + hood think headware

     So headware can be hair or can be a hood. 

    Put on a hood relace headware hair with headware hood?

    The issue here is I don't have control over that. The users has the ability to choose any hair and hood combination in this case, so I am trying to figure out if there is a solution where it would work with any hood and hair combination.

  4. How would you approach a customized avatar problem where a user is able to customize their avatar by swapping out meshes, but when they do this, it can cause other meshes to poke through? For example, if a character has long hair and a hood mesh is put on the avatar, is there a way to fit the hair inside of the avatar without having it poked through? If not, are there other approaches that I could take? Right now, we created a "bump" in the hood to give the hair space, but that doesn't look like a pretty solution, so I am interested in hearing other potential solutions. :)

  5. Hmm, so after playing around with this for awhile, I have not been able to set the positioning of the loading screen or disable it. :( I have been unable to get the id of the CSS, possibly because I am loading the scenes within a Vue component, what should I do in this case?

    My code looks something like this to create the scene canvas:

     

    <template>
      <canvas ref="canvas" class="canvas" :style="{height: height, width: width, outline: none, display: 'block'}"></canvas>
    </template>
    
    
    <script lang="ts">
    export interface ISceneArgs {
      engine: BABYLON.Engine;
      scene: BABYLON.Scene;
      canvas: HTMLCanvasElement;
    }
    
    export default {
      name: "SceneComponent",
      data: function() {
        return {
          engine: null,
          scene: null
        };
      },
      props: {
        onSceneMount: {
          type: Function,
          required: true
        },
        height: {
          type: String,
          default: "100%"
        },
        width: {
          type: String,
          default: "100%"
        }
      },
      mounted() {
        this.setupScene();
      },
      methods: {
        setupScene() {
          const canvas = this.$refs.canvas as HTMLCanvasElement;
          this.engine = new BABYLON.Engine(
            canvas,
            true,
            { preserveDrawingBuffer: true },
            false
          );
          const scene = new BABYLON.Scene(this.engine);
          this.scene = scene;
          this.onSceneMount({
            scene: this.scene,
            engine: this.engine,
            canvas: this.$refs.canvas
          });
        }
      },
      beforeDestroy() {
        window.removeEventListener("resize", this.handleResize);
      }
    };
    </script>

     

  6. A basic code like this will throw an error in the linter:

    scene.activeCamera.alpha += Math.PI;

    My tsconfig file looks like this:

    {
      "compilerOptions": {
        "target": "es5",
        "module": "esnext",
        "moduleResolution": "node",
        "allowSyntheticDefaultImports": true,
        "sourceMap": true,
        "noImplicitAny": true,
        "removeComments": true,
        "preserveConstEnums": true,
        "baseUrl": ".",
        "lib": ["es2015", "dom"],
        "types": ["node", "jest", "babylonjs"],
        "paths": {
          "@/*": ["src/*"]
        }
      },
      "include": ["src/**/*.ts", "src/**/*.vue", "tests/**/*.ts"],
      "exclude": ["node_modules"]
    }
    

     

  7. Using the 3D Studio Max Exporter, I still get a missing Node warning, not sure if this is related to the exporter or not?

     

    {
    "uri": "Character.glb",
    "mimeType": "model/gltf+json",
    "validatorVersion": "2.0.0-dev.2.5",
    "validatedAt": "2018-10-23T16:17:15.774Z",
    "issues": {
    "numErrors": 0,
    "numWarnings": 0,
    "numInfos": 1,
    "numHints": 0,
    "messages": [
    {
    "code": "NODE_EMPTY",
    "message": "Empty node encountered.",
    "severity": 2,
    "pointer": "/nodes/6"
    }
    ],
    "truncated": false
    },
    "info": {
    "version": "2.0",
    "generator": "babylon.js glTF exporter for 3ds max 2017 v1.3.4",
    "extensionsUsed": [
    "KHR_materials_unlit"
    ],
    "resources": [
    {
    "pointer": "/buffers/0",
    "mimeType": "application/gltf-buffer",
    "storage": null
    },
    {
    "pointer": "/images/0",
    "mimeType": null,
    "storage": "bufferView"
    },
    {
    "pointer": "/images/1",
    "mimeType": null,
    "storage": "bufferView"
    },
    {
    "pointer": "/images/2",
    "mimeType": null,
    "storage": "bufferView"
    }
    ],
    "hasAnimations": false,
    "hasMaterials": true,
    "hasMorphTargets": false,
    "hasSkins": false,
    "hasTextures": true,
    "hasDefaultScene": true,
    "primitivesCount": 6,
    "maxAttributesUsed": 3
    }
    }

    It seems like a default light mesh is added by default for some reason.

    2058563353_Screenshotfrom2018-10-2312-30-33.png.db116f84377fcc59fc2dd569ade8a5ee.png

  8. This is a question coming from an artist that I am working with. He is using the 3D Studio Max version and he downloaded the zip version from Github, but it's not updating him to the 1.3.1 version, instead he seems stuck on version 1.2.4. Is there something else that he is suppose to be doing besides just downloading and running the code inside of the .zip file?

  9. I am getting glTF validation error when I export with unlit materials. Here is what the error looks like when I load it into the BabylonJS sandbox:

    {
    "uri": "Character.glb",
    "mimeType": "model/gltf+json",
    "validatorVersion": "2.0.0-dev.2.5",
    "validatedAt": "2018-10-09T01:41:05.107Z",
    "issues": {
    "numErrors": 8,
    "numWarnings": 1,
    "numInfos": 1,
    "numHints": 0,
    "messages": [
    {
    "code": "UNSUPPORTED_EXTENSION",
    "message": "Unsupported extension encountered: 'KHR_lights'.",
    "severity": 1,
    "pointer": "/extensionsUsed/0"
    },
    {
    "code": "UNDECLARED_EXTENSION",
    "message": "Extension was not declared in extensionsUsed.",
    "severity": 0,
    "pointer": "/materials/0/extensions/KHR_materials_unlit"
    },
    {
    "code": "UNDECLARED_EXTENSION",
    "message": "Extension was not declared in extensionsUsed.",
    "severity": 0,
    "pointer": "/materials/1/extensions/KHR_materials_unlit"
    },
    {
    "code": "UNDECLARED_EXTENSION",
    "message": "Extension was not declared in extensionsUsed.",
    "severity": 0,
    "pointer": "/materials/2/extensions/KHR_materials_unlit"
    },
    {
    "code": "UNDECLARED_EXTENSION",
    "message": "Extension was not declared in extensionsUsed.",
    "severity": 0,
    "pointer": "/materials/3/extensions/KHR_materials_unlit"
    },
    {
    "code": "UNDECLARED_EXTENSION",
    "message": "Extension was not declared in extensionsUsed.",
    "severity": 0,
    "pointer": "/materials/4/extensions/KHR_materials_unlit"
    },
    {
    "code": "UNDECLARED_EXTENSION",
    "message": "Extension was not declared in extensionsUsed.",
    "severity": 0,
    "pointer": "/materials/5/extensions/KHR_materials_unlit"
    },
    {
    "code": "UNDECLARED_EXTENSION",
    "message": "Extension was not declared in extensionsUsed.",
    "severity": 0,
    "pointer": "/materials/6/extensions/KHR_materials_unlit"
    },
    {
    "code": "UNDECLARED_EXTENSION",
    "message": "Extension was not declared in extensionsUsed.",
    "severity": 0,
    "pointer": "/materials/7/extensions/KHR_materials_unlit"
    },
    {
    "code": "NODE_EMPTY",
    "message": "Empty node encountered.",
    "severity": 2,
    "pointer": "/nodes/9"
    }
    ],
    "truncated": false
    },
    "info": {
    "version": "2.0",
    "generator": "babylon.js glTF exporter for 3ds max 2017 v1.2.40",
    "extensionsUsed": [
    "KHR_lights"
    ],
    "resources": [
    {
    "pointer": "/buffers/0",
    "mimeType": "application/gltf-buffer",
    "storage": null
    },
    {
    "pointer": "/images/0",
    "mimeType": null,
    "storage": "bufferView"
    },
    {
    "pointer": "/images/1",
    "mimeType": null,
    "storage": "bufferView"
    },
    {
    "pointer": "/images/2",
    "mimeType": null,
    "storage": "bufferView"
    },
    {
    "pointer": "/images/3",
    "mimeType": null,
    "storage": "bufferView"
    }
    ],
    "hasAnimations": false,
    "hasMaterials": true,
    "hasMorphTargets": false,
    "hasSkins": false,
    "hasTextures": true,
    "hasDefaultScene": true,
    "primitivesCount": 9,
    "maxAttributesUsed": 3
    }

    Does anyone know what's going on?

  10. 1 hour ago, Mark Bufton said:

    OK, been doing some playing tonight as "the wife" let me have the night off haha.

    I copied your image into GIMP (basically like photoshop, but without the hole in my wallet).  I made the highlights transparent (could have done this with the pupil too if I fancied more coding), increased contrast etc and used it on an isis only mesh.  This means you can change the colour of the iris without affecting the colour of the white areas.  I'll include the edited eyeball image though you need to be aware I didn't exactly spend a lot of time on it, so it's rough around the edges, but it works for a demo.

    I'll include a few screenshots also as well.

    Here is the code I used in the scene:

    
    var eye = BABYLON.Mesh.CreatePlane("eye",7,scene);
    var iris = BABYLON.Mesh.CreatePlane("iris",5,scene);
      iris.parent = eye;
      iris.position.z -= 0.01;
    
    var irisMat = new BABYLON.StandardMaterial("irisMat",scene);
      irisMat.diffuseTexture = new BABYLON.Texture("eyeTestBabylon.png",scene);
      irisMat.diffuseTexture.hasAlpha = true;
      iris.material = irisMat;
    
    var eyeMat = new BABYLON.StandardMaterial("irisMat",scene);
      eyeMat.diffuseColor = new BABYLON.Color3(1,1,1);
    
    irisMat.diffuseColor = new BABYLON.Color3(1,1,0);

    I probably went overboard on the contrast but, as I said, it works as a demonstration.

    Hope this might help.

    redEye.png

    yellowEye.png

    blueEye.png

    eyeTestBabylon.png

    @Mark Bufton thanks a lot for the help! :) I have some questions to see if I can understand this properly. It appears that you created a mesh for just the eyes (the whites of the eyes), then created a mesh for the iris with the alpha value set to true? Also, since this seems to require adding an extra mesh and texture, is it worth it vs just swapping out texture (this is for a game that allows users to customize their character's eye colors)?

  11. 1 hour ago, Wingnut said:

    No need to swap material.  

    Try... putting the exact same material.... on a plane.  Does the iris show on the plane?

    Could the iris part of of the texture... be offset (slid sideways)?  You will know when you put the same material on a plane.  It might be easier to see the iris, then.

    Is NEW texture... same dimensions as old texture?   Might need some new-Texture .uOffset and .vOffset adjustments (slide the texture left/right and up/down on the material), and perhaps some .uScale and .vScale adjustments (adjust height/width of texture).

    By putting the same material on an extra plane... you/we might learn more.

    How do I put the the material on a plane?

    The textures are both 1024x1024.

     

    55 minutes ago, Mark Bufton said:

    Why dispose of the previous texture in the function? I ask purely for my own education. Is this for performance reasons?

    Normally, I just declare a whole bunch of separate materials and manually assign, use a function or even the animations/assets managers to assign them to the mesh(es).

    I no longer need that texture, so I just dispose of it, not sure if there's any performance bonuses with it though.

  12. 45 minutes ago, Wingnut said:

    Hiya FTP.  https://www.babylonjs-playground.com/#WWGO6#2

    Nothing learned, yet.  Just trying some test code in lines 84-89.  Seems to work, so far.  After 6 seconds, albedoTexture on wood... changes.

    Can you reproduce your issue... in a playground scene?  That would make life easier for helpers.

    And, of course, add lots of console.log(whatever)... such as:

    console.log(scene.meshes[2]);
    console.log(scene.meshes[2].material);
    console.log(scene.meshes[2].material.albedoTexture);

    etc, etc.  Make sure everything exsits and is as-expected.

    You might also try wrapping it all in a JS try/catch.

    Just some ideas.  *shrug*  Other/better answers might be coming soon.

    Do I have to create a new material or can I just keep my current material and still do the swap? My code for swapping out the texture is posted above, it first disposes the original texture which works since it leaves an empty hole in the eye socket, then I assign the albedoTexture a new texture which semi works because there is no longer a hole in the eye socket, but the Iris is not showing up :( I checked the console.log and it shows that the texture has been swapped.

  13. I am trying a texture for the eye of my character using the following code:

     

     const changeEyeColor = function(e) {
                        scene.meshes[2].material.albedoTexture.dispose();
                        scene.meshes[2].material.albedoTexture = new BABYLON.Texture("eye2.png", scene);
                       }

     

    However the result is this:

    109717086_Screenshotfrom2018-10-0611-51-34.png.aa3bdff743eba62845a007967e8d1e2c.png

    The texture that I want to swap in is:

    eye2.thumb.png.91af466bff72e1c5b7e7f267ef4fa94a.png

     

    What am I doing wrong here?

  14. On 10/5/2018 at 6:53 AM, Nodragem said:

    As your eyes texture contains only one color, I think the simplest is to:

    1) use a grayscale version of that texture,

    2) use material.diffuseColor to control the color

    Your code would look like that:

    
    let material = new BABYLON.StandardMaterial("eyes_material", scene);
    material.diffuseTexture = new BABYLON.Texture("assets/2D/grayscale_eyes_texture.jpg", scene);
    material.diffuseColor = new BABYLON.Color3(1, 0, 0); // change color to red
    MyEyesMesh.material = material;

     

    I want to give this a try, but when the model gets exported, all the materials turn into PBRMaterial, is there a way to keep Standard Material while exporting as glTF?

×
×
  • Create New...