@6edesign/svelte-three
Version:
[Demo](https://6edesign.github.io/svelte-three-mograph/)
225 lines (205 loc) • 5.76 kB
JavaScript
/* src/documentation/pages/tree/Tree.svelte generated by Svelte v3.31.2 */
import {
SvelteComponent,
create_component,
destroy_component,
detach,
init,
insert,
mount_component,
safe_not_equal,
space,
transition_in,
transition_out
} from "../../../../web_modules/svelte/internal.js";
import AmbientLight from "../../../components/lights/AmbientLight.js";
import Material from "../../../components/materials/Material.js";
import Group from "../../../components/mograph/Group.js";
import Cylinder from "../../../components/primitives/Cylinder.js";
import Scene from "../../../components/Scene.js";
import Branch from "./Branch.js";
function create_default_slot_1(ctx) {
let branch;
let current;
branch = new Branch({
props: {
position: /*position*/ ctx[2],
baseAngle: /*baseAngle*/ ctx[3],
baseHeight: /*baseHeight*/ ctx[5],
radiusBottom: /*radiusBottom*/ ctx[4],
shrinkFactor: /*shrinkFactor*/ ctx[6],
minHeight: /*minHeight*/ ctx[7]
}
});
return {
c() {
create_component(branch.$$.fragment);
},
m(target, anchor) {
mount_component(branch, target, anchor);
current = true;
},
p(ctx, dirty) {
const branch_changes = {};
if (dirty & /*position*/ 4) branch_changes.position = /*position*/ ctx[2];
if (dirty & /*baseAngle*/ 8) branch_changes.baseAngle = /*baseAngle*/ ctx[3];
if (dirty & /*baseHeight*/ 32) branch_changes.baseHeight = /*baseHeight*/ ctx[5];
if (dirty & /*radiusBottom*/ 16) branch_changes.radiusBottom = /*radiusBottom*/ ctx[4];
if (dirty & /*shrinkFactor*/ 64) branch_changes.shrinkFactor = /*shrinkFactor*/ ctx[6];
if (dirty & /*minHeight*/ 128) branch_changes.minHeight = /*minHeight*/ ctx[7];
branch.$set(branch_changes);
},
i(local) {
if (current) return;
transition_in(branch.$$.fragment, local);
current = true;
},
o(local) {
transition_out(branch.$$.fragment, local);
current = false;
},
d(detaching) {
destroy_component(branch, detaching);
}
};
}
// (21:0) <Scene {width} {height}>
function create_default_slot(ctx) {
let ambientlight;
let t;
let material;
let current;
ambientlight = new AmbientLight({});
material = new Material({
props: {
roughness: 0.9,
metalness: 0.1,
$$slots: { default: [create_default_slot_1] },
$$scope: { ctx }
}
});
return {
c() {
create_component(ambientlight.$$.fragment);
t = space();
create_component(material.$$.fragment);
},
m(target, anchor) {
mount_component(ambientlight, target, anchor);
insert(target, t, anchor);
mount_component(material, target, anchor);
current = true;
},
p(ctx, dirty) {
const material_changes = {};
if (dirty & /*$$scope, position, baseAngle, baseHeight, radiusBottom, shrinkFactor, minHeight*/ 508) {
material_changes.$$scope = { dirty, ctx };
}
material.$set(material_changes);
},
i(local) {
if (current) return;
transition_in(ambientlight.$$.fragment, local);
transition_in(material.$$.fragment, local);
current = true;
},
o(local) {
transition_out(ambientlight.$$.fragment, local);
transition_out(material.$$.fragment, local);
current = false;
},
d(detaching) {
destroy_component(ambientlight, detaching);
if (detaching) detach(t);
destroy_component(material, detaching);
}
};
}
function create_fragment(ctx) {
let scene;
let current;
scene = new Scene({
props: {
width: /*width*/ ctx[0],
height: /*height*/ ctx[1],
$$slots: { default: [create_default_slot] },
$$scope: { ctx }
}
});
return {
c() {
create_component(scene.$$.fragment);
},
m(target, anchor) {
mount_component(scene, target, anchor);
current = true;
},
p(ctx, [dirty]) {
const scene_changes = {};
if (dirty & /*width*/ 1) scene_changes.width = /*width*/ ctx[0];
if (dirty & /*height*/ 2) scene_changes.height = /*height*/ ctx[1];
if (dirty & /*$$scope, position, baseAngle, baseHeight, radiusBottom, shrinkFactor, minHeight*/ 508) {
scene_changes.$$scope = { dirty, ctx };
}
scene.$set(scene_changes);
},
i(local) {
if (current) return;
transition_in(scene.$$.fragment, local);
current = true;
},
o(local) {
transition_out(scene.$$.fragment, local);
current = false;
},
d(detaching) {
destroy_component(scene, detaching);
}
};
}
function instance($$self, $$props, $$invalidate) {
let { width } = $$props;
let { height } = $$props;
let { position = [0, -4, 0] } = $$props;
let { baseAngle = [0, 1, 0] } = $$props;
let { radiusBottom = 0.15 } = $$props;
let { baseHeight = 2.8 } = $$props;
let { shrinkFactor = 0.7 } = $$props;
let { minHeight = 0.2 } = $$props;
$$self.$$set = $$props => {
if ("width" in $$props) $$invalidate(0, width = $$props.width);
if ("height" in $$props) $$invalidate(1, height = $$props.height);
if ("position" in $$props) $$invalidate(2, position = $$props.position);
if ("baseAngle" in $$props) $$invalidate(3, baseAngle = $$props.baseAngle);
if ("radiusBottom" in $$props) $$invalidate(4, radiusBottom = $$props.radiusBottom);
if ("baseHeight" in $$props) $$invalidate(5, baseHeight = $$props.baseHeight);
if ("shrinkFactor" in $$props) $$invalidate(6, shrinkFactor = $$props.shrinkFactor);
if ("minHeight" in $$props) $$invalidate(7, minHeight = $$props.minHeight);
};
return [
width,
height,
position,
baseAngle,
radiusBottom,
baseHeight,
shrinkFactor,
minHeight
];
}
class Tree extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, create_fragment, safe_not_equal, {
width: 0,
height: 1,
position: 2,
baseAngle: 3,
radiusBottom: 4,
baseHeight: 5,
shrinkFactor: 6,
minHeight: 7
});
}
}
export default Tree;