Jump to content

Search the Community

Showing results for tags 'lackofdocs'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 1 result

  1. Hello everybody! I'd like to create a modelling application with babylon.js. My problem is to transform the world coordinates (or position whatever) to screen coordinates. I don't find any page, objects, methods (lack of documentation?), which discuss this problem. I created my own algorithm to solve this problem, but it gives back wrong numbers (-10000-3000). Another problem: there is no function to handle the operations between matrixes and vectors (multiply?). // to init every variablevar canvas = document.getElementById('renderCanvas'), engine = new BABYLON.Engine(canvas, true), scene = new BABYLON.Scene(engine), camera = new BABYLON.ArcRotateCamera('Camera', 0, 0.8, 100, new BABYLON.Vector3.Zero(), scene);// in mousedown event handlervar pickResult = scene.pick(evt.offsetX, evt.offsetY); if (!pickResult.hit) { return;}var vM = camera.getViewMatrix(), // viewMatrix 4*4 pM = camera.getProjectionMatrix(), // projectionMatrix 4*4 vpA = pM.multiply(vM).asArray(), // viewProjectionMatrix 4*4 posA = pickResult.pickedPoint.asArray(), // position 3 transform = [], // store the matrix mult vector globalView = camera.viewport.toGlobal(engine),// globalViewPort store widht and height width = globalView.width, // screen width height = globalView.height; // screen heightposA.push(0); // position 4for (var i = 0; i < 4; i++) { // matrix row var value = 0; // temp value for (var j = 0; j < 4; j++) { // matrix column value += vpA[i*4 + j] * posA[i]; // multiply and add } transform.push(value); // store the tempvalue}var winX = Math.round((( transform[0] + 1 ) / 2.0) * width ), // screenX winY = Math.round((( 1 - transform[1] ) / 2.0) * height ); // screenYconsole.log(winX, winY);My conclusion: i count with wrong variables, (which i can't know because of the lack of documentation). So i beg for your help, what is the problem in my algorithm. (Sorry for that bad english)
×
×
  • Create New...