Search the Community

Showing results for tags 'solved'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • HTML5 Game Coding
    • News
    • Game Showcase
    • Coding and Game Design
  • Frameworks
    • Phaser 3
    • Phaser 2
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Found 981 results

  1. Hello, How would WORLDSPACE Mouse Pick and Move (observable), translate into LOCALSPACE of a picked mesh? CONTEXT: a smaller child cube is picked and moved around on a parent cube. BEHAVIOR: without parent rotation, Pick Move works as expected. After parent rotation the following RESULTS: -Z move by mouse in WORLD SPACE results in -Z move of child object in LOCAL SPACE. So, it does not follow the mouse... in WORLDSPACE. GOAL: rotated LOCALSPACE child to follow WORLDSPACE mouse move (e.g. converting -Z mousemove into +X rotated child move). Strange but true. QUESTION: How to convert the WORLDSPACE mouse into LOCALSPACE ... and is that the correct way? The "Frame of Reference" docs are excellent. Found out that vectors do not work in TransformCoordinates. So, guessing that the World Coordinate on Move needs to be converted to local before the vector is calculated... then move the child in local space. Hmmm. Any tips or examples on something like that? Thx.
  2. I am unable to modify (increase) the idleRotationSpeed of my ArcRotateCamera. I tried adjusting the values of speed.idleRotationSpeed but to no avail; the arc rotation camera always circles the object at the same rate. Here is a code snippet: var camera = new BABYLON.ArcRotateCamera("arcCam", 10,1,30, BABYLON.Vector3.Zero(),scene); camera.attachControl(canvas,true); camera.upperBetaLimit = Math.PI / 2; camera.lowerRadiusLimit = 4; var speed = new BABYLON.AutoRotationBehavior("camera",scene); speed.idleRotationSpeed = 0.01; speed.parent = camera; camera.useAutoRotationBehavior = true;
  3. I have an OBJ that starts like this: v -212.947922 761.461914 28.203093 v -213.405563 766.404602 28.193245 v -214.460007 771.238403 28.648092 v -214.639648 776.197327 28.477924 v -215.033905 781.149658 28.498495 v -215.717438 786.059753 28.729038 I copied the vertices to an array using mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind) When I look at vertices[0] I expected to get -212.947922 (the first value in the OBJ file) but it comes up with a value that's somewhere else in the OBJ file. How can I map a value from getVerticesData() to a location in the OBJ file? So for example a value I get from getVerticesData could be -215.033905 which would map to 12th value in the OBJ file.
  4. So would there be any benefits or cons to doing something like this: var time = 0; engine.runRenderLoop(function(){ scene.render(); var d = engine._deltaTime; time+=d*0.0001; shader.setFloat('time', time); }); as opposed to: var time = 0; engine.runRenderLoop(function(){ scene.render(); time+=0.01; shader.setFloat('time', time); }); Is there a way to guarantee clients will get the same time 'coordinates' on a shader even with different io speeds?
  5. Hi there, i do react on a camera change using camera.onViewMatrixChangedObservable Then i watch camera.alpha and camera.beta values and calculate their difference (considering modulo 2*PI) to the previous invocation of camera.onViewMatrixChangedObservable. Lets call it cam_alpha_diff. Using this alpha and beta values I am able to rotate a submesh (a BABYLON.Mesh.CreatePlane mesh located in the WorldMatrix origin) of my scene with mesh.rotate(AXIS, cam_alpha_diff) This works fine as long as i just wanna rotate the submesh around one axis. For instance only around the BABYLON.Axis.Y with the negative cam_alpha_diff. If i wanna rotate the submesh in both alpha and beta direction i can not use the BABYLON.Axis.Y and BABYLON.Axis.X as rotating axis anymore. (except for the first camera movement). I kind of need to re-calcutate the rotation axis after each change of the camera. My approach: Initialize a vector3 as BABYLON.Axis.Y Rotate the vector3 with the negative cam_alpha_diff using BABYLON.Matrix.RotationAxis and BABYLON.Vector3.TransformCoordinates Use the resulting vector3 as new rotation axis Do the same with another vector3 for BABYLON.Axis.X But if i do it for both alpha and beta is kind of "going round in circles". Whats the best way to apply both alpha and beta camera rotations to a submesh? Any hints? My final goal is that the submesh always faces the camera no matter how i rotate the camera (an ArcRotateCamera). Thanks.
  6. hi i get confused by the function Matrix decompose() api in this tutorial i know mesh has its world matrix and its local frame of reference after apply some transform ( position, rotate and scale) whenever we want to get the mesh`s world matrix we can call mesh.getWorldMatrix(true); right? and i see lots of people use decompose() function after i checking its usage i thought the decompose() is for decompose a matrix like the mesh world matrix to get how the mesh be transformed that is to say how a identuty matrix [ BABYLON.Matrix.Identity()] be position, rotated and scaled by using decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3) we can get those three components am i right ? till i see some people use it in this way m.decompose(BABYLON.Vector3.Zero(), BABYLON.Quaternion.Identity(), position) that make me confused how can i set the components the scale set to BABYLON.Vector3.Zero() the rotation set to BABYLON.Quaternion.Identity() can some one tell me why? and how the matrix decompose() exactly the correct usage regards
  7. cmftStudio Support

    Yo @Deltakosh I stumbled across cmftStudio ... an alternative to IBLBaker. It seems to work perfectly. I can create radiance dds file with mip levels. Looks great in ALL other software capable of reading dds files. Unity, Photoshop, GIMP, Visual Studio, etc show the dds file perfectly including all mip levels. But when i try use in Babyon i get a tons of WEBGL errors: [.Offscreen-For-WebGL-000000524DC5DB10]RENDER WARNING: texture bound to texture unit 2 is not renderable. It maybe non-power-of-2 and have incompatible texture filtering. Attached is the Can you take a look and see why we (babylonjs) has issues with this
  8. Hello evryone Sorry in advance for my bad english; I wanna ask somthing about .ArcRotateCamera (); I want to make camera with locked position behind the player when the player moving but if player stand on the place he can moving around with the camera and when he again start moving the camera smoothly rotating to the locked position. I wondered if I will make somehow the camera will checking position.z of the player then camera will be calculate position behind the player. Here is my player how move in game for better understending: By the way I only want some tips or show me a way how I can make this work out I want to fully understand how javascript and babylon.js works. Thank you.
  9. If you try to resize window you'll see it will only resize scene (engine) but not Viewport. How I can update Viewport . Any advice please?
  10. Hi, 1) Is there a way to react on a position/rotation change of the camera? 2) How do i get the position and or the rotation of the camera? What i wanna do: I wanna change the position and/or rotation of another mesh in the scene every time the camera is changed. The rotation of the other mesh is depended of the camera rotation. Thx in advance
  11. Hello, Say I have ParentName > ChildName1 > ChildName2 > ChildName3, is there a quick way to have Babylon tell me the name of the ultimate parent, no matter which child I choose? I can get immediate parent using... scene.meshes[i].parent ... but I need to go right to the top. Cheers,
  12. Yo @Deltakosh and @Sebavan ... I need your help yet again in trying to understand the correct Alpha Blend Mode I should be using for each of the blend mode that unity uses (Opaque - Cutout - Fade - Transparent) I need help in translating what _SrcBlend and _DstBlend values should equal for babylon. Here is the shader code that hey use to enable the various ALPHABLEND, ALPHATEST, etc... public static void SetupMaterialWithBlendMode(Material material, BlendMode blendMode) { switch (blendMode) { case BlendMode.Opaque: material.SetOverrideTag("RenderType", ""); material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One); material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero); material.SetInt("_ZWrite", 1); material.DisableKeyword("_ALPHATEST_ON"); material.DisableKeyword("_ALPHABLEND_ON"); material.DisableKeyword("_ALPHAPREMULTIPLY_ON"); material.renderQueue = -1; break; case BlendMode.Cutout: material.SetOverrideTag("RenderType", "TransparentCutout"); material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One); material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero); material.SetInt("_ZWrite", 1); material.EnableKeyword("_ALPHATEST_ON"); material.DisableKeyword("_ALPHABLEND_ON"); material.DisableKeyword("_ALPHAPREMULTIPLY_ON"); material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.AlphaTest; break; case BlendMode.Fade: material.SetOverrideTag("RenderType", "Transparent"); material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha); material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha); material.SetInt("_ZWrite", 0); material.DisableKeyword("_ALPHATEST_ON"); material.EnableKeyword("_ALPHABLEND_ON"); material.DisableKeyword("_ALPHAPREMULTIPLY_ON"); material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Transparent; break; case BlendMode.Transparent: material.SetOverrideTag("RenderType", "Transparent"); material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One); material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha); material.SetInt("_ZWrite", 0); material.DisableKeyword("_ALPHATEST_ON"); material.DisableKeyword("_ALPHABLEND_ON"); material.EnableKeyword("_ALPHAPREMULTIPLY_ON"); material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Transparent; break; } } Here is my code to setup transparency for babylon for the export: private static void DumpTransparency(Texture2D texture, Material material, BabylonSystemMaterial babylonPbrMaterial) { // Standard Alpha Transparency Mode babylonPbrMaterial.alpha = 1.0f; if (babylonPbrMaterial.albedo != null && babylonPbrMaterial.albedo.Length >= 4) { babylonPbrMaterial.alpha = babylonPbrMaterial.albedo[3]; } if (texture != null && texture.alphaIsTransparency == true) { babylonPbrMaterial.backFaceCulling = false; babylonPbrMaterial.useAlphaFromAlbedoTexture = true; if (babylonPbrMaterial.albedoTexture != null) { babylonPbrMaterial.albedoTexture.hasAlpha = true; } } else { babylonPbrMaterial.useAlphaFromAlbedoTexture = false; if (babylonPbrMaterial.albedoTexture != null) { babylonPbrMaterial.albedoTexture.hasAlpha = false; } } babylonPbrMaterial.alphaCutoff = 0.4f; babylonPbrMaterial.transparencyMode = (int)BabylonTransparencyMode.Opaque; if (material.HasProperty("_Mode")) { var blendMode = (BlendMode)material.GetFloat("_Mode"); if (blendMode == BlendMode.Transparent) { babylonPbrMaterial.alphaMode = 7; // PreMultiply babylonPbrMaterial.alphaCutoff = 0.4f; babylonPbrMaterial.transparencyMode = null; } else if (blendMode == BlendMode.Cutout) { babylonPbrMaterial.alphaMode = 2; // Default combine - but what should it be ??? babylonPbrMaterial.alphaCutoff = material.HasProperty("_Cutoff") ? material.GetFloat("_Cutoff") : 0.4f; babylonPbrMaterial.transparencyMode = (int)BabylonTransparencyMode.AlphaTest; } else if (blendMode == BlendMode.Fade) { babylonPbrMaterial.alphaMode = 2; // Default combine - but what should it be ??? babylonPbrMaterial.alphaCutoff = material.HasProperty("_FadeCutoff") ? material.GetFloat("_FadeCutoff") : 0.4f; babylonPbrMaterial.transparencyMode = (int)BabylonTransparencyMode.AlphaBlend; } } } From looking at the _SrcBlend and _DstBlend from unity, the only one I can tell for sure is TRANSPARENT... IT SAYS PREMULTIPLY But what should I use for CUTOUT and FADE Should FADE be Babylon Alpha Blend Mode Subtractive () material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha); material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha); Can anyone PLEASE try to interpret the Unity Blend Info to what that would be in babylon PRETTY PLEASE
  13. So I have the vertex data: vDat.positions = [ w*-0.5, h*0.5, 0,//0 w*0.5, h*0.5, 0,//1 w*0.5, h*-0.5, 0,//2 w*-0.5, h*-0.5, 0 //3 ]; vDat.uvs = [ 0,1, 1,1, 1,0, 0,0 ]; vDat.normals = [ 0.0, 0.0, 1.0,//0 0.0, 0.0, 1.0,//1 0.0, 0.0, 1.0,//2 0.0, 0.0, 1.0 //3 ]; vDat.indices = [ 2,1,0, 3,2,0 ]; which seems to create the object just fine, but later on now as I started working with the uv, it seems to not be correct. You can see the page here: I/uv.html where the mesh is coming back as grey, which is making me think that the uv is 0.5 across the board for some reason when I set the fragement shader to something like: precision highp float; //Varyings varying vec2 vUV; void main(void) { vec3 color = vec3(vUV.x, vUV.y, vUV.y); gl_FragColor = vec4(color, 1.0); } its prolly something dumb that I am over looking.
  14. Hello, I would like to display the value of the rotation z of a rotating object. I did a test on the PG (line 36), but it does not work. How should I do it ? Thanks for your help.
  15. Hey peeps, Was wondering if anyone else has this bug or if it's just my machine. On Ubuntu 16.04 - Chrome (updated to 65.0.3325.181 (64-bit)) most babylon scenes don't load properly, for example, from homepage At first, I thought because it mentioned materials/shader in the console error, maybe it was to do with my mesh or pbr materials and too many uniforms but when I changed that stuff to the minimum, it still errors. This is shown if you load the "Basic scene" on playground it still has that long list of console errors. Note that in Ubuntu firefox our scene works fine, have also tested on Windows - edge, chrome, firefox and Mac - safari, chrome, firefox, babylon seems to load everything okay without error. I noticed this last year but just used firefox for dev in time being as kind of assumed it would be fixed in 3.2 but we just updated to 3.2 today and see it's still an issue, please let me know if it is known issue, as business wise it doesn't affect too much for us, just my own personal workflow, would like to be able to use chrome lol. Thanks in advance!
  16. Hello everyone, I'm quite a newbie in babylon and I've been reading a lot to understand how things work. Finally, I could make a scene work with an ortho camera, including the possibility of zooming with the mouse wheel. But when I zoom out, an effect appears that I can not understand: the camera goes to the opposite side despite the frustrum is always positive. I tried many different things but I can not understand what is happening. I created an example in babylon playground: Just zoom out with the mouse wheel and see what happens. I know that I am missing something, but I have no idea of what it is, so any idea or suggestion is welcome. Thanks in advance.
  17. Yo @Deltakosh and @Sebavan ... I need to some clarification on using ALPHATEST for BOTH PBRMaterial and StandardMaterial... Basically HOW do I specify that I want that material instance to use alpha testing AND I need to be able to specify the alpha cutoff per material... One material could have a alpha cutoff of 0.3 and another might have a 0.5 or something ... How do I use Alpha Testing With a Custom Cutoff Value ??? Thanks as always UPDATE: Delta added custom alphaCutoff value to the StandardMaterial ALPHATEST Thanks @Deltakosh As Always
  18. I have a bjs/node/webpack app in which the inspector is completely blank/unpopulated (see attached screenshot). No console errors. No network/load errors. Have tried explicitly npm installing and importing inspector but no change.
  19. Yo @Deltakosh How do I tell a Standard Material to use alpha from the diffuse texture... ??? When using PBR there is a property called 'useAlphaFromAlbedoTexture' What is the equivalent for Standard Materials or how do you support 'Transpency' for legacy diffuse workflow ???
  20. Hello guys I have one issue . I unable to import meshes when i using Class () but everything works except for importing meshes. You can see my code here : class Player { constructor(scene) { this.scene = scene; this._skeleton; BABYLON.SceneLoader.ImportMesh("", "", "skull.babylon", this.scene, function (newMeshes, particleSystems, skeletons) { skull = newMeshes[0]; this._skeleton = skeletons[0]; skull.rotation.y= Math.PI; scene.beginAnimation(skeletons[0], 0, 501, true, 1) this.collider = BABYLON.Mesh.CreateBox("collider_box", .32, scene, false); this.collider.position.y = .151; this.collider.rotation.y = 0; this.collider.ellipsoid = new BABYLON.Vector3(0.155, 1.14, 0.155); this.collider.ellipsoidOffset = new BABYLON.Vector3(0, 1.0, 0); this.collider.isVisible = false; skull.parent= this.collider; }); } get mesh (){ return this.collider; } } Why is this didn't work ? It is becouse babylon-loaders doesn't support Class () or do I do something wrong ? Thank you in advance for your answers
  21. Hi all, I have this playground: In it, there is box, and an instance of box, which is box2. box has isVisible set to false, and after 1000 ms, has its material changed to swapMat. This is what happens then: Chrome/Opera: When swapMat is normalMat, nothing seems to happen. When swapMat is set to greenMat, box2 disappears, and the following errors show: Firefox/Edge: When swapMat is normalMat, box2 turns white. When swapMat is greenMat, box2 turns green with no errors. Setting isVisible to true right before/after changing the material makes it work as expected. The same happens in the stable version. What could it be? Thanks.
  22. Sometimes camera captures a cross-shaped(or other shapes like circle) glare at the point where the light's intensity is big. The reason seems to be light diffraction. Like the attached images shows. What kind of technicals do I need to implement this effect ? Is there any demos of babylon.js ? I guess I may need post-precessing, right? Thanks.
  23. So I loaded a STL model using STLFileLoader in to scene. The model seems flat-shaded, and I want it to be smooth-shaded. I know I can call `Mesh#convertToFlatShadedMesh()` to convert a mesh from smooth-shaded to flat-shaded, but what I want is the opposite method. Is there any solutions? Thanks for helping ...
  24. Glow Layer Problem

    Hi guys, I am trying to use a glow layer as seen in this simple example: I get the following error when I try it on my server: GlowLayer is not a constructor. What am I missing? Thanks!
  25. Here is my simple playground demo. Just like the title described, Why this ArcRotate camera can go through the mesh? Is this the gltf file problem?