ABout to try scene and script merger
This commit is contained in:
+3
-4
@@ -1,5 +1,3 @@
|
||||
Console.print('This is called from JavaScript');
|
||||
|
||||
const platformNames = {
|
||||
[System.PLATFORM_LINUX]: 'Linux',
|
||||
[System.PLATFORM_KNULLI]: 'Knulli',
|
||||
@@ -8,5 +6,6 @@ const platformNames = {
|
||||
[System.PLATFORM_WII]: 'Wii',
|
||||
};
|
||||
|
||||
const platformName = platformNames[System.platform] || 'Unknown';
|
||||
Console.print('Platform: ' + platformName);
|
||||
Console.print('Platform: ' + (platformNames[System.platform] || 'Unknown'));
|
||||
|
||||
// Scene.set('testscene.js');
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
// Load rosa.
|
||||
Console.print('Asset time');
|
||||
const entry = Asset.lock('test.png', Asset.TYPE_TEXTURE, Texture.FORMAT_RGBA);
|
||||
Asset.requireLoaded(entry);
|
||||
Console.print('Asset loaded');
|
||||
|
||||
// Camera at (3,3,3) looking at origin
|
||||
const cam = Entity.create();
|
||||
const camPos = cam.add(Component.POSITION);
|
||||
cam.add(Component.CAMERA);
|
||||
camPos.localPosition = new Vec3(3, 3, 3);
|
||||
camPos.lookAt(new Vec3(0, 0, 0));
|
||||
|
||||
// Test entity at origin
|
||||
const testEntity = Entity.create();
|
||||
const testPos = testEntity.add(Component.POSITION);
|
||||
|
||||
/** @type {RenderableSpritebatch} */
|
||||
const testRenderable = testEntity.add(Component.RENDERABLE);
|
||||
testRenderable.texture = entry.texture;
|
||||
testRenderable.sprites = [
|
||||
[0, 0, 1, 1, 0, 1, 1, 0]
|
||||
];
|
||||
testPos.localPosition = new Vec3(0, 0, 0);
|
||||
@@ -0,0 +1,48 @@
|
||||
var scene = {};
|
||||
|
||||
scene.batch = AssetBatch([
|
||||
{ path: 'test.png', type: Asset.TYPE_TEXTURE, format: Texture.FORMAT_RGBA }
|
||||
]);
|
||||
|
||||
var cam;
|
||||
var camPos;
|
||||
var testEntity;
|
||||
var testPos;
|
||||
var testRenderable;
|
||||
var texEntry;
|
||||
|
||||
scene.load = function() {
|
||||
return scene.batch;
|
||||
};
|
||||
|
||||
scene.init = function() {
|
||||
texEntry = scene.batch.entry(0);
|
||||
|
||||
// Camera at (3, 3, 3) looking at origin
|
||||
cam = Entity.create();
|
||||
camPos = cam.add(Component.POSITION);
|
||||
cam.add(Component.CAMERA);
|
||||
camPos.localPosition = new Vec3(3, 3, 3);
|
||||
camPos.lookAt(new Vec3(0, 0, 0));
|
||||
|
||||
// Test entity with textured quad at origin
|
||||
testEntity = Entity.create();
|
||||
testPos = testEntity.add(Component.POSITION);
|
||||
testRenderable = testEntity.add(Component.RENDERABLE);
|
||||
|
||||
testRenderable.texture = texEntry.texture;
|
||||
testRenderable.sprites = [
|
||||
[0, 0, 1, 1, 0, 1, 1, 0]
|
||||
];
|
||||
testPos.localPosition = new Vec3(0, 0, 0);
|
||||
};
|
||||
|
||||
scene.dispose = function() {
|
||||
Entity.dispose(cam);
|
||||
Entity.dispose(testEntity);
|
||||
|
||||
texEntry.unlock();
|
||||
scene.batch.unlock();
|
||||
};
|
||||
|
||||
module.exports = scene;
|
||||
Reference in New Issue
Block a user