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

Media tools followup fixes #463

Merged
merged 63 commits into from
Jul 24, 2018
Merged

Media tools followup fixes #463

merged 63 commits into from
Jul 24, 2018

Conversation

netpro2k
Copy link
Contributor

@netpro2k netpro2k commented Jul 18, 2018

This PR addresses a bunch of the fixes outlined in #451, namely:

  • Fixes for loading google poly urls
  • Fixes for loading GIFs
  • Use positional audio for video/audio objects
  • Destroy objects when they "fall off the world"
  • Fix bounding boxes for certain models
  • Add loading indicators while models/images are loading
  • Unify the code used for media tools and spawners (spawners now can specify the url for the media they wish to spawn)
  • Support for backend media API changes
  • Attribution for Giphy urls in the add media dialog
  • Rotate objects at the end of the cursor to face the user

It would probably have been wise to break this up, but most of these were small fixes. The large majority of the work centered around unifying spawners, adding loading indicator, and fixing bounding boxes. Many underlying bugs and race conditions were discovered in aframe-physics-system and super-hands in the process, many of which exist in production today, but just didn't manifest in very noticeable ways.

There is some additional code cleanup that is probably warranted (particularly position-at-box-shape), though this is in a sufficiently better state than what is in production now that it feels silly to continue holding it back for those.

johnshaughnessy and others added 30 commits July 9, 2018 16:45
@netpro2k netpro2k changed the title Media tools followup fixes (WIP) Media tools followup fixes Jul 21, 2018
@netpro2k netpro2k requested a review from InfiniteLee July 21, 2018 00:01
package.json Outdated
@@ -41,7 +41,7 @@
"jsonschema": "^1.2.2",
"moving-average": "^1.0.0",
"naf-janus-adapter": "^0.10.1",
"networked-aframe": "https://github.com/mozillareality/networked-aframe#mr-social-client/master",
"networked-aframe": "https://github.com/mozillareality/networked-aframe#bug/aframe-initialization-race-condition",
Copy link
Contributor

Choose a reason for hiding this comment

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

can we point back to networked-aframe/master or pull in the latest to the dev fork and keep pointing at that? It got updated with our PR's last week.

@@ -97,6 +98,11 @@ AFRAME.registerComponent("cursor-controller", {
if (this.data.drawLine) {
this.el.setAttribute("line", { start: this.origin.clone(), end: this.data.cursor.object3D.position.clone() });
}

// The curser will always be oriented towards the player about its Y axis, so bjects held by the cursor will rotate towards the player.
Copy link
Contributor

Choose a reason for hiding this comment

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

typos:
// The curser cursor will always be oriented towards the player about its Y axis, so bjects objects held by the cursor will rotate towards the player.

@@ -202,6 +203,7 @@ function cachedLoadGLTF(src, preferredTechnique, onProgress) {
AFRAME.registerComponent("gltf-model-plus", {
schema: {
src: { type: "string" },
basePath: { type: "string", default: undefined },
Copy link
Contributor

Choose a reason for hiding this comment

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

If basePath is not specified, nothing checks for that case and ultimately will wind up with an error being thrown in THREE.GLTFLoader in cachedLoadGLTF(). There should probably be a check to catch that case prior to undefined being passed into THREE.GLTFLoader.

// Load the gltf model from the cache if it exists.
if (!GLTFCache[src]) {
GLTFCache[src] = new Promise((resolve, reject) => {
const gltfLoader = new THREE.GLTFLoader();
gltfLoader.path = basePath;
Copy link
Contributor

Choose a reason for hiding this comment

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

see comment on basePath below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the intent here is that setting undefined is the same as not setting it. GLTFLoader doesnt require a path to be set.

@@ -180,6 +144,7 @@ AFRAME.registerComponent("image-plus", {
texture.minFilter = THREE.LinearFilter;
videoEl.addEventListener("loadedmetadata", () => resolve(texture), { once: true });
videoEl.onerror = reject;
texture.audioSource = this.el.sceneEl.audioListener.context.createMediaElementSource(videoEl);
Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn't attach arbitrary objects to existing three.js constructs. If you need to associate the audioSource with a texture you should create a map in this component.

this.el.setObject3D("mesh", this.mesh);
this.el.setAttribute("shape", {
shape: "box",
halfExtents: { x: width / 2, y: height / 2, z: 0.05 }
Copy link
Contributor

Choose a reason for hiding this comment

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

0.05 should probably be defined in component schema

halfExtents: { x: width / 2, y: height / 2, z: 0.05 }
});
if (this.el.components.body && this.el.components.body.body) {
this.el.components.body.syncToPhysics(); // not sure if necessary?
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't seem like it should be necessary, but verify?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since we have already tested it a bunch with this in, going to leave it in for now to avoid missing some edge case. Put in a todo to evaluate though.

this.el.sceneEl.appendChild(entity);
onGrabEnd(e) {
this.heldEntities.delete(e.detail.hand);
// This tells super-hands we are handling this releae
Copy link
Contributor

Choose a reason for hiding this comment

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

// This tells super-hands we are handling this releae release

/**
* Source of the media asset the spawner will spawn when grabbed. This can be a gltf, video, or image, or a url that the reticiulm media API can resolve to a gltf, video, or image.
*/
src: { default: "https://asset-bundles-prod.reticulum.io/interactables/Ducky/DuckyMesh-438ff8e022.gltf" },
Copy link
Contributor

Choose a reason for hiding this comment

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

having this defined here as the default seems wrong- this should get moved into the environment component data

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, the plan would be to update the enviornments after we push this, then we can remove this default. This is just to allow us to push without breaking the existing environments during out push.

src/hub.html Outdated
>
<a-entity class="delete-button" visible-while-frozen>
<a-entity class="delete-button" visible-while-frozen scale="1.00 1.00 1.00">
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't scale 1 1 1 by default?

@@ -0,0 +1,20 @@
export function getBox(entity, boxRoot) {
Copy link
Contributor

Choose a reason for hiding this comment

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

cache rotation and copy instead of clone

export function getBox() {
  const rotation = new THEE.Quaternion();
  return function (entity, boxRoot) {
    ...
    rotation.copy(entity.object3D.rotation);
...

@@ -1,3 +1,5 @@
import { getBox } from "../utils/auto-box-collider.js";

const PI = Math.PI;
const HALF_PI = PI / 2;
const THREE_HALF_PI = 3 * PI / 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

const THREE_HALF_PI = 3 * HALF_PI;

this.mesh = this.el.getObject3D("mesh");
if (this.el.components.shape) {
this.shape = this.el.components.shape;
this.halfExtents = new THREE.Vector3().copy(this.shape.data.halfExtents);
Copy link
Contributor

Choose a reason for hiding this comment

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

Cache this vector3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants