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

Converted .glsl files to .glsl.js #15280

Merged
merged 1 commit into from
Nov 20, 2018
Merged

Converted .glsl files to .glsl.js #15280

merged 1 commit into from
Nov 20, 2018

Conversation

mrdoob
Copy link
Owner

@mrdoob mrdoob commented Nov 20, 2018

After this change we can now import directly from source:

<script type="module">
	import * as THREE from "../src/Three.js";
</script>

Or import the classes directly:

<script type="module">
	import { WebGLRenderer } from '../src/renderers/WebGLRenderer.js';
	const renderer = new WebGLRenderer();
</script>

Example:
https://raw.githack.com/mrdoob/three.js/dev/examples/webgl2_sandbox.html

This should help for eventually clarifying dependencies and reducing bundle sizes.

Unfortunately we lose glsl syntax highlighting.

Fixes #14446


EDIT:

However... Even if it's now possible, it's not recommended. We can't guarantee backwards compatibility with that approach.

@mrdoob mrdoob added this to the r99 milestone Nov 20, 2018
@mrdoob mrdoob merged commit 0c51e57 into dev Nov 20, 2018
@mrdoob mrdoob deleted the src-es6module branch November 20, 2018 05:25
@WestLangley
Copy link
Collaborator

How do we do this now?

> scene.children
> renderer.info

@mrdoob
Copy link
Owner Author

mrdoob commented Nov 20, 2018

That code should still work?

@donmccurdy
Copy link
Collaborator

ES modules have isolated scope. Their variables won't be accessible from the console unless assigned to the global scope, e.g. Object.assign(window, {scene, renderer});.

@mrdoob
Copy link
Owner Author

mrdoob commented Nov 20, 2018

Oh! I understand the question now.

@WestLangley #5835 (comment)

@mrdoob
Copy link
Owner Author

mrdoob commented Nov 20, 2018

Hmm... Added a note at the end of the first post.

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