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

[ENHANCEMENT] All three.js examples displayed in iframes should be hosted locally #5

Open
looeee opened this issue Apr 22, 2021 · 5 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@looeee
Copy link
Owner

looeee commented Apr 22, 2021

Currently, many of the official three.js examples are included as iframes throughout the book. These slow down the page load and upstream changes on the three.js repo may unexpectedly break something (if an example gets deleted from the three.js repo, for example).

{{< iframe src="https://threejs.org/examples/webgl_materials_envmaps.html" height="500" title="Image Based Lighting (IBL) in action" caption="Image Based Lighting (IBL): the scene background is reflected on the sphere" >}}

It would be better to extract the code from these and include them in this repo.

@looeee looeee added enhancement New feature or request good first issue Good for newcomers labels Apr 22, 2021
@looeee looeee changed the title All three.js examples displayed in iframes should be hosted locally {ENHNACEMENT] All three.js examples displayed in iframes should be hosted locally Apr 23, 2021
@looeee looeee changed the title {ENHNACEMENT] All three.js examples displayed in iframes should be hosted locally [ENHNACEMENT] All three.js examples displayed in iframes should be hosted locally Apr 23, 2021
@looeee looeee changed the title [ENHNACEMENT] All three.js examples displayed in iframes should be hosted locally [ENHANCEMENT] All three.js examples displayed in iframes should be hosted locally Apr 23, 2021
@xiejay97
Copy link
Contributor

Currently, many of the official three.js examples are included as iframes throughout the book. These slow down the page load and upstream changes on the three.js repo may unexpectedly break something (if an example gets deleted from the three.js repo, for example).

{{< iframe src="https://threejs.org/examples/webgl_materials_envmaps.html" height="500" title="Image Based Lighting (IBL) in action" caption="Image Based Lighting (IBL): the scene background is reflected on the sphere" >}}

It would be better to extract the code from these and include them in this repo.

@looeee I think just download threejs, and put files into web server,
such as nginx, than we can get html from our own website.

image
image

@looeee
Copy link
Owner Author

looeee commented Apr 28, 2021

Yeah, it's a nice and simple solution. Unfortunately, the examples and docs are not in the NPM package so this would require yet another copy of three to be included.

There are a couple of additional reasons that I want to include the examples locally that I forgot to mention above:

  1. Some of the examples have a controls menu that doesn't look good on small screens, like here:

2021-04-28 14_23_52-Transformations and Coordinate Systems _ Discover three js — Mozilla Firefox

There's no need for this menu when showing the example in the book so I would like to remove it.

  1. Currently on some pages up to three versions of three.module.js and OrbitControls.js are included in the page (one for IDE, one for inline scenes, then another for iframes loaded from threejs.org). That's a lot of unnecessary JS to force on users, especially for mobile. If we include the three.js scenes in the same way as the inline scenes we can at least make everything except the IDE use the same script. We could even bundle and minify it, possibly reducing JS load by 1mb or so.

For these reasons I'd prefer to include these examples under /static/examples/worlds/threejs-examples and only include the files we need rather than the whole repo.

@looeee
Copy link
Owner Author

looeee commented Apr 28, 2021

put files into web server,such as nginx,

FYI the actual site is running on a DigitalOcean droplet using nginx as the server. So serving any kind of static files is trivial to set up, but to keep things simple we should make sure all files are served from within the public/ folder.

@xiejay97
Copy link
Contributor

Yeah, it's a nice and simple solution. Unfortunately, the examples and docs are not in the NPM package so this would require yet another copy of three to be included.

There are a couple of additional reasons that I want to include the examples locally that I forgot to mention above:

  1. Some of the examples have a controls menu that doesn't look good on small screens, like here:

2021-04-28 14_23_52-Transformations and Coordinate Systems _ Discover three js — Mozilla Firefox

There's no need for this menu when showing the example in the book so I would like to remove it.

  1. Currently on some pages up to three versions of three.module.js and OrbitControls.js are included in the page (one for IDE, one for inline scenes, then another for iframes loaded from threejs.org). That's a lot of unnecessary JS to force on users, especially for mobile. If we include the three.js scenes in the same way as the inline scenes we can at least make everything except the IDE use the same script. We could even bundle and minify it, possibly reducing JS load by 1mb or so.

For these reasons I'd prefer to include these examples under /static/examples/worlds/threejs-examples and only include the files we need rather than the whole repo.

Make a script to resolve these point isnt tricky, but it seems that the work to modify content directly is not very large.
Of course, I'm glad to provide the script if needed.

@looeee
Copy link
Owner Author

looeee commented Apr 28, 2021

I think doing this by hand is ok, there's no need for a script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants