Script: Blockly Sliced Mesh Example

Blockly Sliced Mesh Example picture
Type
Blockly logo indicatorblockly
Date Created
Nov 27, 2024, 2:22:45 PM
Last Edit Date
Nov 27, 2024, 3:02:38 PM

Project Information

We have recently integrated Manifold CAD kernel into our core. These projects demonstrate how it can be used in bitbybit. Manifold CAD is powerful C++ based geometry kernel developed by Emmett Lalish

View Full Project

Script Code

<xml xmlns="https://developers.google.com/blockly/xml">
 <variables>
  <variable id="n19,8r-a?7A+qkb)ElAf">manifolds</variable>
  <variable id="Wtd}qrQ+lWdP1OtQ3dg|">translationYValues</variable>
  <variable id="Y@}{o*[I+D}${[w~7rCJ">translatedManifoldPromises</variable>
  <variable id="D)(kr!NQi#s]C`#xv1pQ">i</variable>
  <variable id="lio_h#o#b-8*4FT;}6Oz">manifold</variable>
  <variable id="EE^[ulD}B^`eyBU]h?5X">composedMesh</variable>
  <variable id="EVi?j$eH8]M$0KJIyoB(">translationY</variable>
  <variable id="c71}MAe5uvx!XR@z1I3I">timeElapsedFromPreviousFrame</variable>
 </variables>
 <block type="bitbybit.babylon.scene.enableSkybox" id="[|jMfZm-TZwL7*#Hz,tN" x="-583" y="-3084">
  <value name="Skybox">
   <block type="bitbybit.babylon.enums.skyboxEnum" id="#%Xl(j}Vh8f(;](7Pi.h">
    <field name="bitbybit.babylon.enums.skyboxEnum">'city'</field>
   </block>
  </value>
  <value name="Size">
   <block type="math_number" id="WV7Aw+9by!UHlP1$~xZJ">
    <field name="NUM">1000</field>
   </block>
  </value>
  <value name="Blur">
   <block type="math_number" id="/lVb33lk7`}i1a-~T[@Y">
    <field name="NUM">0.5</field>
   </block>
  </value>
  <value name="EnvironmentIntensity">
   <block type="math_number" id="7SH$zgCM@QrktO?WQ[*~">
    <field name="NUM">0.7</field>
   </block>
  </value>
  <next>
   <block type="bitbybit.babylon.scene.drawDirectionalLightNoReturn" id="Ch=;]1?YjRAC:WxOG=L|">
    <value name="Direction">
     <block type="bitbybit.vector.vectorXYZ" id="[P3xg?eR+5OOQ;ZZcz)T">
      <value name="X">
       <block type="math_number" id="G!8T$U+/:Tr#7OoaO?ac">
        <field name="NUM">0</field>
       </block>
      </value>
      <value name="Y">
       <block type="math_number" id="eE/@GTCk^{FfV]J9T@1f">
        <field name="NUM">-100</field>
       </block>
      </value>
      <value name="Z">
       <block type="math_number" id="a+@x?t;-g0*.oipN23%:">
        <field name="NUM">-100</field>
       </block>
      </value>
     </block>
    </value>
    <value name="Intensity">
     <block type="math_number" id="}ZgtdN7b2MNiV=2t0pb+">
      <field name="NUM">3</field>
     </block>
    </value>
    <value name="Diffuse">
     <block type="colour_picker" id="YW:K~IL}WUC]X.7epatL">
      <field name="COLOUR">#ffffff</field>
     </block>
    </value>
    <value name="Specular">
     <block type="colour_picker" id="$lO^bSs;7V,f`Gj$MGX]">
      <field name="COLOUR">#ffffff</field>
     </block>
    </value>
    <value name="ShadowGeneratorMapSize">
     <block type="math_number" id="Zp#U@_5@$cw._T_VeoFi">
      <field name="NUM">1024</field>
     </block>
    </value>
    <value name="EnableShadows">
     <block type="logic_boolean" id=",^S[T?Sq+rd$U,$?axrx">
      <field name="BOOL">TRUE</field>
     </block>
    </value>
    <value name="ShadowDarkness">
     <block type="math_number" id="749n8@VxgU7}9;.+Rj?3">
      <field name="NUM">0</field>
     </block>
    </value>
    <value name="ShadowUsePercentageCloserFiltering">
     <block type="logic_boolean" id="/UYq-sAv2SwU/,ExD1~Q">
      <field name="BOOL">TRUE</field>
     </block>
    </value>
    <value name="ShadowContactHardeningLightSizeUVRatio">
     <block type="math_number" id="!92%~T}QDOa).3r?c3_0">
      <field name="NUM">0.2</field>
     </block>
    </value>
    <value name="ShadowBias">
     <block type="math_number" id="$vN}KtcxRIwY-NO*WpqO">
      <field name="NUM">0.0001</field>
     </block>
    </value>
    <value name="ShadowNormalBias">
     <block type="math_number" id="mU!]s{?Vj3W?,Fq~-z@V">
      <field name="NUM">0.002</field>
     </block>
    </value>
    <value name="ShadowMaxZ">
     <block type="math_number" id="-]hwc$lX]gxHq;:sg85t">
      <field name="NUM">1000</field>
     </block>
    </value>
    <value name="ShadowMinZ">
     <block type="math_number" id="yZ9aGSAd=QsI)urRw`Mm">
      <field name="NUM">0</field>
     </block>
    </value>
    <next>
     <block type="bitbybit.draw.drawAnyAsyncNoReturn" id="Ks09U!8c*K/UygF;pD]@">
      <value name="Entity">
       <block type="bitbybit.occt.shapes.face.createCircleFace" id="=0o%WTHRC[w4vxj?-a1=">
        <value name="Radius">
         <block type="math_number" id="M3XHsY3*C)xO5S;{gyd@">
          <field name="NUM">5</field>
         </block>
        </value>
        <value name="Center">
         <block type="bitbybit.point.pointXYZ" id="vqDzlTR~Og+2L{?/R[6@">
          <value name="X">
           <block type="math_number" id="T4:k{/)on*lji;RZ]a.C">
            <field name="NUM">0</field>
           </block>
          </value>
          <value name="Y">
           <block type="math_number" id="?-/y)72_9Q~|7]xD+htD">
            <field name="NUM">-2</field>
           </block>
          </value>
          <value name="Z">
           <block type="math_number" id="IEvG~:5cA.HrnDi_u!HH">
            <field name="NUM">0</field>
           </block>
          </value>
         </block>
        </value>
        <value name="Direction">
         <block type="bitbybit.vector.vectorXYZ" id=";n~RJ~:?9mMf[U:z^r:M">
          <value name="X">
           <block type="math_number" id="cTV_XzTYR,z4CS5]HJ.;">
            <field name="NUM">0</field>
           </block>
          </value>
          <value name="Y">
           <block type="math_number" id="f|n3uFudwO55=G,i`@Wo">
            <field name="NUM">1</field>
           </block>
          </value>
          <value name="Z">
           <block type="math_number" id="hg9:YGvS)F1A:R4hpDZ8">
            <field name="NUM">0</field>
           </block>
          </value>
         </block>
        </value>
       </block>
      </value>
      <next>
       <block type="base_time_async_context" id="sjmnbsOS6WMtY?%2)*{I">
        <statement name="Then">
         <block type="variables_set" id=".`FP^y-#r`ZZ*Y0H^XJs">
          <field name="VAR" id="n19,8r-a?7A+qkb)ElAf">manifolds</field>
          <value name="VALUE">
           <block type="base_time_await_return" id="qm6HMPZ!`SI[U)jyG,Vo">
            <value name="Promise">
             <block type="bitbybit.manifold.manifold.booleans.splitByPlaneOnOffsets" id="fh2,;BcRK=dp%7$Eax[U">
              <value name="Manifold">
               <block type="bitbybit.manifold.manifold.shapes.sphere" id="iON;/WlA)QsNmt=wKYX@">
                <value name="Radius">
                 <block type="math_number" id="A):ZqTT|rab6C8-ZzK^}">
                  <field name="NUM">1</field>
                 </block>
                </value>
                <value name="CircularSegments">
                 <block type="math_number" id="{#?M}O!@Wz|[}3ZUWzuq">
                  <field name="NUM">32</field>
                 </block>
                </value>
               </block>
              </value>
              <value name="Normal">
               <block type="bitbybit.vector.vectorXYZ" id="wxEx_FHmV?atx]8prn`J">
                <value name="X">
                 <block type="math_number" id="rcEbCmCKc.(5Fbrsw2/p">
                  <field name="NUM">1</field>
                 </block>
                </value>
                <value name="Y">
                 <block type="math_number" id="trjZOkHahc{$)W5p`rtf">
                  <field name="NUM">1</field>
                 </block>
                </value>
                <value name="Z">
                 <block type="math_number" id="Q;;wxqt~Ejy@M_sW6-PJ">
                  <field name="NUM">0.3</field>
                 </block>
                </value>
               </block>
              </value>
              <value name="OriginOffsets">
               <block type="bitbybit.vector.span" id="x~4!l/ulrOmwV8H1nJrT">
                <value name="Step">
                 <block type="math_number" id="jo.{pHF05J+O4p0K1vmM">
                  <field name="NUM">0.1</field>
                 </block>
                </value>
                <value name="Min">
                 <block type="math_number" id="Qu5r+76P/IXmSXhPG,!w">
                  <field name="NUM">-1</field>
                 </block>
                </value>
                <value name="Max">
                 <block type="math_number" id=":sxgoz%Ec$STnx4kRk-*">
                  <field name="NUM">1</field>
                 </block>
                </value>
               </block>
              </value>
             </block>
            </value>
           </block>
          </value>
          <next>
           <block type="variables_set" id="|u$ISg0hAWaAHEz?I$1Z">
            <field name="VAR" id="Wtd}qrQ+lWdP1OtQ3dg|">translationYValues</field>
            <value name="VALUE">
             <block type="bitbybit.vector.span" id="Wy7[:u;@0%tLHF_v#M8]">
              <value name="Step">
               <block type="math_number" id="m:a3Z^Y3JHqz(!1n$-1V">
                <field name="NUM">0.2</field>
               </block>
              </value>
              <value name="Min">
               <block type="math_number" id="XT9orVpje,I4Sf}8$77t">
                <field name="NUM">0</field>
               </block>
              </value>
              <value name="Max">
               <block type="math_number" id="!.P9EV2QJA8_cQ|:?4E;">
                <field name="NUM">42</field>
               </block>
              </value>
             </block>
            </value>
            <next>
             <block type="variables_set" id="e:b;v93$:_@r}GDY}1wp">
              <field name="VAR" id="Y@}{o*[I+D}${[w~7rCJ">translatedManifoldPromises</field>
              <value name="VALUE">
               <block type="lists_create_with" id="*^8hUYq`!rP0bTO;Mwt5">
                <mutation items="0">
                </mutation>
               </block>
              </value>
              <next>
               <block type="controls_for" id="b:23.]u+MQPeOa;[MYV3">
                <field name="VAR" id="D)(kr!NQi#s]C`#xv1pQ">i</field>
                <value name="FROM">
                 <block type="math_number" id="ac_F?,QK*f~v%{vYejN)">
                  <field name="NUM">1</field>
                 </block>
                </value>
                <value name="TO">
                 <block type="lists_length" id="rX^F9sG4AUYzvxn~I+dz">
                  <value name="VALUE">
                   <block type="variables_get" id="gcQ2EroL.@)x#/aPET,f">
                    <field name="VAR" id="n19,8r-a?7A+qkb)ElAf">manifolds</field>
                   </block>
                  </value>
                 </block>
                </value>
                <value name="BY">
                 <block type="math_number" id="o8q,}IPH4h}}hh@og!2y">
                  <field name="NUM">1</field>
                 </block>
                </value>
                <statement name="DO">
                 <block type="variables_set" id="UWvyuDpgJu@;:wwTdfTx">
                  <field name="VAR" id="lio_h#o#b-8*4FT;}6Oz">manifold</field>
                  <value name="VALUE">
                   <block type="lists_getIndex" id="(V6Ru0[o-#FV;6y!qxQS">
                    <mutation statement="false" at="true">
                    </mutation>
                    <field name="MODE">GET</field>
                    <field name="WHERE">FROM_START</field>
                    <value name="VALUE">
                     <block type="variables_get" id="Fz~(X42!VlB8=67.XI{;">
                      <field name="VAR" id="n19,8r-a?7A+qkb)ElAf">manifolds</field>
                     </block>
                    </value>
                    <value name="AT">
                     <block type="variables_get" id="eHgy=F@h5$odP5S@qou?">
                      <field name="VAR" id="D)(kr!NQi#s]C`#xv1pQ">i</field>
                     </block>
                    </value>
                   </block>
                  </value>
                  <next>
                   <block type="variables_set" id="u`~5V}$uxTfWJOD$RoES">
                    <field name="VAR" id="EVi?j$eH8]M$0KJIyoB(">translationY</field>
                    <value name="VALUE">
                     <block type="lists_getIndex" id=":!aLYpqk5N=d1MDbFZj.">
                      <mutation statement="false" at="true">
                      </mutation>
                      <field name="MODE">GET</field>
                      <field name="WHERE">FROM_START</field>
                      <value name="VALUE">
                       <block type="variables_get" id="r3:ua4r$++USfp.vBt;-">
                        <field name="VAR" id="Wtd}qrQ+lWdP1OtQ3dg|">translationYValues</field>
                       </block>
                      </value>
                      <value name="AT">
                       <block type="variables_get" id="w$2TMG[q|m])F2TF~_k?">
                        <field name="VAR" id="D)(kr!NQi#s]C`#xv1pQ">i</field>
                       </block>
                      </value>
                     </block>
                    </value>
                    <next>
                     <block type="lists_setIndex" id="dR3c8*QcqRIiRj/xUM5b">
                      <mutation at="false">
                      </mutation>
                      <field name="MODE">INSERT</field>
                      <field name="WHERE">LAST</field>
                      <value name="LIST">
                       <block type="variables_get" id="[~*5P7ey#cYA4XQei%2T">
                        <field name="VAR" id="Y@}{o*[I+D}${[w~7rCJ">translatedManifoldPromises</field>
                       </block>
                      </value>
                      <value name="TO">
                       <block type="bitbybit.manifold.manifold.transforms.translate" id="^8/CH1v1@QA;]+/[^/:o">
                        <value name="Manifold">
                         <block type="variables_get" id="Md^3cxV;-Rk@yPlgJ+{B">
                          <field name="VAR" id="lio_h#o#b-8*4FT;}6Oz">manifold</field>
                         </block>
                        </value>
                        <value name="Vector">
                         <block type="bitbybit.vector.vectorXYZ" id="*Zt4cPn2kbX[Tol+!3Bd">
                          <value name="X">
                           <block type="math_number" id="J+AMDytdJ.)!}a*]#-u7">
                            <field name="NUM">0</field>
                           </block>
                          </value>
                          <value name="Y">
                           <block type="variables_get" id="pc)tam8Thl_;j6S@pKu!">
                            <field name="VAR" id="EVi?j$eH8]M$0KJIyoB(">translationY</field>
                           </block>
                          </value>
                          <value name="Z">
                           <block type="math_number" id="tV(^E!ou-rkZ}.xBD0dN">
                            <field name="NUM">0</field>
                           </block>
                          </value>
                         </block>
                        </value>
                       </block>
                      </value>
                     </block>
                    </next>
                   </block>
                  </next>
                 </block>
                </statement>
                <next>
                 <block type="variables_set" id="eoP6n[VqFAQWm9npu*e.">
                  <field name="VAR" id="EE^[ulD}B^`eyBU]h?5X">composedMesh</field>
                  <value name="VALUE">
                   <block type="base_time_await_return" id="m5Ps^eGE8y]83m%3O6aL">
                    <value name="Promise">
                     <block type="bitbybit.draw.drawAnyAsync" id="Q{E?I7e@^wU_4i:6:!T-">
                      <value name="Entity">
                       <block type="bitbybit.manifold.manifold.operations.compose" id="v.WylFDGba+G[Wrm7Ssr">
                        <value name="Manifolds">
                         <block type="variables_get" id="!5y9-`/V]GVZ,0+!k*;`">
                          <field name="VAR" id="Y@}{o*[I+D}${[w~7rCJ">translatedManifoldPromises</field>
                         </block>
                        </value>
                       </block>
                      </value>
                      <value name="Options">
                       <block type="bitbybit.draw.optionsManifoldShapeMaterial" id="gDi-syg~7vzfIGv#o;_A">
                        <value name="FaceOpacity">
                         <block type="math_number" id="vJ3X?xrYd6np9%s-/Oa$">
                          <field name="NUM">1</field>
                         </block>
                        </value>
                        <value name="FaceColour">
                         <block type="colour_picker" id="OOw]|7ET/X:/Kxjrmbor">
                          <field name="COLOUR">#33ff33</field>
                         </block>
                        </value>
                        <value name="CrossSectionColour">
                         <block type="colour_picker" id=")2C=G$v#}0IO4]CQ8:qu">
                          <field name="COLOUR">#ff00ff</field>
                         </block>
                        </value>
                        <value name="CrossSectionWidth">
                         <block type="math_number" id="UWxJ:vIvK):u`Zo[1p%7">
                          <field name="NUM">2</field>
                         </block>
                        </value>
                        <value name="CrossSectionOpacity">
                         <block type="math_number" id="SmlHr3[P.JC|Lco$M:S-">
                          <field name="NUM">1</field>
                         </block>
                        </value>
                        <value name="ComputeNormals">
                         <block type="logic_boolean" id="_z,;.T%g3FqqQR|+FeHo">
                          <field name="BOOL">FALSE</field>
                         </block>
                        </value>
                       </block>
                      </value>
                     </block>
                    </value>
                   </block>
                  </value>
                  <next>
                   <block type="base_time_update" id="3^^Vb|:%3QueIY~3/S8$">
                    <field name="TimePassedMs" id="c71}MAe5uvx!XR@z1I3I">timeElapsedFromPreviousFrame</field>
                    <statement name="Update">
                     <block type="bitbybit.babylon.mesh.yaw" id="^h(GEK(wBohC7boKF5,o">
                      <value name="BabylonMesh">
                       <block type="variables_get" id="]m4F5OF]0B(uY~Moc@W=">
                        <field name="VAR" id="EE^[ulD}B^`eyBU]h?5X">composedMesh</field>
                       </block>
                      </value>
                      <value name="Rotate">
                       <block type="math_number" id="2ckYJ{ZRME8S=olF]OlU">
                        <field name="NUM">0.5</field>
                       </block>
                      </value>
                     </block>
                    </statement>
                   </block>
                  </next>
                 </block>
                </next>
               </block>
              </next>
             </block>
            </next>
           </block>
          </next>
         </block>
        </statement>
       </block>
      </next>
     </block>
    </next>
   </block>
  </next>
 </block>
</xml>
Plans & Pricing

Choose Your Plan

Editor plans for 3D development, API keys for server-side CAD algorithms

B2B

ENTERPRISE

Custom pricing

Custom software development, dedicated servers & CAD automation at scale.

CAD Automation & Software
  • Custom software development
  • Cloud CAD automation pipelines
  • 3D configurators (STEP & GLTF)
  • Batch export jobs
  • Custom algorithms & deployment
Infrastructure & Support
  • Custom compute allocation
  • Dedicated / VPS server tenants
  • Long-running computation jobs
  • Custom upload limits & overage
  • SLA & premium support