UNPKG

@6edesign/svelte-three

Version:

[Demo](https://6edesign.github.io/svelte-three-mograph/)

63 lines (52 loc) 1.89 kB
/* src/components/lights/DirectionalLight.svelte generated by Svelte v3.31.2 */ import { SvelteComponent, assign, exclude_internal_props, init, safe_not_equal } from "../../../web_modules/svelte/internal.js"; import { DirectionalLight } from "../../../web_modules/three.js"; import { getContext } from "../../../web_modules/svelte.js"; function instance($$self, $$props, $$invalidate) { let { position = [0, 10, 0] } = $$props; let { targetPosition = [0, 0, 0] } = $$props; let { intensity = 1 } = $$props; const sceneCtx = getContext("sceneCtx"); const light = new DirectionalLight(16777215, intensity); sceneCtx.scene.add(light); sceneCtx.scene.add(light.target); $$self.$$set = $$new_props => { $$invalidate(5, $$props = assign(assign({}, $$props), exclude_internal_props($$new_props))); if ("position" in $$new_props) $$invalidate(0, position = $$new_props.position); if ("targetPosition" in $$new_props) $$invalidate(1, targetPosition = $$new_props.targetPosition); if ("intensity" in $$new_props) $$invalidate(2, intensity = $$new_props.intensity); }; $$self.$$.update = () => { if ($$self.$$.dirty & /*intensity*/ 4) { $: $$invalidate(3, light.intensity = intensity, light); } $: Object.entries($$props, ([key, val]) => { $$invalidate(3, light[key] = val, light); }); if ($$self.$$.dirty & /*light, position*/ 9) { $: light.position.set.apply(light, position); } if ($$self.$$.dirty & /*light, targetPosition*/ 10) { $: light.target.position.set.apply(light, targetPosition); } }; $$props = exclude_internal_props($$props); return [position, targetPosition, intensity, light]; } class DirectionalLight_1 extends SvelteComponent { constructor(options) { super(); init(this, options, instance, null, safe_not_equal, { position: 0, targetPosition: 1, intensity: 2 }); } } export default DirectionalLight_1;