-
Notifications
You must be signed in to change notification settings - Fork 22.4k
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
Fixed outdated code and documentation in A-Frame tutorial in Games section #34159
Conversation
files/en-us/games/techniques/3d_on_the_web/building_up_a_basic_demo_with_a-frame/index.md
Outdated
Show resolved
Hide resolved
Preview URLs External URLs (4)URL:
(comment last updated: 2024-07-11 10:00:29) |
files/en-us/games/techniques/3d_on_the_web/building_up_a_basic_demo_with_a-frame/index.md
Outdated
Show resolved
Hide resolved
…_demo_with_a-frame/index.md Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
files/en-us/games/techniques/3d_on_the_web/building_up_a_basic_demo_with_a-frame/index.md
Outdated
Show resolved
Hide resolved
…_demo_with_a-frame/index.md Co-authored-by: Brian Thomas Smith <brian@smith.berlin>
files/en-us/games/techniques/3d_on_the_web/building_up_a_basic_demo_with_a-frame/index.md
Outdated
Show resolved
Hide resolved
…_demo_with_a-frame/index.md Co-authored-by: Brian Thomas Smith <brian@smith.berlin>
Thanks for the additional fixes. I'm going to have to come back to this one as there's more to consider. In general, we want to get rid of JSFiddle examples & links to other repos that we don't maintain because they diverge so much over time. Usually for live samples, we can embed and render the output directly in the page, but we need aframe as a dependency, so I'm going to think about alternatives first before merging. Thanks for your patience 🙌🏻 |
@bsmth <head>
<script src="https://cdn.jsdelivr.net/gh/aframevr/aframe@3f0df33946cf12e3d552b3b4e500dd5b8ff6f692/dist/aframe-master.min.js"></script>
</head>
<body>
<a-scene>
<a-sky color="#DDDDDD"></a-sky>
<a-light type="directional" color="#FFF" intensity="0.5" position="-1 1 2"></a-light>
<a-light type="ambient" color="#FFF"></a-light>
<a-camera
position="0 1 4"
cursor-visible="true"
cursor-scale="2"
cursor-color="#0095DD"
cursor-opacity="0.5">
</a-camera>
<a-box color="#0095DD" position="0 1 0" rotation="20 40 0" animation="property: rotation;from:20 0 0; to: 20 360 0;dir: alternate; loop: true; dur: 4000; easing: easeInOutQuad;"></a-box>
<a-entity
geometry="
primitive: torus;
radius: 1;
radiusTubular: 0.1;
segmentsTubular: 12;"
material="
color: #EAEFF2;
roughness: 0.1;
metalness: 0.5;"
rotation="10 0 0"
position="-3 1 0"
animation="property: scale; to: 1 0.5 1; dir: alternate; dur: 2000; loop: true; easing: linear;">
</a-entity>
</a-scene>
<a-light type="directional" color="#FFF" intensity="0.5" position="-1 1 2">
</a-light>
<a-light type="ambient" color="#FFF"></a-light>
<script>
const scene = document.querySelector("a-scene");
const cylinder = document.createElement("a-cylinder");
cylinder.setAttribute("color", "#FF9500");
cylinder.setAttribute("height", "2");
cylinder.setAttribute("radius", "0.75");
cylinder.setAttribute("position", "3 1 0");
scene.appendChild(cylinder);
let t = 0;
function render() {
t += 0.01;
requestAnimationFrame(render);
cylinder.setAttribute("position", `3 ${Math.sin(t * 2) + 1} 0`);
}
render();
</script>
</body>
It seems to work fine, but maybe there is something I am missing! |
I think we cannot run JavaScript served from jsdelivr on MDN pages due to security concerns, so we'll need an alternative that might take a little time to get right. Hopefully I have some more information about this soon. |
I am sorry, for keeping you here, but do you mean cannot as in it's not allowed by certain guidelines? |
files/en-us/games/techniques/3d_on_the_web/building_up_a_basic_demo_with_a-frame/index.md
Outdated
Show resolved
Hide resolved
…_demo_with_a-frame/index.md
Heya @low-perry I've come back to this and I don't think it's worth blocking this PR from going in despite us wanting to move away from JSFiddles. Let's get your improvements landed and we'll tackle the embeds separately at a later stage. Thanks a lot! |
Yes, and we have CSP rules for resources we explicitly allow and I don't think we'd add jsDeliver to that. We want to remove jsFiddles in general because they're hard (impossible) to maintain, really. When it comes to the examples, one good question is whether it's necessary to embed it in the page at all. We have a lot of standalone examples that are good when served by themselves and we link to them, like the source in a repo:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going to leave a +1 on this one! Thank you for your work and your patience!
I'll keep you posted on any updates when we start to move examples if you like!
@bsmth Thank you for your patience. I am very grateful that you took the time to reply to my questions. And I would love to be updated, when a better solution comes along. 🧡 |
…ction (mdn#34159) * Fixed outdated code and documentation * Fixed linting issue. * Update files/en-us/games/techniques/3d_on_the_web/building_up_a_basic_demo_with_a-frame/index.md Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update files/en-us/games/techniques/3d_on_the_web/building_up_a_basic_demo_with_a-frame/index.md Co-authored-by: Brian Thomas Smith <brian@smith.berlin> * fixed animation bug on the a-entity element * Updates jsfiddle to mirror the changes. * fixed unsafe html * Update files/en-us/games/techniques/3d_on_the_web/building_up_a_basic_demo_with_a-frame/index.md Co-authored-by: Brian Thomas Smith <brian@smith.berlin> * Update files/en-us/games/techniques/3d_on_the_web/building_up_a_basic_demo_with_a-frame/index.md --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Brian Thomas Smith <brian@smith.berlin>
Description
Changed the docs in order for the code presented to work, since A-FRAME has probably deprecated some of the code used. Replaced the jsfiddle iframe with a version that uses the updated code.
Motivation
It makes the reader follow the tutorial and have a finished product at the end that works
Additional details
This docs also contain a link to a github repo with a solution that does not work. I already created a pull request there, to update the code.
Related issues and pull requests
Fixes #34126