locked
Is there a 3D API for JavaScript in Windows 8? RRS feed

  • Question

  • Can JavaScript be used for 3D programming in Windows 8?  I don't see anything similar to WebGL.  Can JavaScript use Direct3D?

     

    Monday, January 9, 2012 7:42 AM

Answers

  • No it cannot.  You would want to use DirectX for 3D programming:

    I'm ready to start building Metro style games. How do I get started?

     

    -Jeff


    Jeff Sanders (MSFT)
    Monday, January 9, 2012 1:22 PM
    Moderator
  • To clarify Jeff's answer, you cannot use Direct3D from JavaScript, nor can you use it within a C#/C++ DLL in a hybrid app. There are parts of DirectX (non-graphics related) that you can use through the hybrid method. TO use Direct3D graphics, you need to write in C++.

    As for 3D in JavaScript, you might be able to find an appropriate JavaScript library to suit your needs. I don't have anything specific to recommend, however.

     

    .Kraig

    • Marked as answer by Jie Bao Tuesday, February 7, 2012 5:22 AM
    Tuesday, January 10, 2012 4:45 AM

All replies

  • No it cannot.  You would want to use DirectX for 3D programming:

    I'm ready to start building Metro style games. How do I get started?

     

    -Jeff


    Jeff Sanders (MSFT)
    Monday, January 9, 2012 1:22 PM
    Moderator
  • To clarify Jeff's answer, you cannot use Direct3D from JavaScript, nor can you use it within a C#/C++ DLL in a hybrid app. There are parts of DirectX (non-graphics related) that you can use through the hybrid method. TO use Direct3D graphics, you need to write in C++.

    As for 3D in JavaScript, you might be able to find an appropriate JavaScript library to suit your needs. I don't have anything specific to recommend, however.

     

    .Kraig

    • Marked as answer by Jie Bao Tuesday, February 7, 2012 5:22 AM
    Tuesday, January 10, 2012 4:45 AM
  • What about creating a WinRT component in C++ which does the 3D stuff and generates the bitmap representation of the scene. You can call it from Javascript and copy the image to an Canvas... Not ideal but I guess, If you are programming in html/javascript (propably not looking for AAA 3D Game) ... It might be enough for your needs.

     

    - Paul


    • Edited by Paul_X Tuesday, January 10, 2012 8:42 AM
    Tuesday, January 10, 2012 8:40 AM
  • Yes, I believe you can use that subset of APIs to create a bitmap, but no direct rendering from Direct2D/3D to an HTML drawing surface.
    Wednesday, January 11, 2012 3:18 PM
  • Well what I did in WinRTdll is, load an in-code shader, render an offscreen Render target, map the value and pass it back to canvas. It works though. However it is extremely slow when I tryto write back to CanvasPixelArray from a Uint8Array. It cannot reach realtime even for a 320*240 video. Is there any direct connection between canvas and d3d resource? I guess they are all on video memory. It should be some easy way to copy them.
    • Edited by QiZhuang Wednesday, February 8, 2012 8:53 PM
    Wednesday, February 8, 2012 8:53 PM
  • If you want good 3D DirectX performance, you should stick with DirectX and C++.


    Jeff Sanders (MSFT)

    Thursday, February 9, 2012 9:08 PM
    Moderator
  • But there are JavaScript 3D engines out there too. You could/should be able to bring them in and make HTML5/CSS3/JavaScript games.
    Thursday, February 9, 2012 9:33 PM
  • How about transferring the image as a video source. Not to a canvas.

    I haven't gotten it to work, but I was hoping to use the scheme handler used in this sample project.

    http://code.msdn.microsoft.com/windowsapps/Media-extensions-sample-7b466096

     
    Sunday, July 1, 2012 9:01 PM