UNPKG

aframe-lsystem-component

Version:

L-System/LSystem component for A-Frame to draw 3D turtle graphics. Using Lindenmayer as backend.

1 lines 2.03 kB
!function(t){function a(n){if(e[n])return e[n].exports;var r=e[n]={exports:{},id:n,loaded:!1};return t[n].call(r.exports,r,r.exports,a),r.loaded=!0,r.exports}var e={};return a.m=t,a.c=e,a.p="",a(0)}([function(t,a){if("undefined"==typeof AFRAME)throw new Error("Component attempted to register before AFRAME was available.");AFRAME.registerComponent("random-color",{schema:{min:{"default":{x:0,y:0,z:0},type:"vec3"},max:{"default":{x:1,y:1,z:1},type:"vec3"}},update:function(){var t=this.data,a=t.max,e=t.min;this.el.setAttribute("material","color","#"+new THREE.Color(Math.random()*a.x+e.x,Math.random()*a.y+e.y,Math.random()*a.z+e.z).getHexString())}}),AFRAME.registerComponent("random-position",{schema:{min:{"default":{x:-10,y:-10,z:-10},type:"vec3"},max:{"default":{x:10,y:10,z:10},type:"vec3"}},update:function(){var t=this.data,a=t.max,e=t.min;this.el.setAttribute("position",{x:Math.random()*(a.x-e.x)+e.x,y:Math.random()*(a.y-e.y)+e.y,z:Math.random()*(a.z-e.z)+e.z})}}),AFRAME.registerComponent("random-spherical-position",{schema:{radius:{"default":10},startX:{"default":0},lengthX:{"default":360},startY:{"default":0},lengthY:{"default":360}},update:function(){var t=this.data,a=THREE.Math.degToRad(Math.random()*t.lengthX+t.startX),e=THREE.Math.degToRad(Math.random()*t.lengthY+t.startY);this.el.setAttribute("position",{x:t.radius*Math.cos(a)*Math.sin(e),y:t.radius*Math.sin(a)*Math.sin(e),z:t.radius*Math.cos(e)})}}),AFRAME.registerComponent("random-rotation",{schema:{min:{"default":{x:0,y:0,z:0},type:"vec3"},max:{"default":{x:360,y:360,z:360},type:"vec3"}},update:function(){var t=this.data,a=t.max,e=t.min;this.el.setAttribute("rotation",{x:Math.random()*a.x+e.x,y:Math.random()*a.y+e.y,z:Math.random()*a.z+e.z})}}),AFRAME.registerComponent("random-scale",{schema:{min:{"default":{x:0,y:0,z:0},type:"vec3"},max:{"default":{x:2,y:2,z:2},type:"vec3"}},update:function(){var t=this.data,a=t.max,e=t.min;this.el.setAttribute("scale",{x:Math.random()*a.x+e.x,y:Math.random()*a.y+e.y,z:Math.random()*a.z+e.z})}})}]);