microsoft / HoloJS

Provides a framework for creating holographic apps using JavaScript and WebGL.
MIT License
1.19k stars 113 forks source link

Implement .toDataUrl() on canvas element #126

Closed omaralcheikh closed 6 years ago

omaralcheikh commented 6 years ago

Hello,

There is no implementation of the .toDataURL() function on the canvas element. This is causing the code to throw an error when trying to convert a mesh to json format that has a material with texture on it.

Regards, Omar.

Almost-Done commented 6 years ago

Do you need this for the holographic canvas or for the 2D one?

omaralcheikh commented 6 years ago

I guess the 2D one as the code is breaking at line 1108 in three.js.

Almost-Done commented 6 years ago

I implemented toDataURL on the 2d canvas in the develop/todataurl branch. Can you please give it a try to see if it works for you?

omaralcheikh commented 6 years ago

Im trying to deploy the ThreeJSApp but im getting the following errors:

'GlobalUnlock': identifier not found - HoloJsHost-Vs2017 - \HoloJS-develop-todataurl\HoloJS\HoloJsHost\RenderingContext2D.cpp   228 
'GlobalLock': identifier not found - HoloJsHost-Vs2017 - \HoloJS-develop-todataurl\HoloJS\HoloJsHost\RenderingContext2D.cpp 214 
Almost-Done commented 6 years ago

Right. GlobalLock/Unlock require SDK 15063 (RS2), but HoloLens runs 14393 (RS1).

I've reworked the code to avoid using those two functions; it came at a memory cost.

omaralcheikh commented 6 years ago

Thank you Cristi its working now. However, it seems that when generating the base 64 image the image is being inverted (upside down) and slightly distorted.

omaralcheikh commented 6 years ago

Also i had to comment out lines 207 till 218 in HoloJsApp.cpp for it to deploy on the Hololens. Figured i wont need them as I'm running vs 2017.

Almost-Done commented 6 years ago

Is the image inverted when viewed outside of the app? Or do you render with it and it is inverted?

What kind of distortion? Is it skewed as if width and height are swapped?

What error do you get if you don't comment those lines? What do you use for LaunchMode in your app?

omaralcheikh commented 6 years ago

Yes. I attached the original image and an html file that renders the generated base64 files.zip.

Never mind. it seems fine.

And here are the errors:

 name followed by '::' must be a class or namespace name    \HoloJS\HoloJsHost\HoloJsApp.cpp    211 
'Preview': is not a member of 'Windows::ApplicationModel'   \HoloJS\HoloJsHost\HoloJsApp.cpp    211 
'Holographic': is not a member of 'Windows::ApplicationModel'   \HoloJS\HoloJsHost\HoloJsApp.cpp    211 
'HolographicApplicationPreview': is not a member of 'Windows::ApplicationModel' \HoloJS\HoloJsHost\HoloJsApp.cpp    211 
'Preview': the symbol to the left of a '::' must be a type  \HoloJS\HoloJsHost\HoloJsApp.cpp    211 
'Holographic': the symbol to the left of a '::' must be a type  \HoloJS\HoloJsHost\HoloJsApp.cpp    211 
'HolographicApplicationPreview': the symbol to the left of a '::' must be a type    \HoloJS\HoloJsHost\HoloJsApp.cpp    211 
'IsHolographicActivation': is not a member of 'Windows::ApplicationModel'   \HoloJS\HoloJsHost\HoloJsApp.cpp    211 
'IsHolographicActivation': identifier not found \HoloJS\HoloJsHost\HoloJsApp.cpp    211 
Almost-Done commented 6 years ago

I added a vertical flip to the image before encoding.

I wouldn't have expected those error on VS 2017. There is something weird going on. Can you verify that you have SDK 10.0.16299.0 installed? Those lines are irrelevant for now when running on the HoloLens.

omaralcheikh commented 6 years ago

Thank you Cristi works great.

I do have 10.0.16299.0 installed but the thing is i re-target the solution to 10.0.14393.0 so that i can build/deploy it for the Hololens. Building the solution for 10.0.16299.0 works fine but i cant deploy it to the Hololens.

Almost-Done commented 6 years ago

I'll merge it in then.

That explains the compilation error. What happens if you deploy to the HoloLens with target version 16299? In my testing it works deploying to HoloLens running OS version 14393.

omaralcheikh commented 6 years ago

I get this To deploy this application, your deployment target should be running Windows Universal Runtime version 10.0.16299.0 or higher. You currently are running version 10.0.14393.1884. Please update your OS, or change your deployment target to a device with the appropriate version.

Almost-Done commented 6 years ago

Weird, the target platform min version is set to 10.0.14393.0. What happens if you change the TargetPlatformMinVersion to match your exact build (.1884):

image

omaralcheikh commented 6 years ago

The min version was set to .16299 instead of .14393. I fixed it and it deployed without having to comment out the code snippet. properties

Almost-Done commented 6 years ago

That explains it. Thanks!