Popular Content

Showing content with the highest reputation on 04/04/18 in all areas

  1. 2 points
    Me: Trs-80 -> c64 -> Amiga500
  2. 2 points
    @hwd123 welcome to the forum. Am only on mobile so just a quick glance and suggest you try setting size parameters for advanced texture to be in same ratio as plane ie 512 and 256
  3. 2 points
    I understand you so much. Sometimes in the internet I also ask something like "What time is it?" and the response is like "This color is red" But don't worry, some people just don't have a complete solution yet, so they provide at least some ideas/code examples to solve at least some part of your question. Here is my try, I hope complete - https://www.babylonjs-playground.com/#KNE0O#82 I've combined ray and distance calculation. So the idea is to cast a ray from your camera, get picked mesh, calculate the distance between camera and mesh, print results in a console. White dot in the screen center is to help to see camera's direction.
  4. 2 points

    Celestial Sphere Compass

    I like Inteja's Celestial Sphere. It would help one's sense of orientation in a "flying through space" game for example. Here is my Celestial Sphere Compass: https://www.babylonjs-playground.com/index.html#2UFUC3 . I'll use it in an up-coming game to help keep my bearings. All are welcome to use and improve it .
  5. 2 points

    Animation Methodology Review

    AnimationGroup.animatables is the way to go. You can reach each animatable and then set animatable.weight and also call animatable.syncWith
  6. 2 points

    egghunt - my Easter bunny jump & run

    Earlier this year, I gave out pieces of paper to friends and children of friends with a jagged outline on them with the instruction to color it in and send it back to me. I received 7 colored shapes. Little did they know, that they were actually coloring Easter eggs for a little game I was making. Now, just in time for Easter it's finished and I thought I would also share it with you guys. Play it here if you like: http://jppresents.net/static/egghunt (see below for instructions) It's written in js using only babylon.js as a library. I did the modelling and levels in blender. I hope you enjoy it, I had fun making it! Thanks to everyone making, maintaining and improving babylon.js Here are the instructions and tips for playing the game: In the main menu start by clicking on a level button. You can only go to levels that you have reached. Start with level one. As long as you hover over a level button, you can see the best time and most eggs collected for the level (only shows your scores & times). (Warning: You can only get a better time if you collect the same amount of eggs or more) cursor left = bunny hops left cursor right = bunny hops right space or cursor up = bunny jumps (press longer to go higher) cursor down = crouch and wiggle your tail tips & tricks: Jumping while crouching results in a high back flip. Jumping three times while maintaining speed results in a high forward flip. Pushing into the direction of a box while falling makes you slide along the box, you can now wall jump.
  7. 1 point
    Hi! Thanks for joining me from my previous thread or if you're new here! Previous thread: MAJOR GOAL: Create a multiplayer game using websockets. GAME CONCEPT: Attempt to be the last ball surviving as other balls and environmental effects attempt to knock you off the platform. STATUS: Finessing the single-player version where it is just player vs. environmental effects. Check out the current incarnation of the single-player game here: http://aaronjanke.com/ballGame/ Github: https://github.com/ballAndBoardInc/ballGame CHALLENGE #1 Currently, I'm looking at finessing the controls. They accelerate too quickly, since holding down the key doesn't provide immediate repetition of the trigger. It's awkward. Looking for smoother acceleration. CHALLENGE #2 We are implementing a game reset, but in its current incarnation it doesnt properly rebind the controls after it resets. Definitely open to thoughts. This is our current control system: scene.actionManager = new BABYLON.ActionManager(scene); scene.actionManager.registerAction( new BABYLON.ExecuteCodeAction( { trigger: BABYLON.ActionManager.OnKeyDownTrigger, parameter: 'a' }, function () { console.log('a pressed'); playerMesh.applyImpulse(new BABYLON.Vector3(10, 0, 0), playerMesh.getAbsolutePosition()); } ) ); scene.actionManager.registerAction( new BABYLON.ExecuteCodeAction( { trigger: BABYLON.ActionManager.OnKeyDownTrigger, parameter: 'w' }, function () { console.log('w pressed'); playerMesh.applyImpulse(new BABYLON.Vector3(0, 0, -10), playerMesh.getAbsolutePosition()); } ) ); scene.actionManager.registerAction( new BABYLON.ExecuteCodeAction( { trigger: BABYLON.ActionManager.OnKeyDownTrigger, parameter: 'd' }, function () { console.log('d pressed'); playerMesh.applyImpulse(new BABYLON.Vector3(-10, 0, 0), playerMesh.getAbsolutePosition()); } ) ); scene.actionManager.registerAction( new BABYLON.ExecuteCodeAction( { trigger: BABYLON.ActionManager.OnKeyDownTrigger, parameter: 's' }, function () { console.log('s pressed'); playerMesh.applyImpulse(new BABYLON.Vector3(0, 0, 10), playerMesh.getAbsolutePosition()); } ) );
  8. 1 point

    Why don't use `Date.now()` ?

    I found there are some `new Date().getTime()` in Babylon's source , Why don't use `Date.now()` ?
  9. 1 point

    PBR on iOS

    As an epilogue, and thinking it can be useful for somebody, I finally managed to have my DDS local file loaded by means of CreateFromPrefilteredData, on Cordova-iOS, with the help of cordova-plugin-wkwebview-file-xhr. Best regards.
  10. 1 point
    Thanks @adam. That's really helpful. Also, love your profile pic - Commodore logo. Nostalgic for me as I started with Vic20, onto C64 then Amiga ... the good 'ol days :-)
  11. 1 point

    Why don't use `Date.now()` ?

    Reference should all be to BABYLON.Now. window.performance.now, if available uses more precision than getTime().
  12. 1 point
    haha, that was fun figuring out it was a real person. I realized once you started doing the same stuff as me at different times.
  13. 1 point
    hahah Im pretty sure me and someone else just sat there and ran around with a single ball fora while then we both hit run a bunch of times and everything went to hell. Was cool to see someone else on.
  14. 1 point
    For the fun of it, I tried recreating a multiplayer version. This is mostly copy/paste from various other projects of mine, so it's messsaah. It is using native CannonJS, and you can't really push other players as their angularvelocity is zeroed when keys aren't pressed. Easy to fix, though. It is FAR from perfect, but it has the basics. Authoritative server, input prediction, server reconciliation, entity interpolation and a fixed timestep input loop in case of lags. Pretty much anything could be optimized. Loops, meshes(instances) etc. But in case you need some ideas for how you Could handle networking, you can take a look at it. I have a 130ms ping or round trip latency, and it seems to run decently, although collisions do seem a bit off at times. Networking is hard Btw. If you press "Run" in the playground, the socket connection isn't dropped, so you'll have multiple balls to control, with only the most recent being applied reconciliation and prediction, so it should represent how you see other players. http://playground.babylonjs.com/#RM9TBC#1 It does seem to have some crashes that don't happen in the non-pg version, but you'll get the idea. var CANNON = require('cannon'), express = require('express'), WebSocket = require('ws'), gameloop = require('node-gameloop'), http = require('http'); var server = http.createServer(function(request, response) { }); server.listen(7777, function() { process.on('warning', e => console.warn(e.stack)); //console.log(id); }); var players = [], boxBodies = []; var world; var playerIDs = 1, bodyIDs = 1; var bodiesToRemoveFromWorld = []; var wss = new WebSocket.Server({ port: 8088 }); wss.on('connection', function connection(ws, req) { ws.isAlive = true; ws.on('pong', function(){ ws.isAlive = true}); ws.id = playerIDs++; ws.on('message', function incoming(message) { translate(message, ws); }); ws.on('error', function close(e) { console.log('error', e); }); ws.on('close', function close() { console.log('disconnected'); if(!ws.id){ console.log("no ID"); return; } var player = findPlayerByID(ws.id); if(player){ console.log("Player found"); broadcastToAllSockets({m:17, p:ws.id}); removePlayer(player); } }); }); const interval = setInterval(() => { wss.clients.forEach((ws) => { if (ws.isAlive === false) { var player = findPlayerByID(ws.id); if(player){ console.log("Player found"); broadcastToAllSockets({m:17, p:ws.id}); removePlayer(player); } return ws.terminate() }; ws.isAlive = false; //ws.pingStart = Date.now(); ws.ping('', false, true); }); }, 2000); function removePlayer(player){ if(!player){ console.log("Not found"); return; } bodiesToRemoveFromWorld.push(player.body); var index = players.indexOf(player); if(index > -1){ players.splice(index, 1); } } function translate(message, socket){ var decoded = JSON.parse(message); if(decoded.m === 0){ requestGameState(socket); //var player = new Player(); //player.id = socket.id = playerIDs++; //emitIfOpen(socket, {m:1, p:player.id}); } else if(decoded.m === 2){ console.log("Requesting players"); // var player = new Player(); //player.id = socket.id; //emitIfOpen(socket, {m:1, p:player.id}); //broadcastToAllSockets({m:1, p:player.id}); } else if(decoded.m === 4){ var player = new Player(); player.id = socket.id; player.socket = socket; player.hasSpawned = true; broadcastToAllSockets({m:1, p:player.id}); emitIfOpen(socket, {m:1, p:player.id}); players.push(player); } else if(decoded.m === 10){ //console.log("m"); applyInput(socket.id, decoded.p); } } function applyInput(id, input){ var player = findPlayerByID(id); if(!player){ console.log("nope"); return; } if(input.w){ player.body.angularVelocity.x = 10; //player.body.position.x += 0.1; } else if(input.s) { // player.body.position.x -= 0.1; player.body.angularVelocity.x = -10; } else { player.body.angularVelocity.x = 0; } if(input.a){ player.body.angularVelocity.z = 10; // player.body.position.z -= 0.1; } else if(input.d) { player.body.angularVelocity.z = -10; // player.body.position.z += 0.1; } else { player.body.angularVelocity.z = 0; } player.lastProcessedInput = input.seq; } function requestGameState(socket){ var states = []; for(var i=0;i<players.length;i++){ var player = players[i]; if(player){ states.push([player.id, player.body.position.x, player.body.position.y, player.body.position.z]); } } emitIfOpen(socket, {m:4, p:states, i:socket.id}); } function emitIfOpen(socket, packet){ if (socket.readyState === WebSocket.OPEN) { socket.send(JSON.stringify(packet)); } } var Player = function(){ this.mass = 5; this.radius = 0.5; this.pings = []; this.ping = 0; this.lastProcessedInput = 0; this.alive = false; this.hasSpawned = false; this.shape = new CANNON.Sphere(this.radius); this.body = new CANNON.Body({mass: 1}); this.body.fixedRotation = true; this.body.updateMassProperties(); this.body.addShape(this.shape, new CANNON.Vec3(0,0,0)); world.add(this.body); return this; } function findPlayerByID(id){ for (var i=0;i<players.length;i++){ if(players[i].id === id){ // console.log("Player Found"); return players[i]; } } } var createWorld = function(){ world = new CANNON.World(); world.quatNormalizeSkip = 0; world.quatNormalizeFast = false; world.defaultContactMaterial.contactEquationStiffness = 1e128; world.defaultContactMaterial.contactEquationRelaxation = 4; // world.gravity.set(0, -9.82, 0); world.solver.iterations = 20; world.solver.tolerance = 0.0; world.gravity.set(0,-30,0); world.broadphase = new CANNON.NaiveBroadphase(); var groundShape = new CANNON.Plane(); var groundBody = new CANNON.Body({ mass: 0, shape: groundShape}); //, collisionFilterGroup: 2, collisionFilterMask: 1 groundBody.quaternion.setFromAxisAngle(new CANNON.Vec3(1,0,0),-Math.PI/2); //world.add(groundBody); var boxShape01 = new CANNON.Box(new CANNON.Vec3(10,0.2,3)); var boxShape02 = new CANNON.Box(new CANNON.Vec3(10,10,0.2)); // x: -0.08715574274765817, y: -0, z: -0, w: 0.9961946980917455 var boxBody = new CANNON.Body({ mass: 0}); boxBody.addShape(boxShape01, new CANNON.Vec3(0,-1,0), new CANNON.Quaternion(-0.08715574274765817,0,0,0.9961946980917455)); boxBody.addShape(boxShape02, new CANNON.Vec3(0,9,7), new CANNON.Quaternion(0.19509032201612825,0,0,0.9807852804032304)); world.add(boxBody); for(var i=0;i<3;i++){ var body = {cType:0, id:bodyIDs++}; var boxShape = new CANNON.Box(new CANNON.Vec3(2*0.5,1*0.5,2*0.5)); var boxBody = new CANNON.Body({ mass: 50}); boxBody.addShape(boxShape); body.body = boxBody; world.add(boxBody); boxBodies.push(body); } for(var i=0;i<3;i++){ var body = {cType:1, id:bodyIDs++}; var sphereShape = new CANNON.Sphere(1); var sphereBody = new CANNON.Body({ mass: 50}); sphereBody.addShape(sphereShape); body.body = sphereBody; world.add(sphereBody); boxBodies.push(body); } return world; } var mainLoop = gameloop.setGameLoop(function(delta) { if(world){ for(var i=0,length=bodiesToRemoveFromWorld.length;i<length;i++){ if(bodiesToRemoveFromWorld[i]){ world.remove(bodiesToRemoveFromWorld[i]); } bodiesToRemoveFromWorld.splice(i,1); } for(var i=0;i<boxBodies.length;i++){ var body = boxBodies[i]; if(body){ body.body.velocity.z = -3; } } //console.log("stp"); world.step(1.0/60); } }, 1000 / 60); var networkLoop2 = gameloop.setGameLoop(function(delta) { sendStates(); for(var i=0;i<boxBodies.length;i++){ var body = boxBodies[i]; if(body){ if(body.body.position.y < -10){ body.body.velocity.set(0,0,0); body.body.angularVelocity.set(Math.random()*5,Math.random()*5,Math.random()*5); body.body.position.set(Math.random()*20-10,50,15); } } } for(var i=0;i<players.length;i++){ var player = players[i]; if(player){ if(player.body.position.y < -10){ player.body.velocity.set(0,0,0); player.body.position.set(Math.random()*20-10,20,0); } } } }, 1000 / 10); function sendStates(){ var states = []; var bodies = []; for(var i=0;i<players.length;i++){ var player = players[i]; if(player && player.hasSpawned){ states.push([player.id,parseFloat(player.body.position.x.toFixed(5)),parseFloat(player.body.position.y.toFixed(5)),parseFloat(player.body.position.z.toFixed(5)), player.lastProcessedInput]); } } for(var i=0;i<boxBodies.length;i++){ var body = boxBodies[i]; if(body){ bodies.push([body.id, body.cType, parseFloat(body.body.position.x.toFixed(5)),parseFloat(body.body.position.y.toFixed(5)),parseFloat(body.body.position.z.toFixed(5)), parseFloat(body.body.quaternion.x.toFixed(5)),parseFloat(body.body.quaternion.y.toFixed(5)),parseFloat(body.body.quaternion.z.toFixed(5)),parseFloat(body.body.quaternion.w.toFixed(5))]); } } broadcastToAllSockets({m:6, p:states, b:bodies}); } function broadcastToAllSockets(packet){ for(var i=0,length=players.length;i<length;i++){ var player = players[i]; if(player){ emitIfOpen(player.socket, packet); } } } world = createWorld();
  15. 1 point

    Gamepad in non-VR-environment

    Ok, i got it done. Thanks again, friends. This one can be closed. BR, Markus
  16. 1 point

    Animation Methodology Review

    https://www.babylonjs-playground.com/index.html#DS22WT#3 Since 3.2.0-beta.1 to the latest, setting animatable.weight to no -1 will cause error. if (weight !== -1.0) { this._scene._registerTargetForLateAnimationBinding(this); } BTW, the stable version Babylon.js engine (v3.1.1) I found in https://www.babylonjs-playground.com/indexstable#DS22WT#2 is not a tag in github (AnimationGroup was not supported). So, After commit 1c51062c8d9860baa9f91e7757a30cd9c2df35dc, animatable.weight can only be -1 and before that no syncWith for animatable.
  17. 1 point

    Texture 3D, is it real?

    Hi @Deltakosh , I am currently cleaning up this example a bit to make it more robust because for now, a lot of things are dirty and hardcoded. As soon as it's cleaner (hopefully this week), I'll let you know!! Thanks
  18. 1 point

    Samples for CustomMaterial

    hi i start write some documentation here for custom material ( its realy easy for me to make it here but i can move it in documentation after that complete ) definition : Custom Material inherited from stable version of Standard material (a carbon Copy of BABYLON.StandarMaterial) when we need CustomMaterial ? : any time you wanna make any custom option but you can't manage that in standard material . vertex shader definitions : position(readonly) or positionUpdated(vec3) : local position per vertex normal(readonly) or NormalUpdated(vec3) : local normal fragment shader definitions : vPositionW( readonly) : world position per pixel vNormalW(read only) vDiffuseUV(vec2) : (readonly) : defined uv attribute append when you have DiffuseTexture diffuseColor(vec3) you can manage that with Fragment_Custom_Diffuse : for control Diffuse color **** that mixed with diffuseTexture if you add any texture alpha(float) you can manage that from Fragment_Custom_alpha : for control transparency color(vec4) last result after attached all effect (light fog shadow ... ) you can manage that in Fragment_before_FragColor methods : Start .material = new BABYLON.CustomMaterial("name",scene); Demo : You can define customMaterial exactly like StandardMaterial and you have all property and methods in custom material too AddUniform material.AddUniform('test1','vec3'); simple (float,vec2, vec3,vec4,...) demo sampler without UV with Define UV array array3 , float Fragment_Begin material.Fragment_Begin( string) #include<__decl__defaultFragment> [Fragment_Begin] #extension GL_OES_standard_derivatives : enable for define any new extension or include any shader (not find any requirement for make sample) Fragment_Definitions material.Fragment_Definitions( string) #[Fragment_Definitions] void main(void) { this define before main you can define any varying or global function before main demo : make varying for simple noise used vertex data to add normal demo : change vertex use definition function Fragment_MainBegin void main(void) { vNormalW = vNormalW_helper; #[Fragment_MainBegin] demo : correct normal for back face Fragment_Custom_Diffuse you most find your result red and green and blue (witch any way you like ) and set it in diffuseColor or result *** result (vec3) in this method replaced (one time) by diffuseColor set texture setTexture use diffuseColor Fragment_Custom_Alpha you most find your alpha and set it to alpha variable or in result *** result (vec3) in this method replaced (one time) byalpha demo manage transparency Fragment_Before_FragColor before the last result you have chance to manage your result your final color available in color variable and you most be set it color after your changes *** result (vec4) in this method replaced (one time) by color demo result with and without light effect Vertex_Begin for define any new extension or include any shader (not find any requirement for make sample) Vertex_Definitions this define before main you can define any varying or global function before main Vertex_MainBegin same as Fragment_Main Vertex_Before_PositionUpdated localPosition = positionUpdated; #[Vertex_Before_PositionUpdated] gl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0); you most change positionUpdated in here for change last vertex result Vertex_Before_NormalUpdated #ifdef NORMAL #[Vertex_Before_NormalUpdated] localNormal = normalUpdated; vNormalW_helper=normalize(vec3(finalWorld*vec4(normalUpdated,0.0))); you most change normalUpdated in here for change last vertex normal result related samples Update Uniform demo
  19. 1 point
    Add min max pitch to lookAt: https://www.babylonjs-playground.com/#NM5LIX#2
  20. 1 point

    Stereo 360 cubemap display

    Ok. Got it. onBeforeCameraRenderObservable will work I think. Will check. And yeah, not anaglyphic but real stereo rendering in split screen (just like vrDeviceOrientationCamera), meant for smartphone VR box.
  21. 1 point
    In fact mesh position was the position of the character who looks in front of him. But you can use the camera instead.
  22. 1 point

    Merging polygons with dynamic textures

    Ciao, lei รจ italiano? Imparo l'italiano ma conosco molto poco Are you trying to do something similar to this? If not please make a picture to show what you want. Note a merged mesh does not merge materials. When you merge meshes the material for the merged mesh is the material of the first mesh. If you want to group the meshes together so that they move as one then use transformNode as a parent
  23. 1 point
    Oh I am sorry, I forgot to call addShadowCaster before the first call of _shouldRender(). Sorry for the noise...
  24. 1 point

    Path lineTo only creates point in particle?

    Sorry, there was a bug stopping this from working properly. This has been fixed in 3.4, so the above code will do as you'd expect. 3.4 will be released shortly, or can be found in the repo master branch.
  25. 1 point

    Spine and mesh

    So cool.
  26. 1 point
    Doh, this is what happens when you don't search properly before posting. Now reading https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  27. 1 point

    Recording Babylon to Video

    Someone already did that with Babylon. Look at this PG http://playground.babylonjs.com/#Z5RY9C#6
  28. 1 point
    Take a look at this playground: http://playground.babylonjs.com/#JA1ND3#73 See the selected/unselected events that fire when someone looks at a flag on the ceiling. You could create something similar using your buttons instead of the flags and when your button is selected/selected add your desired timer logic.
  29. 1 point

    Merging polygons with dynamic textures

    Hi and welcome to the forum. It would be very helpful if you could produce a simple playground to show the problem.
  30. 1 point

    Panda 2 now supports Instant Games

    Due to the changes that Facebook made to the Instant Games SDK, the plugin and also the uploading was not working properly anymore. I have now fixed and updated Instant Games plugin to v1.3.1. You should update the plugin to all your games that use Instant Games. https://www.panda2.io/plugins
  31. 1 point
    Hi all, Due to the changes that Facebook made to the Instant Games SDK, the plugin and also the uploading was not working properly anymore. I have now fixed and updated Instant Games plugin to v1.3.1. You should update the plugin to all your games that use Instant Games. https://www.panda2.io/plugins
  32. 1 point
    Thanks for the reply! That document was useful. For anyone else that is new, and is reading this, this is my summary (and please correct me if I am wrong): MetallicRoughness and SpecularGlossiness: are materials for "beginners" to get started into PBR and making simple tests before learning the more complex PBRMaterial. PBRMaterial: is the material to use for production usage, as it combines all the properties of both the MetallicRoughness and SpecularGlosiness, plus adds new properties. This the only material you should be using for production. So basically, we will be using only PBRMaterial for production.
  33. 1 point

    What's next?

    I just did! Issue created: https://github.com/BabylonJS/Editor/issues/51 I added the steps for reproduction of bug. About reflection probes, that awesome to hear that!. P.S: This seems to be a nice community. Thanks for all your replies.
  34. 1 point
    Added constellation lines (H A Reys scheme), better star texture and other tweaks. WIP link: Celestial sphere
  35. 1 point

    Texture 3D, is it real?

    YEAH! it works perfectly! Thanks for adding that to the core! For loading the MRI data I use Pixpipe , which is a lib I am developing at the Montreal Neurological Hospital. I will share this example in a git page because I am not too sure how to deal with dependencies and remote data in a PG, and also the MRI has to be loaded in advance and use a callback that only then creates the scene -- I'm not sure we can do that in the playground. I will update this thread when I have a cleaner source to share! But in the meantime, here is a youtube capture of it in action: Cheers!
  36. 1 point
    just sterilize any input before you run it on the server.
  37. 1 point

    Animation Methodology Review

    @shen In this case I put a debugger before beginAnimation() and look at the armature and animations. Usually something is wrong with the skeleton on the import... not a problem with the animation (necessarily). Sometimes it is missing too. I did find a singular glTF anomaly in export and using AssetManager. (if i recall correctly). perhaps these are different. Important. With all animations - must prove the concept first. Build animations gradually - exporting every step. see what exported and what didn't (see above) -> because you cannot export everything that you can create in blender... ... then use the blender workflow that is confirmed to export. BabylonJS does famously on the import -> and I switched back to .babylon files. you will probably have to experiment on the Blender side. Good tips above. I was able to do successfully, but it is tricky.