Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Entity Framework #5536

Merged
merged 155 commits into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
155 commits
Select commit Hold shift + click to select a range
4a19679
Experimental JSX entity templating
netpro2k Apr 19, 2022
26a565b
Try doing interactable-camera outside of hub.html
netpro2k Apr 19, 2022
ebb0a4e
Play with refs and Object3D entities
netpro2k Apr 20, 2022
a32dbd7
Check in Dom's code
johnshaughnessy May 4, 2022
59eb658
Rewrite single-action buttons using bitECS
johnshaughnessy May 4, 2022
fc1f4c8
Rewrite the networked object button with bitECS
johnshaughnessy May 4, 2022
764e446
Move floaty-object to bitECS land
johnshaughnessy May 5, 2022
d70e153
Add component inflator map to jsx rendering
johnshaughnessy May 5, 2022
160d230
Make mirrors without aframe
johnshaughnessy May 5, 2022
7e3ce4c
Remove console logs
johnshaughnessy May 5, 2022
1b187fd
WIP Inflating media frames
johnshaughnessy May 6, 2022
dfabc0d
Media frames mostly working locally
johnshaughnessy May 6, 2022
80014d5
Media frames a bit cleaned up
johnshaughnessy May 7, 2022
12771dd
Disable physics debug
johnshaughnessy May 12, 2022
c3875e7
Network media frames
johnshaughnessy May 14, 2022
5a90c46
Separate media frame into step, apply, display
johnshaughnessy May 14, 2022
e491ca3
Cleanup
johnshaughnessy May 15, 2022
a56a90a
Rename capturedEntity -> captured
johnshaughnessy May 15, 2022
fcb4ec2
Send media frame isFull. Also requeue messages
johnshaughnessy May 15, 2022
c1a8d08
Add the desired media frame
johnshaughnessy May 15, 2022
d268238
Rename originalTargetScale -> scale
johnshaughnessy May 15, 2022
49c97d7
Change Networked/DesiredMediaFrame to FrameUpdate
johnshaughnessy May 15, 2022
4cd9c70
Update comments about snap to frame
johnshaughnessy May 15, 2022
5fdeafb
Leave a note about a bug with re-enqueing network updates
johnshaughnessy May 15, 2022
c8ca7a4
Change logging
johnshaughnessy May 16, 2022
602a689
Send captured nid, not isFull
johnshaughnessy May 17, 2022
ec26fbf
Remove derived state (FrameUpdate.captured)
johnshaughnessy May 17, 2022
618065e
Rename FrameUpdate -> NetworkedMediaFrame
johnshaughnessy May 17, 2022
af99289
Change NetworkedMediaFrame so that it is not consumed
johnshaughnessy May 17, 2022
a2c1907
Remove logs
johnshaughnessy May 17, 2022
004b8f3
Remove derived captured state from MediaFrame
johnshaughnessy May 17, 2022
47e31b9
Correct box calculation when snapping into frame
johnshaughnessy May 17, 2022
bac2bac
Rename "eid" suffix from variable names
johnshaughnessy May 17, 2022
f5ea8c1
Don't allow a media frame to capture its ancestor
johnshaughnessy May 17, 2022
c3e28fb
Snap when we capture an entity
johnshaughnessy May 17, 2022
4573887
optimize isAncestor
johnshaughnessy May 17, 2022
15fabc6
Fix definition orders in hub.html
johnshaughnessy May 18, 2022
2782781
Add support for text component inflation
johnshaughnessy May 19, 2022
8535699
slice9 component and start of a button
netpro2k May 19, 2022
541c1d4
Move components into bit-components
johnshaughnessy May 21, 2022
7cafa96
Reimplement hovering and holding
johnshaughnessy May 22, 2022
42d6374
Reorder grab and drops
johnshaughnessy May 22, 2022
309bf42
Reimplement constraints
johnshaughnessy May 22, 2022
65539d1
Implement network create
johnshaughnessy May 24, 2022
44496ee
Add previousState back for old interaction system
netpro2k May 24, 2022
1da5563
Fix taking ownership of grabbed objects
netpro2k May 24, 2022
a48a3ce
Remove concept of "templates" from netcode
netpro2k May 24, 2022
3b47cba
Very basic network transform position
netpro2k May 24, 2022
909b831
Set unowned bodies kinematic.
johnshaughnessy May 24, 2022
28a257b
Use anyAframeEntityWith
johnshaughnessy May 24, 2022
377db53
Move stuff around in netcode. No changes
johnshaughnessy May 24, 2022
4ee5bda
Moved bit-interaction-system stuff to its own function
johnshaughnessy May 24, 2022
e645bbb
Implement network delete for new entities
johnshaughnessy May 25, 2022
e4d9b1c
Change execution order of physicsCompatSystem
netpro2k May 26, 2022
ed24d85
Handle removing for nested Object3D entities
netpro2k May 26, 2022
1f81c08
Rough template for late joiner handling
netpro2k May 26, 2022
0e52140
Support for nested networked objects
netpro2k May 26, 2022
ec6bf39
Clarify comments. Fix a-entity deletion
johnshaughnessy May 26, 2022
a7d69f4
Implement late-joiner logic
johnshaughnessy May 26, 2022
d07bd8a
Take ownership of all abandoned network entities
johnshaughnessy May 26, 2022
70fe650
Inline some stuff
johnshaughnessy May 26, 2022
0a0c78b
Handle clients leaving
johnshaughnessy May 27, 2022
3fcc97f
Add resolveRef to inflation
johnshaughnessy May 27, 2022
5d62955
Basic render target on camera tool
netpro2k May 28, 2022
ff051cc
Basic photo snapping
netpro2k May 28, 2022
1b1af2c
Basic video snapping state
netpro2k May 31, 2022
d11e1cc
Fix camera rotation (missing shape)
netpro2k Jun 1, 2022
aeee57e
Add camera cancel button. Modify camera timer
johnshaughnessy Jun 1, 2022
ecae01d
Button hover coloring
netpro2k Jun 2, 2022
0a73ffc
Fix hovering on legacy buttons
netpro2k Jun 2, 2022
0a2c26f
Remove some dead code
netpro2k Jun 2, 2022
9dcf69e
Remove more dead code
netpro2k Jun 2, 2022
da113bc
Basic hand hovering
netpro2k Jun 3, 2022
1cf03e6
WIP trying to fix hand grabbing
netpro2k Jun 3, 2022
1f33af8
Remove double hovering
netpro2k Jun 3, 2022
6bbb466
Port the rest of floaty-object
netpro2k Jun 4, 2022
4c2ff23
Fix/Simplify AppAwareMouse
netpro2k Jun 6, 2022
c2aa2f2
Remove uses of tags.data (todo: touch input)
netpro2k Jun 6, 2022
dc93e27
Cleanup
netpro2k Jun 6, 2022
ff6ecf6
Clenup jsx-entiteis
netpro2k Jun 6, 2022
2246f38
Remove renderAsGLTF
netpro2k Jun 6, 2022
54f2b17
More cleanup
netpro2k Jun 6, 2022
9b14251
Re-implement video recording
netpro2k Jun 7, 2022
9b6fb11
Factor out RenderTargetRecorder
netpro2k Jun 7, 2022
219e078
Add todo about floaty-object race
netpro2k Jun 7, 2022
4f70f93
Camera tool menu should always face player
netpro2k Jun 8, 2022
e18d36e
Rework net serialization to do diffing
netpro2k Jun 8, 2022
c1dc605
Camera tool menu update not committed
netpro2k Jun 8, 2022
3d280e1
Remove some logs
netpro2k Jun 8, 2022
8fd74e2
Permissions + simplification of netcode
netpro2k Jun 8, 2022
08e4812
Rework pending nid handling. Simplify parting more
netpro2k Jun 8, 2022
b4e1082
Only update diff on non full syncs
netpro2k Jun 8, 2022
6c5390f
Update TODOs
netpro2k Jun 8, 2022
35ad56a
Add rotation/scale to NetworkedTransform
netpro2k Jun 8, 2022
97a97dc
Fix physics race in floaty object system
netpro2k Jun 9, 2022
e55c46e
Cleanup
netpro2k Jun 9, 2022
f0a2819
applyNetworkUpdates -> networkReceiveSystem
netpro2k Jun 9, 2022
720aa06
Handle objects collding with multiple MediaFrames
netpro2k Jun 9, 2022
76a7af6
Point at bitecs branches of aframe and NAF
netpro2k Jun 9, 2022
effdfdd
Restore periodic-full-syncs
netpro2k Jun 9, 2022
5d57add
Fix name assignment for jsx-entities
netpro2k Jun 9, 2022
29d1f62
Move pixelsToPNG into RenderTargetRecorder
netpro2k Jun 9, 2022
c788146
Fix admin package-lock
netpro2k Jun 9, 2022
1fe0ce7
Tidy up camera UI
netpro2k Jun 10, 2022
461dd56
Limit camera viewfinder updates
netpro2k Jun 10, 2022
548aab4
Only update viewfinders in view
netpro2k Jun 10, 2022
0fb498d
snapshot binding for grabbed camera
netpro2k Jun 10, 2022
9b2d4b8
Don't render spacebubbles in camera tool
netpro2k Jun 10, 2022
46f6213
Remove debug
netpro2k Jun 10, 2022
2e663be
Add tick to time system
netpro2k Jun 10, 2022
92efbaa
Don't hardcode gltf media frame root nid
netpro2k Jun 10, 2022
19dc0a1
Add simple camera toggle
netpro2k Jun 10, 2022
02a68e3
Add /cube command, more work on physics
netpro2k Jun 10, 2022
d5ea1bd
Temporarily allow continuous frame snapping
netpro2k Jun 10, 2022
eb595fc
Port destroy-at-extreme-distance, use on cubes
netpro2k Jun 10, 2022
a50280f
Fix inspecting avatars
netpro2k Jun 11, 2022
12a2624
Fix camera menu rotation
netpro2k Jun 14, 2022
d5a9e18
Move camera tool system
netpro2k Jun 15, 2022
b6ccc8b
More UI layer. Remove camtool code from billboard.
netpro2k Jun 15, 2022
b0f6d3b
Port remaining parts of old camera tool system
netpro2k Jun 16, 2022
85d41c6
Fix some physics system todos
netpro2k Jun 16, 2022
afa795f
Fix some jsx reserved properties
netpro2k Jun 16, 2022
a5ffc03
Cleanup camera tool media spawning + init
netpro2k Jun 16, 2022
ec718d0
Lower default entity count to 10k and add to stats
netpro2k Jun 16, 2022
2dd65f5
Load camera model in a nicer way
netpro2k Jun 17, 2022
68d4460
dispose() GLTFModel, Slice9, and Text. Fix leaks.
netpro2k Jun 17, 2022
ef61ab5
Fix leak in aframe slice9
netpro2k Jun 17, 2022
dae0649
Correctly dispose() MediaFrame geometry. DRY up.
netpro2k Jun 17, 2022
0be4492
Speed up camera loading a bit
netpro2k Jun 17, 2022
4623cd2
Add a temporary way to rotate camreas with mouse
netpro2k Jun 17, 2022
3fcf9b7
Fix video saving
netpro2k Jun 17, 2022
5cc3bbe
Only show camtool viewfinder n VR when held or rec
netpro2k Jun 22, 2022
7724c6b
Make camtool kinematic on release
netpro2k Jun 22, 2022
cee6df7
Rename camtool "schema" to "prefab"
netpro2k Jun 22, 2022
c830cc0
Fix spawners
netpro2k Jun 22, 2022
4c812b8
Cleanup unused interaction state
netpro2k Jun 22, 2022
84c96d5
Move inflators out of jsx-entity.js
netpro2k Jun 22, 2022
bc6674c
Cleanup media frame previews
netpro2k Jun 23, 2022
8ec30f8
Media Frames should Ignore loading objects
netpro2k Jun 23, 2022
1a6a096
Fix/simplify media frame scaling
netpro2k Jun 24, 2022
a3e8175
Add audio recording toggle to camtool, rework UI
netpro2k Jun 24, 2022
e88daf9
Render cursor on UI layer
netpro2k Jun 24, 2022
785ec9f
Fix edge case removing object while its loading
netpro2k Jun 24, 2022
1dc43c0
Fix incorrect assumption about layer masks
netpro2k Jun 24, 2022
e435a26
Fix interactions on touchscreen
netpro2k Jun 28, 2022
dfdb425
Misc cleanups
netpro2k Jun 28, 2022
266eb35
Delint
netpro2k Jun 28, 2022
21d8e26
Cleanup
netpro2k Jul 14, 2022
8433044
Merge remote-tracking branch 'origin/master' into bitecs-experiment
netpro2k Jul 15, 2022
bad24f1
Remove isVideoTexture hack from camera tool
netpro2k Jul 15, 2022
d72ff01
Hack fix for camera menu matrix update issue
netpro2k Jul 19, 2022
feba3df
Fix sRGB encoding on camera tool images
netpro2k Jul 19, 2022
07ec12d
Merge remote-tracking branch 'origin/master' into bitecs-experiment
netpro2k Jul 19, 2022
c2b72ad
Update lockfiles to merged versions of aframe/NAF
netpro2k Jul 19, 2022
ecd712d
Remove physics debug changes from webpack config
netpro2k Jul 19, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions admin/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"ammo-debug-drawer": "github:infinitelee/ammo-debug-drawer",
"ammo.js": "github:mozillareality/ammo.js#hubs/master",
"animejs": "github:mozillareality/anime#hubs/master",
"bitecs": "^0.3.38",
"buffered-interpolation": "github:Infinitelee/buffered-interpolation",
"classnames": "^2.2.5",
"color": "^3.1.2",
Expand Down
76 changes: 75 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
import Store from "./storage/store";
import * as bitecs from "bitecs";
import { addEntity, createWorld } from "bitecs";
import "./aframe-to-bit-components";
import { AEntity, Networked, Object3DTag, Owned } from "./bit-components";
import MediaSearchStore from "./storage/media-search-store";
import Store from "./storage/store";
import qsTruthy from "./utils/qs_truthy";

window.$B = bitecs;

const timeSystem = world => {
const { time } = world;
const now = performance.now();
const delta = now - time.then;
time.delta = delta;
time.elapsed += delta;
time.then = now;
time.tick++;
return world;
};

export class App {
constructor() {
this.scene = null;
Expand All @@ -23,6 +40,50 @@ export class App {
this.clippingState = new Set();
this.mutedState = new Set();
this.isAudioPaused = new Set();

this.world = createWorld();

// TODO: Create accessor / update methods for these maps / set
this.world.eid2obj = new Map(); // eid -> Object3D

this.world.nid2eid = new Map();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to think up a better pattern for storing system state like this. Here we are putting it on world, in other spots like camera tool we just store it in a module local variable. I think having some pattern for this would be useful.

this.world.deletedNids = new Set();
this.world.ignoredNids = new Set();

this.str2sid = new Map([[null, 0]]);
this.sid2str = new Map([[0, null]]);
this.nextSid = 1;

window.$o = eid => {
this.world.eid2obj.get(eid);
};

// reserve entity 0 to avoid needing to check for undefined everywhere eid is checked for existance
addEntity(this.world);

// used in aframe and networked aframe to avoid imports
this.world.nameToComponent = {
object3d: Object3DTag,
networked: Networked,
owned: Owned,
AEntity
};
}

// TODO nothing ever cleans these up
getSid(str) {
if (!this.str2sid.has(str)) {
const sid = this.nextSid;
this.nextSid = this.nextSid + 1;
this.str2sid.set(str, sid);
this.sid2str.set(sid, str);
return sid;
}
return this.str2sid.get(str);
}

getString(sid) {
return this.sid2str.get(sid);
}

// This gets called by a-scene to setup the renderer, camera, and audio listener
Expand Down Expand Up @@ -66,13 +127,24 @@ export class App {
const camera = new THREE.PerspectiveCamera(80, window.innerWidth / window.innerHeight, 0.05, 10000);

const audioListener = new THREE.AudioListener();
APP.audioListener = audioListener;
camera.add(audioListener);

const renderClock = new THREE.Clock();

// TODO NAF currently depends on this, it should not
sceneEl.clock = renderClock;

// TODO we should have 1 source of truth for time
APP.world.time = {
delta: 0,
elapsed: 0,
then: performance.now(),
tick: 0
};

APP.world.scene = sceneEl.object3D;

// Main RAF loop
function mainTick(_rafTime, xrFrame) {
// TODO we should probably be using time from the raf loop itself
Expand All @@ -82,6 +154,8 @@ export class App {
// TODO pass this into systems that care about it (like input) once they are moved into this loop
sceneEl.frame = xrFrame;

timeSystem(APP.world);

// Tick AFrame systems and components
if (sceneEl.isPlaying) {
sceneEl.tick(time, delta);
Expand Down
31 changes: 31 additions & 0 deletions src/aframe-to-bit-components.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { addComponent, removeComponent } from "bitecs";
import {
RemoteRight,
RemoteLeft,
HandRight,
HandLeft,
RemoteHoverTarget,
NotRemoteHoverTarget,
RemoveNetworkedEntityButton,
DestroyAtExtremeDistance
} from "./bit-components";

[
["remote-right", RemoteRight],
["remote-left", RemoteLeft],
["hand-right", HandRight],
["hand-left", HandLeft],
["is-remote-hover-target", RemoteHoverTarget],
["is-not-remote-hover-target", NotRemoteHoverTarget],
["remove-networked-object-button", RemoveNetworkedEntityButton],
["destroy-at-extreme-distances", DestroyAtExtremeDistance]
].forEach(([aframeComponentName, bitecsComponent]) => {
AFRAME.registerComponent(aframeComponentName, {
init: function() {
addComponent(APP.world, bitecsComponent, this.el.object3D.eid);
},
remove: function() {
removeComponent(APP.world, bitecsComponent, this.el.object3D.eid);
}
});
});
121 changes: 121 additions & 0 deletions src/bit-components.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import { defineComponent, setDefaultSize, Types } from "bitecs";

// TODO this has to happen before all components are defined. Is there a better spot to be doing this?
setDefaultSize(10000);

export const $isStringType = Symbol("isStringType");

export const Networked = defineComponent({
id: Types.ui32,
creator: Types.ui32,
owner: Types.ui32,

lastOwnerTime: Types.ui32
});
Networked.id[$isStringType] = true;
Networked.creator[$isStringType] = true;
Networked.owner[$isStringType] = true;

export const Owned = defineComponent();
export const NetworkedMediaFrame = defineComponent({
capturedNid: Types.ui32,
scale: [Types.f32, 3]
});
NetworkedMediaFrame.capturedNid[$isStringType] = true;

export const MediaFrame = defineComponent({
capturedNid: Types.ui32,
scale: [Types.f32, 3],
mediaType: Types.ui8,
bounds: [Types.f32, 3],
preview: Types.eid,
previewingNid: Types.eid
});
export const Text = defineComponent();
export const Slice9 = defineComponent({
insets: [Types.ui32, 4],
size: [Types.f32, 2]
});

export const NetworkedTransform = defineComponent({
position: [Types.f32, 3],
rotation: [Types.f32, 4],
scale: [Types.f32, 3]
});

export const AEntity = defineComponent();
export const Object3DTag = defineComponent();
export const GLTFModel = defineComponent();
export const CursorRaycastable = defineComponent();
export const RemoteHoverTarget = defineComponent();
export const NotRemoteHoverTarget = defineComponent();
export const Holdable = defineComponent();
export const RemoveNetworkedEntityButton = defineComponent();
export const Interacted = defineComponent();

export const HandRight = defineComponent();
export const HandLeft = defineComponent();
export const RemoteRight = defineComponent();
export const RemoteLeft = defineComponent();
export const HoveredHandRight = defineComponent();
export const HoveredHandLeft = defineComponent();
export const HoveredRemoteRight = defineComponent();
export const HoveredRemoteLeft = defineComponent();
export const HeldHandRight = defineComponent();
export const HeldHandLeft = defineComponent();
export const HeldRemoteRight = defineComponent();
export const HeldRemoteLeft = defineComponent();
export const Held = defineComponent();
export const OffersRemoteConstraint = defineComponent();
export const HandCollisionTarget = defineComponent();
export const OffersHandConstraint = defineComponent();
export const TogglesHoveredActionSet = defineComponent();

export const HoverButton = defineComponent({ type: Types.ui8 });
export const TextButton = defineComponent({ labelRef: Types.eid });
export const HoldableButton = defineComponent();
export const SingleActionButton = defineComponent();

export const Pen = defineComponent();
export const HoverMenuChild = defineComponent();
export const Static = defineComponent();
export const Inspectable = defineComponent();
export const PreventAudioBoost = defineComponent();
export const IgnoreSpaceBubble = defineComponent();
export const Rigidbody = defineComponent({
bodyId: Types.ui16,
collisionGroup: Types.ui32,
collisionMask: Types.ui32,
flags: Types.ui8,
gravity: Types.f32
});
export const PhysicsShape = defineComponent({ bodyId: Types.ui16, shapeId: Types.ui16, halfExtents: [Types.f32, 3] });
export const Pinnable = defineComponent();
export const Pinned = defineComponent();
export const DestroyAtExtremeDistance = defineComponent();

export const MediaLoading = defineComponent();

export const FloatyObject = defineComponent({ flags: Types.ui8, releaseGravity: Types.f32 });
export const MakeKinematicOnRelease = defineComponent();

export const CameraTool = defineComponent({
snapTime: Types.f32,
state: Types.ui8,
captureDurIdx: Types.ui8,
trackTarget: Types.eid,

snapMenuRef: Types.eid,
button_next: Types.eid,
button_prev: Types.eid,
snapRef: Types.eid,
cancelRef: Types.eid,
recVideoRef: Types.eid,
screenRef: Types.eid,
selfieScreenRef: Types.eid,
cameraRef: Types.eid,
countdownLblRef: Types.eid,
captureDurLblRef: Types.eid,
sndToggleRef: Types.eid
});
export const MyCameraTool = defineComponent();
Loading