Scene.set() JS lifecycle, UI sprite caching, emulator test scripts
- Add Scene.set(module) so JerryScript can switch scenes via
require()'d {init, update, dispose} modules; wire it into
engineUpdate() and rework overworldscene.js/init.js to the new shape.
- Fix scriptManagerExecFile() never pushing its own file's directory
onto the require() dir stack, breaking relative require() calls from
a top-level entry script (e.g. init.js -> ./overworldscene.js).
- Cache sprite geometry across frames for uislider/uitab/uiframe
(dialogs/textbox/settings) and give uitextbox a per-page glyph cache
instead of one spriteBatchBuffer call per visible character. uiconsole
drops its alloc/free vertex buffer for a fixed-size one. uifps skips
rebuilding its label when the text hasn't changed.
- Add PSP_OPTIMIZATION_PLAN.md and a handful of UI/spritebatch unit
tests covering the new caching logic.
- Add Dolphin/PPSSPP emulator smoke-test scripts (+ Docker variants and
CI jobs) for GameCube/Wii/PSP.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
// Copyright (c) 2026 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
// Entry point run once at startup (see game.c). Swap which scene module
|
||||
// gets passed to Scene.set() here to change what the game boots into.
|
||||
var overworldScene = require('./overworldscene.js');
|
||||
Scene.set(overworldScene);
|
||||
@@ -1,3 +1,8 @@
|
||||
// Copyright (c) 2026 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
// Radius must stay well outside the floor's footprint (a 20x20 plane has a
|
||||
// corner-to-center distance of 10*sqrt(2) =~ 14.1) -- orbiting inside that
|
||||
// puts parts of the floor's own geometry near/behind the camera's view
|
||||
@@ -24,49 +29,57 @@ function updateCameraOrbit() {
|
||||
cameraPosition.lookAt(eyeX, eyeY, eyeZ, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
|
||||
}
|
||||
|
||||
// Called once per engine frame (see engineUpdate() -> scriptManagerCall
|
||||
// Global("update")).
|
||||
function update() {
|
||||
if(cameraPosition) updateCameraOrbit();
|
||||
}
|
||||
module.exports = {
|
||||
// Called once by Scene.set(), right after it creates and activates the
|
||||
// scene this module owns.
|
||||
init: function() {
|
||||
// Camera, orbiting the origin (see updateCameraOrbit above).
|
||||
var camera = new Entity();
|
||||
cameraPosition = camera.add(POSITION);
|
||||
camera.add(CAMERA);
|
||||
updateCameraOrbit();
|
||||
|
||||
(function setup() {
|
||||
var scene = new Scene();
|
||||
scene.setActive();
|
||||
// Static ground plane. Physics ignores the entity's position
|
||||
// component -- the shape's own normal/distance fully define the
|
||||
// plane in world space.
|
||||
var plane = new Entity();
|
||||
var planePosition = plane.add(POSITION);
|
||||
planePosition.setLocalPosition(-10.0, 0.0, -10.0);
|
||||
planePosition.setLocalScale(20.0, 1.0, 20.0);
|
||||
|
||||
// Camera, orbiting the origin (see updateCameraOrbit above).
|
||||
var camera = new Entity();
|
||||
cameraPosition = camera.add(POSITION);
|
||||
camera.add(CAMERA);
|
||||
updateCameraOrbit();
|
||||
var planePhysics = plane.add(PHYSICS);
|
||||
planePhysics.setBodyType(PHYSICS_BODY_STATIC);
|
||||
planePhysics.setShape(PHYSICS_SHAPE_PLANE, 0.0, 1.0, 0.0, 0.0);
|
||||
|
||||
// Static ground plane. Physics ignores the entity's position component --
|
||||
// the shape's own normal/distance fully define the plane in world space.
|
||||
var plane = new Entity();
|
||||
var planePosition = plane.add(POSITION);
|
||||
planePosition.setLocalPosition(-10.0, 0.0, -10.0);
|
||||
planePosition.setLocalScale(20.0, 1.0, 20.0);
|
||||
var planeRenderable = plane.add(RENDERABLE);
|
||||
planeRenderable.setMesh(0, MESH_PLANE);
|
||||
planeRenderable.setColor(128, 128, 128, 255);
|
||||
|
||||
var planePhysics = plane.add(PHYSICS);
|
||||
planePhysics.setBodyType(PHYSICS_BODY_STATIC);
|
||||
planePhysics.setShape(PHYSICS_SHAPE_PLANE, 0.0, 1.0, 0.0, 0.0);
|
||||
// Player: dynamic capsule body, moved relative to the camera by
|
||||
// PLAYER's own update callback (see entityplayer.c).
|
||||
var player = new Entity();
|
||||
var playerPosition = player.add(POSITION);
|
||||
playerPosition.setLocalPosition(0.0, 2.0, 0.0);
|
||||
|
||||
var planeRenderable = plane.add(RENDERABLE);
|
||||
planeRenderable.setMesh(0, MESH_PLANE);
|
||||
planeRenderable.setColor(128, 128, 128, 255);
|
||||
var playerPhysics = player.add(PHYSICS);
|
||||
playerPhysics.setShape(PHYSICS_SHAPE_CAPSULE, 0.5, 0.5);
|
||||
|
||||
// Player: dynamic capsule body, moved relative to the camera by
|
||||
// PLAYER's own update callback (see entityplayer.c).
|
||||
var player = new Entity();
|
||||
var playerPosition = player.add(POSITION);
|
||||
playerPosition.setLocalPosition(0.0, 2.0, 0.0);
|
||||
var playerRenderable = player.add(RENDERABLE);
|
||||
playerRenderable.setMesh(0, MESH_CAPSULE);
|
||||
playerRenderable.setColor(0, 0, 255, 255);
|
||||
|
||||
var playerPhysics = player.add(PHYSICS);
|
||||
playerPhysics.setShape(PHYSICS_SHAPE_CAPSULE, 0.5, 0.5);
|
||||
player.add(PLAYER);
|
||||
},
|
||||
|
||||
var playerRenderable = player.add(RENDERABLE);
|
||||
playerRenderable.setMesh(0, MESH_CAPSULE);
|
||||
playerRenderable.setColor(0, 0, 255, 255);
|
||||
// Called once per engine frame while this module is the active scene
|
||||
// (see Scene.set(), engineUpdate() -> moduleSceneUpdateCurrent()).
|
||||
update: function() {
|
||||
if(cameraPosition) updateCameraOrbit();
|
||||
},
|
||||
|
||||
player.add(PLAYER);
|
||||
})();
|
||||
// Called once by Scene.set() when this module is replaced by another,
|
||||
// right before the scene it owns is destroyed.
|
||||
dispose: function() {
|
||||
cameraPosition = null;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user