thomasboyt / coquette-inspect Goto Github PK
View Code? Open in Web Editor NEWA Chrome DevTools extension for inspecting games made with the Coquette framework
A Chrome DevTools extension for inspecting games made with the Coquette framework
Picker between true
/false
UI thoughts:
<input type="number" />
<input type="text" />
<select><option value="true">True</option><option value="false">False</option></select>
null
: This is super tricky because it's totally unknown what they're supposed to be. I'm thinking they could just be an <input type="text" />
and autocast based on whether it's a number or string? Obviously that's not great but seems better than not letting you change it at all.undefined
or null
, no matter the type.Agent thoughts:
{
name: "modify",
data: {
entityId: "<uuid>",
path: "foo.bar.baz",
value: "<value>"
}
}
Allows runloop-paused games to send state to newly-opened inspector
Currently, they all say [[circular reference]]
which is actually usually not even true, they're just objects already seen.
There's basically four reasons an object is hidden:
[object ObjectType]
[object hidden]
may not be clear - may not be obvious where else in the tree it'll be. Right now, this just is [circular reference],
so it should be able to stay that way for v0.1.[entity <uuid>]
[coquette namespace]
entityMap
/seen
to indicate whether it's a previously serialized object (2), or another entity (3).This goes in tandem with the above. One of the tricky bits about this is making sure that these fancy strings with fancy meanings don't end up conflicting with actual set strings, because there's going to be a regex match used against them to ensure that the UI doesn't allow them to be edited.
From the above, I could think of a few regexes to match:
^\[object\s[^\s]*]$
- matches [object Object]
, not [object]
, not [object object object]
^[circular reference]$
^[entity \s[^\s]*$
- similar to 1^[coquette namespace]$
These should probably be in the docs somewhere, as a way of saying "make sure your strings don't match things!"
Change the cursor for hovering over the canvas, maybe?
So, there's a "step" button now, but it's a bit weird because there's no delta time in the frame (it's set to 0 for the first frame after start()
, see https://github.com/maryrosecook/coquette/blob/master/src/ticker.js#L13-L17). This means that no update
code is going to go that depends on a delta time (e.g. moving things).
Easiest way to do this would be to set a "perfect" delta time for 60fps, which would be 1000/60
ms (~16.67). Easiest way to do that would probably be to monkey patch start()
to accept an initial prev
time. Unfortunately, any monkey patch wouldn't have access to the gameLoop
variable that's in the closure, so likely the entire Ticker constructor needs to be patched to store that in its context :(
:>
This one's pretty out there, but I think it's doable, if prone to breaking in intense ways:
Any entity in Coquette's collision detection framework should have this.size{x,y}
and this.center{x,y}
properties that could be used to determine whether two x,y coordinates lie within an entity. In fact, Coquette even has a super awesome method built in for this, used like this in the spinning shapes demo.
The debugger could have an "inspect at cursor" toggle, almost exactly like the inspect element button in the DOM inspector, that would allow you to click an entity and open its particular tree.
Great test case: the game object in 33rpm.
Displays fine when paused, of course. Seems likely that there's an O(n^2) algo doing dumb things somewhere. Should experiment with different object shapes in a testbed - should test objects, arrays, number of properties, depth, etc.
a nice side effect of this will be rewriting the way subscribed objects are stored on both sides, neither of which I'm very happy with
See #14.
Instead of serializing & sending all entities on each tick, only serialize the current open one in the interface.
Expands all objects in the entity's tree.
this would be super, super cool, and make it easy to create "playground" demos with coquette.
seems like the main thing to do here is to have an "adapter" abstraction for the communication between the Agent and the UI, like how Ember Inspector does, that could replaced with just pure window.postMessage()
or whatever weird shit you have to do to make iframe communication go (if that's how it's embedded)
https://github.com/thomasboyt/coquette-inspect/blob/master/src/ui/actions/GameActions.js ew
That could be replaced by allowing the UI to directly sendMessage
instead of calling actions, and for AgentHandler to directly dispatch events.
The latter should definitely happen, the former is arguable.
I think this is as easy as sendMessage('logProperty', {entityId: ..., path: ...})
on the UI side, and a console.log
on the agent side
this seems like a relatively easy piece of work - simply report the current time on each entities tick, and have the UI calculate the average FPS over time.
When entities are listed, their position in the entities
array is currently used as the React key. However, this means that an entity being moved in position (i.e. if a prior entity is removed) will require the DOM for that entity to be entirely recomputed, which is a big overhead. It also makes it extremely hard to subscribe to the state of a specific entity.
So, there are two changes that need to happen:
There's a couple options to implement UUIDs -
entities.create
to generate a UUID and store it in the entity, then iterate over the current entities list and backfill any that don't have UUIDsentities.create
entities.create
is pretty simple; the easiest way to monkey-patch would be to simply wrap the original function:
var orig = this.__coquette__.entities.create;
this.__coquette__.entities.create = function(Constructor, settings) {
var entity = orig.apply(this, Constructor, settings);
entity._uuid = generateUUID();
return entity;
};
Backfilling's also easy, e.g. this.__coquette__.entities.all().map((entity) => { entity._uuid = generateUUID() })
For looking up an entity by UUID, a filter
should be good enough to start. Could cache a map of {uuid: entityObject}
, but would have to make sure that the map entry is removed if the entity is deleted, which would require a monkey-patch around entities.remove
This is specifically related to the (non-)performance of serializing entities. This demo creates lots of tiny particles, each represented as an entity. Serializing all of them is mad expensive. It's unclear whether the cost is due to the number of entities, or if some very complex object is getting serialized.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.