I was trying to use the ratelimiter in my project in Unity, but couldn't get it working.
When I add the rate-limiter.js script, from the airconsole-controls github to my Unity project. I get errors concerning missing semicolons, which can be seen in this picture:
Semicolon errors
When I add these semicolons, I get a lot of new errors, seen in this picture:
New errors
I don't really know what the problem is. Am I required to import the rate-limiter.js script? Nothing happens when I try to use the ratelimiter without it. It doesn't send the data to my OnMessage, in my other script, where I print out all data, which works fine without ratelimiter.
My instantiation of airconsole in controller.html looks like this:
var airconsole;
var rateLimiter = new RateLimiter(airconsole);
function init() {
airconsole = new AirConsole({ "orientation": "portrait", "device_motion": 100});
}
function move(amount) {
rateLimiter.message(AirConsole.SCREEN, {move: amount})
}
The part of the other script where I print out the data looks like this:
void OnMessage(int device_id, JToken data)
{
print(data);
}
I have also tried instantiating ratelimiter in function init and I also tried it without the function init like this.
var airconsole = new AirConsole({ "orientation": "portrait", "device_motion": 100});
var rateLimiter = new RateLimiter(airconsole);
Do anyone know what I am doing wrong or how to correctly use ratelimiter?
The AirConsole RateLimiter does not work on the screen inside the AirConsole Unity Plugin. It is intended for HTML5 controllers & HTML5 Screens.
Just to be clear: The RateLimiter works fine in html5 controllers that talk to unity games, but not inside unity games.
Related
As part of a project for college, i have to be able to play video in my java app.
I've written the following code:
EmbeddedMediaPlayerComponent component = new EmbeddedMediaPlayerComponent();
JFrame f = new JFrame ();
f.setContentPane(component);
f.setBounds(new Rectangle (200,200,800,600));
f.addWindowListener(new WindowAdapter() {
public void windowClosing (WindowEvent e) {
component.release();
System.exit(0);
}
});
f.setVisible(true);
component.mediaPlayer().media().play("video");
Everything compiles successfully and when i run the project, the window for the video opens, i can hear the sound of the video but no image is shown. Can anyone help me fix this?
The EmbeddedMediaPlayerComponent needs an AWT Canvas to embed the video.
When running on macOS there is no heavyweight AWT so a normal embedded media player component will not work.
You need instead to use some form of "direct rendering" where you paint the video yourself into some lightweight component. vlcj provides an implementation of this with the CallbackMediaPlayerComponent
To get the basics working, you can simply replace your code:
EmbeddedMediaPlayerComponent component = new EmbeddedMediaPlayerComponent();
With:
CallbackMediaPlayerComponent component = new CallbackMediaPlayerComponent();
This will give you reasonable default behaviour, you can customise the CallbackMediaPlayerComponent if you need to.
The performance of this approach will not be as good as the embedded component, but for most use-cases it will be plenty good enough.
I have an A-Frame scene with three gltf models in it.
I am trying to programmatically trigger animations and I'm not sure what I'm doing wrong. Probably something very obvious, I'll admit. But after hours of researching and fiddling, there must be something very basic that isn't clicking with me.
Be nice - my js isn't exactly beautiful. It's a huge work in progress.
Check out the Glitch Project for more context, but this is probably a problem because I'm using jQuery to store the entity (see below). Right? Is that why? If so, what do I do about it?
function triggerClip(model, clipToPlay, clipDirection) {
model.setAttribute('animation-mixer', {
clip: clipToPlay,
timeScale: clipDirection
});
}
EDIT: After making the changes suggested by Diego, the animations played but I was still getting warnings about timeScale not being recognized. I had to update the version of A-Frame extras to get it working as expected.
jQuery wraps native DOM elements in its own structure. You have to do the following to access it:
model[0].setAttribute('animation-mixer', {
clip: 'step' + clipToPlay,
timeScale: clipDirection
});
Is it possible to embed YouTube video without CSS3DRenderer in three.js? I'm using cardboard effect, So CSS3DRenderer won't work here.
Here is the code that i used so far. But im facing cross domain issue
video = document.createElement('video');
video.autoplay = true;
video.src = 'http://myurl.com/videos/video.mp4';
newcanvas = document.createElement('canvas');
context = newcanvas.getContext('2d');
videoTexture = new THREE.Texture( newcanvas );
.....
In animate function i have used the below code.
if (video.readyState === video.HAVE_ENOUGH_DATA ){
context.drawImage(video,0, 0);
if(videoTexture)
videoTexture.needsUpdate = true;
}
First you need to embed your youtube video in an html video tag. If you have a look on the internet you'll find a lot of ways for doing this. This may come useful to you: YouTube URL in Video Tag
After having this working you need to convert it to a THREE.Texture, so you can map it to a mesh and use WebGL Renderer. There's a Three.jsextension for this: threex.videotexture
Is not possible in praticle. Youtube.com will not accept any cross domain job with there assets. Only way is to use youtube API with iframe but i make some action to make this possible.
You will need to add server part for you web app. I use nodejs.
This is procedure:
Use classic google , youtube APi login/search
Make search and collect search result data (Most important is videoId )
Save to your own server
Call from web app your new route.
Now you can do what ever you want.
Direct demo link: https://maximumroulette.com:3000
https://github.com/zlatnaspirala/vue-typescript-starter
I've been trying for two days to find an alternative to loading an image into my current project. I am using Adobe Flash Professional CS6 as my IDE and Animation program. I would like to be able to display an image in my application. What I am trying to do is have the image display onto the screen, the user enters the PLU associated with the image, and if the PLU is right then they receive a point. I have everything else already to go, but I just can't find an efficient way to deal with loading the image.
Right now I'm using this to accomplish getting my image on the display:
var myDisp:Layer0 = new Layer0();
var bmp:Bitmap = new Bitmap(myDisp);
spDispBox.addChild(bmp);
The above code works just find, but the limitation I can't get around is that I'm going to have to import each image into the library and then consecutively code each part in. I wanted to stick to OOP and streamline this process, I just don't know where I should turn to in order to accomplish my project goal. I'm more than happy to give more information. Thanks in advance, everyone.
July, 26, 2014 - Update: I agree, now, that XML is the way to go. I'm just having a hard time getting the grasp of loading an external XML file. I'm following along, but still not quite getting the idea. I understand about creating a new XML data object, Loader, and URLRequest. It's just loading the picture. I've been able to get output by using trace in the function to see that the XML is loaded, but when I go to add the XML data object to the stage I'm getting a null object reference.
I'm going to try a few more things, I just wanted to update the situation. Thanks again everyone.
it seems like these images are in your FLA library. To simplify your code you can make a singleton class which you can name ImageFactory (factory design pattern) and call that when needing an image which will return a Sprite (lighter than a MovieClip)
spDispBox.addChild( ImageFactory.getImageA() ); // returns a Sprite with your image
and in your ImageFactory
public function getImageA():DisplayObject {
var image:Layer0 = new Layer0(); // image from the FLA library
var holder:Sprite = new Sprite();
holder.addChild( new Bitmap( image ) );
return holder;
}
also recommend using a more descriptive name than Layer0
This issue has been following me around for almost a year now, and I want to kill it, for my sake and for the sake of all.
I'm working on some banner ads that need to load in images from a client's site for display. When I tried to do this using AS2, I found out that AS2 doesn't let you do that. It's a bug in the language. There are workarounds for images on the local server, but images loaded from are not allowed to share their BitmapData, so those workarounds don't work. I ended up capitulating after about two months of banging my head against the desk and cursing Macromedia.
Now we are talking about moving to AS3 (finally) and I'm really excited. Or, I was really excited until I started doing some tests for image quality and found that there is very little change in image quality happening here. It's a repeat of my trials with AS2: everything loads perfectly in the IDE, I get all excited, I move the swfs over to the test server to run them online, and POOF - jaggies. Jaggies everywhere.
I've read a number of solutions online, none of which work. They include:
Setting target.content.smoothing to "true". Works great in the IDE. All improvements disappear in the browser.
Setting target.scaleX = target.scaleY to 1.01. It just breaks the swf.
Adding "new LoaderContext(true)" to my parameters for the load command. Does nothing.
Setting target.content.pixelSnapping to "always". Looks perfect in the IDE, not in the browser.
Setting a crossdomain.xml file. The images are showing up - they're being loaded, even if jaggedly, so there must be a functioning crossdomain file on the client's server, right?
So now I'm just stuck, and brokenhearted. Could anyone offer insight on my code, and why it might not be rendering as beautifully as it should be? Here is the client-safe version of the quick demo I am making (only the image URL has been deleted, everything else is as it is now):
import flash.events.Event;
function completeHandler(e:Event) {
e.target.content.pixelSnapping = "always";
e.target.content.smoothing = true;
}
var imgurl:String = "CLIENT'S IMAGE URL HERE";
var imageLoader01:Loader = new Loader();
var image01:URLRequest = new URLRequest(imgurl);
imageLoader01.load(image01);
imageLoader01.contentLoaderInfo.addEventListener(Event.COMPLETE,completeHandler);
addChild(imageLoader01);
imageLoader01.x = 2;
imageLoader01.y = 0;
imageLoader01.scaleX = imageLoader01.scaleY = .6;
var imageLoader02:Loader = new Loader();
var image02:URLRequest = new URLRequest(imgurl);
imageLoader02.load(image02);
imageLoader02.contentLoaderInfo.addEventListener(Event.COMPLETE,completeHandler);
addChild(imageLoader02);
imageLoader02.x = 100;
imageLoader02.y = 80;
imageLoader02.scaleX = imageLoader02.scaleY = .308;
var imageLoader03:Loader = new Loader();
var image03:URLRequest = new URLRequest(imgurl);
imageLoader03.load(image03);
imageLoader03.contentLoaderInfo.addEventListener(Event.COMPLETE,completeHandler);
addChild(imageLoader03);
imageLoader03.x = 200;
imageLoader03.y = 180;
imageLoader03.scaleX = imageLoader03.scaleY = .152;
var bannerLegend:legend = new legend();
addChild(bannerLegend);
Thank you very much in advance. Any help will be sorely appreciated.
Update: Here is the HTML embed code:
<div id="swf_mr_sc_wt_si"></div>
<script type="text/javascript">
<!--
var swfurl = "http://DOMAIN_WITHELD_SORRY/static/AS3.swf?m=DEFAULT&t=" + (new Date().getTime());
swfobject.embedSWF(swfurl, "swf_mr_sc_wt_si", 300, 250, "8.0.0", "");
// -->
</script>
<p>
Hope this helps.
Further Update: We are not listed in the crossdomain.xml file. But we can still load the jagged images. And those images, when loaded into the same swf run in the IDE, are smooth. I think I'm missing understanding of some kind of apocryphal knowledge here, because everything I read points to me being able to do this. This is VERY confusing.
It's because the image you're loading is located on another domain, and that domain's crossdomain.xml does not contain the domain the .swf is residing on, basically giving the .swf "permission" to access the image's pixel data (Yes, just enabling smoothing on an image loaded from another domain requires the same security as when reading the pixel data using BitmapData.draw(), which is a bit curious). When running in local security sandbox the restrictions are more lax, that's why it works running from the IDE.
Even if your domain were among the approved domains in the crossdomain.xml you might need to tell the Flash Player to check the policy file by sending in new LoaderContext(true) as a second argument to Loader.load() when loading the image.
Edit: I originally thought using loadBytes() would be a workaround, but it turns out it's not. I have removed that example code