Rich-Harris/svelte-cubed

Feature Request: expose GL, Scene, Camera, etc

thisispete opened this issue · 1 comments

For doing things like GLSL reflections / refraction etc. as materials I'm setting up a CubeCamera, which needs access to the Scene, and GL Renderer, currently I have some wild hack to pull them out of the canvas, but there's gotta be an easier way to get to these.

something like a store or context similar to ReactThreeFiber's useThree hook?

If anyone knows an easier method I'm ALL ears.

let canvas, gl, scene;
onMount(() => {
        const mapIter = canvas.$$.context.values();
	mapIter.next()
	const ctx = mapIter.next().value;
	gl = ctx.renderer;
	scene = ctx.scene;
})

<Canvas bind:this={canvas} ...

I agree with this request. Svelte Cubed is great! But, it's a work in progress and so developers need access to the core objects in some way to utilize more of the Three.js framework