coolroar

Members
  • Content Count

    61
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by coolroar

  1. I rolled out RAVEL a week ago. The roll-out magically revealed serious errors and omissions.😒 After a week of frantic fixing, I'm ready to publicize it. It is a permutation puzzle that you solve by sorting the sub-cubes into color-order. Easier than Rubik's Cube, but still challenging. You can experiment custom dimensions -- here's a big one: Give it a try! 😃 Feedback welcome... Here or at RAVEL Forum.
  2. I'm pretty sure that the first two PGs in this topic are generating two interleaved lattices (not my intention). https://www.babylonjs-playground.com/#USDWIJ and https://www.babylonjs-playground.com/#USDWIJ#1 The lattices are produced in this triple nested for loop: for (var i = -count; i < count; i++) {// make lattice for (var j = -count; j < count; j++) { for (var k = -count; k < count; k++) { var newInstance = polygon.createInstance("i" + i); newInstance.checkCollisions = true; newInstance.position.set(i*24,i*24+j*24,i*24+k*24) chamberLabel(newInstance.position.clone()) newInstance = mpolygon.createInstance("ii" + i); newInstance.checkCollisions = true; newInstance.position.set(i*24+12,i*24+j*24+12,i*24+k*24+12) chamberLabel(newInstance.position.clone()) }}} [sorry 'bout not giving literal 24 a var name] Anyone care to try fixing this gnarly inscrutable lattice generator? 😕 ⁉️ ---------------------------------------------------------------------------------------------------------------------- Edit: Fixed it by replacing the triple nested for loop with a recursive version https://www.babylonjs-playground.com/#USDWIJ#4 /////////// recursive lattice builder var occupied = {} var count = 4 var radiusComponent = 12 function addRR(n, gx,gy,gz) { if (n >= count) return // done, go home addOneRR(n, gx-1, gy+1, gz+1) addOneRR(n, gx+1, gy+1, gz-1) addOneRR(n, gx-1, gy-1, gz-1) addOneRR(n, gx+1, gy-1, gz+1) } function addLL(n, gx,gy,gz) { if (n >= count) return // done, go home addOneLL(n, gx+1, gy-1, gz-1) addOneLL(n, gx-1, gy-1, gz+1) addOneLL(n, gx+1, gy+1, gz+1) addOneLL(n, gx-1, gy+1, gz-1) } function addOneRR(n, gx,gy,gz) { var name = gx+","+gy+","+gz if (occupied[name]) return occupied[name] = true var newInstance = mpolygon.createInstance("i" + n); newInstance.checkCollisions = true; newInstance.position.set(gx*radiusComponent, gy*radiusComponent, gz*radiusComponent) chamberLabel(newInstance.position.clone()) addLL(n+1, gx,gy,gz) // go add connected chambers (recursive) } function addOneLL(n, gx,gy,gz) { var name = gx+","+gy+","+gz if (occupied[name]) return occupied[name] = true var newInstance = polygon.createInstance("i" + n); newInstance.checkCollisions = true; newInstance.position.set(gx*radiusComponent, gy*radiusComponent, gz*radiusComponent) chamberLabel(newInstance.position.clone()) addRR(n+1, gx,gy,gz) // go add connected chambers (recursive) } addRR(0, 0,0,0) // start recursive lattice builder /////////// end of recursive lattice builder 👍
  3. I woke up this AM with questions and musings about this project. Q: Are the [even, even, even], [odd, odd, odd] lattice node positions required? A: No, the lattice can be started (seeded) anywhere. The [even, even, even], [odd, odd, odd] pattern is convenient. Q: Are all [even, even, even] and [odd, odd, odd] positions occupied? A: No. A node (eg. [3,5,7]) has four neighbors, but there are eight neighboring [even, even, even] positions: [2, 4, 6], [2, 4, 8], [2, 6, 6], [2, 6, 8], [4, 4, 6], [4, 4, 8], [4, 6, 6], [4, 6, 8]. Q: So exits at positions with coordinates divisible by ten might not exist? A: Possibly, 50% chance since I chose div by 10 arbitrarily. Q: How can I choose periodic exit locations that do exist? A: Don't know. Working on it. Help? (https://www.babylonjs-playground.com/#USDWIJ#2 lines 191 - 194). 💡 ------------------------------------------------------------------------------------------------------------------ Postscript: The lattice repeats every 4 along cardinal axis, so here I've put exits at positions with coordinates all divisible by four: https://www.babylonjs-playground.com/#USDWIJ#5 and changed other references to PG with non-existing exits.
  4. To INFINITY and b e y o n d ! Now the lattice develops as you approach, adding chambers ahead of you using chambers that you've left behind. Your processors only have to manage 16 total chambers instead of XxYxZ chambers for an XxYxZ sized lattice. So better frame rate and an infinity of chambers! PG:-------------- 👉 https://www.babylonjs-playground.com/#USDWIJ#5 👈 For challenge, try to make your way to an exit -- exits are at grid coordinates that are divisible by four: [4, 4, 4], [40,-12,8], etc. Another challenge: try exit a chamber and return through a different tunnel. The Code: My goal was to make a regular labyrinth: uniform sized and spaced chambers with tunnels connected to each nearest neighbor. To avoid sight-lines that extend beyond neighboring chambers, I based the chambers on the tetrahedron. The tetrahedron has four faces, none of which are parallel. Actually, I used the truncated tetrahedron which has hexagon instead of triangle faces. I extended the hexagons to form the tunnels. [Some of the code is kinda complicated and the commenting is rather sparse: I need to develop vocabulary.] The following may help. Some interesting characteristics of this tetrahedral lattice: Adjacent chambers are mirror images. The absolute values of the components of a vector between neighboring chambers are equal (opposite corners of a cube). So with a grid increment gi, a chamber located at [a,b,c], its four neighbors would be at: [a-gi, b+gi, c+gi], [a+gi, b+gi, c-gi], [a-gi, b-gi, c-gi], and [a+gi, b-gi, c+gi]. Since neighboring chambers are mirrored, the signs of gi must be reversed for alternate chambers. (PG lines 166 - 178) If the grid increment gi = 1, as it is in the PG, the chamber grid coordinates will all be even or all be odd: [even, even, even] or [odd, odd, odd]. See nearestLatticePoint() (PG lines 200- 230) __________________________________________________________________________ Please come back with your questions and suggestions! 💡 👉
  5. @Dad72 Oops! Here it is with much smaller lattice: https://www.babylonjs-playground.com/#USDWIJ#4 My newly acquired refurbished computer has a bit more oomph than I thought! Edit: I think I'm seeing a mistake -- when viewing the labyrinth from outside, I think I'm seeing two interlaced but unconnected labyrinths. This would also apply to the PG in the OP. Hopefully not apply to the PGs in my later posts, since they use a different method to generate the lattice. 😐 Edit 2: Fixed it by replacing lattice generator with recursive version.
  6. (Installment one is embodied at https://jounce.space/zoom (infinite field of polyhedra).) This is installment two towards infinite 3D Terrain. "Exterior" shot: Interior shot: This is not yet "infinite". For now it's a limited 3D lattice. Go to https://www.babylonjs-playground.com/#USDWIJ#4 and make your way to an exit for an over-all view. For all the effort I've put into this, I'm now at a loss over what to do with it. Suggestions? A technique looking for an idea! Happy Holidays! 🌲 🎅
  7. After var camera = new BABYLON.... try adding: camera.minZ = 1; camera.maxZ = 44; Also you can add camera.fov = 2.7 (or something) to widen or narrow the frustum. Look over the properties and methods in http://doc.babylonjs.com/api/classes/babylon.camera#maxz Here's an index of BABYLONjs classes, etc. http://doc.babylonjs.com/api/globals It's not the easiest thing to browse, but along with GOOGLE I find it valuable. Good luck with your projects! ☘️
  8. For "camera pan away from a character until that character hits the edge of the screen" try while ( camera.isInFrustum( character )) { pan } or while ( camera.isCompletelyInFrustum( character )) { pan } From the first page of "google babylonjs frustum": https://doc.babylonjs.com/api/classes/babylon.frustum https://stackoverflow.com/questions/2866350/move-camera-to-fit-3d-scene
  9. coolroar

    Star

    Woo Woo! Very nice!
  10. coolroar

    Star

    @JCPalmer I see that your my .gif is animated. Maybe the transparent background clashes with site avatar?
  11. coolroar

    Star

    Hey @JCPalmer & @DylanD, well surprisingly, googling "webm to gif" led me straight to it. But issues: I repeatedly ran the PG with different time values in recorder.startRecording("test.webm", 2) in order to eliminate the jump as the vid cycled. (using the converter at https://convertio.co/webm-gif/) Ended up exceeding their 10/day limit. Then I went to https://ezgif.com/video-to-gif where they had editing options (trim by frame numbers) for the resulting gif. I also used those editing options to remove alternate frames to shrink file size to fit avatar requirements. Good luck, I hope it goes smoothly for you! 😃 Edit: one other issue: to make the avatar, I put the playground code in a local .html where I set the canvas dimensions to avatar size (128px x 128px).
  12. coolroar

    Star

    I keep changing my avatar. A character defect? 🤒 Anyway I created it using BJS: https://www.babylonjs-playground.com/#SVZL1I#3 https://www.babylonjs-playground.com/#SVZL1I#4 I needed to take a break from long-term projects, so I did this instant gratification stuff. 😁 Take a look, they're short, fun, & tinkerable!
  13. @ -- JohnK: Wow! Beautiful & Voluptuous! 💥 👀
  14. I made this http://playground.babylonjs.com/#2VXLRC using: Way-to-go JohnK Scroll to end of code for how to use Bezier smoother. 💥 👀
  15. coolroar

    N Queens

    Watch this speedy little app zip through n-queens solutions! N-Queens at Jounce.Space Simple javascript, no dependencies. A classic computer science exercise, the n queens puzzle is the problem of placing n chess queens on an nxn chessboard so that no queen threatens any another. Thus no queen shares a row, column, or diagonal with any other queen. My method does not use recursion and a global variable represents the chess board. [The CS professor frowns.] Mesmerizing! 👀 🎃 😃
  16. Hi Steven, Here is one way -- paste this into your createScene function: // other stuff ... var rotationRate = .00002, winCntrX = engine.getRenderWidth(true)/2, winCntrY = engine.getRenderHeight(true)/2; window.addEventListener("resize", function () {// in case user adjusts window engine.resize(); winCntrX = engine.getRenderWidth(true)/2, // current screen center X winCntrY = engine.getRenderHeight(true)/2; // current screen center Y }); scene.registerBeforeRender(function(){ // other stuff ... var mx = (scene.pointerX-winCntrX) * rotationRate, // get rotation increments my = -(scene.pointerY-winCntrY) * rotationRate; camera.rotation.y += mx; // increment rotation camera.rotation.x += -my; if (camera.rotation.x > Math.PI/2.2) camera.rotation.x = Math.PI/2.2; // up limit if (camera.rotation.x < -Math.PI/2.2) camera.rotation.x = -Math.PI/2.2; // down limit // other stuff ... }); Here's an example: https://www.babylonjs-playground.com/index.html#PFC6AM Have fun! 💥
  17. " ...Using right/left arrow keys (per the instructions)..." Oops, did not intend to leave in the roll control. My understanding: you want to be able to steer the ship in any direction away from straight ahead using yaw and pitch and have the consequential roll cancelled. [right?] That is what the PG does: https://www.babylonjs-playground.com/index.html#2M2LCV It does the pitch and yaw and has resulting roll (relative to World) zeroed (lines 108, 109). My understanding of "...auto roll control..." is that the roll is undesirable, so after yaw and pitch I zero the roll. If my understanding is correct but my solution doesn't produce the expected effect, then ... /// Well, more later, need sleep...
  18. ... Because https://www.babylonjs-playground.com/index.html#2M2LCV see lines 108, 109 (instantaneous roll correction I dreamed up last night). Compare with https://www.babylonjs-playground.com/index.html#PFC6AM just works on UniversalCamera.rotation. This seems to make auto roll correction moot. [sorry 🤒 ] But all this is just preliminaries for much grander goals: Epic Space Game! 💥 Right?
  19. Hey Phuein, awsome! To better understand what's going on, I added celestial compass to a new version of the above PG: https://www.babylonjs-playground.com/index.html#7MNJ8A Also set camera.fov = 2; for a wider view. Here is similar using UniversalCamera: https://www.babylonjs-playground.com/index.html#2UFUC3#9 I worry that if you are successful implementing immediate roll correction, it will be practically the same as universalCamera. I hope I'm wrong and that you can make it happen, 'cause I've given up on it. Admire your persistence and agility on github. 😃 ☘️
  20. I've worked up a "flying through space" camera that might be applicable: https://www.babylonjs-playground.com/index.html#Q1RH6C I used the technique in my ZOOM game at jounce.space. Here is a thread where Phuein is trying to create a camera rolls so "up" is always in the same direction: and here: Good luck! 😃 ☘️
  21. This has already been done, it's called BABYLON.UniversalCamera(...)! I believe that if you successfully automatically adjust roll continuously so that the horizon stays level, you'll have BABYLON.UniversalCamera the hard way. Hmm... I may be going out on a limb with that. See my April 3 post: 💡 !
  22. Weighing in re. @JohnK 's post: I regard camera.yawPitchRoll(y,p,r) in https://www.babylonjs-playground.com/index.html#Q1RH6C to be applicable to either aircraft, spacecraft, submarines, or ?. Aircraft example: The aircraft's bank indicator points in the direction of the vectorSum(gravity, lateralAcceleration). (lateralAcceleration derived from aircraft's turn rate.) The pilot in real time controls yaw and roll for the desired turn, keeping the aircraft's roll aligned with the bank indicator. I don't try to calculate yaw, pitch, & roll; I am in the loop, increasing or decreasing yaw, pitch, & roll according to the bank indicator, the view, and where I want to go. Although https://www.babylonjs-playground.com/index.html#Q1RH6C has no gravity, it does show how to control yaw, pitch, roll with mouse and arrow keys. Spacecraft example: I have quibbles with the info at http://wtamu.edu/~cbaird/sq/2013/02/16/what-kind-of-space-ships-can-make-banking-turns/ . Baird says: "A space ship turns by reorienting and then firing its engines in the desired direction..." If the spaceship was flying "west" the intended turn to "south" as illustrated does not remove the "westward" velocity component. At some point the ship must have a thrust component opposite the original velocity. This illustration shows my speculation of the most efficient way to change course: So the pilot would use "attitude thrusters" to continuously orient the main thrusters perpendicular to the current course until achieving the desired course. But in sci-fi movies and games people want to bank and swoop and dog-fight etc. Here is a PG that uses an arbitrary bank: https://www.babylonjs-playground.com/#UL7W2M The terrain and stuff is just decoration; without it the PG would resemble typical s.f. fictional physics. 😏
  23. Clarification of my previous post: "... you will get roll as you yaw when pitch != 0" should be: " the horizon will tilt (relative to your craft) as you yaw when pitch != 0". The tilted horizon makes you think your craft rolled. (Since at computer we lack the physical sensations of yaw, pitch, & roll). Imagine: You are heading North, straight and level. Then you pitch to straight up. Then you yaw PI/2 to the left. What is your heading? Describe the horizon as seen looking straight ahead. You are headed West, the horizon appears vertical with the ground out the left window. With no craft roll! Pitch(PI/2), Yaw(PI/2) = Roll(PI/2), Pitch(PI/2) = Yaw(PI/2), Roll(PI/2) A series of yaws and pitches can equal a roll: Roll(PI/2) = Pitch(PI/2), Yaw(PI/2), Pitch(-PI/2). (Check my work? 🙄) I hope I'm not blathering stuff you already know. 😏 For the benefit of others, I'll also post this to
  24. Clarification of my previous post: "... you will get roll as you yaw when pitch != 0" should be: " the horizon will tilt (relative to your craft) as you yaw when pitch != 0". The tilted horizon makes you think your craft rolled. (Since at computer we lack the physical sensations of yaw, pitch, & roll). Imagine: You are heading North, straight and level. Then you pitch to straight up. Then you yaw PI/2 to the left. What is your heading? Describe the horizon as seen looking straight ahead. You are headed West, the horizon appears vertical with the ground out the left window. With no craft roll! Pitch(PI/2), Yaw(PI/2) = Roll(PI/2), Pitch(PI/2) = Yaw(PI/2), Roll(PI/2) A series of yaws and pitches can equal a roll: Roll(PI/2) = Pitch(PI/2), Yaw(PI/2), Pitch(-PI/2). (Check my work? 🙄) I hope I'm not blathering stuff you already know. 😏 For the benefit of others, I'll also post this to
  25. "...suffers from a mysterious bug where moving the camera in a circle will slowly Roll it." Do you know that you will get roll naturally as you yaw when pitch != 0 ? Test with pitch locked to zero: https://www.babylonjs-playground.com/index.html#Q1RH6C#2 Try locking pitch to 0.01 etc. (line 80). 😲 ❔