• Stars
    star
    2,802
  • Rank 16,255 (Top 0.4 %)
  • Language
    Objective-C
  • Created about 12 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Fast, Open Source JavaScript, Canvas & Audio Implementation for iOS

Ejecta

Ejecta is a fast, open source JavaScript, Canvas & Audio implementation for iOS (iPhone, iPod Touch, iPad) and tvOS (Apple TV). Think of it as a Browser that can only display a Canvas element.

More info & Documentation: http://impactjs.com/ejecta

Ejecta is published under the MIT Open Source License.

Quick Start

  1. Create a folder called App within this Xcode project
  2. Copy your canvas application into the App folder
  3. Ensure you have at least 1 file named index.js
  4. Build the Xcode project

For an example application, copy ./index.js into the App folder.

Recent Breaking Changes

2016-06-23 - Typed Arrays are fast again!

The JSC version that comes with iOS 10 provides a new API to read and write Typed Arrays in native code. The workaround from previous versions is not needed anymore

2016-06-23 - Removed iAds

Apple will discontinue its own iAd Network on June 30. The iAd-Banner API has been removed from Ejecta.

2015-12-12 - Use OS provided JavaScriptCore library

Since 08741b4 Ejecta uses the JSC lib provided by iOS and tvOS instead of bundling a custom fork of it. This mainly means two things: The resulting binary will be much smaller and reading/writing of Typed Arrays is much slower.

This only affects WebGL and the get/setImageData() functions for Canvas2D. Some tests indicate that the performance is still good enough for most WebGL games. On 64bit systems it's highly optimized to take about 7ms/Megabyte for reading and about 20ms/Megabyte for writing. It's much slower on 32bit systems, though.

More info about this change can be found in my blog. Please comment on this Webkit bug if you want to have fast Typed Array support again.

2015-11-27 – Allowed orientation change

Allowed interface orientations should now be set using the "Device Orientation" checkboxes in the Project's General settings. Ejecta now rotates to all allowed orientations automatically. If the window size changes due to a rotation (i.e. when rotating from landscape to portrait or vice versa), the window's resize event is fired.

window.addEventListener('resize', function() {
	// Resize your screen canvas here if needed.
	console.log('new window size:', window.innerWidth, window.innerHeight);
});

2015-11-09 - Moved Antialias (MSAA) settings to getContext options

The canvas.MSAAEnabled and canvas.MSAASamples properties have been removed. Instead, you can now specify antialias settings in a separate options object when calling getContext(), similar to how it works in a browser. Antialias now works on 2D and WebGL contexts.

Note that for 2D contexts antialias will have no effect when drawing images, other than slowing down performance. It only makes sense to enable antialias if you draw shapes and paths.

var gl = canvas.getContext('webgl', {antialias: true, antialiasSamples: 4});

// Or for 2d contexts

var ctx = canvas.getContext('2d', {antialias: true, antialiasSamples: 4});

2015-11-08 - Removed automatic pixel doubling for retina devices

The Canvas' backing store is now exactly the same size as the canvas.width and canvas.height. Ejecta does not automatically double the internal resolution on retina devices anymore. The ctx.backingStorePixelRatio and canvas.retinaResolutionEnabled properties as well as the HD variants for the ctx.getImageData, ctx.putImageData and ctx.createImageData functions have been removed.

You can of course still render in retina resolution, by setting the width and height to the retina resolution while forcing the style to scale the canvas to the logical display resolution. This is in line with current browsers.

canvas.width = window.innerWidth * window.devicePixelRatio;
canvas.height = window.innerHeight * window.devicePixelRatio;
canvas.style.width = window.innerWidth + 'px';
canvas.style.height = window.innerHeight + 'px';

// For 2D contexts you may want to zoom in afterwards
ctx.scale( window.devicePixelRatio, window.devicePixelRatio );

WebGL Support

Ejecta supports WebGL out of the box, alongside with Canvas2D. You can create WebGL textures from Canvas2D instances and also draw WebGL Canvases into 2D Contexts as images. Note that you can't change the "mode" (2D or WebGL) of a Context after it has been created.

Three.js on iOS with Ejecta

Ejecta always creates the screen Canvas element for you. You have to hand this Canvas element over to Three.js instead of letting it create its own.

renderer = new THREE.WebGLRenderer( {canvas: document.getElementById('canvas')} );

An example App folder with the Three.js Walt CubeMap demo can be found here:

http://phoboslab.org/files/Ejecta-ThreeJS-CubeMap.zip

More Repositories

1

qoi

The “Quite OK Image Format” for fast, lossless image compression
C
6,851
star
2

jsmpeg

MPEG1 Video Decoder in JavaScript
JavaScript
6,313
star
3

wipeout-rewrite

C
2,613
star
4

jsmpeg-vnc

A low latency, high framerate screen sharing server for Windows and client for browsers
C
2,373
star
5

Impact

HTML5 Game Engine
JavaScript
1,955
star
6

q1k3

A tiny FPS for js13k
JavaScript
1,852
star
7

underrun

Twin stick shooter game in 13kb of JavaScript/WebGL
JavaScript
1,086
star
8

pl_mpeg

Single file C library for decoding MPEG1 Video and MP2 Audio
C
737
star
9

qoa

The “Quite OK Audio Format” for fast, lossy audio compression
C
724
star
10

JavaScriptCore-iOS

Apple's JavaScript Engine, with modified project files for iOS
C++
691
star
11

wipeout

WipEout (PSX) Model Viewer in WebGL/Three.js
JavaScript
524
star
12

voidcall

Real time strategy game in 13kb of JavaScript/WebGL
JavaScript
367
star
13

WebGLImageFilter

Fast image filters for Browsers with WebGL support
JavaScript
329
star
14

js-hqx

hqx Pixel Art Scaling Algorithm in JavaScript
JavaScript
190
star
15

TwoPointFive

3D View Plugin for the Impact HTML5 Game Engine
JavaScript
141
star
16

Quakespasm-Rift

Quake for Oculus Rift
C
140
star
17

ttt

Tiny Texture Tumbler – A JS library and an editor to create textures
HTML
106
star
18

Asaph

A micro-blogging system, focusing on collecting links and images
PHP
97
star
19

neuralink_brainwire

Attempt at Neuralink's Compression Challenge
C
84
star
20

pagenode

Pagenode – No Bullshit Content Management
PHP
75
star
21

OculusWeb

A fast and lean HTTP/WebSocket Oculus Rift Tracking Server for Windows and Mac
C
58
star
22

impact-box2d

Box2D Plugin for the Impact Game Engine
JavaScript
51
star
23

JS360

A NET framework for JavaScript on the XBox with XNA.
C#
48
star
24

pl_json

Yet another single header json parser
C
41
star
25

json-format

JSON Pretty Printer for JavaScript
JavaScript
38
star
26

picturelicious

Social Imaging Platform
PHP
37
star
27

impact-splash-loader

A loading screen for Impact that shows the Impact logo
JavaScript
34
star
28

rectpack

Super Simple Rectangle Packing for JS
JavaScript
15
star
29

arduboy-games

My Arduboy Mini Games
C
14
star
30

jQuery-JSH

Tiny jQuery Plugin for JavaScript SyntaxHighlighting
11
star
31

pagenode-legacy

Older version of Pagenode with a complete admin interface
PHP
2
star
32

badissue.com

HTML
2
star